refundApply.js
23 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
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
// tabWorkOrder/pages/refundApply/refundApply.js
import { getSubOrderInfoAPI, auditRefundAllpyAPI, getRefundDetailInfoAPI, getRefundStatusAPI, getRefundLogByOrderCodeAPI } from "./api";
import refundAPI from "./api";
import NP from "number-precision";
import qs from "~/utils/lib/qs";
import api from "~/api/api.js";
import reportPageTrackMixin from "~/mixins/reportPageTrackMixin";
import { enrichRefundSubOrderMarketingFlags, fetchOrderDetailData } from "./services/refundApplyMarketing";
const IMG_URL = "https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/";
let toastList = {
payee: "收款人姓名不能为空",
openAccBankName: "开户行名称不能为空",
openAccBranchBankName: "开户支行名称不能为空",
bankAccountNo: "银行卡号不能为空",
remark: "退款原因不能为空",
};
import dayjs from "dayjs";
Page({
behaviors: [reportPageTrackMixin],
/**
* 页面的初始数据
*/
data: {
IMG_URL,
messageObj: [
{
label: "门店名称",
value: "shopMerchantName",
required: true,
},
{
label: "园区店名称",
value: "yqMerchantName",
required: true,
},
{
label: "订单编号",
value: "orderCode",
required: true,
},
],
roleMessageObj: [
{
label: "申请人",
value: "applyStaffName",
},
{
label: "门店名称",
value: "shopMerchantName",
required: true,
},
{
label: "园区店名称",
value: "yqMerchantName",
required: true,
},
{
label: "订单编号",
value: "orderCode",
required: true,
},
],
infoData: {
merchantName: "",
yqMerchantName: "",
orderCode: "",
beforeStatus: "",
afterStatus: "",
transferStatus: "",
refundType: "",
refundAmount: "",
subOrderList: [],
refundedOrderList: [],
attachmentList: [],
// 退款人
payee: "",
},
disapprovalReason: "", // 审核不通过原因
submitStatus: false,
allTotalPrice: "", // 订单支付总金额
refundablePrice: "", // 可选可退金额
track_event_code: "", //埋点动作类型
scene: null, // 埋点业务类型
repealVisible: false,
repealStatus: false,
userInfo: {},
refundPayType: "",
initialRefundName: "",
collapse: {
refundRule: {
data: "",
show: false,
title: "查看",
},
},
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(_options) {
const options = qs.parse(decodeURIComponent(qs.stringify(_options)));
// 跳转进入页面 清空防止选择账号后再次进入页面
wx.$SCENE = null;
let userInfo = wx.$util.getUserInfo();
if (options.refundPayType == 2) {
wx.setNavigationBarTitle({ title: "退款标记申请" });
} else {
wx.setNavigationBarTitle({ title: "零售退款申请表" });
}
console.log("userInfo", userInfo);
this.setData({
scene: userInfo?.sceneType, // 埋点业务场景
userInfo,
refundPayType: options.refundPayType,
initialRefundName: options?.refundName || "",
});
console.log("options", options);
// 申请退款
if (!options.applyCode) {
this.setData({
track_event_code: "apply_refund_view_page",
});
this.fetchSubOrderInfo(options, userInfo);
} else {
// 退款详情
this.setData({
track_event_code: "refund_detail_view_page",
});
this.fetchRefundInfo(options, userInfo);
}
},
async handlePayeeConfirm(e) {
const { value } = e.detail;
const that = this;
setTimeout(() => {
that.setData({
"infoData.payee": value,
});
}, 500);
},
onCollapseChange(e) {
const value = e.detail ? "收起" : "查看";
this.setData({
"collapse.refundRule.show": e.detail,
"collapse.refundRule.title": value,
});
},
// 获取申请退款初始化数据
async fetchSubOrderInfo(options, userInfo) {
try {
// 获取子订单数据
let res = await getSubOrderInfoAPI({ orderCode: options.orderCode });
console.log("res", res);
if (res.code != 0) {
wx.$util.showToast(res.message);
return;
}
// 获取退款记录
let result = await getRefundLogByOrderCodeAPI({
orderCode: options.orderCode,
});
console.log("result", result);
if (result.code != 0) {
wx.$util.showToast(result.message);
return;
}
// 处理主订单总支付金额 用于显示可选可退总金额
this.setOrderPayPrice(res.data);
// 处理子订单商品规格
res.data?.map((val) => {
let listShowSpecificationData = this.filterSpeciation(val);
val.upgradeGoodsName = listShowSpecificationData ? `${val.upgradeGoodsName}(${listShowSpecificationData})` : val.upgradeGoodsName;
return val;
});
const marketingOptions = {
orderCode: options?.orderCode,
merchantId: options?.shopMerchantId,
};
const orderDetailData = await fetchOrderDetailData(marketingOptions.orderCode);
const subOrderList = await this.enrichSubOrderMarketingFlags(res.data || [], {
...marketingOptions,
orderDetailData,
});
// 处理退款记录商品规格
const refundedOrderList = result?.data || [];
for (const val of refundedOrderList) {
if (val.refundTime) val.refundTime = dayjs(val.refundTime).format("YYYY-MM-DD HH:mm:ss");
val?.refundApplyDetailList?.forEach((v) => {
let listShowSpecificationData = this.filterSpeciation(v);
v.upgradeGoodsName = listShowSpecificationData ? `${v.goodsName}(${listShowSpecificationData})` : v.goodsName;
});
await this.enrichSubOrderMarketingFlags(val.refundApplyDetailList || [], {
...marketingOptions,
orderDetailData,
});
}
this.setData({
"infoData.subOrderList": subOrderList,
"infoData.orderCode": options?.orderCode,
"infoData.shopMerchantName": options?.shopMerchantName,
"infoData.shopMerchantId": options?.shopMerchantId,
"infoData.yqMerchantName": userInfo?.merchantName,
"infoData.yqMerchantId": userInfo?.merchantId,
"infoData.refundedOrderList": refundedOrderList,
// 退款人
"infoData.payee": options?.refundName || "",
initialRefundName: options?.refundName || "",
});
// 判断是否默认选中部分退款
if (res.data.filter((val) => val.status == 2)?.length) this.setData({ showAllRefundBtn: false, "infoData.refundType": 2 });
} catch (error) {}
},
// 获取退款详情数据
async fetchRefundInfo(options, userInfo) {
try {
// 获取退款状态
const res = await getRefundStatusAPI({ applyCode: options?.applyCode });
if (res.code != 0) {
wx.$util.showToast(res.message);
return;
}
// 退款成功 退款时间处理
if (res?.data?.refundTime) res.data.refundTime = dayjs(res.data.refundTime).format("YYYY-MM-DD HH:mm:ss");
// 获取退款详情
const result = await getRefundDetailInfoAPI({
applyCode: options?.applyCode,
});
const { code, data, message } = result;
if (code != 0) {
wx.$util.showToast(message);
return;
}
const marketingOptions = {
orderCode: data?.orderCode,
merchantId: data?.shopMerchantId,
};
const orderDetailData = await fetchOrderDetailData(marketingOptions.orderCode);
for (const val of data?.refundedOrderList || []) {
if (val.refundTime) val.refundTime = dayjs(val.refundTime).format("YYYY-MM-DD HH:mm:ss");
val?.refundApplyDetailList?.forEach((v) => {
let listShowSpecificationData = this.filterSpeciation(v);
v.upgradeGoodsName = listShowSpecificationData ? `${v.goodsName}(${listShowSpecificationData})` : v.goodsName;
});
await this.enrichSubOrderMarketingFlags(val.refundApplyDetailList || [], {
...marketingOptions,
orderDetailData,
});
}
let subOrderList = [];
// 审核不通过并且是驻店进入页面 获取子订单数据
if (res.data.afterStatus == 5 && !wx.$hasPermission?.canViewRecruit?.(userInfo)) {
const re = await getSubOrderInfoAPI({
orderCode: result.data.orderCode,
});
if (re.code == 0) {
subOrderList = re.data || [];
subOrderList.forEach((val) => {
const listShowSpecificationData = this.filterSpeciation(val);
val.upgradeGoodsName = listShowSpecificationData ? `${val.upgradeGoodsName}(${listShowSpecificationData})` : val.upgradeGoodsName;
data?.refundApplyDetailList?.forEach((v) => {
if (val.subOrderCode === v.subOrderCode) {
val.checked = true;
val.refundPrice = v.refundAmount;
}
});
});
subOrderList = await this.enrichSubOrderMarketingFlags(subOrderList, {
...marketingOptions,
orderDetailData,
});
}
} else {
const refundApplyDetailList = (data?.refundApplyDetailList || []).map((val) => {
const listShowSpecificationData = this.filterSpeciation(val);
val.upgradeGoodsName = listShowSpecificationData ? `${val.goodsName}(${listShowSpecificationData})` : val.goodsName;
val.upgradeGoodsAlias = val.goodsAlias;
val.checked = true;
return val;
});
subOrderList = await this.enrichSubOrderMarketingFlags(refundApplyDetailList, {
...marketingOptions,
orderDetailData,
});
}
// 处理主订单总支付金额 用于显示可选可退总金额
this.setOrderPayPrice(subOrderList);
this.setData(
{
infoData: {
...data,
yqMerchantName: data?.applyStaffYqMerchantName,
yqMerchantId: data?.applyStaffYqMerchantId,
beforeStatus: res.data.beforeStatus,
afterStatus: res.data.afterStatus,
transferStatus: res.data.transferStatus,
subOrderList,
refundTime: res.data.refundTime ? dayjs(res.data.refundTime).format("YYYY/MM/DD HH:mm:ss") : "", // 状态流转下展示的退款成功时间
payAmount: res.data.payAmount, // 状态流转下展示的实际退款金额
reviewRemark: res.data.remark || `你的申请被【${res.data.oaSpFailAuditorName || "总部"}】驳回,请联系驳回人员!`, // 状态流转下展示的审批不通过原因
},
},
() => {
this.setRefundAblePrice();
},
);
} catch (error) {}
},
/**
* 退款明细子单补强活动标(工单子单优先,与工单详情 orderDetail 一致)
* @param {Array<object>} list goodsSubOrder / refundApplyDetail 列表
* @param {{ orderCode?: string, merchantId?: string|number }} [options]
* @returns {Promise<Array<object>>}
*/
async enrichSubOrderMarketingFlags(list = [], options = {}) {
return enrichRefundSubOrderMarketingFlags(list, options);
},
// 处理规格数据
filterSpeciation(val) {
let listShowSpecificationData = "";
let specificationTypeSequenceArr = val?.specificationTypeSequence ? val?.specificationTypeSequence?.split(";~;") : [];
let specificationValueSequenceArr = val?.specificationData?.includes(";~;") ? val?.specificationData?.split(";~;") : [];
const suffixMapping = {
1: "年",
2: "(km/万)",
3: "万",
};
if (specificationTypeSequenceArr?.length) {
specificationValueSequenceArr?.forEach((val, index) => {
const suffix = suffixMapping[specificationTypeSequenceArr[index]];
if (suffix) {
specificationValueSequenceArr[index] = `${val}${suffix}`;
}
});
listShowSpecificationData = specificationValueSequenceArr?.join("/");
} else if (val?.specificationData?.includes(";~;")) {
listShowSpecificationData = val?.specificationData?.replace(RegExp(";~;", "g"), "/");
}
return listShowSpecificationData;
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
// 埋点 只统计非门店收款订单的申请退款
if (this.data.refundPayType != 2) this.onPageShow();
},
// 计算订单总支付金额
setOrderPayPrice(orderData) {
let allTotalPrice = 0;
orderData?.forEach((val) => {
allTotalPrice = NP.plus(allTotalPrice, val.finalPrice);
});
this.setData({
allTotalPrice, // 订单支付金额
});
},
// 计算可选可退金额
setRefundAblePrice() {
// 计算可选可退金额 选中子订单输入金额之和
let { infoData } = this.data;
let customerRefundPrice = 0;
infoData.subOrderList?.map((val) => {
if (val.checked) {
customerRefundPrice = NP.plus(customerRefundPrice, val.finalPrice);
}
});
this.setData({
refundablePrice: customerRefundPrice,
});
},
// 选择退款方式
chooseRefundType(e) {
let { type } = e.currentTarget.dataset;
let { infoData } = this.data;
if (type == 1) {
// 全额退款可选可退总金额=订单支付总金额
this.setOrderPayPrice(infoData.subOrderList);
} else {
// 重置之前选择未保存的部分退款选项
let arr = infoData.subOrderList?.map((val) => {
val.checked = false;
val.refundPrice = "";
return val;
});
this.setData({
refundablePrice: "",
"infoData.subOrderList": arr,
});
}
this.setData({
"infoData.refundType": type,
});
},
// 选择子订单
checkSubOrder(e) {
let { item, index } = e.currentTarget.dataset;
this.setData(
{
[`infoData.subOrderList[${index}].checked`]: !item.checked,
[`infoData.subOrderList[${index}].refundPrice`]: "",
[`infoData.subOrderList[${index}].errorZero`]: false,
[`infoData.subOrderList[${index}].errorTarget`]: false,
},
() => {
this.setRefundAblePrice();
},
);
},
// 金额输入限制
priceFormat(inputStr) {
// 使用正则表达式过滤掉除数字和小数点以外的字符
let filteredStr = inputStr.replace(/[^0-9.]/g, "");
let [number, decimal] = filteredStr.split(".");
if (decimal != undefined) {
decimal = decimal.substring(0, 2);
number += `.${decimal}`;
filteredStr = number;
}
return filteredStr;
},
// 输入退款金额
changePrice(e) {
let { index } = e.currentTarget.dataset;
let { value } = e.detail;
let { infoData } = this.data;
let number = this.priceFormat(value);
this.setData({
[`infoData.subOrderList[${index}].refundPrice`]: number,
});
infoData.subOrderList?.map((val) => {
if (!((val.refundPrice ?? "") === "") && val.refundPrice == 0) {
val.errorZero = true;
} else {
val.errorZero = false;
}
if (!((val.refundPrice ?? "") === "") && val.refundPrice > val.finalPrice) {
// val.errorTarget = true;
val.errorTarget = false;
} else {
val.errorTarget = false;
}
});
this.setData({
["infoData.subOrderList"]: infoData.subOrderList,
});
},
// 上传图片
uploadImages() {
let _this = this;
let { infoData } = _this.data;
wx.chooseMedia({
count: 5 - infoData.attachmentList?.length,
sizeType: ["original"], // 选择图片为原图
mediaType: ["image"],
success(res) {
_this.setData({
loadingFlag: true,
});
const uploadImages = async (tempFiles) => {
try {
for (const item of tempFiles) {
const val = item.tempFilePath;
const imgType = val.split(".")[1];
const type = imgType === "unknown" ? "jpg" : imgType;
const fileName = val.substring(val.lastIndexOf("/") + 1)?.split(".")[0];
const _res = await new Promise((resolve, reject) => {
wx.getFileSystemManager().readFile({
filePath: val, // 选择图片返回的相对路径
encoding: "base64", // 编码格式
success: resolve,
fail: reject,
});
});
const img = await api.uploadImg({
file: `${type}@${_res.data}`,
});
const { code, data, message } = img;
if (code == 0) {
infoData.attachmentList.push({
fileUrl: data,
fileName: fileName,
});
_this.setData({
[`infoData.attachmentList`]: infoData.attachmentList,
});
} else {
wx.$util.showToast(message);
}
}
} catch (error) {
wx.$util.showToast("上传失败,请重试");
} finally {
_this.setData({
loadingFlag: false,
});
}
};
uploadImages(res?.tempFiles);
},
});
},
// 图片预览
previewImage(e) {
let { url, index } = e.currentTarget.dataset;
let imageUrl = url?.map((v) => {
return v.fileUrl;
});
wx.previewImage({
urls: imageUrl,
current: imageUrl[index],
});
},
// 删除图片
deleteFile(e) {
let { index } = e.currentTarget.dataset;
let { infoData } = this.data;
infoData.attachmentList.splice(index, 1);
this.setData({ infoData });
},
// 区域运营审核
review(e) {
let { type } = e.currentTarget.dataset;
let { infoData } = this.data;
if (type == 1) {
// 审核通过
if (this.data.auditFlag || infoData.beforeStatus != 6 || infoData.afterStatus != 7) return
this.setData({auditFlag: true})
wx.$util.showLoading()
auditRefundAllpyAPI({
applyCode: infoData.applyCode,
auditStatus: 1,
id: infoData.id,
}).then((res) => {
wx.$util.hideLoading()
let { code, message } = res;
if (code == 0) {
wx.showToast({
title: "操作成功",
icon: "success",
});
// 跳转到退款审批列表
setTimeout(() => {
const pages = getCurrentPages();
if (pages.length > 1) {
wx.$router.back();
} else {
wx.redirectTo({
url: `/tabWorkOrder/pages/refundOperationList/refundOperationList`,
});
}
}, 300);
} else {
this.setData({auditFlag: false})
wx.$util.showToast(message);
}
}).catch(() => {
wx.$util.hideLoading()
})
} else {
// 审核不通过
this.setData({
repealVisible: true,
disapprovalReason: "",
});
}
},
textareaInput(e) {
let { value } = e.detail;
value = value.replace(/[^\u4e00-\u9fa5a-zA-Z0-9,。、;:?!""''()《》【】\-\+=/*.,;:?!@#$%^&*()_+=\[\]{}|\\<>\/\s]/g, "");
this.setData({
disapprovalReason: value.trim(),
});
},
confirmRepeal() {
let { disapprovalReason, repealStatus, infoData } = this.data;
if (repealStatus || infoData.beforeStatus != 6 || infoData.afterStatus != 7) return;
if (!disapprovalReason) return wx.$util.showToast("审核不通过原因不能为空");
this.setData({ repealStatus: true });
wx.$util.showLoading()
auditRefundAllpyAPI({
applyCode: infoData.applyCode,
auditStatus: 2,
remark: disapprovalReason,
id: infoData.id,
}).then((res) => {
wx.$util.hideLoading()
let { code, message } = res;
if (code == 0) {
wx.showToast({
title: "操作成功",
icon: "success",
});
this.cancelRepeal();
// 跳转到退款审批列表
setTimeout(() => {
const pages = getCurrentPages();
if (pages.length > 1) {
wx.$router.back();
} else {
wx.redirectTo({
url: `/tabWorkOrder/pages/refundOperationList/refundOperationList`,
});
}
}, 300);
} else {
this.setData({ repealStatus: false });
wx.$util.showToast(message);
}
}).catch(() => {
wx.$util.hideLoading()
})
},
cancelRepeal() {
this.setData({
repealVisible: false,
});
},
input(e) {
let { name } = e.currentTarget.dataset;
let { value } = e.detail;
if (name == "bankAccountNo") {
value = value.replace(/[^0-9]/g, "");
} else {
// 限制只能输入汉字英文数字常用特殊符号
value = value.replace(/[^\u4e00-\u9fa5a-zA-Z0-9,。、;:?!""''()《》【】\-\+=/*.,;:?!@#$%^&*()_+=\[\]{}|\\<>\/\s]/g, "");
}
this.setData({
[`infoData.${name}`]: value.trim(),
});
},
checkRequired(infoData) {
let target = ["payee", "openAccBankName", "openAccBranchBankName", "bankAccountNo", "remark"];
try {
target.map((key) => {
if ((infoData[key] ?? "") === "") {
throw key;
}
});
} catch (error) {
return error;
}
return false;
},
checkSubOrderValid(subOrderList) {
if (!subOrderList?.filter((v) => v.checked).length && this.data.infoData.refundType == 2) return "请选择具体退款项";
let [errorZeroNum, errTargetNum, errorEmptyNum] = [0, 0, 0];
subOrderList?.map((val) => {
if ((val.refundPrice ?? "") === "" && val.checked) errorEmptyNum++;
if (val.errorZero) errorZeroNum++;
if (val.errorTarget) errTargetNum++;
});
if (errorEmptyNum) {
return "退款金额不能为空";
}
if (errorZeroNum) {
return "退款金额不能为0";
}
if (errTargetNum) {
return "退款金额不能大于支付金额";
}
},
// 提交申请
submit() {
let { submitStatus, infoData, userInfo, refundPayType } = this.data;
// 校验是否选择退款方式
if (!infoData.refundType) return wx.$util.showToast("请选择退款方式");
if (infoData.payee === "" || infoData.payee == null || infoData.payee == undefined) return wx.$util.showToast("请输入收款人姓名");
// 部分退款校验子订单
let checkKey = this.checkSubOrderValid(infoData.subOrderList);
if (checkKey) return wx.$util.showToast(checkKey);
if (infoData.refundType == 2 && !infoData.subOrderList?.filter((v) => v.checked)?.length) return wx.$util.showToast("");
let key = this.checkRequired(infoData);
if (key && refundPayType != 2) {
toastList[key] && wx.$util.showToast(toastList[key]);
toastList[key] &&
wx.pageScrollTo({
selector: `.${key}`,
});
return;
}
// 门店收款标记退款,客户退款回单必传
if (refundPayType == 2 && !infoData.attachmentList?.length) return wx.$util.showToast("客户退款回单不能为空");
if (submitStatus) return;
this.setData({
submitStatus: true,
});
const refundApplyDetailList = (infoData?.subOrderList || [])
.filter((val) => infoData.refundType == 1 || val.checked)
.map((val) => ({
finalPrice: val.finalPrice,
subOrderCode: val.subOrderCode,
orderCode: infoData.orderCode,
refundAmount: infoData.refundType == 1 ? val.finalPrice : val.refundPrice,
}));
let params = {
sourceApplyId: infoData.id,
refundType: infoData.refundType,
yqMerchantId: infoData?.yqMerchantId,
yqMerchantName: infoData?.yqMerchantName,
shopMerchantId: infoData?.shopMerchantId,
shopMerchantName: infoData?.shopMerchantName,
payee: infoData.payee,
openAccBankName: infoData?.openAccBankName,
openAccBranchBankName: infoData?.openAccBranchBankName,
bankAccountNo: infoData?.bankAccountNo,
remark: infoData?.remark,
orderCode: infoData?.orderCode,
sceneType: userInfo?.sceneType,
attachmentList: infoData.attachmentList?.map((val) => {
return { fileUrl: val.fileUrl, fileName: val.fileName };
}),
refundApplyDetailList,
};
const eventObj = refundPayType == 2 ? "markAsRefundedAPI" : "applyRefundAPI";
refundAPI[eventObj](params).then((res) => {
let { code, message } = res;
if (code == 0) {
wx.showToast({
title: "操作成功",
icon: "success",
});
setTimeout(() => {
const pages = getCurrentPages();
if (pages.length > 1) {
wx.$router.back();
} else {
wx.reLaunch({
url: "/pages/loading/loading",
});
}
}, 300);
} else {
this.setData({ submitStatus: false });
wx.$util.showToast(message);
}
});
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
// 埋点 只统计非门店收款订单的申请退款
if (this.data.refundPayType != 2) this.onPageHide();
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
// 埋点 只统计非门店收款订单的申请退款
if (this.data.refundPayType != 2) this.onPageHide();
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {},
});