applyRefundBtn.js
4.26 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
// tabWorkOrder/components/applyRefundBtn/applyRefundBtn.js
import api from "~/api/api";
import qs from "~/utils/lib/qs";
Component({
/**
* 组件的属性列表
*/
properties: {
orderInfo: Object,
showRefundBtn: Boolean,
updateFlag: Boolean,
},
/**
* 组件的初始数据
*/
data: {
moreSelectData: [],
showSelect: false,
moreSelectIndex: null,
areaOperationsFlag: false,
},
/**
* 组件的方法列表
*/
methods: {
// 点击更多按钮
selectTap() {
let { orderInfo } = this.data;
let allOptions = [];
if (orderInfo.selectPayType == 2) {
// 门店收款订单查询退款可展示按钮
allOptions = ["标记退款", "退款详情"];
// 查询订单可展示按钮
api.getMoreBtnAPI({ orderCode: orderInfo.orderCode }).then((res) => {
let { code, data } = res;
if (code == 0) {
this.setData({
moreSelectData: this.filterMoreSelectData(data.refundApplyButton, data.refundApplyDetailButton, allOptions, 1),
showSelect: !this.data.showSelect,
});
}
});
} else {
allOptions = ["申请退款", "退款详情"];
// 查询订单可展示按钮
api.getMoreBtnAPI({ orderCode: orderInfo.orderCode }).then((res) => {
let { code, data } = res;
if (code == 0) {
this.setData({
moreSelectData: this.filterMoreSelectData(data.refundApplyButton, data.refundApplyDetailButton, allOptions, 2),
showSelect: !this.data.showSelect,
});
}
});
}
},
filterMoreSelectData(refundApplyButton, refundApplyDetailButton, allOptions, num) {
const buttonType = num === 2 ? "申请退款" : "标记退款";
const conditions = {
[buttonType]: refundApplyButton === "Y",
退款详情: refundApplyDetailButton === "Y",
};
return allOptions.filter((option) => conditions[option]);
},
closeSelect() {
this.setData({
showSelect: false,
moreSelectIndex: null,
});
},
tapConstruction() {
this.closeSelect();
let thisPage = wx.$router.getPageInstance();
thisPage.setData({
sublistVisible: true,
});
},
optionTap(e) {
let { index, item } = e.currentTarget.dataset;
let { orderInfo } = this.data;
let userInfo = wx.$util.getUserInfo();
if (item == "申请退款" || item == "标记退款") {
// 申请退款点击埋点
if (item == "申请退款") wx.$track.setTrackData(0, "apply_refund_page", {}, "", 1);
// 退款申请时区域运营查询
api.areaSupervisionExistsAPI({
merchantId: userInfo.shopMerchantId,
sceneType: userInfo.sceneType,
}).then((res) => {
let { code, data, message } = res;
if (code == 0) {
if (!data) {
return this.setData({
areaOperationsFlag: true,
showSelect: !this.data.showSelect,
});
} else {
wx.navigateTo({
url:
"/packageWorkspace/pages/refundApply/refundApply?" +
qs.stringify({
orderCode: orderInfo.orderCode,
shopMerchantName: orderInfo.merchantName,
shopMerchantId: orderInfo.merchantId,
refundPayType: orderInfo.selectPayType == 2 ? 2 : 1,
refundName: orderInfo.customerName,
}),
});
this.closeSelect();
}
} else {
return wx.$util.showToast(message);
}
});
} else {
// 退款详情点击埋点
if (orderInfo?.selectPayType != 2) wx.$track.setTrackData(0, "refund_detail_page", {}, "", 1);
// 点击退款详情,判断是否存在多条退款申请记录,存在跳转列表页,不存在直接跳转详情页
api.getRefundDetailListAPI({ orderCode: orderInfo.orderCode }).then((res) => {
let { code, data } = res;
if (code == 0) {
if (data?.length > 1) {
wx.navigateTo({
url: `/packageWorkspace/pages/refundDetailList/refundDetailList?orderCode=${orderInfo.orderCode}`,
});
} else if (data.length == 1) {
wx.navigateTo({
url: `/packageWorkspace/pages/refundApply/refundApply?applyCode=${data[0].applyCode}&refundPayType=${orderInfo.selectPayType == 2 ? 2 : 1}`,
});
}
this.closeSelect();
}
});
}
this.setData({
moreSelectIndex: index,
// showSelect: !this.data.showSelect
});
},
closeModal() {
this.setData({
areaOperationsFlag: false,
});
},
},
});