修复扫码功能重复触发问题
This commit is contained in:
parent
7c23a3f002
commit
ee0d5f202e
@ -76,12 +76,10 @@ const getListData = async () => {
|
|||||||
// 发送请求
|
// 发送请求
|
||||||
try {
|
try {
|
||||||
const data = await getListAPIWX(queryParams)
|
const data = await getListAPIWX(queryParams)
|
||||||
isLoading.value = false
|
|
||||||
|
|
||||||
if (data.data!=null){
|
if (data.data!=null){
|
||||||
uni.showToast({ title: data.data, icon: 'none' })
|
uni.showToast({ title: data.data, icon: 'none' })
|
||||||
isScan.value=true;
|
|
||||||
//等待三秒再次打开扫码窗口
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
handleScan()
|
handleScan()
|
||||||
}, delay.value * 1000);
|
}, delay.value * 1000);
|
||||||
@ -159,18 +157,22 @@ const viewClick = async (item) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
const handleScan = async() => {
|
const handleScan = async() => {
|
||||||
|
if (isScan.value) return
|
||||||
|
isScan.value = true
|
||||||
uni.scanCode({
|
uni.scanCode({
|
||||||
success: async(res) => {
|
success: async(res) => {
|
||||||
isFromScan.value = true
|
isFromScan.value = true
|
||||||
searchVal.value = res.result
|
searchVal.value = res.result
|
||||||
await handleSearch({ inputValue: res.result })
|
await handleSearch({ inputValue: res.result })
|
||||||
isFromScan.value = false
|
isFromScan.value = false
|
||||||
if (isScan.value){
|
|
||||||
handleScan()
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
fail: () => {
|
fail: () => {
|
||||||
uni.showToast({ title: '扫码失败或用户取消扫码', icon: 'none' })
|
uni.showToast({ title: '扫码失败或用户取消扫码', icon: 'none' })
|
||||||
|
},
|
||||||
|
complete: () => {
|
||||||
|
setTimeout(() => {
|
||||||
|
isScan.value = false;
|
||||||
|
}, 200); // 给一点缓冲
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user