收银台增加轮询

This commit is contained in:
yezian 2024-04-22 21:54:06 +08:00
parent 74c5afca5d
commit b1bd9b861d
1 changed files with 69 additions and 60 deletions

View File

@ -16,7 +16,8 @@ export default function Pay({ params }) {
//
const [superfanshipData, setSuperfanshipData] = useState();
const [isFetching, setIsFetching] = useState(true);
useEffect(() => {
//
const getData = async () => {
try {
const base = webviewBaseRequest();
@ -38,7 +39,6 @@ export default function Pay({ params }) {
}
);
const temData = await response.json();
console.log(temData, JSON.stringify(body));
if (temData.ret === -1) {
Toast.show({
content: temData.msg,
@ -51,6 +51,8 @@ export default function Pay({ params }) {
console.error(error);
}
};
//
const getSuperfanshipData = async () => {
try {
const base = webviewBaseRequest();
@ -71,17 +73,24 @@ export default function Pay({ params }) {
}
);
const temData = await response.json();
console.log(temData, JSON.stringify(body));
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