Pārlūkot izejas kodu

fix:修改小程序定位权限提示问题

zeng.chen 5 mēneši atpakaļ
vecāks
revīzija
7f93c487f0
1 mainītis faili ar 14 papildinājumiem un 1 dzēšanām
  1. 14 1
      devices/ble_manager.js

+ 14 - 1
devices/ble_manager.js

@@ -316,6 +316,14 @@ class bleManager {
 
       ///做搜索蓝牙适配器权限
       const permission_util = require('../utils/permission_util');
+      // var location = await permission_util.getSetting()
+      // if (!location) {
+      //   if (boolean != null) {
+      //     boolean(false);
+      //     console.log("没有定位权限")
+      //   }
+      //   return
+      // }
       var available = await permission_util.openBluetoothAdapter();
       that.isAvailable = available;
       if (!available) {
@@ -397,9 +405,14 @@ class bleManager {
         that.compareList = [];
       },
       fail(err) {
-        console.log("开始搜索设备失败", res);
+        console.log("开始搜索设备失败", err);
         that.doStartScaning = false;
         that.requestBlueTime = time_util.getCurrentMills();
+        if (err.errMsg.indexOf("location") >= 0) {
+          wx.showToast({
+            title: '搜索失败,请检查下手机设置的微信定位权限是否开启',
+          })
+        }
         if (boolean != null) {
           boolean(false);
         }