From a6437b7cc553ba4ac3f766a8ff1fe49ae6580a40 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 15 Jul 2023 21:18:36 +0800 Subject: [PATCH] =?UTF-8?q?mall=20+=20pay=EF=BC=9A=201.=20=E5=90=8E?= =?UTF-8?q?=E5=8F=B0=E7=9A=84=E6=94=B6=E9=93=B6=E5=8F=B0=EF=BC=8C=E6=8E=A5?= =?UTF-8?q?=E5=85=A5=E5=BE=AE=E4=BF=A1=E6=89=AB=E7=A0=81=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/assets/images/pay/icon/wx_bar.svg | 1 + yudao-ui-admin/src/utils/constants.js | 4 +++ .../src/views/pay/cashier/index.vue | 33 +++++++++++++++++-- 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 yudao-ui-admin/src/assets/images/pay/icon/wx_bar.svg diff --git a/yudao-ui-admin/src/assets/images/pay/icon/wx_bar.svg b/yudao-ui-admin/src/assets/images/pay/icon/wx_bar.svg new file mode 100644 index 000000000..11292e6e7 --- /dev/null +++ b/yudao-ui-admin/src/assets/images/pay/icon/wx_bar.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/yudao-ui-admin/src/utils/constants.js b/yudao-ui-admin/src/utils/constants.js index 10819e385..801ca76cc 100644 --- a/yudao-ui-admin/src/utils/constants.js +++ b/yudao-ui-admin/src/utils/constants.js @@ -132,6 +132,10 @@ export const PayChannelEnum = { "code": "wx_app", "name": "微信 APP 支付" }, + WX_BAR: { + "code": "wx_bar", + "name": "微信条码支付" + }, ALIPAY_PC: { "code": "alipay_pc", "name": "支付宝 PC 网站支付" diff --git a/yudao-ui-admin/src/views/pay/cashier/index.vue b/yudao-ui-admin/src/views/pay/cashier/index.vue index ef73ed4db..41d8ce159 100644 --- a/yudao-ui-admin/src/views/pay/cashier/index.vue +++ b/yudao-ui-admin/src/views/pay/cashier/index.vue @@ -26,7 +26,7 @@
-
+
{{ channel.name }}
@@ -125,6 +125,10 @@ export default { name: '微信 App 支付', icon: require("@/assets/images/pay/icon/wx_app.svg"), code: "wx_app" + }, { + name: '微信条码支付', + icon: require("@/assets/images/pay/icon/wx_bar.svg"), + code: "wx_bar" }, { name: '模拟支付', icon: require("@/assets/images/pay/icon/mock.svg"), @@ -195,6 +199,15 @@ export default { } return; } + if (channelCode === PayChannelEnum.WX_BAR.code) { + this.barCode = { + channelCode: channelCode, + value: '', + title: '“微信”条码支付', + visible: true + } + return; + } // 默认的提交处理 this.submit0(channelCode) @@ -207,7 +220,16 @@ export default { returnUrl: location.href, // 支付成功后,支付渠道跳转回当前页;再由当前页,跳转回 {@link returnUrl} 对应的地址 ...this.buildSubmitParam(channelCode) }).then(response => { + // 直接返回已支付的情况,例如说扫码支付 const data = response.data + if (data.status === PayOrderStatusEnum.SUCCESS.status) { + this.clearQueryInterval(); + this.$message.success('支付成功!'); + this.goReturnUrl(); + return + } + + // 展示对应的界面 if (data.displayMode === PayDisplayModeEnum.URL.mode) { this.displayUrl(channelCode, data) } else if (data.displayMode === PayDisplayModeEnum.QR_CODE.mode) { @@ -230,11 +252,18 @@ export default { } } } + // ② 微信 BarCode 支付时,需要传递 authCode 条形码 + if (channelCode === PayChannelEnum.WX_BAR.code) { + return { + "channelExtras": { + "authCode": this.barCode.value + } + } + } return {} }, /** 提交支付后,URL 的展示形式 */ displayUrl(channelCode, data) { - // window.open(data.displayContent) location.href = data.displayContent this.submitLoading = false },