diff --git a/app/vip/page.jsx b/app/vip/page.jsx index a0668c7..9bc30e2 100644 --- a/app/vip/page.jsx +++ b/app/vip/page.jsx @@ -1,9 +1,216 @@ "use client"; -import React from "react"; +import React, { useState, useEffect } from "react"; import { generateSignature } from "@/utils/crypto"; import webviewBaseRequest from "@/utils/webviewBaseRequest"; +import { getCookies } from "cookies-next"; +import Image from "next/image"; +import vipbackground from "@/public/images/vipbackground.png"; +import isvip from "@/public/images/isvip.png"; +import notvip from "@/public/images/notvip.png"; +import alipay from "@/public/images/alipay.png"; +import contact from "@/public/images/contact.png"; +import vipright1 from "@/public/images/vipright1.png"; +import vipright2 from "@/public/images/vipright2.png"; +import vipright3 from "@/public/images/vipright3.png"; +import vipright4 from "@/public/images/vipright4.png"; +import viptitle from "@/public/images/viptitle.png"; +import Link from "next/link"; +import { Toast } from "antd-mobile"; export default function Vip() { - return
Vip
; + //检查用户是否是vip + const [isVip, setIsVip] = useState(false); + const [name, setName] = useState(""); + useEffect(() => { + const cookies = getCookies(); + const is_a_member = cookies.is_a_member; + const _name = cookies.name; + setName(_name); + const int_is_a_member = parseInt(is_a_member, 10); + if (int_is_a_member === 1) setIsVip(true); + }, []); + + //创建充值订单 + const [isLoading, setIsLoading] = useState(false); + const createOrder = async () => { + setIsLoading(true); + const base = webviewBaseRequest(); + const body = { + ...base, + product_id: "membership", + pay_type: "alipay_h5", + from: "app", + }; + const signature = generateSignature(body); + try { + const response = await fetch( + `/api/vas/create_order?signature=${signature}`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(body), + } + ); + const data = await response.json(); + console.log(data); + if (data.ret === -1) { + Toast.show({ + content: data.msg, + }); + return; + } + router.push(`${data.data.alipay_h5_param_str}`); + } catch (error) { + console.error(error); + } finally { + setIsLoading(false); + } + }; + + //跳转联系客服 + const handleContact = () => { + if (navigator.userAgent.includes("FromWebview")) { + window.ReactNativeWebView.postMessage( + JSON.stringify({ + type: "NAVIGATE", + data: { + page: "MessageDetail", + params: { + mid: 1, + }, + }, + }) + ); + } else { + Toast.show({ + content: "请下载app联系客服充值", + }); + } + }; + + return ( +
+ {isLoading && ( + + )} + +
+ +
+ {isVip ? ( +
+ +

+ {name} +

+
+ ) : ( + + )} +
+

会员权益

+
+
+ +
+

解锁动态

+

专属标识

+
+
+
+ +
+

身份标签

+

专属标识

+
+
+
+ +
+

专属客服

+

专属标识

+
+
+
+ +
+

期待更多

+

专属标识

+
+
+
+
+
+

会员规则

+

+ 1、阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴 +

+

+ 2、阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴 +

+

+ 注意事项 +

+

+ 1、阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴 +

+

+ 2、阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴 +

+
+
+
+
+
+
+
+ +

支付宝支付

+
+
+ +

联系人工充值

+
+
+

+ 确认购买即视为同意 + + 《用户充值协议》 + +

+
+
+
+
+ ); } diff --git a/public/images/alipay.png b/public/images/alipay.png new file mode 100644 index 0000000..fd2c1f9 Binary files /dev/null and b/public/images/alipay.png differ diff --git a/public/images/contact.png b/public/images/contact.png new file mode 100644 index 0000000..61e853c Binary files /dev/null and b/public/images/contact.png differ diff --git a/public/images/isvip.png b/public/images/isvip.png new file mode 100644 index 0000000..e9be015 Binary files /dev/null and b/public/images/isvip.png differ diff --git a/public/images/notvip.png b/public/images/notvip.png new file mode 100644 index 0000000..41c105c Binary files /dev/null and b/public/images/notvip.png differ diff --git a/public/images/vipbackground.png b/public/images/vipbackground.png new file mode 100644 index 0000000..f386121 Binary files /dev/null and b/public/images/vipbackground.png differ diff --git a/public/images/vipright1.png b/public/images/vipright1.png new file mode 100644 index 0000000..f4f7ece Binary files /dev/null and b/public/images/vipright1.png differ diff --git a/public/images/vipright2.png b/public/images/vipright2.png new file mode 100644 index 0000000..84c3587 Binary files /dev/null and b/public/images/vipright2.png differ diff --git a/public/images/vipright3.png b/public/images/vipright3.png new file mode 100644 index 0000000..0eab0a5 Binary files /dev/null and b/public/images/vipright3.png differ diff --git a/public/images/vipright4.png b/public/images/vipright4.png new file mode 100644 index 0000000..5327904 Binary files /dev/null and b/public/images/vipright4.png differ diff --git a/public/images/viptitle.png b/public/images/viptitle.png new file mode 100644 index 0000000..4bc0350 Binary files /dev/null and b/public/images/viptitle.png differ