myOrder.js
19.0 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
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
// pages/my/myCollection/myCollection.js
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
choose: false,
id: 1,
goodsId: 0,
status: 0,
navId: 1,
orderList: null,
cancel_order: false,
after_order: false,
cancel_id: 0,
minutes: 0,
cancel_value: '',
cancelId: 0,
daifukuan: -1,
is_cancel: false,
nav: [{
id: 1,
name: '全部',
status: 0
}, {
id: 2,
name: '待付款',
status: 1
}, {
id: 3,
name: '待发货',
status: 2
}, {
id: 4,
name: '待收货',
status: 3
}, {
id: 5,
name: '待评价',
status: 4
}, {
id: 6,
name: '已完成',
status: 5
}, {
id: 7,
name: '',
status: 9
}],
cancel_reason: [{
id: 1,
name: '我不想买了'
}, {
id: 2,
name: '卖家缺货'
}, {
id: 3,
name: '多拍了'
}, {
id: 4,
name: '服务太差'
}, {
id: 5,
name: '信息填写错误'
}, {
id: 6,
name: '再等等'
}, {
id: 7,
name: '其他原因'
}],
},
//changeReasonId
changeReasonId(e) {
let id = e.currentTarget.dataset.id;
let value = e.currentTarget.dataset.value;
console.log(id, value + "什么值")
this.setData({
cancel_id: id,
cancel_value: value
});
},
//点击确定取消订单
close_cancel_mask() {
let url = '/wxapp/order/cancelOrder'
let list = this.data.orderList
let ind = this.data.daifukuan
if (this.data.cancel_value == '') {
wx.showToast({
title: '请选择取消原因',
icon: 'none'
})
return;
}
let params = {
id: this.data.cancelId,
msg: this.data.cancel_value
}
app.post(url, params).then(r => {
if (r.code == 1) {
wx.showToast({
title: '订单取消成功',
icon: 'none'
})
this.setData({
cancel_order: !this.data.cancel_order,
});
list.splice(ind, 1)
this.setData({
orderList: list
})
} else {
wx.showToast({
title: r.msg,
icon: 'none'
})
}
})
},
//点击进入待收货订单详情
jump_order_wait_receite(e) {
wx.navigateTo({
url: '../wait_receite/wait_receite?id=' + e.currentTarget.dataset.cancelId,
})
},
//点击确定售后
close_cancel_masks() {
let url = '/wxapp/order/applySaleAfter'
let params = {
id: this.data.cancelId,
sale_after_reason: this.data.cancel_value
}
app.post(url, params).then(r => {
if (r.code == 1) {
this.setData({
after_order: !this.data.after_order
});
wx.showToast({
url: '申请成功',
icon: 'none'
})
} else {
wx.showToast({
title: '只能在订单完成的24小时内申请售后',
icon: 'none'
})
this.setData({
after_order: !this.data.after_order
});
}
})
},
//切换导航
changeNavId(e) {
let navid = e.currentTarget.dataset.navid
let status = e.currentTarget.dataset.status
this.setData({
status: status,
navId: navid
})
this.fetchOrderList();
},
//取消订单
clearOrder(e) {
let id = e.currentTarget.dataset.id
let url = '/wxapp/order/delOrder'
let params = {
id: id
}
app.post(url, params).then(r => {
if (r.code == 1) {
wx.showToast({
title: '删除成功',
icon: 'none'
})
this.setData({
status: 0
})
this.fetchOrderList()
}
})
},
//关闭取消订单
cacel_unpay_orderList() {
this.setData({
cancel_order: false
})
},
//去评价
goComments(e) {
wx.navigateTo({
url: '../comment/comment?id=' + e.currentTarget.dataset.id,
})
},
//进入待发货订单详情
jump_order_detail(e) {
let id = e.currentTarget.dataset.id
let status = e.currentTarget.dataset.status
if (status == 1) {
wx.navigateTo({
url: '../unpayOrderDetail/unpayOrderDetail?id=' + id,
})
} else if (status == 2) {
wx.navigateTo({
url: '../unship/unship?id=' + id,
})
} else if (status == 3) {
wx.navigateTo({
url: '../wait_receite/wait_receite?id=' + id
})
} else if (status == 4 || status == 5) {
wx.navigateTo({
url: '../uncomment/uncomment?id=' + id,
})
}
},
//进入待收货订单详情
unship(e) {
let id = e.currentTarget.dataset.id
wx.navigateTo({
url: '../wait_receite/wait_receite?id=' + id
})
},
//进入待评价订单详情
uncomment(e) {
let id = e.currentTarget.dataset.id
wx.navigateTo({
url: '../uncomment/uncomment?id=' + id,
})
},
//进入售后订单详情
afterMarket(e) {
let id = e.currentTarget.dataset.id
wx.navigateTo({
url: '../aftermarketDetail/aftermarketDetail?id=' + id,
})
},
//进入待付款订单详情
jump_unpay_detail(e) {
let id = e.currentTarget.dataset.id
wx.navigateTo({
url: '../unpayOrderDetail/unpayOrderDetail?id=' + id,
})
},
//确认收货
confirm_goods(e) {
let url = '/wxapp/order/confirmCollect'
let id = e.currentTarget.dataset.id
let orderList = this.data.orderList
let params = {
id: id
}
app.post(url, params).then(r => {
if (r.code == 1) {
wx.showToast({
title: '收货成功',
icon: 'none'
})
orderList.forEach(function(ele, index) {
if (id = ele.id) {
orderList.splice(index, 1)
}
})
this.setData({
orderList: orderList
})
} else {
wx.showToast({
title: r.msg,
icon: 'none'
})
}
})
},
//提醒发货
alert_send_goods(e) {
let order_sn = e.currentTarget.dataset.ordersn
let url = '/wxapp/order/setRemindDeliver'
let params = {
order_sn: order_sn
}
app.post(url, params).then(r => {
if (r.code == 1) {
wx.showToast({
title: '提醒成功',
icon: 'none'
})
} else {
wx.showToast({
title: '已经为您提醒发货',
icon: 'none'
})
}
})
},
//渲染订单列表
fetchOrderList() {
let that = this
let url = '/wxapp/order/index'
let params = {
status: that.data.status
}
app.post(url, params).then(r => {
if (r.code == 1) {
r.data.forEach(function(ele, index) {
ele.is_cancel = false
if (ele.status == 1) {
if (ele.cancel_time > 0) {
ele.is_cancel = true
} else {
ele.is_cancel = false
}
var daojishi = ele.create_time + ele.cancel_time
var now_time = new Date();
now_time = Math.floor(now_time / 1000)
ele.shengyu_time = daojishi - now_time;
if (ele.shengyu_time <= 0) {
let url = '/wxapp/order/cancelOrder'
let params = {
id: ele.id,
msg: '订单超时'
}
app.post(url, params).then(r1 => {
if (r1.code == 1) {}
})
} else {
ele.hours = Math.floor((ele.shengyu_time) / (60 * 60)) % 24;
ele.minutes = Math.floor((ele.shengyu_time) / (60)) % 60;
}
ele.create_time = app.timeFormate(ele.create_time, 'YYMMDDHHMM');
} else {
// r.data.forEach(function (ele, index) {
ele.pay_time = app.timeFormate(ele.pay_time, 'YYMMDDHHMM');
ele.create_time = app.timeFormate(ele.create_time, 'YYMMDDHHMM');
// });
}
if (r.data.length != 0) {
that.setData({
orderList: r.data
});
} else {
that.setData({
orderList: []
})
}
})
} else {
wx.showToast({
title: r.msg,
icon: 'none'
})
}
});
},
//绑定id
changeId() {
this.setData({
id: 0
});
},
//选中商品
choose() {
this.setData({
goods: 0
});
},
//取消订单
cancel_order(e) {
let id = e.currentTarget.dataset.orderid;
let index = e.currentTarget.dataset.index
this.setData({
cancel_id: 0,
cancel_order: !this.data.cancel_order,
cancelId: id,
daifukuan: index
});
},
//申请售后
after_order(e) {
let id = e.currentTarget.dataset.orderid;
// this.setData({
// after_order: !this.data.after_order,
// cancelId: id
// });
wx.navigateTo({
url: '../shenqingshouhou/shengqingshouhou?id='+id,
})
},
//去付款
go_pay(e) {
let index = e.currentTarget.dataset.index;
let orderList = this.data.orderList;
let amount = e.currentTarget.dataset.amount
let pay_type = orderList[index].pay_type;
let pay_order_sn = orderList[index].order_sn;
console.log(pay_order_sn)
let url = '/wxapp/pay/index'
let params = {
order_sn: pay_order_sn
}
app.post(url, params).then(r => {
console.log(r);
if (r.code == 1) {
if (r.data.is_awaken_wechat == 1) {
wx.requestPayment({
timeStamp: r.data.jsApiParameters.timeStamp,
nonceStr: r.data.jsApiParameters.nonceStr,
package: r.data.jsApiParameters.package,
signType: r.data.jsApiParameters.signType,
paySign: r.data.jsApiParameters.paySign,
success(res) {
console.log(456);
console.log(res);
wx.navigateTo({
url: '../paySuccess/paySuccess?order=' + pay_order_sn+'&amount='+amount,
})
},
fail(res) {
console.log(789);
console.log(res);
}
})
}
this.setData({
status: 1
})
this.fetchOrderList();
} else {
wx.showToast({
title: '失败',
icon: 'none'
})
}
});
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
this.setData({
// navId:options.index,
navId: options.status * 1 + 1,
status: options.status * 1
});
console.log()
this.fetchOrderList();
},
// 返回个人中心
get_back() {
wx.switchTab({
url: '../my',
})
},
// 选中
get_pitch() {
this.setData({
choose: !this.data.choose
});
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
wx.hideShareMenu({})
this.fetchOrderList()
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
}
})