From 71b44deaf2e0219171c2d82e82dbe886eb3c2c2f Mon Sep 17 00:00:00 2001 From: yezian Date: Tue, 23 Jan 2024 20:01:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AF=8F=E6=AC=A1=E8=BF=9B=E5=85=A5=E4=BC=9A?= =?UTF-8?q?=E5=91=98=E9=A1=B5=E9=9D=A2=E4=BC=9A=E9=87=8D=E6=96=B0=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E4=BC=9A=E5=91=98=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/vip/page.jsx | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) 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,