main.js
1.2 KB
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'
Vue.config.productionTip = false
// Vue.prototype.apiUrl = "http://tudoujiaju.t.brotop.cn/api"
Vue.prototype.apiUrl = "https://t-d-h.com/api"
App.mpType = 'app'
Vue.prototype.$loginRequest = function(url, data = '', method) {
// var that=this
return new Promise((reslove, reject) => {
uni.request({
url: this.apiUrl + url,
method: method,
header: {
'token': uni.getStorageSync('token')
},
data: data,
success: (res) => {
console.log(res)
//token错误和返回结果都是用code
if (res.data.code == 0) {
// reslove({
// "tcode": 0,
// "msg": "未登录"
// })
// this.code=0
reslove(res.data)
}
if (res.data.code == 1) {
reslove(res.data)
}
// else if (res.data.code == '401') {
// uni.showToast({
// title: '请登录后操作',
// icon: 'none'
// })
// } else if (uni.getStorageSync('token') == '') {
// uni.reLaunch({
// url: '/pages/index/indexNoLogin.vue'
// })
// }
if (res.data.code == 0 || res.data.code) {
reslove(res.data)
}
}
})
})
}
const app = new Vue({
...App
})
app.$mount()