af-mobile-client-vue3 1.4.68 → 1.4.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__dummy__ +9 -9
- package/build/vite/optimize.ts +36 -36
- package/package.json +120 -121
- package/public/favicon.svg +4 -4
- package/scripts/verifyCommit.js +19 -19
- package/src/components/common/MateChat/components/MateChatContent.vue +274 -274
- package/src/components/common/MateChat/components/MateChatHeader.vue +337 -337
- package/src/components/common/MateChat/index.vue +444 -444
- package/src/components/common/MateChat/types.ts +247 -247
- package/src/components/common/otherCharge/ChargePrintSelectorAndRemarks.vue +137 -137
- package/src/components/common/otherCharge/CodePayment.vue +357 -357
- package/src/components/common/otherCharge/FileUploader.vue +602 -602
- package/src/components/common/otherCharge/GridFileUploader.vue +846 -846
- package/src/components/common/otherCharge/PaymentMethodSelector.vue +202 -202
- package/src/components/common/otherCharge/PaymentMethodSelectorCard.vue +45 -45
- package/src/components/common/otherCharge/ReceiptModal.vue +273 -273
- package/src/components/common/otherCharge/index.ts +43 -43
- package/src/components/core/ImageUploader/index.vue +9 -2
- package/src/components/data/OtherCharge/OtherChargeItemModal.vue +547 -547
- package/src/components/data/UserDetail/types.ts +1 -1
- package/src/components/data/XCellList/index.vue +1 -1
- package/src/components/data/XReportGrid/XAddReport/index.ts +1 -1
- package/src/components/data/XReportGrid/XReportDrawer/index.ts +1 -1
- package/src/components/data/XTag/index.vue +10 -10
- package/src/components/layout/TabBarLayout/index.vue +40 -40
- package/src/hooks/useCommon.ts +9 -9
- package/src/plugins/AppData.ts +38 -38
- package/src/router/invoiceRoutes.ts +33 -33
- package/src/services/api/common.ts +109 -109
- package/src/services/api/manage.ts +8 -8
- package/src/services/api/search.ts +16 -16
- package/src/services/restTools.ts +56 -56
- package/src/utils/authority-utils.ts +84 -84
- package/src/utils/crypto.ts +39 -39
- package/src/utils/queryFormDefaultRangePicker.ts +57 -57
- package/src/utils/runEvalFunction.ts +13 -13
- package/src/views/component/EvaluateRecordView/index.vue +40 -40
- package/src/views/component/MateChat/MateChatView.vue +10 -10
- package/src/views/component/XCellDetailView/index.vue +217 -217
- package/src/views/component/XCellListView/index.vue +138 -107
- package/src/views/component/XFormGroupView/index.vue +82 -78
- package/src/views/component/XFormView/index.vue +46 -41
- package/src/views/component/XReportFormIframeView/index.vue +47 -47
- package/src/views/component/XReportFormView/index.vue +13 -13
- package/src/views/component/XSignatureView/index.vue +50 -50
- package/src/views/component/notice.vue +46 -46
- package/src/views/component/topNav.vue +36 -36
- package/src/views/invoiceShow/index.vue +61 -61
- package/src/views/user/login/index.vue +22 -22
- package/pnpm-lock.yaml +0 -11070
|
@@ -1,357 +1,357 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { post } from '@af-mobile-client-vue3/services/restTools'
|
|
3
|
-
import useUserStore from '@af-mobile-client-vue3/stores/modules/user'
|
|
4
|
-
import {
|
|
5
|
-
showDialog,
|
|
6
|
-
showToast,
|
|
7
|
-
Button as VanButton,
|
|
8
|
-
Icon as VanIcon,
|
|
9
|
-
Popup as VanPopup,
|
|
10
|
-
} from 'vant'
|
|
11
|
-
import { defineEmits, defineProps, onMounted, onUnmounted, ref } from 'vue'
|
|
12
|
-
|
|
13
|
-
const props = defineProps({
|
|
14
|
-
show: {
|
|
15
|
-
type: Boolean,
|
|
16
|
-
default: false,
|
|
17
|
-
},
|
|
18
|
-
payment: {
|
|
19
|
-
type: String,
|
|
20
|
-
required: true,
|
|
21
|
-
},
|
|
22
|
-
collection: {
|
|
23
|
-
type: [String, Number],
|
|
24
|
-
required: true,
|
|
25
|
-
},
|
|
26
|
-
type: {
|
|
27
|
-
type: String,
|
|
28
|
-
required: true,
|
|
29
|
-
},
|
|
30
|
-
formData: {
|
|
31
|
-
type: Object,
|
|
32
|
-
required: true,
|
|
33
|
-
},
|
|
34
|
-
user: {
|
|
35
|
-
type: Object,
|
|
36
|
-
default: () => {},
|
|
37
|
-
},
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
const emit = defineEmits(['update:show', 'paymentSuccess', 'paymentCancel'])
|
|
41
|
-
|
|
42
|
-
// 状态变量
|
|
43
|
-
const isTimeout = ref(false)
|
|
44
|
-
const queryState = ref(false)
|
|
45
|
-
const showCode = ref(props.show)
|
|
46
|
-
const order = ref({ tradeNo: '', url: '' })
|
|
47
|
-
const timer = ref(null)
|
|
48
|
-
const qrcodeTimer = ref(null)
|
|
49
|
-
const codeAddress = ref('')
|
|
50
|
-
const businessStore = props.user
|
|
51
|
-
const userInfo = ref({ ...businessStore })
|
|
52
|
-
// 当前登录用户
|
|
53
|
-
const currUser = useUserStore().getLogin().f
|
|
54
|
-
console.log(userInfo, currUser)
|
|
55
|
-
|
|
56
|
-
// 创建订单并生成二维码
|
|
57
|
-
async function createOrder(): Promise<void> {
|
|
58
|
-
try {
|
|
59
|
-
// 创建订单
|
|
60
|
-
const orderData = {
|
|
61
|
-
config: userInfo.value.f_orgid === '1767' ? 'xianyangkonggang' : 'xianyang',
|
|
62
|
-
pay_way: props.payment.includes('微信') ? 'weixin' : 'ali',
|
|
63
|
-
money: (Number(props.collection) * 100).toFixed(0),
|
|
64
|
-
attach: {
|
|
65
|
-
f_userfiles_id: userInfo.value.f_userfiles_id,
|
|
66
|
-
f_userinfo_code: userInfo.value.f_userinfo_code,
|
|
67
|
-
f_userinfo_id: userInfo.value.f_userinfo_id,
|
|
68
|
-
f_terminal_num: '',
|
|
69
|
-
type: props.type,
|
|
70
|
-
orgId: currUser.resources.orgid,
|
|
71
|
-
orgName: currUser.resources.orgs,
|
|
72
|
-
depId: currUser.resources.depids,
|
|
73
|
-
depName: currUser.resources.deps,
|
|
74
|
-
operator: currUser.resources.name,
|
|
75
|
-
operatorId: currUser.resources.id,
|
|
76
|
-
f_pregas: 0,
|
|
77
|
-
f_preamount: 0,
|
|
78
|
-
f_totalcost: 0,
|
|
79
|
-
f_collection: 0,
|
|
80
|
-
f_add_gas: '',
|
|
81
|
-
payment: props.payment,
|
|
82
|
-
f_outlets: '手持设备',
|
|
83
|
-
},
|
|
84
|
-
}
|
|
85
|
-
if (props.type !== '其他收费' && props.type !== '换表' && props.type !== '补卡') {
|
|
86
|
-
if (props.type === '超用收费') {
|
|
87
|
-
orderData.attach.f_add_gas = props.formData.isAccumulative === true ? '计入' : '不计入'
|
|
88
|
-
orderData.attach.f_pregas = props.formData.overusedGas
|
|
89
|
-
orderData.attach.f_preamount = props.formData.overusedAmount
|
|
90
|
-
orderData.attach.f_totalcost = props.formData.receivedAmount
|
|
91
|
-
orderData.attach.f_collection = props.formData.receivedAmount
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
orderData.attach.f_pregas = props.formData.gas
|
|
95
|
-
orderData.attach.f_preamount = props.formData.money
|
|
96
|
-
orderData.attach.f_totalcost = props.formData.totalCost ? props.formData.totalCost : 0
|
|
97
|
-
orderData.attach.f_collection = props.formData.collection
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
orderData.attach.f_preamount = Number(props.collection)
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const response = await post('/rs/logic/WeiXinGetCode', { data: orderData })
|
|
105
|
-
console.log('生成订单返回结果', response)
|
|
106
|
-
if (response.code === 200) {
|
|
107
|
-
order.value.tradeNo = response.f_out_trade_no
|
|
108
|
-
order.value.url = response.url
|
|
109
|
-
const url = response.url.replace(/&/g, '|')
|
|
110
|
-
codeAddress.value = `/rs/pay/paintCode?url=${url}`
|
|
111
|
-
console.log(codeAddress.value)
|
|
112
|
-
// 显示二维码
|
|
113
|
-
isTimeout.value = true
|
|
114
|
-
// 开始轮询订单状态
|
|
115
|
-
await startOrderStatusPolling(response.f_out_trade_no)
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
showToast('创建订单失败!')
|
|
119
|
-
emit('paymentCancel')
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
catch (error) {
|
|
123
|
-
console.error('创建订单失败', error)
|
|
124
|
-
showToast('创建订单失败,请检查网络!')
|
|
125
|
-
emit('paymentCancel')
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// 轮询订单状态
|
|
130
|
-
async function startOrderStatusPolling(tradeNo): Promise<void> {
|
|
131
|
-
let times = 0
|
|
132
|
-
|
|
133
|
-
timer.value = setInterval(async () => {
|
|
134
|
-
times++
|
|
135
|
-
try {
|
|
136
|
-
const orderData = {
|
|
137
|
-
f_out_trade_no: tradeNo,
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const result = await post('/af-revenue/logic/mobile_queryThirdOrderState', orderData)
|
|
141
|
-
console.log('==================>', result)
|
|
142
|
-
if (result.length === 0) {
|
|
143
|
-
clearInterval(timer.value)
|
|
144
|
-
showToast({
|
|
145
|
-
message: '未查询到订单信息,请重新点击支付生成订单信息',
|
|
146
|
-
duration: 5000,
|
|
147
|
-
})
|
|
148
|
-
emit('paymentCancel')
|
|
149
|
-
}
|
|
150
|
-
// 支付成功
|
|
151
|
-
if (result[0].f_bill_state === '1') {
|
|
152
|
-
clearInterval(timer.value)
|
|
153
|
-
clearTimeout(qrcodeTimer.value)
|
|
154
|
-
queryState.value = false
|
|
155
|
-
emit('paymentSuccess', { tradeNo, datetime: new Date().toLocaleString() })
|
|
156
|
-
}
|
|
157
|
-
// 支付成功
|
|
158
|
-
if (result[0].f_bill_state === '0') {
|
|
159
|
-
queryState.value = true
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// 支付失败
|
|
163
|
-
if (result[0].f_bill_state === '2') {
|
|
164
|
-
clearInterval(timer.value)
|
|
165
|
-
showToast({
|
|
166
|
-
message: '支付失败或支付超时,请重新点击支付生成二维码',
|
|
167
|
-
duration: 5000,
|
|
168
|
-
})
|
|
169
|
-
emit('paymentCancel')
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// 查询超时
|
|
173
|
-
if (times > 24) {
|
|
174
|
-
clearInterval(timer.value)
|
|
175
|
-
showToast({
|
|
176
|
-
message: '经多次查询用户支付未成功,请重新点击支付生成二维码',
|
|
177
|
-
duration: 5000,
|
|
178
|
-
})
|
|
179
|
-
emit('paymentCancel')
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
catch (error) {
|
|
183
|
-
console.error('查询订单状态失败', error)
|
|
184
|
-
}
|
|
185
|
-
}, 5000)
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// 取消支付
|
|
189
|
-
function cancelPayment() {
|
|
190
|
-
showDialog({
|
|
191
|
-
title: '确认取消',
|
|
192
|
-
message: '确定要取消支付吗?',
|
|
193
|
-
showCancelButton: true,
|
|
194
|
-
}).then((action) => {
|
|
195
|
-
if (action === 'confirm') {
|
|
196
|
-
clearTimers()
|
|
197
|
-
emit('update:show', false)
|
|
198
|
-
emit('paymentCancel')
|
|
199
|
-
}
|
|
200
|
-
})
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// 清除所有定时器
|
|
204
|
-
function clearTimers() {
|
|
205
|
-
if (timer.value) {
|
|
206
|
-
clearInterval(timer.value)
|
|
207
|
-
timer.value = null
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
if (qrcodeTimer.value) {
|
|
211
|
-
clearTimeout(qrcodeTimer.value)
|
|
212
|
-
qrcodeTimer.value = null
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
// 组件挂载时创建订单
|
|
217
|
-
onMounted(() => {
|
|
218
|
-
if (props.show) {
|
|
219
|
-
createOrder()
|
|
220
|
-
}
|
|
221
|
-
})
|
|
222
|
-
|
|
223
|
-
// 组件卸载时清除定时器
|
|
224
|
-
onUnmounted(() => {
|
|
225
|
-
clearTimers()
|
|
226
|
-
})
|
|
227
|
-
</script>
|
|
228
|
-
|
|
229
|
-
<template>
|
|
230
|
-
<VanPopup
|
|
231
|
-
v-model:show="showCode"
|
|
232
|
-
:close-on-click-overlay="false"
|
|
233
|
-
:style="{ width: '90%', maxWidth: '400px' }"
|
|
234
|
-
>
|
|
235
|
-
<div class="qrcode-payment">
|
|
236
|
-
<div class="qrcode-payment__header">
|
|
237
|
-
<div class="qrcode-payment__title">
|
|
238
|
-
<VanIcon name="scan" size="24" color="#1989fa" />
|
|
239
|
-
<span>请扫描下方二维码进行付款</span>
|
|
240
|
-
</div>
|
|
241
|
-
|
|
242
|
-
<div class="qrcode-payment__amount">
|
|
243
|
-
<span class="qrcode-payment__label">支付金额:</span>
|
|
244
|
-
<span class="qrcode-payment__value">¥{{ props.collection }}元</span>
|
|
245
|
-
</div>
|
|
246
|
-
</div>
|
|
247
|
-
|
|
248
|
-
<div class="qrcode-payment__content">
|
|
249
|
-
<div v-if="queryState" class="qrcode-payment__query-tip">
|
|
250
|
-
用户付款过程中,请勿退出或取消!
|
|
251
|
-
</div>
|
|
252
|
-
<div class="qrcode-payment__qrcode-container">
|
|
253
|
-
<img
|
|
254
|
-
v-if="isTimeout"
|
|
255
|
-
:src="codeAddress"
|
|
256
|
-
class="qrcode-payment__timeout-img"
|
|
257
|
-
alt=""
|
|
258
|
-
>
|
|
259
|
-
</div>
|
|
260
|
-
</div>
|
|
261
|
-
|
|
262
|
-
<div class="qrcode-payment__footer">
|
|
263
|
-
<VanButton
|
|
264
|
-
type="default"
|
|
265
|
-
block
|
|
266
|
-
@click="cancelPayment"
|
|
267
|
-
>
|
|
268
|
-
取消支付
|
|
269
|
-
</VanButton>
|
|
270
|
-
</div>
|
|
271
|
-
</div>
|
|
272
|
-
</VanPopup>
|
|
273
|
-
</template>
|
|
274
|
-
|
|
275
|
-
<style lang="less" scoped>
|
|
276
|
-
.qrcode-payment {
|
|
277
|
-
padding: 20px;
|
|
278
|
-
|
|
279
|
-
&__query-tip {
|
|
280
|
-
text-align: center;
|
|
281
|
-
color: #ff4d4f;
|
|
282
|
-
font-size: 14px;
|
|
283
|
-
font-weight: bold;
|
|
284
|
-
background-color: #fff;
|
|
285
|
-
padding: 4px 8px;
|
|
286
|
-
margin-bottom: 12px;
|
|
287
|
-
width: 266px;
|
|
288
|
-
word-wrap: break-word;
|
|
289
|
-
white-space: pre-wrap;
|
|
290
|
-
line-height: 1.4;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
&__header {
|
|
294
|
-
margin-bottom: 20px;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
&__title {
|
|
298
|
-
display: flex;
|
|
299
|
-
align-items: center;
|
|
300
|
-
justify-content: center;
|
|
301
|
-
gap: 8px;
|
|
302
|
-
margin-bottom: 16px;
|
|
303
|
-
font-size: 16px;
|
|
304
|
-
font-weight: 500;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
&__order-info,
|
|
308
|
-
&__amount {
|
|
309
|
-
display: flex;
|
|
310
|
-
justify-content: center;
|
|
311
|
-
margin-bottom: 8px;
|
|
312
|
-
font-size: 14px;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
&__label {
|
|
316
|
-
color: #646566;
|
|
317
|
-
margin-right: 4px;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
&__value {
|
|
321
|
-
color: #323233;
|
|
322
|
-
font-weight: 500;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
&__content {
|
|
326
|
-
display: flex;
|
|
327
|
-
flex-direction: column;
|
|
328
|
-
align-items: center;
|
|
329
|
-
justify-content: center;
|
|
330
|
-
margin-bottom: 20px;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
&__qrcode-container {
|
|
334
|
-
position: relative;
|
|
335
|
-
width: 266px;
|
|
336
|
-
height: 266px;
|
|
337
|
-
background-color: #f7f8fa;
|
|
338
|
-
display: flex;
|
|
339
|
-
justify-content: center;
|
|
340
|
-
align-items: center;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
&__timeout-img {
|
|
344
|
-
width: 266px;
|
|
345
|
-
height: 266px;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
&__qrcode {
|
|
349
|
-
width: 266px;
|
|
350
|
-
height: 266px;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
&__footer {
|
|
354
|
-
margin-top: 16px;
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
</style>
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { post } from '@af-mobile-client-vue3/services/restTools'
|
|
3
|
+
import useUserStore from '@af-mobile-client-vue3/stores/modules/user'
|
|
4
|
+
import {
|
|
5
|
+
showDialog,
|
|
6
|
+
showToast,
|
|
7
|
+
Button as VanButton,
|
|
8
|
+
Icon as VanIcon,
|
|
9
|
+
Popup as VanPopup,
|
|
10
|
+
} from 'vant'
|
|
11
|
+
import { defineEmits, defineProps, onMounted, onUnmounted, ref } from 'vue'
|
|
12
|
+
|
|
13
|
+
const props = defineProps({
|
|
14
|
+
show: {
|
|
15
|
+
type: Boolean,
|
|
16
|
+
default: false,
|
|
17
|
+
},
|
|
18
|
+
payment: {
|
|
19
|
+
type: String,
|
|
20
|
+
required: true,
|
|
21
|
+
},
|
|
22
|
+
collection: {
|
|
23
|
+
type: [String, Number],
|
|
24
|
+
required: true,
|
|
25
|
+
},
|
|
26
|
+
type: {
|
|
27
|
+
type: String,
|
|
28
|
+
required: true,
|
|
29
|
+
},
|
|
30
|
+
formData: {
|
|
31
|
+
type: Object,
|
|
32
|
+
required: true,
|
|
33
|
+
},
|
|
34
|
+
user: {
|
|
35
|
+
type: Object,
|
|
36
|
+
default: () => {},
|
|
37
|
+
},
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const emit = defineEmits(['update:show', 'paymentSuccess', 'paymentCancel'])
|
|
41
|
+
|
|
42
|
+
// 状态变量
|
|
43
|
+
const isTimeout = ref(false)
|
|
44
|
+
const queryState = ref(false)
|
|
45
|
+
const showCode = ref(props.show)
|
|
46
|
+
const order = ref({ tradeNo: '', url: '' })
|
|
47
|
+
const timer = ref(null)
|
|
48
|
+
const qrcodeTimer = ref(null)
|
|
49
|
+
const codeAddress = ref('')
|
|
50
|
+
const businessStore = props.user
|
|
51
|
+
const userInfo = ref({ ...businessStore })
|
|
52
|
+
// 当前登录用户
|
|
53
|
+
const currUser = useUserStore().getLogin().f
|
|
54
|
+
console.log(userInfo, currUser)
|
|
55
|
+
|
|
56
|
+
// 创建订单并生成二维码
|
|
57
|
+
async function createOrder(): Promise<void> {
|
|
58
|
+
try {
|
|
59
|
+
// 创建订单
|
|
60
|
+
const orderData = {
|
|
61
|
+
config: userInfo.value.f_orgid === '1767' ? 'xianyangkonggang' : 'xianyang',
|
|
62
|
+
pay_way: props.payment.includes('微信') ? 'weixin' : 'ali',
|
|
63
|
+
money: (Number(props.collection) * 100).toFixed(0),
|
|
64
|
+
attach: {
|
|
65
|
+
f_userfiles_id: userInfo.value.f_userfiles_id,
|
|
66
|
+
f_userinfo_code: userInfo.value.f_userinfo_code,
|
|
67
|
+
f_userinfo_id: userInfo.value.f_userinfo_id,
|
|
68
|
+
f_terminal_num: '',
|
|
69
|
+
type: props.type,
|
|
70
|
+
orgId: currUser.resources.orgid,
|
|
71
|
+
orgName: currUser.resources.orgs,
|
|
72
|
+
depId: currUser.resources.depids,
|
|
73
|
+
depName: currUser.resources.deps,
|
|
74
|
+
operator: currUser.resources.name,
|
|
75
|
+
operatorId: currUser.resources.id,
|
|
76
|
+
f_pregas: 0,
|
|
77
|
+
f_preamount: 0,
|
|
78
|
+
f_totalcost: 0,
|
|
79
|
+
f_collection: 0,
|
|
80
|
+
f_add_gas: '',
|
|
81
|
+
payment: props.payment,
|
|
82
|
+
f_outlets: '手持设备',
|
|
83
|
+
},
|
|
84
|
+
}
|
|
85
|
+
if (props.type !== '其他收费' && props.type !== '换表' && props.type !== '补卡') {
|
|
86
|
+
if (props.type === '超用收费') {
|
|
87
|
+
orderData.attach.f_add_gas = props.formData.isAccumulative === true ? '计入' : '不计入'
|
|
88
|
+
orderData.attach.f_pregas = props.formData.overusedGas
|
|
89
|
+
orderData.attach.f_preamount = props.formData.overusedAmount
|
|
90
|
+
orderData.attach.f_totalcost = props.formData.receivedAmount
|
|
91
|
+
orderData.attach.f_collection = props.formData.receivedAmount
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
orderData.attach.f_pregas = props.formData.gas
|
|
95
|
+
orderData.attach.f_preamount = props.formData.money
|
|
96
|
+
orderData.attach.f_totalcost = props.formData.totalCost ? props.formData.totalCost : 0
|
|
97
|
+
orderData.attach.f_collection = props.formData.collection
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
orderData.attach.f_preamount = Number(props.collection)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const response = await post('/rs/logic/WeiXinGetCode', { data: orderData })
|
|
105
|
+
console.log('生成订单返回结果', response)
|
|
106
|
+
if (response.code === 200) {
|
|
107
|
+
order.value.tradeNo = response.f_out_trade_no
|
|
108
|
+
order.value.url = response.url
|
|
109
|
+
const url = response.url.replace(/&/g, '|')
|
|
110
|
+
codeAddress.value = `/rs/pay/paintCode?url=${url}`
|
|
111
|
+
console.log(codeAddress.value)
|
|
112
|
+
// 显示二维码
|
|
113
|
+
isTimeout.value = true
|
|
114
|
+
// 开始轮询订单状态
|
|
115
|
+
await startOrderStatusPolling(response.f_out_trade_no)
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
showToast('创建订单失败!')
|
|
119
|
+
emit('paymentCancel')
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
console.error('创建订单失败', error)
|
|
124
|
+
showToast('创建订单失败,请检查网络!')
|
|
125
|
+
emit('paymentCancel')
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// 轮询订单状态
|
|
130
|
+
async function startOrderStatusPolling(tradeNo): Promise<void> {
|
|
131
|
+
let times = 0
|
|
132
|
+
|
|
133
|
+
timer.value = setInterval(async () => {
|
|
134
|
+
times++
|
|
135
|
+
try {
|
|
136
|
+
const orderData = {
|
|
137
|
+
f_out_trade_no: tradeNo,
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const result = await post('/af-revenue/logic/mobile_queryThirdOrderState', orderData)
|
|
141
|
+
console.log('==================>', result)
|
|
142
|
+
if (result.length === 0) {
|
|
143
|
+
clearInterval(timer.value)
|
|
144
|
+
showToast({
|
|
145
|
+
message: '未查询到订单信息,请重新点击支付生成订单信息',
|
|
146
|
+
duration: 5000,
|
|
147
|
+
})
|
|
148
|
+
emit('paymentCancel')
|
|
149
|
+
}
|
|
150
|
+
// 支付成功
|
|
151
|
+
if (result[0].f_bill_state === '1') {
|
|
152
|
+
clearInterval(timer.value)
|
|
153
|
+
clearTimeout(qrcodeTimer.value)
|
|
154
|
+
queryState.value = false
|
|
155
|
+
emit('paymentSuccess', { tradeNo, datetime: new Date().toLocaleString() })
|
|
156
|
+
}
|
|
157
|
+
// 支付成功
|
|
158
|
+
if (result[0].f_bill_state === '0') {
|
|
159
|
+
queryState.value = true
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// 支付失败
|
|
163
|
+
if (result[0].f_bill_state === '2') {
|
|
164
|
+
clearInterval(timer.value)
|
|
165
|
+
showToast({
|
|
166
|
+
message: '支付失败或支付超时,请重新点击支付生成二维码',
|
|
167
|
+
duration: 5000,
|
|
168
|
+
})
|
|
169
|
+
emit('paymentCancel')
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// 查询超时
|
|
173
|
+
if (times > 24) {
|
|
174
|
+
clearInterval(timer.value)
|
|
175
|
+
showToast({
|
|
176
|
+
message: '经多次查询用户支付未成功,请重新点击支付生成二维码',
|
|
177
|
+
duration: 5000,
|
|
178
|
+
})
|
|
179
|
+
emit('paymentCancel')
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
console.error('查询订单状态失败', error)
|
|
184
|
+
}
|
|
185
|
+
}, 5000)
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// 取消支付
|
|
189
|
+
function cancelPayment() {
|
|
190
|
+
showDialog({
|
|
191
|
+
title: '确认取消',
|
|
192
|
+
message: '确定要取消支付吗?',
|
|
193
|
+
showCancelButton: true,
|
|
194
|
+
}).then((action) => {
|
|
195
|
+
if (action === 'confirm') {
|
|
196
|
+
clearTimers()
|
|
197
|
+
emit('update:show', false)
|
|
198
|
+
emit('paymentCancel')
|
|
199
|
+
}
|
|
200
|
+
})
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// 清除所有定时器
|
|
204
|
+
function clearTimers() {
|
|
205
|
+
if (timer.value) {
|
|
206
|
+
clearInterval(timer.value)
|
|
207
|
+
timer.value = null
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (qrcodeTimer.value) {
|
|
211
|
+
clearTimeout(qrcodeTimer.value)
|
|
212
|
+
qrcodeTimer.value = null
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// 组件挂载时创建订单
|
|
217
|
+
onMounted(() => {
|
|
218
|
+
if (props.show) {
|
|
219
|
+
createOrder()
|
|
220
|
+
}
|
|
221
|
+
})
|
|
222
|
+
|
|
223
|
+
// 组件卸载时清除定时器
|
|
224
|
+
onUnmounted(() => {
|
|
225
|
+
clearTimers()
|
|
226
|
+
})
|
|
227
|
+
</script>
|
|
228
|
+
|
|
229
|
+
<template>
|
|
230
|
+
<VanPopup
|
|
231
|
+
v-model:show="showCode"
|
|
232
|
+
:close-on-click-overlay="false"
|
|
233
|
+
:style="{ width: '90%', maxWidth: '400px' }"
|
|
234
|
+
>
|
|
235
|
+
<div class="qrcode-payment">
|
|
236
|
+
<div class="qrcode-payment__header">
|
|
237
|
+
<div class="qrcode-payment__title">
|
|
238
|
+
<VanIcon name="scan" size="24" color="#1989fa" />
|
|
239
|
+
<span>请扫描下方二维码进行付款</span>
|
|
240
|
+
</div>
|
|
241
|
+
|
|
242
|
+
<div class="qrcode-payment__amount">
|
|
243
|
+
<span class="qrcode-payment__label">支付金额:</span>
|
|
244
|
+
<span class="qrcode-payment__value">¥{{ props.collection }}元</span>
|
|
245
|
+
</div>
|
|
246
|
+
</div>
|
|
247
|
+
|
|
248
|
+
<div class="qrcode-payment__content">
|
|
249
|
+
<div v-if="queryState" class="qrcode-payment__query-tip">
|
|
250
|
+
用户付款过程中,请勿退出或取消!
|
|
251
|
+
</div>
|
|
252
|
+
<div class="qrcode-payment__qrcode-container">
|
|
253
|
+
<img
|
|
254
|
+
v-if="isTimeout"
|
|
255
|
+
:src="codeAddress"
|
|
256
|
+
class="qrcode-payment__timeout-img"
|
|
257
|
+
alt=""
|
|
258
|
+
>
|
|
259
|
+
</div>
|
|
260
|
+
</div>
|
|
261
|
+
|
|
262
|
+
<div class="qrcode-payment__footer">
|
|
263
|
+
<VanButton
|
|
264
|
+
type="default"
|
|
265
|
+
block
|
|
266
|
+
@click="cancelPayment"
|
|
267
|
+
>
|
|
268
|
+
取消支付
|
|
269
|
+
</VanButton>
|
|
270
|
+
</div>
|
|
271
|
+
</div>
|
|
272
|
+
</VanPopup>
|
|
273
|
+
</template>
|
|
274
|
+
|
|
275
|
+
<style lang="less" scoped>
|
|
276
|
+
.qrcode-payment {
|
|
277
|
+
padding: 20px;
|
|
278
|
+
|
|
279
|
+
&__query-tip {
|
|
280
|
+
text-align: center;
|
|
281
|
+
color: #ff4d4f;
|
|
282
|
+
font-size: 14px;
|
|
283
|
+
font-weight: bold;
|
|
284
|
+
background-color: #fff;
|
|
285
|
+
padding: 4px 8px;
|
|
286
|
+
margin-bottom: 12px;
|
|
287
|
+
width: 266px;
|
|
288
|
+
word-wrap: break-word;
|
|
289
|
+
white-space: pre-wrap;
|
|
290
|
+
line-height: 1.4;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
&__header {
|
|
294
|
+
margin-bottom: 20px;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
&__title {
|
|
298
|
+
display: flex;
|
|
299
|
+
align-items: center;
|
|
300
|
+
justify-content: center;
|
|
301
|
+
gap: 8px;
|
|
302
|
+
margin-bottom: 16px;
|
|
303
|
+
font-size: 16px;
|
|
304
|
+
font-weight: 500;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
&__order-info,
|
|
308
|
+
&__amount {
|
|
309
|
+
display: flex;
|
|
310
|
+
justify-content: center;
|
|
311
|
+
margin-bottom: 8px;
|
|
312
|
+
font-size: 14px;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
&__label {
|
|
316
|
+
color: #646566;
|
|
317
|
+
margin-right: 4px;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
&__value {
|
|
321
|
+
color: #323233;
|
|
322
|
+
font-weight: 500;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
&__content {
|
|
326
|
+
display: flex;
|
|
327
|
+
flex-direction: column;
|
|
328
|
+
align-items: center;
|
|
329
|
+
justify-content: center;
|
|
330
|
+
margin-bottom: 20px;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
&__qrcode-container {
|
|
334
|
+
position: relative;
|
|
335
|
+
width: 266px;
|
|
336
|
+
height: 266px;
|
|
337
|
+
background-color: #f7f8fa;
|
|
338
|
+
display: flex;
|
|
339
|
+
justify-content: center;
|
|
340
|
+
align-items: center;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
&__timeout-img {
|
|
344
|
+
width: 266px;
|
|
345
|
+
height: 266px;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
&__qrcode {
|
|
349
|
+
width: 266px;
|
|
350
|
+
height: 266px;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
&__footer {
|
|
354
|
+
margin-top: 16px;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
</style>
|