-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathapp.js
53 lines (49 loc) · 1.07 KB
/
app.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
//app.js
var CONFIG = require("./config");
App({
globalData: {
userInfo: null,
auth: '',
loginData: '',
},
onLaunch: function() {
wx.showLoading({
title: '加载中',
});
},
postRequest: function(action, inputData, showError = true, callback) {
let _this = this;
wx.request({
url: CONFIG.API_URL + action,
data: {
"data": JSON.stringify(inputData)
},
header: {
'Content-Type': 'application/x-www-form-urlencoded',
Auth: wx.getStorageSync('auth') || ''
},
method: 'POST',
dataType: 'json',
responseType: 'text',
success: function(res) {
if (res.data.code != 0) {
if (showError === true) {
_this.showToastTip(res.data.msg)
return;
}
}
callback(res.data);
console.log(res)
},
fail: function(res) {},
complete: function(res) {},
})
},
showToastTip: function(name, icon = 'none') {
wx.showToast({
title: name,
icon: icon,
duration: 2000
})
},
})