Showing
1 changed file
with
11 additions
and
2 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2024-01-16 10:06:47 | 2 | * @Date: 2024-01-16 10:06:47 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2026-01-07 20:54:13 | 4 | + * @LastEditTime: 2026-01-07 21:25:49 |
| 5 | * @FilePath: /xyxBooking-weapp/src/components/qrCode.vue | 5 | * @FilePath: /xyxBooking-weapp/src/components/qrCode.vue |
| 6 | * @Description: 预约码卡组件 | 6 | * @Description: 预约码卡组件 |
| 7 | --> | 7 | --> |
| ... | @@ -169,7 +169,12 @@ const formatGroup = (data) => { | ... | @@ -169,7 +169,12 @@ const formatGroup = (data) => { |
| 169 | const init = async () => { | 169 | const init = async () => { |
| 170 | if (!props.type) { | 170 | if (!props.type) { |
| 171 | try { | 171 | try { |
| 172 | - const { code, data } = await qrcodeListAPI(); | 172 | + // TAG: 设置 5s 超时判定为弱网 |
| 173 | + const timeoutPromise = new Promise((_, reject) => { | ||
| 174 | + setTimeout(() => reject(new Error('TIMEOUT')), 5000); | ||
| 175 | + }); | ||
| 176 | + | ||
| 177 | + const { code, data } = await Promise.race([qrcodeListAPI(), timeoutPromise]); | ||
| 173 | 178 | ||
| 174 | if (code) { | 179 | if (code) { |
| 175 | data.forEach(item => { | 180 | data.forEach(item => { |
| ... | @@ -193,6 +198,10 @@ const init = async () => { | ... | @@ -193,6 +198,10 @@ const init = async () => { |
| 193 | } | 198 | } |
| 194 | } catch (err) { | 199 | } catch (err) { |
| 195 | console.error('Fetch QR List Failed:', err); | 200 | console.error('Fetch QR List Failed:', err); |
| 201 | + // 如果是超时,跳转弱网页面 | ||
| 202 | + if (err.message === 'TIMEOUT') { | ||
| 203 | + go('/pages/weakNetwork/index'); | ||
| 204 | + } | ||
| 196 | } | 205 | } |
| 197 | } else { | 206 | } else { |
| 198 | if (props.payId) { | 207 | if (props.payId) { | ... | ... |
-
Please register or login to post a comment