|
|
@@ -154,10 +154,45 @@ export const CheckoutModal = forwardRef<CheckoutModalRef, CheckoutModalProps>(
|
|
|
|
|
|
setLoading(true);
|
|
|
try {
|
|
|
- const paymentType = 'WALLET';
|
|
|
+ let paymentType = '';
|
|
|
+
|
|
|
+ // Prioritize Wallet if checked
|
|
|
+ if (cashChecked) {
|
|
|
+ paymentType = 'WALLET';
|
|
|
+ } else {
|
|
|
+ // Default to Alipay for now as per branch logic
|
|
|
+ paymentType = 'ALIPAY_APP';
|
|
|
+ }
|
|
|
+
|
|
|
+ // If wallet is insufficient and logic requires mixed payment, it might be more complex
|
|
|
+ // strictly following branch logic: if cashChecked use Wallet, else Alipay
|
|
|
+
|
|
|
const payNum = packFlag ? 1 : num;
|
|
|
|
|
|
const res = await applyOrder(poolId, payNum, paymentType, boxNum, seatNumbers, packFlag);
|
|
|
+
|
|
|
+ // Handle Alipay Response
|
|
|
+ if (res?.payInfo) {
|
|
|
+ const result = await Alipay.pay(res.payInfo);
|
|
|
+ console.log('Alipay Result:', result);
|
|
|
+ const resultStatus = result?.resultStatus;
|
|
|
+
|
|
|
+ if (resultStatus === '9000') {
|
|
|
+ // Payment Success
|
|
|
+ // Maybe verify payment here if needed, or just assume success
|
|
|
+ const tradeNo = res.bizTradeNo || res.tradeNo; // Assuming tradeNo is in applyOrder response
|
|
|
+
|
|
|
+ setVisible(false);
|
|
|
+ router.push({
|
|
|
+ pathname: '/lottery' as any,
|
|
|
+ params: { tradeNo, num, poolId }
|
|
|
+ });
|
|
|
+ onSuccess({ tradeNo, num });
|
|
|
+ } else {
|
|
|
+ Alert.alert('提示', '支付未完成');
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
if (res?.paySuccess || res?.bizTradeNo || res?.tradeNo) {
|
|
|
const tradeNo = res.bizTradeNo || res.tradeNo;
|
|
|
@@ -175,6 +210,7 @@ export const CheckoutModal = forwardRef<CheckoutModalRef, CheckoutModalProps>(
|
|
|
Alert.alert('提示', res?.message || '支付失败,请重试');
|
|
|
}
|
|
|
} catch (error: any) {
|
|
|
+ console.error('Pay error:', error);
|
|
|
Alert.alert('支付失败', error?.message || '请稍后重试');
|
|
|
} finally {
|
|
|
setLoading(false);
|
|
|
@@ -203,7 +239,7 @@ export const CheckoutModal = forwardRef<CheckoutModalRef, CheckoutModalProps>(
|
|
|
} else {
|
|
|
setResultLoading(false);
|
|
|
if (typeof window !== 'undefined') {
|
|
|
- window.alert('获取结果超时,请在仓库中查看');
|
|
|
+ Alert.alert('提示', '获取结果超时,请在仓库中查看');
|
|
|
}
|
|
|
}
|
|
|
} catch {
|
|
|
@@ -213,7 +249,7 @@ export const CheckoutModal = forwardRef<CheckoutModalRef, CheckoutModalProps>(
|
|
|
} else {
|
|
|
setResultLoading(false);
|
|
|
if (typeof window !== 'undefined') {
|
|
|
- window.alert('获取结果失败,请在仓库中查看');
|
|
|
+ Alert.alert('提示', '获取结果失败,请在仓库中查看');
|
|
|
}
|
|
|
}
|
|
|
}
|