app.js
1.1 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
//app.js
App({
post: function (url, data, headerParams) {
wx.showNavigationBarLoading()
wx.showLoading({
title: '',
})
var promise = new Promise((resolve, reject) => {
let that = this;
let postData = data;
let baseUrl = 'http://maifuzi.w.bronet.cn/api/';
let header = {
'content-type': 'application/x-www-form-urlencoded'
}
header = Object.assign(header, headerParams)
wx.request({
url: baseUrl + url,
data: postData,
method: 'POST',
header: header,
success: function (res) {
resolve(res)
setTimeout(function () {
wx.hideLoading()
}, 600)
wx.hideNavigationBarLoading()
},
error: function (e) {
reject('');
wx.hideLoading()
wx.hideNavigationBarLoading()
wx.showModal({
title: '',
content: res.data.msg,
showCancel: false
})
}
})
});
wx.hideLoading()
return promise;
},
globalData: {
userInfo: null
}
})