integral.js
8.91 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
// pages/yhq/yhq.js
var e = function (e) {
return e && e.__esModule ? e : {
default: e
};
}(require("../../../utils/LoadMore.js")), t = getApp(), a = t.request, o = t.globalData.setting, os = o,
i = require("../../../utils/util.js"), ut = i, b = require("../../../app.js"), app = b, s = require("../../../utils/common.js"), n = new e.default();
var regeneratorRuntime = require('../../../utils/runtime.js');
Page({
/**
* 页面的初始数据
*/
data: {
details: [], //数据
is_no_more:0,
current_page: 0,
showModal:false,//积分弹框的控制器
number:0,
jfmx:true,
jfcz:false,
val:1,
/**
* 页面配置
*/
winWidth: 0,
winHeight: 0,
// tab切换
currentTab: 0,
money:1.00,
integral:50,
iurl: o.imghost,
is_show_jfcz:0,
},
/**
* 刷出积分劵
*/
async exchange() {
var e = this, result;
var user_id = getApp().globalData.user_id;
var store_id = os.stoid;
var get_data = {
user_id: user_id, store_id: store_id,
pageSize: 10, page: e.data.current_page
///api/weshop/users/listExchangeCoupons
}; //api/index/yuck
await getApp().request.promiseGet("/api/weshop/users/listExchangeCoupons", {
data:get_data
}).then(res => {
var msg = res.data;
result = msg.data.pageData;
})
e.setData({
result: result
})
},
/**
* 积分明细
*/
async detaileds() {
if (this.data.is_no_more) return;
this.data.current_page++;
var e = this, details;
var user_id = getApp().globalData.user_id;
var store_id = os.stoid;
var get_data = {
user_id: user_id, store_id: store_id,
pageSize: 10, page: e.data.current_page
};
var big_arr = this.data.details;
await getApp().request.promiseGet("/api/weshop/users/listPoints", {
data: get_data
}).then(res => {
var msg = res.data;
if(!msg || !msg.data.pageData || msg.data.pageData.length == 0){
this.data.is_no_more = 1;
getApp().showWarning("未找更多数据");
return false;
}
details = msg.data.pageData;
details.forEach(function (val, ind) {
big_arr.push(val);
})
setTimeout(() => {
this.setData({
details: big_arr
});
}, 1500)
})
var get_datas= {
user_id: user_id, store_id: store_id,
};
await getApp().request.promiseGet("/api/weshop/users/getAllPoints", {
data: get_datas
}).then(res => {
var msg = res.data;
var integrals=msg.data.Integral;
console.log(integrals);
this.setData({number: integrals})
})
},
//---加载更多是靠这个函数----
onReachBottom: function () {
console.log("加载跟多");
this.detaileds();
},
//积分弹框控制器
integral:function(e){
var integral = e.target.dataset.integral;
var money = e.target.dataset.money;
console.log(money, "积分", integral);
this.setData({
showModal: true, money: money, integral: integral
})
},
//弹窗的方法
preventTouchMove: function () {
},
// 票数量的加
plus:function(e){
var val = this.data.val;
val++;
console.log("加",val);
this.setData({
val: val
})
},
//票数量的减
reduce:function(e){
var val = this.data.val;
//console.log("减", val);
if (val>1){
val--;
//console.log("减", val);
this.setData({
val: val
})
}
},
//关闭弹框
shut: function (e) {
this.setData({ showModal: false })
console.log("bb");
},
/**
* 点击tab切换
*/
swichNav: function (e) {
console.log("是什么", e.target.dataset.current);
var val=e.target.dataset.current;
var that = this;
if (this.data.currentTab== parseInt(e.target.dataset.current)) {
return false;
} else {
//如果是积分充值,但是不显示的话,不响应点击事件,退出
if(val!=0 && !this.data.is_show_jfcz){
return false;
}
that.setData({
currentTab: e.target.dataset.current
})
}
if (val==0){
console.log("积分明细", e.target.dataset.current);
var jfmx=true;
var jfcz= false;
this.setData({ jfmx: jfmx, jfcz: jfcz, current_page: 0,details:[] });
this.detaileds();
}else{
if(this.data.is_show_jfcz) {
console.log("积分充值", e.target.dataset.current);
var jfmx = false;
var jfcz = true;
this.setData({jfmx: jfmx, jfcz: jfcz, current_page:1,result:[] });
this.exchange();
}else{
return false;
}
}
},
// 积分收支明细
detailed:function(){
wx:wx.navigateTo({
url: 'query/index',
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var th=this;
getApp().request.get("/api/wx/weappSendlist/page", {
data: {
store_id: os.stoid,
typeid: "1002"
},
success: function(res) {
if (res.data.code == 0 && res.data.data.pageData.length > 0) {
var template_id = res.data.data.pageData[0].template_id;
th.setData({template_id:template_id});
}
}
});
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
//点击确定
determine(event) {
console.log(event.currentTarget.dataset.money);
var money = event.currentTarget.dataset.money;
var integral = event.currentTarget.dataset.integral;
var val = event.currentTarget.dataset.val
//console.log(money, integral, val,"参数", a);
var user_id = getApp().globalData.user_id;
var store_id = os.stoid;
var th= this, number;
this.sendsm(function(){
getApp().request.promiseGet("/api/weshop/users/getPay"
, {
data: { user_id: user_id, store_id: store_id, buynum: val, mon: money, integ: integral, recharge_type:1}
}).then(res => {
// console.log("1" + res);
var msg = res.data.data;
var parentSn = msg.order_sn;
var store_id = os.stoid;
getApp().request.post("/api/weshop/order/pay/createRechargeOrder", {
data: {
parentSn: parentSn,
store_id: store_id
},
success: function (su) {
var n = su.data.data;
th.weixinPay(n,
function () {
console.log("支付成功页面2333");
th.jumpPaymentPage();
}, function () {
getApp().showWarning("支付失败");
})
}
})
})
})
},
//------支付成功页面--------
jumpPaymentPage: function () {
console.log("支付成功页面2333");
wx.redirectTo({
url: "msg/msg"
});
},
//------调起支付框--------
weixinPay: function (n, success, fail) {
wx.requestPayment({
timeStamp: String(n.timeStamp),
nonceStr: n.nonceStr,
package: n.packageValue,
signType: n.signType,
paySign: n.paySign,
success: function (n) {
console.log(n), getApp().showSuccess("支付成功!");
"function" == typeof success && success();
// wx.redirectTo({
// url: "jf"
// });
},
fail: function (n) {
console.log(n), "requestPayment:fail" == n.errMsg ? getApp().showWarning("支付失败") : "requestPayment:fail cancel" == n.errMsg ? getApp().showWarning("您已取消支付") : getApp().showWarning("支付失败:" + n.errMsg.substr("requestPayment:fail ".length)),
"function" == typeof fail && fail();
}
});
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
//--先判断会员状态--
var user_info = getApp().globalData.userInfo;
if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
wx.navigateTo({ url: '/pages/togoin/togoin', })
return false;
}
this.exchange();
this.detaileds();
wx.setNavigationBarTitle({
title: "我的积分",
})
//要实时获取开关是显示
var th=this;
getApp().getConfig2(function(ee){
var json_d = JSON.parse(ee.switch_list);
th.setData({ is_show_jfcz: json_d.jfcz_switch });
},1)
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
//订阅消息提醒
sendsm:function(func)
{
var template_id = this.data.template_id;
// //授权订阅
wx.requestSubscribeMessage({
tmplIds: [template_id],
success(res) {
func();
},
fail(res) {
func();
}
})
},
})