VtuanOrder.js
9.9 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
import {
request
} from "../../request/index.js"
const a = getApp()
var isClick = true;
Page({
data: {
imagesUrl: a.globalData.baseUrl,
nav_list: ['全部订单', '待付款', '待分享', '待发货', '待收货', '待评价', '已完成', '退款中', '已退款'],
count: 2,
active: "1",
myOrder: [],
msg: '',
publicList: [],
timeStamp: '',
nonceStr: '',
package: '',
signType: 'MD5',
paySign: '',
way: 1,
esl: '',
it_cloose: false,
time: 30 * 60 * 60 * 1000,
timeData: {},
good_id: '',
good_name: '',
imgShare: '',
deltrue: false
},
onLoad: function (options) { // 接收参数
console.log(options);
let that = this
that.setData({
id: options.id
})
that.getMyorder()
},
onShow: function () {},
onChange(e) {
this.setData({
timeData: e.detail,
});
},
switchTap(e) {
let index = e.currentTarget.dataset.index;
this.setData({
esl: index,
way: index + 1
})
this.getMyorder()
},
tomyOrderObligation(e) { // 进订单详情
console.log(e);
let StateWay = e.currentTarget.dataset.stateway
let order_no = e.currentTarget.dataset.order_no
let is_car = e.currentTarget.dataset.is_car
if (is_car == 1) {
wx.navigateTo({
url: '/pages/VtuanOrderDetail/VtuanOrderDetail?order_no=' + order_no + '&StateWay=' + StateWay
})
} else {
wx.navigateTo({
url: '/pages/VtuanOrderDetail/VtuanOrderDetail?order_no=' + order_no + '&StateWay=' + StateWay
})
}
},
gotoplay() { // 去支付
wx.navigateTo({
url: '/pages/cheConfirmAnOrder/cheConfirmAnOrder'
})
},
tuiOrder(e) {
let order_no = e.currentTarget.dataset.order_no
let that = this
console.log(order_no);
wx.showModal({
title: '提示',
content: '确认要申请退款嘛?',
success: async function (res) {
if (res.confirm) {
try {
const {
data
} = await request({
url: 'api/my/tuiOrder',
data: {
order_no: order_no
}
})
console.log(data, "申请退款");
that.setData({
msg: data.msg
})
that.popSuccessTest()
setTimeout(() => {
that.getMyorder()
}, 1300);
} catch (err) {
that.setData({
msg: err.msg
})
that.popMaskTest()
}
}
}
})
},
async getMyorder() { // 获取订单
let that = this;
try {
const {
data: {
data
}
} = await
request({
url: 'api/my2/tuanOrder',
data: {
way: that.data.way
}
})
if (data.length == 0) {
that.setData({
it_cloose: true
})
}
that.setData({
myOrder: data,
})
console.log(that.data.myOrder, "订单");
} catch (err) {
console.log(err);
that.setData({
msg: '未获取到数据'
})
that.popMaskTest()
}
},
async cancelOrder(e) { // 取消订单
let that = this
try {
const {
data
} = await request({
url: 'api/my/qvOrder',
data: {
order_no: e.currentTarget.dataset.order_no
}
})
console.log(data, "取消订单");
that.setData({
msg: data.msg
})
that.popSuccessTest()
setTimeout(() => {
that.getMyorder()
}, 1300);
} catch (err) {
that.setData({
msg: err.msg
})
that.popMaskTest()
}
},
delOrder(e) { // 删除
let that = this
that.setData({
deltrue: true
})
wx.showModal({
title: '提示',
content: '确定要删除该订单吗?',
success: async function (res) {
if (res.confirm) {
try {
const {
data
} = await request({
url: 'api/new2/tuiOrderDel',
data: {
order_no: e.currentTarget.dataset.order_no
}
})
console.log(data, "取消订单");
if (data.code == 1) {
let msg = data.msg
a.popSuccessTest(msg)
setTimeout(() => {
that.getMyorder()
that.setData({
deltrue: false
})
}, 1000);
} else {
let msg = data.msg
a.popTest(msg)
that.setData({
deltrue: false
})
}
} catch (err) {
let msg = err.msg
a.popTest(msg)
that.setData({
deltrue: false
})
}
} else {}
}
})
},
async returnStore(e) { // 申请退货
let that = this
try {
const {
data
} = await request({
url: 'api/my/tuiOrder',
data: {
order_no: e.currentTarget.dataset.order_no
}
})
console.log(data, "申请退货");
that.setData({
msg: data.msg
})
that.popSuccessTest()
that.getMyorder()
} catch (err) {
that.setData({
msg: err.msg
})
that.popMaskTest()
}
},
async returnMoney(e) { // 申请退款
let that = this
try {
const {
data
} = await request({
url: 'api/my/tuiOrder',
data: {
order_no: e.currentTarget.dataset.order_no
}
})
console.log(data, "申请退款");
that.setData({
msg: data.msg
})
that.popSuccessTest()
setTimeout(() => {
that.getMyorder()
}, 1300);
} catch (err) {
that.setData({
msg: err.msg
})
that.popMaskTest()
}
},
Immediate(e) { // 立即评价
let order_no = e.currentTarget.dataset.order_no
let token = wx.getStorageSync("token")
if (token) {
wx.navigateTo({
url: '/pages/appraise/appraise?order_no=' + order_no
})
} else {
this.setData({
msg: '请登录后操作'
})
this.popMaskTest()
}
},
async CancelRefund(e) { //取消退款
let that = this
try {
const {
data
} = await request({
url: 'api/my/qvTui',
data: {
order_no: e.currentTarget.dataset.order_no
}
})
console.log(data, "取消退款");
that.setData({
msg: data.msg
})
that.popSuccessTest()
setTimeout(() => {
that.getMyorder()
}, 1300);
} catch (err) {
that.setData({
msg: err.msg
})
that.popMaskTest()
}
},
gotopay(e) { // 订单支付
let that = this
request({
url: 'api/my/liPay',
data: {
order_no: e.currentTarget.dataset.order_no
}
}).then(res => {
console.log(res, "订单支付");
that.setData({
timeStamp: res.data.data.timeStamp,
nonceStr: res.data.data.nonceStr,
package: res.data.data.package,
signType: 'MD5',
paySign: res.data.data.paySign,
})
wx.requestPayment({
timeStamp: that.data.timeStamp,
nonceStr: that.data.nonceStr,
package: that.data.package,
signType: 'MD5',
paySign: that.data.paySign,
success(res) {
console.log(res);
// wx.redirectTo({
// url: '/pages/MyOrder/MyOrder?order_no=' + that.data.order_no,
// })
that.getMyorder()
},
fail(res) {
console.log(res)
}
})
}).catch(err => {
that.setData({
msg: err.msg
})
this.popMaskTest()
console.log(err);
})
},
async sureShouOrder(e) { //确认收货
let that = this
if (isClick) {
isClick = false;
try {
const {
data
} = await request({
url: 'api/my/shouOrder',
data: {
order_no: e.currentTarget.dataset.order_no
}
})
console.log(data, "确认收货");
that.setData({
msg: data.msg
})
that.popSuccessTest()
setTimeout(() => {
that.getMyorder()
}, 1000);
} catch (err) {
that.setData({
msg: err.msg
})
that.popMaskTest()
}
setTimeout(function () {
isClick = true
}, 1000); //一秒内不能重复点击
} else {
return;
}
},
gotopaybuy(e) {
let order_no = e.currentTarget.dataset.order_no
if (isClick) {
isClick = false;
setTimeout(function () {
isClick = true;
}, 3000); //一秒内不能重复点击
} else {
return;
}
},
popSuccessTest() {
wx.showToast({
title: this.data.msg,
icon: '', //默认值是success,就算没有icon这个值,就算有其他值最终也显示success
duration: 1200, //停留时间
})
},
popMaskTest() {
wx.showToast({
title: this.data.msg,
duration: 1200,
icon: 'none',
mask: true //是否有透明蒙层,默认为false
//如果有透明蒙层,弹窗的期间不能点击文档内容
})
},
onShareAppMessage(options) {
console.log(options);
let that = this;
let good_id = options.target.dataset.good_id
let good_name = options.target.dataset.good_name
let imgShare = options.target.dataset.imgshare
let shareObj = {
title: good_name || "车唛团购分享", // 默认是小程序的名称(可以写slogan等)
path: '/pages/VtuanDetail/VtuanDetail?id=' + good_id, // 默认是当前页面,必须是以‘/’开头的完整路径
imageUrl: imgShare, //自定义图片路径,可以是本地文件路径、代码包文件路径或者网络图片路径,支持PNG及JPG,不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
};
// 返回shareObj
return shareObj;
},
})