123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- // #ifndef VUE3
- import Vue from "vue";
- import App from "./App";
- import uView from "uview-ui";
- Vue.use(uView);
- import store from "@/store/index.js";
- import {
- $http
- } from "@escook/request-miniprogram";
- import {
- BASE_URL
- } from './config.js'
- uni.$http = $http;
- // 请求的根路径
- $http.baseUrl = BASE_URL;
- // 请求拦截器
- $http.beforeRequest = function (options) {
- // uni.showLoading({
- // title: '数据加载中...'
- // })
- console.log("请求拦截器", options);
- options.header = {
- Token: uni.getStorageSync("token"),
- };
- };
- // 响应拦截器
- $http.afterRequest = function (res) {
- console.log("响应拦截器", res)
- if (res.data.code === 2000) {
- store.state.m_user.userInfo = ""
- store.state.m_user.token = ""
- store.commit("m_user/saveUserInfoToStorage", "")
- store.commit("m_user/saveTokenToStorage", "")
- store.commit("m_business/saveCurrentHotelToStorage", "{}")
- uni.$showMsg("令牌过期,请重新登录");
- uni.reLaunch({
- url: "/pages/login/login",
- })
- return
- }
- // uni.$showMsg('加载成功')
- // uni.hideLoading()
- };
- // 封装弹框的方法
- uni.$showMsg = function (title = "数据请求失败!", duration = 1500) {
- uni.showToast({
- title,
- duration,
- icon: "none",
- });
- };
- Vue.config.productionTip = false;
- App.mpType = "app";
- const app = new Vue({
- ...App,
- store,
- });
- app.$mount();
- // #endif
- // #ifdef VUE3
- import {
- createSSRApp
- } from "vue";
- import App from "./App.vue";
- import Log from "./mp_ecard_sdk/constants/log";
- export function createApp() {
- const app = createSSRApp(App);
- return {
- app,
- };
- }
- // #endif
|