supplementaryOrderList.js
10.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
// subvehicleConversion/components/supplementaryOrderDetail/supplementaryOrderDetail.js
import api from '~/subvehicleConversion/api'
const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/'
Component({
/**
* 组件的属性列表
*/
properties: {
navBarHeight: Number
},
/**
* 组件的初始数据
*/
data: {
IMG_URL,
userInfo: {},
storeInfo: {},
tabIndex: 0,
pageSize: 4,
pageNum: 1,
tabList: ['全部', '待支付', '已支付', '已退款'],
btnTxt: {
0: '去支付',
1: '去退款',
4: '去退款'
},
orderStatusObj: {
0: '待支付',
1: '已支付',
2: '已退款',
3: '预支付',
4: '退定金', // 正常流程 自定义值
5: '退定金' // 预支付状态下退定金 自定义值
},
orderStatusList: [
{
confName: '全部',
confId: ''
}, {
confName: '待支付',
confId: '0'
}, {
confName: '已支付',
confId: '1'
},
{
confName: '已退款',
confId: '2'
}
],
subOrderCodeCopy: '',
searchObj: {},
orderObj: [
{
label: '商品名称',
key: 'goodsName'
},
{
label: '订金金额',
key: 'activityPrice',
type: 'price'
},
{
label: '订金支付',
key: 'payedDateStr'
},
{
label: '订单编号',
key: 'subOrderCode'
},
// {
// label: '尾款金额',
// key: 'tailPayment',
// type: 'price'
// },
{
label: '转化人员',
key: 'transfer'
},
],
list: [],
isToBottom: false,
selectData: ['客户姓名','订单编号','手机号'], // 下拉列表的数据
selectIndex: 0, // 选择的下拉列表下标
showSelect: false, // 下拉框
confirmFlag: false,
total: 0,
inputValue: '',
showRemark: false,
showCopyPopup: false, // 复制二次选择
copyObj: {}, // 复制 姓名/手机号
remarkType: '' // 备注类型 1备注 2 退款原因
},
lifetimes: {
attached() {
this.setData({
storeInfo: wx.$util.getUserInfo()?.default4SStoreInfo_newCarConversion || {},
userInfo: wx.$util.getUserInfo() || {}
})
// this.onLoad(true)
}
},
/**
* 组件的方法列表
*/
methods: {
onLoad(noGetList) {
this.setData({
nothing: false,
pageNum: 1,
storeInfo: wx.$util.getUserInfo()?.default4SStoreInfo_newCarConversion || {}
})
if (!noGetList) this.getList(true)
},
search() {
this.setData({
pageNum: 1,
nothing: false,
total: 0
})
this.getList(true)
},
onBottomRefresh() {
let { isToBottom } = this.data
if (isToBottom) return
this.setData({isToBottom: true})
this.getList()
},
getList(isReset = false) {
this.setData({
isToBottom: false
})
let {pageSize, pageNum, tabList, tabIndex, inputValue, nothing, orderStatusList, selectIndex} = this.data
let userInfo = wx.$util.getUserInfo()
if (nothing) {
return
}
let params = {
pageSize,
pageNum,
customerName: selectIndex == 0 ? inputValue: '',
subOrderCode: selectIndex == 1 ? inputValue: '',
customerPhone: selectIndex == 2 ? inputValue: '',
merchantId: userInfo?.default4SStoreInfo_newCarConversion?.merchantId,
sceneType: 2, // 场景值(2 次新车转化)
tailOrderStatus: orderStatusList.find(item => item.confName == tabList[tabIndex])?.confId || ''
}
wx.showLoading()
api.getSupplementaryOrderList(params).then(res => {
wx.hideLoading()
if (res.code == '0') {
let {list, total} = res.data
list.forEach(val => {
val.payedDateStr = val.payedDate ? wx.$util.tsFormatTime(val.payedDate, 'Y年M月D日 h:m:s') : ''
val.tailPayedDateStr = val.tailPayedDate ? wx.$util.tsFormatTime(val.tailPayedDate, 'Y年M月D日 h:m:s') : ''
// depositStatus定金状态 1:退定金 0:未退定金 tailOrderStatus尾款状态 0:待支付 1:已支付 2:已退款 3:预支付
if (val?.depositStatus == 1 && val.tailOrderStatus == 1) { // 已支付状态的 退定金
val.tailOrderStatus = 4 // 可操作退款
} else if ((val?.depositStatus == 1 && val.tailOrderStatus == 0) || (val?.depositStatus == 1 && val?.tailOrderStatus == 3)) { // 待支付或预支付 退定金
val.tailOrderStatus = 5 // 不可操作
} else {
val.tailOrderStatus = val.tailOrderStatus
}
})
let tempList = isReset ? list : this.data.list.concat(list)
this.setData({
list: tempList,
pageNum: pageNum + 1,
total,
nothing: total == tempList.length,
triggered: false
})
if (isReset) {
this.setData({
scrollTop: 0
})
}
// console.log(this.data.list)
} else {
this.setData({
list: [],
nothing: false,
total: 0
})
wx.$util.showToast(res.message || '接口异常')
}
})
},
// tab切换
tabClick(e) {
let {searchObj} = this.data
delete searchObj.statusList
this.setData({
tabIndex: e?.detail,
searchObj
})
this.search()
},
handleReset() {
this.setData({
inputValue: ''
})
this.search()
},
showMask(e) {
const { item } = e.currentTarget.dataset || {}
this.setData({
showRemark: true,
remarkType: 1,
selectItem: item
})
},
// 备注确认
remarkConfirm(e) {
let value = e.detail
// 备注类型 remarkType 1备注 2退款原因
const {subOrderCodeCopy, remarkType, list, selectItem} = this.data
if (remarkType == 1) {
if (value) {
wx.showLoading()
api.updateOrderRemark({
orderCode: selectItem?.subOrderCode,
remark: value
}).then(res => {
wx.hideLoading()
let { code } = res
if (code == 0) {
// 将订单项备注值回填 不请求接口刷新页面
list.forEach(val => {
if (val.subOrderCode == selectItem.subOrderCode) {
val.remark = value
}
})
this.setData({list})
}
})
}
} else {
let params = {
orderCode: subOrderCodeCopy,
refundRemark: value
}
wx.showModal({
title: '温馨提示',
content: '请确定将此订单状态标记为已退款',
complete: (res) => {
if (res.confirm) {
wx.showLoading()
api.markAsRefunded(params).then(res => {
wx.hideLoading()
if (res.code == 0) {
wx.$util.showToast('退款成功!')
this.getList()
} else {
wx.$util.showToast(res.message || '接口异常')
}
})
}
}
})
}
},
input(e) {
let {value} = e.detail
this.setData({
inputValue: value
})
},
// 查询条件类型切换
selectTap() {
this.setData({
showSelect: !this.data.showSelect
});
},
optionTap(e) {
let { index } = e.currentTarget.dataset
this.setData({
selectIndex: index,
showSelect: !this.data.showSelect
})
},
closeSelect() {
this.setData({
showSelect: false
})
},
// 复制文案(订单编号)
copyData(e) {
const {target, flag} = e.currentTarget.dataset
if (flag == 1) { // 姓名和手机号
if (target.customerName && target.customerPhone) { // 姓名手机号都有
return this.setData({
showCopyPopup: true,
copyObj: {
customerName: target.customerName,
customerPhone: target.customerPhone
}
})
}
let copyItem = target.customerName || target.customerPhone // 只手机号或姓名
wx.setClipboardData({
data: copyItem
})
}
let copyItem = target.subOrderCode
wx.setClipboardData({
data: copyItem
})
},
// 复制文案(手机号/姓名)
handleCopy(e) {
const {target} = e.currentTarget.dataset
wx.setClipboardData({
data: target
})
this.setData({
showCopyPopup: false
})
},
onCopyPopupClose() {
this.setData({
showCopyPopup: false
})
},
handleClickBtn(e) {
const {target} = e.currentTarget.dataset
let { confirmFlag } = this.data
this.setData({
subOrderCodeCopy: target.subOrderCode
})
if (target.tailOrderStatus == 0) { // 待支付
let {accountName} = wx.$util.getUserInfo()
const {subOrderCode, goodsId: shopmallGoodsId,} = target
let params = {
subOrderCode,
shopmallGoodsId,
orderPaySource: 1, // 订单支付源(1.正常付尾款,2关联尾款单)
selectPayType: 1, // 支付方式(1:线上微信支付,2:线下收款,3:POS机收款, 4:支付宝支付) 默认使用微信支付
updatedBy: accountName,
remark: target?.remark
}
if (confirmFlag) return
wx.showLoading()
this.setData({confirmFlag: true})
api.createPayOrderAPI(params).then(res => {
let {code, data, message} = res
wx.hideLoading()
if (code == '0') {
// wx.$router.reLaunch
wx.$router.go('supplementaryOrderPay', {orderCode: target.subOrderCode})
setTimeout(() => {
this.setData({
confirmFlag: false
})
}, 3000)
} else {
wx.$util.showToast(message || '接口异常')
this.setData({
confirmFlag: false
})
}
})
}
if (target.tailOrderStatus == 1 || target.tailOrderStatus == 4) { // 已支付或退定金状态
this.setData({
showRemark: true,
remarkType: 2
})
}
},
remarkCancel() {
this.setData({
showRemark: false
})
},
// 关联尾款单
handlefinalPayment(e) {
const {target} = e.currentTarget.dataset
wx.$router.go('relatedFinalPayment', {list: target})
}
}
})