Commit a6437b7cc553ba4ac3f766a8ff1fe49ae6580a40
1 parent
c44ace60
mall + pay:
1. 后台的收银台,接入微信扫码支付
Showing
3 changed files
with
36 additions
and
2 deletions
yudao-ui-admin/src/assets/images/pay/icon/wx_bar.svg
0 → 100644
| 1 | +<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1627279586085" class="icon" viewBox="0 0 1036 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6737" xmlns:xlink="http://www.w3.org/1999/xlink" width="40.46875" height="40"><defs><style type="text/css">@font-face { font-family: feedback-iconfont; src: url("//at.alicdn.com/t/font_1031158_1uhr8ri0pk5.eot?#iefix") format("embedded-opentype"), url("//at.alicdn.com/t/font_1031158_1uhr8ri0pk5.woff2") format("woff2"), url("//at.alicdn.com/t/font_1031158_1uhr8ri0pk5.woff") format("woff"), url("//at.alicdn.com/t/font_1031158_1uhr8ri0pk5.ttf") format("truetype"), url("//at.alicdn.com/t/font_1031158_1uhr8ri0pk5.svg#iconfont") format("svg"); }</style></defs><path d="M27.587124 336.619083h69.148134a13.978733 13.978733 0 0 0 13.79235-13.978733V13.989916A13.978733 13.978733 0 0 0 96.735258 0.011183H27.587124a13.978733 13.978733 0 0 0-13.792351 13.978733v308.650434a13.978733 13.978733 0 0 0 13.792351 13.978733z m165.880969 0h27.584701a13.978733 13.978733 0 0 0 13.79235-13.978733V13.989916a13.978733 13.978733 0 0 0-13.79235-13.978733h-27.584701a13.978733 13.978733 0 0 0-13.79235 13.978733v308.650434a13.978733 13.978733 0 0 0 13.79235 13.978733z m138.109886 322.629167h-110.525185a27.771084 27.771084 0 0 0-27.584701 28.14385v111.829867a27.771084 27.771084 0 0 0 27.584701 28.14385h110.525185a27.957467 27.957467 0 0 0 27.584701-28.14385v-111.829867a27.957467 27.957467 0 0 0-27.584701-28.14385z m484.596091-322.629167h27.584701a13.978733 13.978733 0 0 0 13.79235-13.978733V13.989916a13.978733 13.978733 0 0 0-14.537883-13.978733h-27.5847a13.978733 13.978733 0 0 0-13.978734 13.978733v308.650434a13.978733 13.978733 0 0 0 13.978734 13.978733z m-469.871825 0H428.68358a13.978733 13.978733 0 0 0 13.792351-13.978733V13.989916A13.978733 13.978733 0 0 0 428.68358 0.011183h-83.126867a13.978733 13.978733 0 0 0-13.792351 13.978733v308.650434a13.978733 13.978733 0 0 0 13.792351 13.978733z m594.189361 0h69.148134a13.978733 13.978733 0 0 0 13.792351-13.978733V13.989916a13.978733 13.978733 0 0 0-14.537883-13.978733h-69.148135a13.978733 13.978733 0 0 0-13.79235 13.978733v308.650434a13.978733 13.978733 0 0 0 13.79235 13.978733z m-412.279444 126.181367H66.91396A67.470687 67.470687 0 0 0 0.002423 530.830286v425.139878a67.470687 67.470687 0 0 0 66.911537 68.029836h418.802853a67.470687 67.470687 0 0 0 66.911537-68.029836V487.775787a24.788954 24.788954 0 0 0-24.416188-24.975337z m-58.337914 433.899885a42.681733 42.681733 0 0 1-42.495349 43.054498H125.438257a42.681733 42.681733 0 0 1-42.495349-43.054498V590.100115a42.681733 42.681733 0 0 1 42.495349-43.054498h301.940642a42.681733 42.681733 0 0 1 42.495349 43.054498z m525.22761-433.899885a41.749817 41.749817 0 0 0-41.377051 42.122583v55.914934a41.377051 41.377051 0 1 0 82.940485 0v-55.914934a41.749817 41.749817 0 0 0-41.563434-42.122583z m0 223.659734a41.749817 41.749817 0 0 0-41.377051 42.122584V894.65012a45.477479 45.477479 0 0 1-45.291096 45.850246h-159.730327a43.240882 43.240882 0 0 0-43.613649 37.276622A41.9362 41.9362 0 0 0 745.534871 1024h233.538039a57.778765 57.778765 0 0 0 57.405999-58.337914V729.3283a41.749817 41.749817 0 0 0-41.377051-41.9362zM732.488053 322.64035V13.989916a13.978733 13.978733 0 0 0-13.79235-13.978733h-82.940485a13.978733 13.978733 0 0 0-13.79235 13.978733v308.650434a13.978733 13.978733 0 0 0 13.79235 13.978733h82.940485a13.978733 13.978733 0 0 0 13.79235-13.978733zM532.126208 0.011183c-11.36937 0-20.688525 6.337026-20.688526 13.978733v308.650434c0 7.828091 9.319156 13.978733 20.688526 13.978733s20.688525-6.337026 20.688525-13.978733V13.989916c0-7.641708-9.319156-13.978733-20.688525-13.978733z" p-id="6738" fill="#04C361"/><path d="M745.534871 462.80045a41.749817 41.749817 0 0 0-41.377051 42.122583v252.549117a41.377051 41.377051 0 1 0 82.940485 0V504.923033A41.749817 41.749817 0 0 0 745.534871 462.80045" p-id="6739" fill="#04C361"/></svg> | ||
| 0 | \ No newline at end of file | 2 | \ No newline at end of file |
yudao-ui-admin/src/utils/constants.js
| @@ -132,6 +132,10 @@ export const PayChannelEnum = { | @@ -132,6 +132,10 @@ export const PayChannelEnum = { | ||
| 132 | "code": "wx_app", | 132 | "code": "wx_app", |
| 133 | "name": "微信 APP 支付" | 133 | "name": "微信 APP 支付" |
| 134 | }, | 134 | }, |
| 135 | + WX_BAR: { | ||
| 136 | + "code": "wx_bar", | ||
| 137 | + "name": "微信条码支付" | ||
| 138 | + }, | ||
| 135 | ALIPAY_PC: { | 139 | ALIPAY_PC: { |
| 136 | "code": "alipay_pc", | 140 | "code": "alipay_pc", |
| 137 | "name": "支付宝 PC 网站支付" | 141 | "name": "支付宝 PC 网站支付" |
yudao-ui-admin/src/views/pay/cashier/index.vue
| @@ -26,7 +26,7 @@ | @@ -26,7 +26,7 @@ | ||
| 26 | <!-- 微信支付 --> | 26 | <!-- 微信支付 --> |
| 27 | <el-descriptions title="选择微信支付" style="margin-top: 20px;" /> | 27 | <el-descriptions title="选择微信支付" style="margin-top: 20px;" /> |
| 28 | <div class="pay-channel-container"> | 28 | <div class="pay-channel-container"> |
| 29 | - <div class="box" v-for="channel in channels" v-if="channel.code.indexOf('wx_') === 0" :key="channel.code"> | 29 | + <div class="box" v-for="channel in channels" v-if="channel.code.indexOf('wx_') === 0" :key="channel.code" @click="submit(channel.code)"> |
| 30 | <img :src="channel.icon"> | 30 | <img :src="channel.icon"> |
| 31 | <div class="title">{{ channel.name }}</div> | 31 | <div class="title">{{ channel.name }}</div> |
| 32 | </div> | 32 | </div> |
| @@ -126,6 +126,10 @@ export default { | @@ -126,6 +126,10 @@ export default { | ||
| 126 | icon: require("@/assets/images/pay/icon/wx_app.svg"), | 126 | icon: require("@/assets/images/pay/icon/wx_app.svg"), |
| 127 | code: "wx_app" | 127 | code: "wx_app" |
| 128 | }, { | 128 | }, { |
| 129 | + name: '微信条码支付', | ||
| 130 | + icon: require("@/assets/images/pay/icon/wx_bar.svg"), | ||
| 131 | + code: "wx_bar" | ||
| 132 | + }, { | ||
| 129 | name: '模拟支付', | 133 | name: '模拟支付', |
| 130 | icon: require("@/assets/images/pay/icon/mock.svg"), | 134 | icon: require("@/assets/images/pay/icon/mock.svg"), |
| 131 | code: "mock" | 135 | code: "mock" |
| @@ -195,6 +199,15 @@ export default { | @@ -195,6 +199,15 @@ export default { | ||
| 195 | } | 199 | } |
| 196 | return; | 200 | return; |
| 197 | } | 201 | } |
| 202 | + if (channelCode === PayChannelEnum.WX_BAR.code) { | ||
| 203 | + this.barCode = { | ||
| 204 | + channelCode: channelCode, | ||
| 205 | + value: '', | ||
| 206 | + title: '“微信”条码支付', | ||
| 207 | + visible: true | ||
| 208 | + } | ||
| 209 | + return; | ||
| 210 | + } | ||
| 198 | 211 | ||
| 199 | // 默认的提交处理 | 212 | // 默认的提交处理 |
| 200 | this.submit0(channelCode) | 213 | this.submit0(channelCode) |
| @@ -207,7 +220,16 @@ export default { | @@ -207,7 +220,16 @@ export default { | ||
| 207 | returnUrl: location.href, // 支付成功后,支付渠道跳转回当前页;再由当前页,跳转回 {@link returnUrl} 对应的地址 | 220 | returnUrl: location.href, // 支付成功后,支付渠道跳转回当前页;再由当前页,跳转回 {@link returnUrl} 对应的地址 |
| 208 | ...this.buildSubmitParam(channelCode) | 221 | ...this.buildSubmitParam(channelCode) |
| 209 | }).then(response => { | 222 | }).then(response => { |
| 223 | + // 直接返回已支付的情况,例如说扫码支付 | ||
| 210 | const data = response.data | 224 | const data = response.data |
| 225 | + if (data.status === PayOrderStatusEnum.SUCCESS.status) { | ||
| 226 | + this.clearQueryInterval(); | ||
| 227 | + this.$message.success('支付成功!'); | ||
| 228 | + this.goReturnUrl(); | ||
| 229 | + return | ||
| 230 | + } | ||
| 231 | + | ||
| 232 | + // 展示对应的界面 | ||
| 211 | if (data.displayMode === PayDisplayModeEnum.URL.mode) { | 233 | if (data.displayMode === PayDisplayModeEnum.URL.mode) { |
| 212 | this.displayUrl(channelCode, data) | 234 | this.displayUrl(channelCode, data) |
| 213 | } else if (data.displayMode === PayDisplayModeEnum.QR_CODE.mode) { | 235 | } else if (data.displayMode === PayDisplayModeEnum.QR_CODE.mode) { |
| @@ -230,11 +252,18 @@ export default { | @@ -230,11 +252,18 @@ export default { | ||
| 230 | } | 252 | } |
| 231 | } | 253 | } |
| 232 | } | 254 | } |
| 255 | + // ② 微信 BarCode 支付时,需要传递 authCode 条形码 | ||
| 256 | + if (channelCode === PayChannelEnum.WX_BAR.code) { | ||
| 257 | + return { | ||
| 258 | + "channelExtras": { | ||
| 259 | + "authCode": this.barCode.value | ||
| 260 | + } | ||
| 261 | + } | ||
| 262 | + } | ||
| 233 | return {} | 263 | return {} |
| 234 | }, | 264 | }, |
| 235 | /** 提交支付后,URL 的展示形式 */ | 265 | /** 提交支付后,URL 的展示形式 */ |
| 236 | displayUrl(channelCode, data) { | 266 | displayUrl(channelCode, data) { |
| 237 | - // window.open(data.displayContent) | ||
| 238 | location.href = data.displayContent | 267 | location.href = data.displayContent |
| 239 | this.submitLoading = false | 268 | this.submitLoading = false |
| 240 | }, | 269 | }, |