Showing
1 changed file
with
29 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: 2024-01-19 19:15:34 | 4 | + * @LastEditTime: 2024-01-22 12:23:30 |
| 5 | * @FilePath: /xysBooking/src/components/qrCode.vue | 5 | * @FilePath: /xysBooking/src/components/qrCode.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -87,6 +87,14 @@ const nextCode = () => { | ... | @@ -87,6 +87,14 @@ const nextCode = () => { |
| 87 | } | 87 | } |
| 88 | }; | 88 | }; |
| 89 | 89 | ||
| 90 | +watch( | ||
| 91 | + () => select_index.value, | ||
| 92 | + (index) => { | ||
| 93 | + // 监听用户选择变化时,刷新二维码 | ||
| 94 | + refreshBtn(); | ||
| 95 | + } | ||
| 96 | +) | ||
| 97 | + | ||
| 90 | /** | 98 | /** |
| 91 | * 生成15位身份证号中间8位替换为*号 | 99 | * 生成15位身份证号中间8位替换为*号 |
| 92 | * @param {*} inputString | 100 | * @param {*} inputString |
| ... | @@ -185,7 +193,26 @@ onMounted(async () => { | ... | @@ -185,7 +193,26 @@ onMounted(async () => { |
| 185 | userList.value = data; | 193 | userList.value = data; |
| 186 | } | 194 | } |
| 187 | } | 195 | } |
| 188 | -}) | 196 | +}); |
| 197 | + | ||
| 198 | +// 定义轮询函数 | ||
| 199 | +const poll = async () => { | ||
| 200 | + // 二维码未使用不停轮询接口 | ||
| 201 | + if (useStatus.value !== '7') { | ||
| 202 | + const { code, data } = await qrcodeStatusAPI({ qr_code: userList.value[select_index.value].qr_code }); | ||
| 203 | + if (code) { | ||
| 204 | + useStatus.value = data.status; | ||
| 205 | + } | ||
| 206 | + } | ||
| 207 | +}; | ||
| 208 | + | ||
| 209 | +// 每秒执行一次轮询函数 | ||
| 210 | +const intervalId = setInterval(poll, 1000); | ||
| 211 | + | ||
| 212 | +// 在组件卸载时清除定时器 | ||
| 213 | +onUnmounted(() => { | ||
| 214 | + clearInterval(intervalId); | ||
| 215 | +}); | ||
| 189 | </script> | 216 | </script> |
| 190 | 217 | ||
| 191 | <style lang="less" scoped> | 218 | <style lang="less" scoped> | ... | ... |
-
Please register or login to post a comment