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 },