|
@@ -1,29 +1,29 @@
|
|
|
import { Image } from "expo-image";
|
|
import { Image } from "expo-image";
|
|
|
import { useRouter } from "expo-router";
|
|
import { useRouter } from "expo-router";
|
|
|
import React, {
|
|
import React, {
|
|
|
- forwardRef,
|
|
|
|
|
- useImperativeHandle,
|
|
|
|
|
- useRef,
|
|
|
|
|
- useState,
|
|
|
|
|
|
|
+ forwardRef,
|
|
|
|
|
+ useImperativeHandle,
|
|
|
|
|
+ useRef,
|
|
|
|
|
+ useState,
|
|
|
} from "react";
|
|
} from "react";
|
|
|
import {
|
|
import {
|
|
|
- ActivityIndicator,
|
|
|
|
|
- Alert,
|
|
|
|
|
- AppState,
|
|
|
|
|
- Dimensions,
|
|
|
|
|
- Modal,
|
|
|
|
|
- ScrollView,
|
|
|
|
|
- StyleSheet,
|
|
|
|
|
- Text,
|
|
|
|
|
- TouchableOpacity,
|
|
|
|
|
- View,
|
|
|
|
|
|
|
+ ActivityIndicator,
|
|
|
|
|
+ Alert,
|
|
|
|
|
+ AppState,
|
|
|
|
|
+ Dimensions,
|
|
|
|
|
+ Modal,
|
|
|
|
|
+ ScrollView,
|
|
|
|
|
+ StyleSheet,
|
|
|
|
|
+ Text,
|
|
|
|
|
+ TouchableOpacity,
|
|
|
|
|
+ View,
|
|
|
} from "react-native";
|
|
} from "react-native";
|
|
|
|
|
|
|
|
import { applyOrder, getApplyResult, previewOrder } from "@/services/award";
|
|
import { applyOrder, getApplyResult, previewOrder } from "@/services/award";
|
|
|
import Alipay from "expo-native-alipay";
|
|
import Alipay from "expo-native-alipay";
|
|
|
import {
|
|
import {
|
|
|
- LotteryResultModal,
|
|
|
|
|
- LotteryResultModalRef,
|
|
|
|
|
|
|
+ LotteryResultModal,
|
|
|
|
|
+ LotteryResultModalRef,
|
|
|
} from "./LotteryResultModal";
|
|
} from "./LotteryResultModal";
|
|
|
|
|
|
|
|
const { width: SCREEN_WIDTH } = Dimensions.get("window");
|
|
const { width: SCREEN_WIDTH } = Dimensions.get("window");
|
|
@@ -260,13 +260,24 @@ export const CheckoutModal = forwardRef<CheckoutModalRef, CheckoutModalProps>(
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ const isNavigatingRef = useRef(false);
|
|
|
|
|
+
|
|
|
const handleSuccess = (tradeNo: string) => {
|
|
const handleSuccess = (tradeNo: string) => {
|
|
|
setVisible(false);
|
|
setVisible(false);
|
|
|
|
|
+
|
|
|
|
|
+ if (isNavigatingRef.current) return;
|
|
|
|
|
+ isNavigatingRef.current = true;
|
|
|
|
|
+
|
|
|
router.push({
|
|
router.push({
|
|
|
pathname: "/happy-spin" as any,
|
|
pathname: "/happy-spin" as any,
|
|
|
params: { tradeNo, num, poolId },
|
|
params: { tradeNo, num, poolId },
|
|
|
});
|
|
});
|
|
|
onSuccess({ tradeNo, num });
|
|
onSuccess({ tradeNo, num });
|
|
|
|
|
+
|
|
|
|
|
+ // Reset after a short delay to allow subsequent purchases
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ isNavigatingRef.current = false;
|
|
|
|
|
+ }, 2000);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const handleNativePay = async (
|
|
const handleNativePay = async (
|
|
@@ -342,6 +353,7 @@ export const CheckoutModal = forwardRef<CheckoutModalRef, CheckoutModalProps>(
|
|
|
Alert.alert("支付中断", `状态码: ${status}`);
|
|
Alert.alert("支付中断", `状态码: ${status}`);
|
|
|
}
|
|
}
|
|
|
} catch (e: any) {
|
|
} catch (e: any) {
|
|
|
|
|
+ if (isResolved) return;
|
|
|
isResolved = true;
|
|
isResolved = true;
|
|
|
console.log("Alipay Error:", e);
|
|
console.log("Alipay Error:", e);
|
|
|
Alert.alert("支付异常", e.message || "调用支付宝失败");
|
|
Alert.alert("支付异常", e.message || "调用支付宝失败");
|