app.js
1.3 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
App({
post: function (url, data, headerParams) {
wx.showNavigationBarLoading()
var promise = new Promise((resolve, reject) => {
let that = this;
let postData = data;
let baseUrl = 'https://einp.net/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;
},
nowDate(later) {
let date = new Date();
date.setDate(date.getDate() + later);
let month = date.getMonth() + 1;
let day = date.getDate();
return date.getFullYear() + '/' + (month > 9 ? month : ('0' + month)) + '/' + (day > 9 ? day : ('0' + day));
},
globalData: {
userInfo: null
}
})