2
0

feat: 支付宝手机端支付测试

This commit is contained in:
caiyuchao
2025-01-21 17:05:45 +08:00
parent b04c243acd
commit 9aa3ea373c
2 changed files with 19 additions and 2 deletions

View File

@@ -9,6 +9,15 @@ export function aliPayPcPay(params: {orderId: number}) {
});
}
/** AliPay wapPay with orderId */
export function aliPayWapPay(params: {orderId: number}) {
return rawRequest({
url: '/payment/aliPay/wapPay',
method: 'post',
params
});
}
/** WxPay scanCode with orderId */
export function wxPayScanCode(params: {orderId: number}) {
return request({

View File

@@ -2,9 +2,10 @@
import { ref, computed, onMounted, onUnmounted } from 'vue';
import { useI18n } from 'vue-i18n';
import { submitOrder } from '@/service/api/auth';
import { aliPayPcPay } from '@/service/api/payment';
import { aliPayPcPay, aliPayWapPay } from '@/service/api/payment';
import { message } from 'ant-design-vue';
import { useRouterPush } from '@/hooks/common/router';
import { useAppStore } from '@/store/modules/app';
import type { Ref } from 'vue';
defineOptions({
@@ -13,6 +14,7 @@ defineOptions({
const { t } = useI18n();
const { routerPushByKey } = useRouterPush();
const appStore = useAppStore();
interface RechargeOption {
amount: number;
@@ -106,7 +108,13 @@ const handleAliPay = async () => {
type: 1,
orderAmount: paymentAmount.value
});
const res = await aliPayPcPay({orderId: orderRes.data});
// 区分手机端和pc端支付
let res;
if(appStore.isMobile) {
res = await aliPayWapPay({orderId: orderRes.data});
} else {
res = await aliPayPcPay({orderId: orderRes.data});
}
console.log(res);
const div = document.createElement("div");
div.innerHTML = res; // html code