hookehuyr

fix: 添加弱网超时处理并跳转弱网页面

在初始化二维码列表时添加5秒超时判定,超时后跳转至弱网页面
<!--
* @Date: 2024-01-16 10:06:47
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2026-01-07 20:54:13
* @LastEditTime: 2026-01-07 21:25:49
* @FilePath: /xyxBooking-weapp/src/components/qrCode.vue
* @Description: 预约码卡组件
-->
......@@ -169,7 +169,12 @@ const formatGroup = (data) => {
const init = async () => {
if (!props.type) {
try {
const { code, data } = await qrcodeListAPI();
// TAG: 设置 5s 超时判定为弱网
const timeoutPromise = new Promise((_, reject) => {
setTimeout(() => reject(new Error('TIMEOUT')), 5000);
});
const { code, data } = await Promise.race([qrcodeListAPI(), timeoutPromise]);
if (code) {
data.forEach(item => {
......@@ -193,6 +198,10 @@ const init = async () => {
}
} catch (err) {
console.error('Fetch QR List Failed:', err);
// 如果是超时,跳转弱网页面
if (err.message === 'TIMEOUT') {
go('/pages/weakNetwork/index');
}
}
} else {
if (props.payId) {
......