每次进入会员页面会重新获取用户信息更新会员状态
This commit is contained in:
parent
526b844e97
commit
71b44deaf2
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue