Browse Source

pref: update wx.authorize

wangyuan 2 years ago
parent
commit
c3880afeac
2 changed files with 18 additions and 4 deletions
  1. 3 0
      pages/login/login.js
  2. 15 4
      pages/permissions/permissions.js

+ 3 - 0
pages/login/login.js

@@ -36,6 +36,7 @@ Page({
           workerLogin({code: res.code}).then(res => {
             // 登录成功 进入首页 如果绑定过设备 直接进入到用户档案扫码
             wx.hideLoading()
+            wx.vibrateShort()
             that.setAppGlobalData(res.data)
             const device = res.data.device
             if (device !== null) {
@@ -138,6 +139,7 @@ Page({
             }
           })
         } else { // 已经绑定过微信
+          wx.vibrateShort()
           if (device !== null) {
             wx.redirectTo({
               url: '/pages/workbench/workbench?form=login&deviceName=' + device.deviceName
@@ -169,6 +171,7 @@ Page({
           })
           bindWecaht({code: res.code}).then(res => {
             wx.hideLoading()
+            wx.vibrateShort()
             wx.showToast({
               title: '绑定成功',
               icon: 'success'

+ 15 - 4
pages/permissions/permissions.js

@@ -8,7 +8,8 @@ Page({
    */
   data: {
     scanFlag: true,
-    scanTimer: null
+    scanTimer: null,
+    reloadPage: false
   },
 
   /**
@@ -30,9 +31,15 @@ Page({
         } 
       })
     } else {
-      this.setData({
-        scanFlag: true
-      })
+      if (this.data.reloadPage) {
+        wx.redirectTo({
+          url: '/pages/login/login'
+        })
+      } else {
+        this.setData({
+          scanFlag: true
+        })
+      }
     }
   },
 
@@ -130,6 +137,7 @@ Page({
   },
 
   bindscanerror () {
+    var that = this
     wx.showModal({
       content: '请打开相机权限',
       confirmColor: '#333',
@@ -139,6 +147,9 @@ Page({
           wx.openSetting({
             success (res) {
               console.log(res.authSetting)
+              that.setData({
+                reloadPage: true
+              })
             }
           })
         }