From bb9c05273f267cd914333aa41db110bffa903163 Mon Sep 17 00:00:00 2001 From: yezian Date: Thu, 13 Jun 2024 22:02:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BC=9A=E5=91=98=E7=9A=84?= =?UTF-8?q?=E9=87=91=E5=B8=81=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/vip/page.jsx | 100 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 74 insertions(+), 26 deletions(-) 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" + > + + + +

+ 微信支付 +

+
-
+ )}

确认购买即视为同意