-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathmain.js
55 lines (49 loc) · 979 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import App from './App'
import * as Pinia from 'pinia'
import config from './config.js'
// #ifndef VUE3
import Vue from 'vue'
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
...App
})
app.$mount()
// #endif
const request = function(path,method,data,failCallback,completeCallback) {
// loading
uni.showLoading({
mask:true
})
return new Promise(resolve =>{
uni.request({
url:config.baseUrl + path,
data:data,
method:method,
header:{
'Content-Type':'application/json;charset=UTF-8',
'token':uni.getStorageSync('token')
},
success:res=>{
// 隐藏loading
uni.hideLoading()
if(res.data.code === 200){
resolve(res.data)
}
}
})
})
}
// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
const app = createSSRApp(App)
app.use(Pinia.createPinia());
// 全局挂载
app.config.globalProperties.$request = request
return {
app,
Pinia
}
}
// #endif