-
Notifications
You must be signed in to change notification settings - Fork 144
/
post.js
51 lines (41 loc) · 1.2 KB
/
post.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
Page({
data: {
array: ["福利", "Android", "iOS", "休息视频", "扩展资源", "前端", "all"],
index: 0,
toastHidden: true
},
onLoad: function (options) {
that = this;
},
onPickerChanged: function (event) {
this.setData({index: event.detail.value})
},
onToastChanged: function () {
that.setData({toastHidden: true});
},
formSubmit: function (event) {
console.log(event);
post(event.detail.value);
}
});
function post(data) {
console.log(Util.json2Form(data));
wx.request({
url: Constant.BASE_URL + "/add2gank",
header: {
"Content-Type": "application/x-www-form-urlencoded"
},
method: "POST",
data: Util.json2Form(data).concat("&debug=false"),
complete: function (res) {
if (res == null || res.data == null || res.data.msg == null) {
console.error(Constant.ERROR_DATA_IS_NULL);
return;
}
that.setData({toastHidden: false, toastText: res.data.msg});
}
});
}
var that;
var Constant = require('../../utils/constant.js');
var Util = require('../../utils/util.js');