Browse Source

pref: handle clear setTimeout function

wangyuan 2 years ago
parent
commit
99ad9eed9c
2 changed files with 10 additions and 5 deletions
  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,
           showCancel: false,
           success (scanres) {
           success (scanres) {
             if (scanres.confirm) {
             if (scanres.confirm) {
-              that.setData({
-                scanFlag: true
-              })
+              var stimer = setTimeout(() => {
+                that.setData({
+                  scanFlag: true
+                })
+                clearTimeout(stimer)
+              }, 400);
             }
             }
           } 
           } 
         })
         })
@@ -104,10 +107,11 @@ Page({
         confirmText: '重新扫描',
         confirmText: '重新扫描',
         success (res) {
         success (res) {
           if (res.confirm) {
           if (res.confirm) {
-            setTimeout(() => {
+            var timer = setTimeout(() => {
               that.setData({
               that.setData({
                 scanFlag: true
                 scanFlag: true
               })
               })
+              clearTimeout(timer)
             }, 400);
             }, 400);
           }
           }
         }
         }

+ 2 - 1
pages/workbench/workbench.js

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