pay: 接入支付宝 PC 支付的表单

This commit is contained in:
YunaiV 2023-02-18 21:16:22 +08:00
parent b34801f303
commit ce8571e313
3 changed files with 34 additions and 26 deletions

View File

@ -69,10 +69,6 @@ public class AlipayPcPayClient extends AbstractAlipayClient {
log.error("[unifiedOrder][request({}) 发起支付失败]", JsonUtils.toJsonString(reqDTO), e); log.error("[unifiedOrder][request({}) 发起支付失败]", JsonUtils.toJsonString(reqDTO), e);
return PayCommonResult.build(e.getErrCode(), e.getErrMsg(), null, codeMapping); return PayCommonResult.build(e.getErrCode(), e.getErrMsg(), null, codeMapping);
} }
// 1. form
// 2. url
// 3. code
// 4. code url
// 2.2 处理结果 // 2.2 处理结果
System.out.println(response.getBody()); System.out.println(response.getBody());

View File

@ -160,6 +160,9 @@ export const PayDisplayModeEnum = {
IFRAME: { IFRAME: {
"mode": "iframe", "mode": "iframe",
}, },
FORM: {
"mode": "form"
}
} }
/** /**

View File

@ -41,20 +41,20 @@
</div> </div>
</el-card> </el-card>
<!-- 展示形式二维码 --> <!-- 展示形式二维码 URL -->
<el-dialog :title="qrCode.title" :visible.sync="qrCode.visible" width="350px" append-to-body <el-dialog :title="qrCode.title" :visible.sync="qrCode.visible" width="350px" append-to-body
:close-on-press-escape="false"> :close-on-press-escape="false">
<qrcode-vue :value="qrCode.url" size="310" level="H" /> <qrcode-vue :value="qrCode.url" size="310" level="H" />
</el-dialog> </el-dialog>
<!-- 展示形式iframe --> <!-- 展示形式IFrame -->
<el-dialog :title="iframe.title" :visible.sync="iframe.visible" width="800px" height="800px" append-to-body <el-dialog :title="iframe.title" :visible.sync="iframe.visible" width="800px" height="800px" append-to-body
:close-on-press-escape="false"> :close-on-press-escape="false">
<iframe :src="iframe.url" width="100%" /> <iframe :src="iframe.url" width="100%" />
</el-dialog> </el-dialog>
<!-- 阿里支付 --> <!-- 展示形式 -->
<div ref="alipayWap" v-html="alipayHtml.value" /> <div ref="formRef" v-html="form.value" />
</div> </div>
</template> </template>
@ -88,6 +88,7 @@ export default {
mock: require("@/assets/images/pay/icon/mock.svg"), mock: require("@/assets/images/pay/icon/mock.svg"),
}, },
submitLoading: false, // loading submitLoading: false, // loading
interval: undefined, //
qrCode: { // qrCode: { //
url: '', url: '',
title: '', title: '',
@ -98,8 +99,9 @@ export default {
title: '', title: '',
visible: false visible: false
}, },
interval: undefined, // form: { // form
alipayHtml: '' // HTML html: '',
},
}; };
}, },
created() { created() {
@ -164,6 +166,8 @@ export default {
this.displayIFrame(channelCode, data) this.displayIFrame(channelCode, data)
} else if (data.displayMode === 'url') { } else if (data.displayMode === 'url') {
this.displayUrl(channelCode, data) this.displayUrl(channelCode, data)
} else if (data.displayMode === 'form') {
this.displayForm(channelCode, data)
} }
// //
// if (channelCode === PayChannelEnum.ALIPAY_QR.code) { // if (channelCode === PayChannelEnum.ALIPAY_QR.code) {
@ -203,7 +207,7 @@ export default {
// 4- // 4-
// return { // return {
// "channelExtras": { // "channelExtras": {
// "qr_pay_mode": "2" // "qr_pay_mode": "4"
// } // }
// } // }
// //
@ -212,6 +216,10 @@ export default {
"qr_pay_mode": "2" "qr_pay_mode": "2"
} }
} }
//
// return {
// displayMode: PayDisplayModeEnum.FORM.mode
// }
} }
return {} return {}
}, },
@ -224,33 +232,34 @@ export default {
} }
this.submitLoading = false this.submitLoading = false
}, },
/** 提交支付后IFrame 内置 URL 的展示形式 */
displayIFrame(channelCode, data) { displayIFrame(channelCode, data) {
// this.iframe = { // TODO
// title: '', this.iframe = {
// url: data.displayContent, title: '支付窗口',
// visible: true url: data.displayContent,
// } visible: true
window.open(data.displayContent) }
this.submitLoading = false
}, },
/** 提交支付后URL 的展示形式 */ /** 提交支付后URL 的展示形式 */
displayUrl(channelCode, data) { displayUrl(channelCode, data) {
window.open(data.displayContent) window.open(data.displayContent)
this.submitLoading = false this.submitLoading = false
}, },
/** 提交支付后(支付宝 PC 网站支付) */ /** 提交支付后Form 的展示形式 */
submitAfterAlipayPc(invokeResponse) { displayForm(channelCode, data) {
// //
this.alipayHtml = { this.form = {
value: invokeResponse.body, value: data.displayContent
visible: true
} }
// //
this.$nextTick(() => { this.$nextTick(() => {
// //
// this.$refs.alipayWap.children[0].submit(); this.$refs.formRef.children[0].submit();
// setTimeout(() => { setTimeout(() => {
// this.submitLoading = false this.submitLoading = false
// }, 1000); }, 1000);
}); });
}, },
/** 轮询查询任务 */ /** 轮询查询任务 */