zone #77

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

View File

@ -16,72 +16,81 @@ export default function Pay({ params }) {
//
const [superfanshipData, setSuperfanshipData] = useState();
const [isFetching, setIsFetching] = useState(true);
useEffect(() => {
const getData = async () => {
try {
const base = webviewBaseRequest();
const body = {
zid: parseInt(params.zid),
moment_id: parseInt(params.moment_id),
product_id: params.product_id,
...base,
};
const signature = generateSignature(body);
const response = await fetch(
`/api/zone/get_cashier?signature=${signature}`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(body),
}
);
const temData = await response.json();
console.log(temData, JSON.stringify(body));
if (temData.ret === -1) {
Toast.show({
content: temData.msg,
});
return;
//
const getData = async () => {
try {
const base = webviewBaseRequest();
const body = {
zid: parseInt(params.zid),
moment_id: parseInt(params.moment_id),
product_id: params.product_id,
...base,
};
const signature = generateSignature(body);
const response = await fetch(
`/api/zone/get_cashier?signature=${signature}`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(body),
}
setData(temData.data);
setIsFetching(false);
} catch (error) {
console.error(error);
);
const temData = await response.json();
if (temData.ret === -1) {
Toast.show({
content: temData.msg,
});
return;
}
};
const getSuperfanshipData = async () => {
try {
const base = webviewBaseRequest();
const body = {
zid: parseInt(params.zid),
product_id: "h5_zone_superfanship",
...base,
};
const signature = generateSignature(body);
const response = await fetch(
`/api/zone/get_cashier?signature=${signature}`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(body),
}
);
const temData = await response.json();
console.log(temData, JSON.stringify(body));
if (temData.ret === -1) return;
setSuperfanshipData(temData.data);
} catch (error) {
console.error(error);
}
};
setData(temData.data);
setIsFetching(false);
} catch (error) {
console.error(error);
}
};
//
const getSuperfanshipData = async () => {
try {
const base = webviewBaseRequest();
const body = {
zid: parseInt(params.zid),
product_id: "h5_zone_superfanship",
...base,
};
const signature = generateSignature(body);
const response = await fetch(
`/api/zone/get_cashier?signature=${signature}`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(body),
}
);
const temData = await response.json();
if (temData.ret === -1) return;
setSuperfanshipData(temData.data);
} catch (error) {
console.error(error);
}
};
//
useEffect(() => {
setTimeout(() => {
getData();
getSuperfanshipData();
}, 500);
const intervalId = setInterval(() => {
getData();
getSuperfanshipData();
}, 2000);
return () => clearInterval(intervalId);
}, []);
//switch