Kaynağa Gözat

Merge branch '2025北京诚祥-家政版' of https://gogs.mtavip.com/wangguoyu/uniProject into 2025北京诚祥-家政版

tanxue 3 hafta önce
ebeveyn
işleme
c52e7763e7

+ 4 - 0
components/zhuapaiConfirm/zhuapai.vue

@@ -409,6 +409,10 @@
       clearTimeout(timer1);
       timer1 = null;
     }
+    if (stopTimer.value) {
+      clearTimeout(stopTimer.value);
+      stopTimer.value = null;
+    }
   })
 
 	defineExpose({

+ 21 - 9
pages/client/Kaoshi/exam.vue

@@ -145,25 +145,37 @@
 		init: qiepingInit
 	} = useQiePing();
 
-  function debounce(func, wait) {
-    let timeout;
-    return function (...args) {
+  function onceImmediate(func, coolDownTime) {
+    let canRun = true; // 状态标志:是否允许执行函数
+    let timeoutId = null;
+
+    return function(...args) {
       const context = this;
-      clearTimeout(timeout);
-      timeout = setTimeout(() => {
+
+      // 如果允许执行
+      if (canRun) {
+        // 立即执行一次
         func.apply(context, args);
-      }, wait);
+        // 立即将状态设置为“不可执行”
+        canRun = false;
+
+        // 设置一个定时器,在冷却时间结束后重置状态
+        timeoutId = setTimeout(() => {
+          canRun = true;
+          timeoutId = null; // 清除定时器ID引用
+        }, coolDownTime);
+      }
+      // 如果不允许执行,则什么也不做,忽略此次调用
     };
   }
-  const handleBack = debounce(() => {
-    console.log('back')
+  const handleBack = onceImmediate(() => {
     const pages = getCurrentPages();
     if (pages.length > 1) {
       uni.navigateBack()
     } else {
       history.back();
     }
-  },1000)
+  },8000)
 
 	onLoad((option) => {
 		data.ksId = option.ksId;