import App from './App' // #ifndef VUE3 import Vue from 'vue' import store from "@/store/index.js" import './uni.promisify.adaptor' import uView from '@/uni_modules/uview-ui' import "./utils/permission.js" import { $http } from "@escook/request-miniprogram" uni.$http = $http // 请求的根路径 $http.baseUrl = "https://pro.cloud.boyuantech.net/manage" // $http.baseUrl = "https://test.cloud.boyuantech.net/manage" // 请求拦截器 $http.beforeRequest = function(options) { // uni.showLoading({ // title: '数据加载中...', // mask: true, // }) // console.log(options); options.header = { Token: uni.getStorageSync('Token') } } // 响应拦截器 $http.afterRequest = function(err) { console.log(err.errMsg); if (err.errMsg == 'request:fail ') { console.log(1) uni.showToast({ icon: 'error', title: '无网络' }) } // if (err.errMsg) { // console.log('无网络'); // uni.showToast({ // icon: 'error', // title: '无网络' // }) // uni.hideLoading() // return // } // uni.hideLoading() if (err.data.code === 2000) { uni.removeStorageSync('Token') uni.showToast({ title: '令牌过期,请重新登录', icon: 'none', duration: 2000 }) uni.removeStorageSync('Token') // uni.hideLoading() uni.redirectTo({ url: "/pages/login/login" }) return } } // (response) => { // // console.log(response,'1'); // const { // success, // msg, // data // } = response.data // // 要根据success的成功与否决定下面的操作 // console.log(success,msg,data); // if (success) { // return data // } else { // // 业务已经错误了 还能进then ? 不能 ! 应该进catch // console.log(response.data.msg); // return Promise.reject(new Error(message)) // } // }, error => { // error 信息 里面 response的对象 // if (err.data.code === 2000) { // uni.showToast({ // title: '令牌过期,请重新登录', // icon: 'none', // duration: 2000 // }) // // uni.hideLoading() // uni.redirectTo({ // url: "/pages/login/login" // }) // } else { // console.log(error.msg); // 提示错误信息 // } // return Promise.reject(error) // } // 封装弹框的方法 uni.$showMsg = function(title = '数据请求失败!', duration = 1500) { uni.showToast({ title, duration, icon: 'none', mask: true }) } Vue.use(uView); Vue.config.productionTip = false App.mpType = 'app' const app = new Vue({ ...App, store }) app.$mount() // #endif // #ifdef VUE3 import { createSSRApp } from 'vue' export function createApp() { const app = createSSRApp(App) return { app } } // #endif