增加会员的金币支付

This commit is contained in:
yezian 2024-06-13 22:02:10 +08:00
parent 747903396b
commit bb9c05273f
1 changed files with 74 additions and 26 deletions

View File

@ -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,6 +272,26 @@ export default function Vip() {
<div className="flex flex-col w-full fixed left-0 bottom-0 z-20">
<div className="h-12 bg-gradient-to-t from-[#07050AE5] to-[#07050A00]"></div>
<div className="flex flex-col pt-3 pb-11 px-4 bg-[#07050AE5]">
{useCoinpay ? (
<div className="flex flex-row justify-between">
<div className="w-full px-2">
<div
onClick={() => createOrder("coin")}
className="flex flex-row cursor-pointer gap-1.5 h-11 items-center justify-center bg-primary rounded-full"
>
<svg viewBox="0 0 1024 1024" width="18" height="18">
<path
d="M512 967.0656c-251.392 0-455.0656-203.776-455.0656-455.0656S260.608 56.9344 512 56.9344s455.0656 203.776 455.0656 455.0656S763.392 967.0656 512 967.0656z m-57.344-540.3648h-84.8896c-15.6672 0-28.4672 12.6976-28.4672 28.4672 0 15.6672 12.6976 28.4672 28.4672 28.4672h113.7664v85.2992H369.7664c-15.6672 0-28.4672 12.6976-28.4672 28.4672 0 15.6672 12.6976 28.4672 28.4672 28.4672h113.7664v113.7664c0 15.6672 12.6976 28.4672 28.4672 28.4672s28.4672-12.6976 28.4672-28.4672V625.7664h113.7664c15.6672 0 28.4672-12.6976 28.4672-28.4672 0-15.6672-12.6976-28.4672-28.4672-28.4672H540.4672v-85.2992h113.7664c15.6672 0 28.4672-12.6976 28.4672-28.4672 0-15.6672-12.6976-28.4672-28.4672-28.4672h-82.944l81.92-81.92c11.0592-11.0592 11.0592-29.0816 0-40.2432-11.0592-11.0592-29.0816-11.0592-40.2432 0L513.024 404.48l-99.9424-99.9424c-11.0592-11.0592-29.0816-11.0592-40.2432 0-11.0592 11.0592-11.0592 29.0816 0 40.2432l81.8176 81.92z"
fill="#FFFFFF"
></path>
</svg>
<p className="text-white text-base font-medium whitespace-nowrap">
金币支付
</p>
</div>
</div>
</div>
) : (
<div className="flex flex-row justify-between">
<div className="basis-1/2 px-2">
<div
@ -274,6 +321,7 @@ export default function Vip() {
</div>
</div>
</div>
)}
<p className="text-secondary text-xs font-medium mt-4 text-center mb-1">
确认购买即视为同意
<Link