xytSk-App/main.js

53 lines
1.0 KiB
JavaScript
Raw Normal View History

2024-05-28 14:14:34 +08:00
// #ifndef VUE3
import Vue from 'vue'
2024-05-30 13:53:09 +08:00
import uView from '@/uni_modules/uview-ui'
Vue.use(uView)
2024-05-28 14:14:34 +08:00
import App from './App'
2024-05-28 15:39:21 +08:00
import { $http } from '@escook/request-miniprogram'
2024-05-28 14:14:34 +08:00
Vue.config.productionTip = false
2024-05-31 10:36:46 +08:00
uni.$http = $http
$http.baseUrl = 'http://local.gunshiiot.com:18083'
2024-05-28 15:39:21 +08:00
// 请求拦截器
2024-05-31 10:36:46 +08:00
$http.beforeRequest = function (options) {
uni.showLoading({
title: '数据加载中'
})
2024-06-07 10:56:32 +08:00
if (options.url.indexOf('/doLogin') == -1) {
2024-05-31 10:36:46 +08:00
options.header = {
2024-06-05 17:26:16 +08:00
'gs-token': uni.getStorageSync('Gs-Token')
2024-05-28 15:39:21 +08:00
}
2024-05-31 10:36:46 +08:00
}
2024-05-28 15:39:21 +08:00
}
// 响应拦截器
2024-05-31 10:36:46 +08:00
$http.afterRequest = function (options) {
2024-05-28 15:39:21 +08:00
uni.hideLoading()
}
2024-05-31 10:36:46 +08:00
uni.$showMsg = function (title = '数据请求失败了', duration = 1500) {
2024-05-28 15:39:21 +08:00
return uni.showToast({
title,
duration,
2024-05-31 10:36:46 +08:00
icon: 'none'
2024-05-28 15:39:21 +08:00
})
}
Vue.config.productionTip = false
2024-05-28 14:14:34 +08:00
App.mpType = 'app'
const app = new Vue({
2024-05-31 10:36:46 +08:00
...App
2024-05-28 14:14:34 +08:00
})
app.$mount()
// #endif
// #ifdef VUE3
import { createSSRApp } from 'vue'
import App from './App.vue'
2024-05-31 10:36:46 +08:00
export function createApp () {
2024-05-28 14:14:34 +08:00
const app = createSSRApp(App)
return {
app
}
}
2024-05-31 10:36:46 +08:00
// #endif