1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- // #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", "")
- uni.$showMsg("令牌过期,请重新登录");
- uni.reLaunch({
- url: "/pages/login/login?code=2000",
- })
- 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
|