1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- 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 = "http://test.cloud.boyuantech.net:9001"
- // 请求拦截器
- $http.beforeRequest = function(options) {
- uni.showLoading({
- title: '数据加载中...'
- })
- // console.log(options);
- options.header = {
- Token: uni.getStorageSync('Token')
- }
- }
- // 响应拦截器
- $http.afterRequest = function(err) {
- if (err.data.code === 2000) {
- uni.removeStorage('userId')
- uni.removeStorage('Token')
- uni.removeStorage('testProjectId')
- uni.showToast({
- title: '令牌过期,请重新登录',
- icon: 'none',
- duration: 2000
- })
- uni.hideLoading()
- uni.redirectTo({
- url: "/pages/login/login"
- })
- return
- }
- uni.hideLoading()
- }
- // 封装弹框的方法
- 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
|