coupon.js
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
var t = function(t) {
return t && t.__esModule ? t : {
default: t
};
}(require("../../../utils/LoadMore.js")), e = getApp(), a = new t.default(), o = require("../../../utils/util.js");
Page({
data: {
url: e.globalData.setting.url,
resourceUrl: e.globalData.setting.resourceUrl,
iurl: e.globalData.setting.imghost,
categories: [ {
name: "未使用",
id: 0
}, {
name: "已使用",
id: 1
}, {
name: "已过期",
id: 2
} ],
typeId: 0,
coupons: null,
currentPage: 1,
storeName: "自营商店"
},
onLoad: function(t) {
var e = void 0 === t.type ? this.data.typeId : t.type;
a.init(this, "", "coupons"), this.setStoreName(), this.requestCoupons(e);
},
changeTab: function(t) {
this.reloadCoupons(t.currentTarget.id);
},
requestCoupons: function(t) {
var e = this, n = "/api/user/getCouponList?type=" + t + "&p=" + e.data.currentPage;
this.setData({
typeId: t
}), a.request(n, function(t) {
e.data.currentPage++, t.data.result.forEach(function(t, e, a) {
t.deadTimeFommat = o.format(t.use_end_time, "yyyy-MM-dd");
}), wx.stopPullDownRefresh();
});
},
onReachBottom: function() {
a.canloadMore() && this.requestCoupons(this.data.typeId);
},
onPullDownRefresh: function(t) {
this.reloadCoupons(this.data.typeId);
},
reloadCoupons: function(t) {
a.resetConfig(), this.setData({
coupons: null
}), this.data.currentPage = 1, this.requestCoupons(t);
},
setStoreName: function() {
var t = this;
e.getConfig(function(e) {
for (var a = e.config, o = 0; o < a.length; o++) if ("store_name" == a[o].name) {
t.setData({
storeName: a[o].value
});
break;
}
});
}
});