orderPromptPop.js
3.85 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
// components/orderPromptPop/orderPromptPop.js
const FULL_PAY_TYPE_LIST = [
{
label: '收款方为门店收款',
value: '3'
},
{
label: '收款方为嘀加且属于对公转账收款',
value: '4'
},
{
label: '收款方为嘀加二维码收款',
value: '5',
tips: '适用于已有交易收款流水需补录订单时'
},
{
label: '特殊收款',
value: '6',
tips: '仅用于无法关联流水或混合支付场景,请谨慎选择。'
}
]
const DJ_QR_ONLY_PAY_TYPE_LIST = FULL_PAY_TYPE_LIST.filter(item => item.value === '5')
Component({
/**
* 组件的属性列表
*/
properties: {
show: {
type: Boolean,
observer(n) {
if (n) {
this.applyDjQrOnlyPresentation(this.properties.djQrOnlyMode)
}
}
},
/** 异常流水锁单态:仅允许嘀加二维码收款 */
djQrOnlyMode: {
type: Boolean,
value: false,
observer(n) {
if (this.data.show) {
this.applyDjQrOnlyPresentation(n)
}
}
},
popupSlotStyle: {
type: String,
value: 'height: calc(100% - var(--fontSize120));'
},
height: {
type: String,
value: 'var(--fontSize500)'
},
includesChildHeight: {
type: String,
value: 'var(--fontSize1020)'
},
sceneObj: {
type: Object,
value: {},
observer: function (v) {
if (this.properties.djQrOnlyMode) return
// 是否是扫码核销或再次下单,是的话不显示补录入口
if (Object.keys(v)?.length) {
let { payTypeList } = this.data
let index = payTypeList?.findIndex(v => v.value == 5)
if (index > -1) {
payTypeList?.splice(index, 1)
this.setData({
payTypeList,
includesChildHeight: 'var(--fontSize870)'
})
}
this.setData({
payTypeList
})
}
}
}
},
/**
* 组件的初始数据
*/
data: {
infoData: {},
payTypeList: FULL_PAY_TYPE_LIST.map(item => ({ ...item }))
},
/**
* 组件的方法列表
*/
methods: {
/**
* 锁单态仅展示嘀加二维码,并预选已支付 + 嘀加二维码
* @param {boolean} djQrOnlyMode
*/
applyDjQrOnlyPresentation(djQrOnlyMode) {
if (djQrOnlyMode) {
this.setData({
payTypeList: DJ_QR_ONLY_PAY_TYPE_LIST.map(item => ({ ...item })),
includesChildHeight: 'var(--fontSize870)',
infoData: { payFlag: '2', payType: '5' }
})
return
}
this.setData({
payTypeList: FULL_PAY_TYPE_LIST.map(item => ({ ...item })),
includesChildHeight: 'var(--fontSize1020)',
infoData: {}
})
},
chooseParent(e) {
if (this.properties.djQrOnlyMode) {
return wx.$util.showToast('存在异常流水未处理,请选择嘀加二维码收款')
}
let { type } = e.currentTarget.dataset
this.setData({
'infoData.payFlag': type
})
},
chooseChild(e) {
let { type } = e.currentTarget.dataset
if (this.properties.djQrOnlyMode && String(type) !== '5') {
return wx.$util.showToast('存在异常流水未处理,请选择嘀加二维码收款')
}
this.setData({
'infoData.payType': type
})
},
cancel() {
this.triggerEvent('cancel')
},
confirm() {
let { infoData } = this.data
const { djQrOnlyMode } = this.properties
if (djQrOnlyMode && String(infoData.payType) !== '5') {
return wx.$util.showToast('存在异常流水未处理,请选择嘀加二维码收款')
}
if (!infoData.payFlag || (infoData.payFlag == 2 && !infoData.payType)) {
return wx.$util.showToast('请选择订单收款方式')
}
this.cancel()
this.triggerEvent('confirm', infoData)
}
}
})