diff --git a/pages/index/index.vue b/pages/index/index.vue
index 8956175..597c99c 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -267,7 +267,7 @@
-
+
@@ -343,11 +343,23 @@
},
onShow() {
+ wx.openBluetoothAdapter({
+ success: function (res) {
+ console.log('蓝牙适配器初始化成功');
+ },
+ fail: function (err) {
+ console.error('蓝牙适配器初始化失败,可能是因为没有权限', err);
+ uni.showToast({
+ title: '蓝牙适配器初始化失败,可能是因为没有权限',
+ icon: 'none',
+ duration:2000
+ })
+ }
+ })
// 请求个人信息
this.getinfo()
// 一进来每分钟发一次上传信息命令
this.getshuju()
-
},
methods: {
// 点击进行设备录入
@@ -401,7 +413,6 @@
this.getshebxq()
setTimeout(()=>{
uni.hideLoading()
-
if(this.datalist == ''){
let that = this
uni.showModal({
@@ -924,6 +935,30 @@
}
})
},
+ // 一开始提示是否连接
+ getlianjie(){
+ if(this.datalist == ''){
+ let that = this
+ uni.showModal({
+ title: '提示',
+ content: '设备未连接,是否进行设备连接?',
+ success: function (res) {
+ if (res.confirm) {
+ uni.hideLoading()
+ that.btnlj()
+ } else if (res.cancel) {
+ uni.hideLoading()
+ uni.showToast({
+ title: '已取消连接',
+ icon: 'none',
+ duration:2000
+ })
+ }
+ }
+ })
+ }
+ },
+
// 获取设备列表
getlist(){
this.$u.get(`/app/getDeviceInfoByUser?userId=${this.userobj.userId}`).then((res) => {
@@ -934,26 +969,21 @@
this.mac = res.data[0].mac
this.user = res.data[0]
this.shebid = res.data[0].deviceId
- if(this.datalist == ''){
- let that = this
- uni.showModal({
- title: '提示',
- content: '设备未连接,是否进行设备连接?',
- success: function (res) {
- if (res.confirm) {
- uni.hideLoading()
- that.btnlj()
- } else if (res.cancel) {
- uni.hideLoading()
- uni.showToast({
- title: '已取消连接',
- icon: 'none',
- duration:2000
- })
- }
- }
+ let that = this
+ wx.openBluetoothAdapter({
+ success: function (res) {
+ console.log('蓝牙适配器初始化成功');
+ that.getlianjie()
+ },
+ fail: function (err) {
+ console.error('蓝牙适配器初始化失败,可能是因为没有权限', err);
+ uni.showToast({
+ title: '蓝牙适配器初始化失败,可能是因为没有权限',
+ icon: 'none',
+ duration:2000
})
- }
+ }
+ })
}else{
this.bjflag = true
}
@@ -981,17 +1011,7 @@
if (!options.result) {
this.datalist = ''
this.ver_data = ''
- // uni.showModal({
- // title: '很抱歉提醒你!',
- // content: '小程序与设备异常断开',
- // showCancel: false,
- // //是否显示取消按钮
- // success: function(res) {
- // uni.hideLoading()
- // this.datalist = ''
- // this.ver_data = ''
- // }
- // })
+
}
break;
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS: