zone #77

Merged
yezian merged 9 commits from zone into main 2024-04-25 20:54:36 +08:00
1 changed files with 38 additions and 33 deletions
Showing only changes of commit 59dace7c2b - Show all commits

View File

@ -36,44 +36,49 @@ export default function Vip() {
const [isVip, setIsVip] = useState(false);
const [name, setName] = useState("");
const [isFetching, setIsFetching] = useState(true);
useEffect(() => {
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;
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,
}),
}
setName(detailData.data.account.name);
if (detailData.data.account.is_a_member === 1) setIsVip(true);
setIsFetching(false);
} catch (error) {
console.error(error);
);
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);
setIsFetching(false);
} catch (error) {
console.error(error);
}
};
//
useEffect(() => {
setTimeout(() => {
getUserData();
}, 500);
const intervalId = setInterval(() => {
getUserData();
}, 2000);
return () => clearInterval(intervalId);
}, []);
//