-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
executable file
·71 lines (56 loc) · 1.44 KB
/
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import Vue from 'vue'
import App from './App'
import store from './store'
// 引入插件
import request from '@/common/request.js'
import VueI18n from 'vue-i18n'
import zh from './common/lang/zh.js'
import en from './common/lang/en.js'
// 全局配置
request.setConfig({
// baseUrl: 'http://bluecoffee.s1.natapp.cc/',
baseUrl: 'https://jeetpan.mynatapp.cc/',
header: {
'content-type': 'application/json'
}
})
// 设置请求拦截器
request.interceptors.request(request => {
return request; // 返回修改后的配置,如未修改也需添加这行
})
// 设置响应拦截器
request.interceptors.response(
response => {
if (response.data.code === 0) {
return response.data; // 原样返回
} else {
return Promise.reject(response.data) // 向外层抛出错误,用catch捕获
}
}
)
// // 挂载到全局vue实例上,在页面中可以使用this.$request调用request实例下相应方法
Vue.prototype.$request = request;
Vue.config.productionTip = false
Vue.prototype.$store = store
Vue.prototype.$appId = 'wx6d8cc793be64b899'
App.mpType = 'app'
Vue.use(VueI18n)
Vue.config.productuinTip = false
const i18n = new VueI18n({
locale: uni.getStorageSync('lang') || 'cn',
messages: {
'en': {
index: en
},
'cn': {
index: zh
}
}
})
Vue.prototype._i18n = i18n
const app = new Vue({
store,
i18n,
...App
})
app.$mount()