diff --git a/src/service/api/payment.ts b/src/service/api/payment.ts index b07728e..de45217 100644 --- a/src/service/api/payment.ts +++ b/src/service/api/payment.ts @@ -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({ diff --git a/src/views/recharge/balancerecharge/index.vue b/src/views/recharge/balancerecharge/index.vue index 3e017dc..d8c9f41 100644 --- a/src/views/recharge/balancerecharge/index.vue +++ b/src/views/recharge/balancerecharge/index.vue @@ -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