hookehuyr

预约码需要轮询使用状态

<!--
* @Date: 2024-01-16 10:06:47
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-01-19 19:15:34
* @LastEditTime: 2024-01-22 12:23:30
* @FilePath: /xysBooking/src/components/qrCode.vue
* @Description: 文件描述
-->
......@@ -87,6 +87,14 @@ const nextCode = () => {
}
};
watch(
() => select_index.value,
(index) => {
// 监听用户选择变化时,刷新二维码
refreshBtn();
}
)
/**
* 生成15位身份证号中间8位替换为*号
* @param {*} inputString
......@@ -185,7 +193,26 @@ onMounted(async () => {
userList.value = data;
}
}
})
});
// 定义轮询函数
const poll = async () => {
// 二维码未使用不停轮询接口
if (useStatus.value !== '7') {
const { code, data } = await qrcodeStatusAPI({ qr_code: userList.value[select_index.value].qr_code });
if (code) {
useStatus.value = data.status;
}
}
};
// 每秒执行一次轮询函数
const intervalId = setInterval(poll, 1000);
// 在组件卸载时清除定时器
onUnmounted(() => {
clearInterval(intervalId);
});
</script>
<style lang="less" scoped>
......