12
12
</el-descriptions >
13
13
</el-card >
14
14
15
+
15
16
<!-- 支付选择框 -->
16
- <el-card style =" margin-top : 10px " >
17
+ <el-card style =" margin-top : 10px " v-loading = " submitLoading " element-loading-text = " 提交支付中... " >
17
18
<!-- 支付宝 -->
18
19
<el-descriptions title =" 选择支付宝支付" >
19
20
</el-descriptions >
46
47
:close-on-press-escape =" false" >
47
48
<qrcode-vue :value =" qrCode.url" size =" 310" level =" H" />
48
49
</el-dialog >
50
+
51
+ <!-- 阿里支付 -->
52
+ <div ref =" alipayWap" v-html =" alipayHtml.value" />
53
+
49
54
</div >
50
55
</template >
51
56
<script >
@@ -77,12 +82,14 @@ export default {
77
82
wx_pub: require (" @/assets/images/pay/icon/wx_pub.svg" ),
78
83
mock: require (" @/assets/images/pay/icon/mock.svg" ),
79
84
},
85
+ submitLoading: false , // 提交支付的 loading
80
86
qrCode: { // 支付二维码
81
87
url: ' ' ,
82
88
title: ' ' ,
83
89
visible: false ,
84
90
},
85
91
interval: undefined , // 定时任务,轮询是否完成支付
92
+ alipayHtml: ' ' // 阿里支付的 HTML
86
93
};
87
94
},
88
95
created () {
@@ -136,14 +143,20 @@ export default {
136
143
},
137
144
/** 提交支付 */
138
145
submit (channelCode ) {
146
+ this .submitLoading = true
139
147
submitOrder ({
140
148
id: this .id ,
141
149
channelCode: channelCode
142
150
}).then (response => {
151
+ const invokeResponse = response .data .invokeResponse
143
152
// 不同的支付,调用不同的策略
144
153
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)
146
158
}
159
+
147
160
// 打开轮询任务
148
161
this .createQueryInterval ()
149
162
})
@@ -155,6 +168,23 @@ export default {
155
168
url: invokeResponse .qrCode ,
156
169
visible: true
157
170
}
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
+ });
158
188
},
159
189
/** 轮询查询任务 */
160
190
createQueryInterval () {
0 commit comments