Skip to content

Commit 17ba74c

Browse files
committed
pay: 临时性的提交,准备 client 部分的重构
1 parent 5c991f5 commit 17ba74c

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

src/views/pay/order/submit.vue

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
</el-descriptions>
1313
</el-card>
1414

15+
1516
<!-- 支付选择框 -->
16-
<el-card style="margin-top: 10px">
17+
<el-card style="margin-top: 10px" v-loading="submitLoading" element-loading-text="提交支付中...">
1718
<!-- 支付宝 -->
1819
<el-descriptions title="选择支付宝支付">
1920
</el-descriptions>
@@ -46,6 +47,10 @@
4647
:close-on-press-escape="false">
4748
<qrcode-vue :value="qrCode.url" size="310" level="H" />
4849
</el-dialog>
50+
51+
<!-- 阿里支付 -->
52+
<div ref="alipayWap" v-html="alipayHtml.value" />
53+
4954
</div>
5055
</template>
5156
<script>
@@ -77,12 +82,14 @@ export default {
7782
wx_pub: require("@/assets/images/pay/icon/wx_pub.svg"),
7883
mock: require("@/assets/images/pay/icon/mock.svg"),
7984
},
85+
submitLoading: false, // 提交支付的 loading
8086
qrCode: { // 支付二维码
8187
url: '',
8288
title: '',
8389
visible: false,
8490
},
8591
interval: undefined, // 定时任务,轮询是否完成支付
92+
alipayHtml: '' // 阿里支付的 HTML
8693
};
8794
},
8895
created() {
@@ -136,14 +143,20 @@ export default {
136143
},
137144
/** 提交支付 */
138145
submit(channelCode) {
146+
this.submitLoading = true
139147
submitOrder({
140148
id: this.id,
141149
channelCode: channelCode
142150
}).then(response => {
151+
const invokeResponse = response.data.invokeResponse
143152
// 不同的支付,调用不同的策略
144153
if (channelCode === PayChannelEnum.ALIPAY_QR.code) {
145-
this.submitAfterAlipayQr(response.data.invokeResponse)
154+
this.submitAfterAlipayQr(invokeResponse)
155+
} else if (channelCode === PayChannelEnum.ALIPAY_PC.code
156+
|| channelCode === PayChannelEnum.ALIPAY_WAP.code) {
157+
this.submitAfterAlipayPc(invokeResponse)
146158
}
159+
147160
// 打开轮询任务
148161
this.createQueryInterval()
149162
})
@@ -155,6 +168,23 @@ export default {
155168
url: invokeResponse.qrCode,
156169
visible: true
157170
}
171+
this.submitLoading = false
172+
},
173+
/** 提交支付后(支付宝 PC 网站支付) */
174+
submitAfterAlipayPc(invokeResponse) {
175+
// 渲染支付页面
176+
this.alipayHtml = {
177+
value: invokeResponse.body,
178+
visible: true
179+
}
180+
// 防抖避免重复支付
181+
this.$nextTick(() => {
182+
// 提交支付表单
183+
// this.$refs.alipayWap.children[0].submit();
184+
// setTimeout(() => {
185+
// this.submitLoading = false
186+
// }, 1000);
187+
});
158188
},
159189
/** 轮询查询任务 */
160190
createQueryInterval() {

0 commit comments

Comments
 (0)