|
@@ -2,7 +2,9 @@
|
|
|
import btHelper from './devices/bt_helper';
|
|
|
import mqtt from './utils/mqtt';
|
|
|
//连接的服务器域名
|
|
|
-const host = 'wxs://mqtt.test.radio1964.com';
|
|
|
+// const host = 'wxs://mqtt.test.radio1964.com';
|
|
|
+const host = 'wxs://mqtt.ssl.keepradioon.net:8884'
|
|
|
+
|
|
|
// const host = 'wxs://mqtt.test.radio1964.com:8884';
|
|
|
// const host = 'wxs://mqtt.ssl.keepradioon.net:8884'
|
|
|
App({
|
|
@@ -216,14 +218,46 @@ App({
|
|
|
// 获取蓝牙权限
|
|
|
getBluetoothStatus() {
|
|
|
const _this = this;
|
|
|
- btHelper.initBluetooth((adpter, hasPermission) => {
|
|
|
- console.log("蓝牙权限", adpter, hasPermission);
|
|
|
- _this.globalData.scopeBluetooth = hasPermission;
|
|
|
- if (getCurrentPages()[getCurrentPages().length - 1].getBluetoothStatusCallck) {
|
|
|
- getCurrentPages()[getCurrentPages().length - 1].getBluetoothStatusCallck(_this.globalData.scopeBluetooth);
|
|
|
+ wx.getSetting({
|
|
|
+ success(res) {
|
|
|
+ if (res.authSetting["scope.bluetooth"]) {
|
|
|
+ _this.globalData.scopeBluetooth = true;
|
|
|
+ } else if (res.authSetting["scope.bluetooth"] === undefined) {
|
|
|
+ _this.globalData.scopeBluetooth = false;
|
|
|
+ wx.authorize({
|
|
|
+ scope: "scope.bluetooth",
|
|
|
+ complete() {
|
|
|
+ _this.getBluetoothStatus();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ _this.globalData.scopeBluetooth = false;
|
|
|
+ wx.showModal({
|
|
|
+ title: '请打开系统蓝牙进行配网',
|
|
|
+ content: '如已打开蓝牙仍然弹框,请尝试重启小程序',
|
|
|
+ success(res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ console.log('用户点击确定')
|
|
|
+ wx.openSetting({
|
|
|
+ complete() {
|
|
|
+ // _this.getBluetoothStatus();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else if (res.cancel) {
|
|
|
+ console.log('用户点击取消')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ };
|
|
|
+ if (getCurrentPages()[getCurrentPages().length - 1].getBluetoothStatusCallck) {
|
|
|
+ getCurrentPages()[getCurrentPages().length - 1].getBluetoothStatusCallck(_this.globalData.scopeBluetooth);
|
|
|
+ }
|
|
|
+ // res.authSetting = {
|
|
|
+ // "scope.userInfo": true,
|
|
|
+ // "scope.userLocation": true
|
|
|
+ // }
|
|
|
}
|
|
|
- });
|
|
|
-
|
|
|
+ })
|
|
|
},
|
|
|
})
|
|
|
|