浏览代码

pref: handle clear setTimeout function

wangyuan 2 年之前
父节点
当前提交
99ad9eed9c
共有 2 个文件被更改,包括 10 次插入5 次删除
  1. 8 4
      pages/permissions/permissions.js
  2. 2 1
      pages/workbench/workbench.js

+ 8 - 4
pages/permissions/permissions.js

@@ -47,9 +47,12 @@ Page({
           showCancel: false,
           success (scanres) {
             if (scanres.confirm) {
-              that.setData({
-                scanFlag: true
-              })
+              var stimer = setTimeout(() => {
+                that.setData({
+                  scanFlag: true
+                })
+                clearTimeout(stimer)
+              }, 400);
             }
           } 
         })
@@ -104,10 +107,11 @@ Page({
         confirmText: '重新扫描',
         success (res) {
           if (res.confirm) {
-            setTimeout(() => {
+            var timer = setTimeout(() => {
               that.setData({
                 scanFlag: true
               })
+              clearTimeout(timer)
             }, 400);
           }
         }

+ 2 - 1
pages/workbench/workbench.js

@@ -148,10 +148,11 @@ Page({
         confirmText: '重新扫描',
         success (res) {
           if (res.confirm) {
-            setTimeout(() => {
+            var timer = setTimeout(() => {
               that.setData({
                 scanFlag: true
               })
+              clearTimeout(timer)
             }, 400);
           }
         }