diff --git a/app/vip/page.jsx b/app/vip/page.jsx index f6bad47..f88ceaf 100644 --- a/app/vip/page.jsx +++ b/app/vip/page.jsx @@ -16,10 +16,11 @@ import vipright4 from "@/public/images/vipright4.png"; import viptitle from "@/public/images/viptitle.png"; import Link from "next/link"; import { Toast } from "antd-mobile"; -import { useRouter } from "next/navigation"; +import { useRouter, useSearchParams } from "next/navigation"; export default function Vip() { const router = useRouter(); + const searchParams = useSearchParams(); const alipayBlock = () => { const base = webviewBaseRequest(); @@ -32,6 +33,13 @@ export default function Vip() { }); }; + //检查是否需要使用金币支付 + const [useCoinpay, setUseCoinpay] = useState(false); + useEffect(() => { + const useCoinpayStr = searchParams.get("use_coinpay"); + setUseCoinpay(useCoinpayStr === "1" ? true : false); + }, []); + //检查用户是否是vip const [isVip, setIsVip] = useState(false); const [name, setName] = useState(""); @@ -98,6 +106,25 @@ export default function Vip() { return; } + //金币支付 + if (type === "coin") { + window.ReactNativeWebView.postMessage( + JSON.stringify({ + type: "COINPAY", + data: { + url: "/api/vas/create_order", + body: { product_id: "membership" }, + product: "会员资格", + coinPrice: 490, + validity: "永久", + info: "", + onPurchaseDone: () => {}, + }, + }) + ); + return; + } + setIsLoading(true); const signature = generateSignature(body); @@ -245,35 +272,56 @@ export default function Vip() {
-
-
-
createOrder("alipay_h5")} - className="flex flex-row cursor-pointer gap-1.5 h-11 items-center justify-center bg-primary rounded-full" - > - -

- 支付宝支付 -

+ {useCoinpay ? ( +
+
+
createOrder("coin")} + className="flex flex-row cursor-pointer gap-1.5 h-11 items-center justify-center bg-primary rounded-full" + > + + + +

+ 金币支付 +

+
-
-
createOrder("wxpay_h5")} - className="flex flex-row cursor-pointer gap-1.5 h-11 items-center justify-center bg-primary rounded-full" - > - - - -

- 微信支付 -

+ ) : ( +
+
+
createOrder("alipay_h5")} + className="flex flex-row cursor-pointer gap-1.5 h-11 items-center justify-center bg-primary rounded-full" + > + +

+ 支付宝支付 +

+
+
+
+
createOrder("wxpay_h5")} + className="flex flex-row cursor-pointer gap-1.5 h-11 items-center justify-center bg-primary rounded-full" + > + + + +

+ 微信支付 +

+
-
+ )}

确认购买即视为同意