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-30 17:41:44 +08:00
|
|
|
uni.$http = $http
|
|
|
|
|
$http.baseUrl = 'http://local.gunshiiot.com:18083'
|
2024-05-28 15:39:21 +08:00
|
|
|
// 请求拦截器
|
2024-05-30 17:41:44 +08:00
|
|
|
$http.beforeRequest = function (options) {
|
|
|
|
|
uni.showLoading({
|
|
|
|
|
title: '数据加载中'
|
|
|
|
|
})
|
|
|
|
|
if (options.url.indexOf('/my/') !== -1) {
|
|
|
|
|
options.header = {
|
|
|
|
|
Authorization: store.state.address.token
|
|
|
|
|
}
|
|
|
|
|
console.log(options.header)
|
|
|
|
|
}
|
|
|
|
|
if (options.url.indexOf('/getLoginInfo') !== -1) {
|
|
|
|
|
options.header = {
|
|
|
|
|
'Gs-Token': '827C4B2AA67D4724B2677B0A708D5033'
|
2024-05-28 15:39:21 +08:00
|
|
|
}
|
2024-05-30 17:41:44 +08:00
|
|
|
}
|
2024-05-28 15:39:21 +08:00
|
|
|
}
|
|
|
|
|
// 响应拦截器
|
2024-05-30 17:41:44 +08:00
|
|
|
$http.afterRequest = function (options) {
|
2024-05-28 15:39:21 +08:00
|
|
|
uni.hideLoading()
|
|
|
|
|
}
|
2024-05-30 17:41:44 +08:00
|
|
|
uni.$showMsg = function (title = '数据请求失败了', duration = 1500) {
|
2024-05-28 15:39:21 +08:00
|
|
|
return uni.showToast({
|
|
|
|
|
title,
|
|
|
|
|
duration,
|
2024-05-30 17:41:44 +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-30 17:41:44 +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-30 17:41:44 +08:00
|
|
|
export function createApp () {
|
2024-05-28 14:14:34 +08:00
|
|
|
const app = createSSRApp(App)
|
|
|
|
|
return {
|
|
|
|
|
app
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-30 17:41:44 +08:00
|
|
|
// #endif
|