diff --git a/app/vip/page.jsx b/app/vip/page.jsx index b2ae66b..2ea093f 100644 --- a/app/vip/page.jsx +++ b/app/vip/page.jsx @@ -25,12 +25,40 @@ export default function 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 getUserData = async () => { + try { + const base = webviewBaseRequest(); + const signature = generateSignature({ + ...base, + mid: base.b_mid, + }); + const detailResponse = await fetch( + `/api/account/list_by_mid?signature=${signature}`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + ...base, + mid: base.b_mid, + }), + } + ); + const detailData = await detailResponse.json(); + if (detailData.ret === -1) { + Toast.show({ + content: detailData.msg, + }); + return; + } + setName(detailData.data.account.name); + if (detailData.data.account.is_a_member === 1) setIsVip(true); + } catch (error) { + console.error(error); + } + }; + getUserData(); }, []); //创建充值订单 @@ -57,7 +85,6 @@ export default function Vip() { } ); const data = await response.json(); - console.log(data); if (data.ret === -1) { Toast.show({ content: data.msg,