优化开关蓝牙连接
This commit is contained in:
parent
fc0cfeb1b7
commit
b0f9987eac
|
@ -19,7 +19,7 @@ const install = (Vue, vm) => {
|
|||
// },
|
||||
// });
|
||||
Vue.prototype.$u.http.setConfig({
|
||||
// baseUrl: 'http://192.168.2.12:10002',
|
||||
// baseUrl: 'http://192.168.2.27:10002',
|
||||
baseUrl: 'https://kg.chuangtewl.com/prod-api',
|
||||
// loadingText: '加载中...',
|
||||
// loadingTime: 1000,
|
||||
|
|
|
@ -142,6 +142,9 @@
|
|||
this.sn = option.sn
|
||||
},
|
||||
onShow() {
|
||||
if(uni.getStorageSync('lianjie')){
|
||||
this.id = uni.getStorageSync('lianjie')
|
||||
}
|
||||
this.wateringList = []
|
||||
this.setMode == null
|
||||
this.taocan = ''
|
||||
|
@ -151,6 +154,9 @@
|
|||
},
|
||||
onUnload: function() {
|
||||
console.log("unload ");
|
||||
// uni.removeStorage({
|
||||
// key: 'lianjie'
|
||||
// })
|
||||
xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent);
|
||||
wx.closeBLEConnection({
|
||||
deviceId: this.deviceId,
|
||||
|
@ -290,135 +296,150 @@
|
|||
},
|
||||
// 点击wifi进行配网
|
||||
btnwifi() {
|
||||
this.shibaiflag = false
|
||||
this.bluetoothflag = true
|
||||
// console.log(this.deviceId,'idididididdidii');
|
||||
if (this.setMode == null) {
|
||||
xBlufi.initXBlufi(1)
|
||||
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': true
|
||||
uni.setStorageSync('lianjie',this.id)
|
||||
let systemInfo = uni.getSystemInfoSync()
|
||||
if (systemInfo.platform == 'android') {
|
||||
// 当前设备是 Android
|
||||
uni.navigateTo({
|
||||
url: '/page_components/wifilist/index?deviceId=' + this
|
||||
.qrResult + '&name=' + this.name
|
||||
})
|
||||
|
||||
// 停止蓝牙搜索
|
||||
setTimeout(() => {
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': false
|
||||
})
|
||||
xBlufi.notifyConnectBle({
|
||||
isStart: true,
|
||||
deviceId: this.deviceId,
|
||||
name: this.name
|
||||
})
|
||||
xBlufi.notifyInitBleEsp32({
|
||||
deviceId: this.deviceId
|
||||
})
|
||||
let name = ''
|
||||
let index = this.name.indexOf('-')
|
||||
if (index !== -1) {
|
||||
name = this.name.slice(index + 1)
|
||||
}
|
||||
let data = {
|
||||
storeId: this.storeId,
|
||||
mac: this.mac
|
||||
}
|
||||
this.$u.put('/app/device/bind', data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
uni.hideLoading();
|
||||
this.shibaiflag = false
|
||||
this.bluetoothflag = false
|
||||
uni.removeStorageSync('mac');
|
||||
let systemInfo = uni.getSystemInfoSync()
|
||||
if (systemInfo.platform == 'android') {
|
||||
// 当前设备是 Android
|
||||
uni.navigateTo({
|
||||
url: '/page_components/wifilist/index?deviceId=' + this
|
||||
.deviceId + '&name=' + this.name
|
||||
})
|
||||
} else if (systemInfo.platform == 'ios') {
|
||||
// 当前设备是 iOS
|
||||
uni.navigateTo({
|
||||
url: '/page_fenbao/device/wifivideo?deviceId=' + this
|
||||
.deviceId + '&name=' + this.name
|
||||
})
|
||||
}
|
||||
} else if (res.msg == '设备编号和mac不能同时为空') {
|
||||
this.shibaiflag = true
|
||||
this.bluetoothflag = false
|
||||
// uni.showToast({
|
||||
// title: '连接失败',
|
||||
// icon: 'none',
|
||||
// duration: 2000
|
||||
// });
|
||||
} else {
|
||||
// uni.showToast({
|
||||
// title: res.msg,
|
||||
// icon: 'none',
|
||||
// duration: 2000
|
||||
// });
|
||||
// uni.navigateBack()
|
||||
}
|
||||
})
|
||||
}, 1000)
|
||||
} else {
|
||||
let name = ''
|
||||
let index = this.name.indexOf('-')
|
||||
if (index !== -1) {
|
||||
name = this.name.slice(index + 1)
|
||||
}
|
||||
let data = {
|
||||
storeId: this.storeId,
|
||||
mac: this.mac
|
||||
}
|
||||
this.$u.put('/app/device/bind', data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
// uni.showToast({
|
||||
// title: '绑定成功',
|
||||
// icon: 'none',
|
||||
// duration: 2000
|
||||
// })
|
||||
this.shibaiflag = false
|
||||
this.bluetoothflag = false
|
||||
uni.hideLoading();
|
||||
uni.removeStorageSync('mac');
|
||||
let systemInfo = uni.getSystemInfoSync()
|
||||
if (systemInfo.platform == 'android') {
|
||||
// 当前设备是 Android
|
||||
uni.navigateTo({
|
||||
url: '/page_components/wifilist/index?deviceId=' + this.deviceId +
|
||||
'&name=' + this.name
|
||||
})
|
||||
} else if (systemInfo.platform == 'ios') {
|
||||
// 当前设备是 iOS
|
||||
uni.navigateTo({
|
||||
url: '/page_fenbao/device/wifivideo?deviceId=' + this.deviceId +
|
||||
'&name=' + this.name
|
||||
})
|
||||
}
|
||||
} else {
|
||||
if (res.msg == '设备编号和mac不能同时为空') {
|
||||
this.shibaiflag = true
|
||||
this.bluetoothflag = false
|
||||
uni.hideLoading()
|
||||
// uni.showToast({
|
||||
// title: '连接失败',
|
||||
// icon: 'none',
|
||||
// duration: 2000
|
||||
// })
|
||||
} else {
|
||||
this.shibaiflag = true
|
||||
this.bluetoothflag = false
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
// uni.navigateBack()
|
||||
}
|
||||
}
|
||||
} else if (systemInfo.platform == 'ios') {
|
||||
// 当前设备是 iOS
|
||||
uni.navigateTo({
|
||||
url: '/page_fenbao/device/wifivideo?deviceId=' + this
|
||||
.qrResult + '&name=' + this.name
|
||||
})
|
||||
}
|
||||
// this.shibaiflag = false
|
||||
// this.bluetoothflag = true
|
||||
// // console.log(this.deviceId,'idididididdidii');
|
||||
// if (this.setMode == null) {
|
||||
// xBlufi.initXBlufi(1)
|
||||
// xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
|
||||
// xBlufi.notifyStartDiscoverBle({
|
||||
// 'isStart': true
|
||||
// })
|
||||
|
||||
// // 停止蓝牙搜索
|
||||
// setTimeout(() => {
|
||||
// xBlufi.notifyStartDiscoverBle({
|
||||
// 'isStart': false
|
||||
// })
|
||||
// xBlufi.notifyConnectBle({
|
||||
// isStart: true,
|
||||
// deviceId: this.deviceId,
|
||||
// name: this.name
|
||||
// })
|
||||
// xBlufi.notifyInitBleEsp32({
|
||||
// deviceId: this.deviceId
|
||||
// })
|
||||
// let name = ''
|
||||
// let index = this.name.indexOf('-')
|
||||
// if (index !== -1) {
|
||||
// name = this.name.slice(index + 1)
|
||||
// }
|
||||
// let data = {
|
||||
// storeId: this.storeId,
|
||||
// mac: this.mac
|
||||
// }
|
||||
// this.$u.put('/app/device/bind', data).then((res) => {
|
||||
// if (res.code == 200) {
|
||||
// uni.hideLoading();
|
||||
// this.shibaiflag = false
|
||||
// this.bluetoothflag = false
|
||||
// uni.removeStorageSync('mac');
|
||||
// let systemInfo = uni.getSystemInfoSync()
|
||||
// if (systemInfo.platform == 'android') {
|
||||
// // 当前设备是 Android
|
||||
// uni.navigateTo({
|
||||
// url: '/page_components/wifilist/index?deviceId=' + this
|
||||
// .deviceId + '&name=' + this.name
|
||||
// })
|
||||
// } else if (systemInfo.platform == 'ios') {
|
||||
// // 当前设备是 iOS
|
||||
// uni.navigateTo({
|
||||
// url: '/page_fenbao/device/wifivideo?deviceId=' + this
|
||||
// .deviceId + '&name=' + this.name
|
||||
// })
|
||||
// }
|
||||
// } else if (res.msg == '设备编号和mac不能同时为空') {
|
||||
// this.shibaiflag = true
|
||||
// this.bluetoothflag = false
|
||||
// // uni.showToast({
|
||||
// // title: '连接失败',
|
||||
// // icon: 'none',
|
||||
// // duration: 2000
|
||||
// // });
|
||||
// } else {
|
||||
// // uni.showToast({
|
||||
// // title: res.msg,
|
||||
// // icon: 'none',
|
||||
// // duration: 2000
|
||||
// // });
|
||||
// // uni.navigateBack()
|
||||
// }
|
||||
// })
|
||||
// }, 1000)
|
||||
// } else {
|
||||
// let name = ''
|
||||
// let index = this.name.indexOf('-')
|
||||
// if (index !== -1) {
|
||||
// name = this.name.slice(index + 1)
|
||||
// }
|
||||
// let data = {
|
||||
// storeId: this.storeId,
|
||||
// mac: this.mac
|
||||
// }
|
||||
// this.$u.put('/app/device/bind', data).then((res) => {
|
||||
// if (res.code == 200) {
|
||||
// // uni.showToast({
|
||||
// // title: '绑定成功',
|
||||
// // icon: 'none',
|
||||
// // duration: 2000
|
||||
// // })
|
||||
// this.shibaiflag = false
|
||||
// this.bluetoothflag = false
|
||||
// uni.hideLoading();
|
||||
// uni.removeStorageSync('mac');
|
||||
// let systemInfo = uni.getSystemInfoSync()
|
||||
// if (systemInfo.platform == 'android') {
|
||||
// // 当前设备是 Android
|
||||
// uni.navigateTo({
|
||||
// url: '/page_components/wifilist/index?deviceId=' + this.deviceId +
|
||||
// '&name=' + this.name
|
||||
// })
|
||||
// } else if (systemInfo.platform == 'ios') {
|
||||
// // 当前设备是 iOS
|
||||
// uni.navigateTo({
|
||||
// url: '/page_fenbao/device/wifivideo?deviceId=' + this.deviceId +
|
||||
// '&name=' + this.name
|
||||
// })
|
||||
// }
|
||||
// } else {
|
||||
// if (res.msg == '设备编号和mac不能同时为空') {
|
||||
// this.shibaiflag = true
|
||||
// this.bluetoothflag = false
|
||||
// uni.hideLoading()
|
||||
// // uni.showToast({
|
||||
// // title: '连接失败',
|
||||
// // icon: 'none',
|
||||
// // duration: 2000
|
||||
// // })
|
||||
// } else {
|
||||
// this.shibaiflag = true
|
||||
// this.bluetoothflag = false
|
||||
// uni.hideLoading()
|
||||
// uni.showToast({
|
||||
// title: res.msg,
|
||||
// icon: 'none',
|
||||
// duration: 2000
|
||||
// })
|
||||
// // uni.navigateBack()
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
},
|
||||
|
||||
sremakes() {
|
||||
|
|
|
@ -244,6 +244,7 @@
|
|||
},
|
||||
onShow() {
|
||||
// this.getuserinfo()
|
||||
this.swindleflag = true
|
||||
this.getzfqd()
|
||||
setTimeout(()=>{
|
||||
if (this.id != '') {
|
||||
|
@ -292,6 +293,7 @@
|
|||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '该设备暂无套餐,是否前去配置?',
|
||||
showCancel: false,
|
||||
success: function(res) {
|
||||
if (res.confirm) {
|
||||
uni.setStorageSync('tcidlist', that.arrlists)
|
||||
|
@ -307,7 +309,7 @@
|
|||
uni.showToast({
|
||||
title:'该设备暂无套餐,请联系商家添加套餐在使用',
|
||||
icon: 'none',
|
||||
duration:2000
|
||||
duration:5000
|
||||
})
|
||||
}
|
||||
},
|
||||
|
@ -458,7 +460,7 @@
|
|||
this.zfobj = res.data.suitList[0]
|
||||
let targetDateStr = this.deviceobj.expireTime
|
||||
this.mchShowBillMobile = res.data.mchShowBillMobile
|
||||
if(this.mchShowBillMobile == true && this.phonenumber == ''){
|
||||
if(this.phonenumber == '' || this.phonenumber == null){
|
||||
this.telslag = true
|
||||
}else{
|
||||
this.telslag = false
|
||||
|
@ -508,8 +510,9 @@
|
|||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
}else if(this.mchShowBillMobile == true && this.phonenumber == ''){
|
||||
this.getPhoneNumber()
|
||||
}else if(this.phonenumber == '' || this.phonenumber == null){
|
||||
// this.getPhoneNumber()
|
||||
this.telslag = true
|
||||
}else {
|
||||
// this.zhifuflag = true
|
||||
this.getzhifu()
|
||||
|
@ -517,9 +520,10 @@
|
|||
},
|
||||
// 获取手机号
|
||||
getPhoneNumber(e){
|
||||
console.log(e);
|
||||
this.$u.put(`/app/user/bindWxMobile?mobileCode=${e.detail.code}`).then(res =>{
|
||||
if(res.code == 200){
|
||||
this.zhifuflag = true
|
||||
this.zhifuflag = false
|
||||
this.getzhifu()
|
||||
}else{
|
||||
uni.showToast({
|
||||
|
|
|
@ -190,7 +190,7 @@
|
|||
</view>
|
||||
</view>
|
||||
</view> -->
|
||||
|
||||
<view class="mask" v-if="ljljflag"></view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
@ -241,6 +241,9 @@
|
|||
|
||||
currentIndex: 0, // 控制当前应该显示到哪个点
|
||||
dotShowInterval: null,
|
||||
devicesList:[],
|
||||
ver_data:'',
|
||||
ljljflag:true
|
||||
};
|
||||
},
|
||||
|
||||
|
@ -302,13 +305,35 @@
|
|||
},
|
||||
onLoad: function(option) {
|
||||
// 传过来的蓝牙信息
|
||||
this.Binddevice()
|
||||
this.objlist = option
|
||||
|
||||
setTimeout(() =>{
|
||||
if(this.ver_data == ''){
|
||||
uni.showModal({
|
||||
title: '温馨提示',
|
||||
content: '蓝牙连接失败,请重新操作',
|
||||
showCancel: false,
|
||||
success: function(res) {
|
||||
this.ljljflag = false
|
||||
uni.reLaunch({
|
||||
url:'/pages/index/index'
|
||||
})
|
||||
}
|
||||
})
|
||||
}else{
|
||||
console.log('32751212');
|
||||
}
|
||||
},15000)
|
||||
// 接受蓝牙信息
|
||||
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent);
|
||||
xBlufi.notifyInitBleEsp32({
|
||||
deviceId: this.objlist.deviceId
|
||||
})
|
||||
// xBlufi.initXBlufi(1)
|
||||
// xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
|
||||
// xBlufi.notifyStartDiscoverBle({
|
||||
// 'isStart': true
|
||||
// })
|
||||
// xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent);
|
||||
// xBlufi.notifyInitBleEsp32({
|
||||
// deviceId: this.objlist.deviceId
|
||||
// })
|
||||
|
||||
var that = this
|
||||
wx.startWifi({
|
||||
|
@ -375,6 +400,7 @@
|
|||
},
|
||||
onUnload: function() {
|
||||
console.log("unload返回 ");
|
||||
|
||||
if (this.dotShowInterval) {
|
||||
clearInterval(this.dotShowInterval);
|
||||
}
|
||||
|
@ -389,6 +415,67 @@
|
|||
this.startDotShow()
|
||||
},
|
||||
methods: {
|
||||
Binddevice() {
|
||||
uni.showLoading({
|
||||
title: '蓝牙连接中..'
|
||||
})
|
||||
xBlufi.initXBlufi(1);
|
||||
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent);
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': true
|
||||
})
|
||||
// 两秒后停止蓝牙搜索
|
||||
setTimeout(() => {
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': false
|
||||
});
|
||||
setTimeout(() => {
|
||||
if (this.devicesList.length == 0) {
|
||||
uni.showToast({
|
||||
title: '暂无发现对应设备,请重试',
|
||||
icon: 'none'
|
||||
});
|
||||
} else {
|
||||
let uniqueDevicesList = Array.from(new Set(this.devicesList));
|
||||
this.devicesList = uniqueDevicesList;
|
||||
// console.log(this.devicesList,'this.devicesListthis.devicesList');
|
||||
this.devicesList.forEach(device => {
|
||||
let macFromName = device.name.substring(device.name.length - 12);
|
||||
console.log(macFromName, 'macFromNamemacFromName');
|
||||
// 与 this.mac 进行比较
|
||||
if (macFromName == this.objlist.deviceId) {
|
||||
// 如果相同,则将 this.ishave 设置为 true
|
||||
console.log(device);
|
||||
this.deviceInfoss = device
|
||||
this.createBLEConnection(device)
|
||||
console.log('对比正确1111111111');
|
||||
} else {
|
||||
console.log('对比错误');
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}, 200)
|
||||
}, 2000)
|
||||
},
|
||||
createBLEConnection(e) {
|
||||
console.log('调用了');
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': false
|
||||
});
|
||||
console.log(e, '蓝牙信息')
|
||||
const deviceId = e.deviceId
|
||||
this.deviceId = e.deviceId
|
||||
this.Bluetoothmac = e.localName.substring(5) //从第七位开始截取 只取后面的mac号
|
||||
console.log(this.Bluetoothmac, '11111');
|
||||
let name = e.name;
|
||||
console.log('点击了,蓝牙准备连接的deviceId:' + e.deviceId);
|
||||
xBlufi.notifyConnectBle({
|
||||
isStart: true,
|
||||
deviceId: e.deviceId,
|
||||
name
|
||||
});
|
||||
},
|
||||
// 开始旋转图片
|
||||
|
||||
// 模拟异步请求
|
||||
|
@ -513,9 +600,6 @@
|
|||
btnsd() {
|
||||
this.sdmaskflag = true
|
||||
this.ssid = ''
|
||||
// uni.navigateTo({
|
||||
// url: '/page_user/wifijoint/index?objlist=' + JSON.stringify(this.objlist) + '&ssid=' + JSON.stringify(this.ssid)
|
||||
// })
|
||||
},
|
||||
|
||||
|
||||
|
@ -547,7 +631,7 @@
|
|||
content: '配网失败,请重新操作',
|
||||
showCancel: false,
|
||||
success: function(res) {
|
||||
uni.switchTab({
|
||||
uni.reLaunch({
|
||||
url:'/pages/index/index'
|
||||
})
|
||||
}
|
||||
|
@ -580,6 +664,37 @@
|
|||
// uni.hideLoading();
|
||||
// }
|
||||
// break;
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS:
|
||||
if (options.result) {
|
||||
let devicesarr = options.data
|
||||
devicesarr.forEach(device => {
|
||||
this.devicesList.push(device);
|
||||
let uniqueDevicesList = Array.from(new Set(this.devicesList));
|
||||
// 将去重后的数组重新赋值给 this.devicesList
|
||||
this.devicesList = uniqueDevicesList;
|
||||
})
|
||||
}
|
||||
break;
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_CONNECTED:
|
||||
console.log("连接回调:" + JSON.stringify(options));
|
||||
if (options.result) {
|
||||
uni.showToast({
|
||||
title: '连接成功',
|
||||
icon: 'success',
|
||||
duration:2000
|
||||
})
|
||||
setTimeout(()=>{
|
||||
this.ljljflag = false
|
||||
uni.hideLoading();
|
||||
},1500)
|
||||
{
|
||||
xBlufi.notifyInitBleEsp32({
|
||||
deviceId: options.data.deviceId
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_CONNECT_ROUTER_RESULT:
|
||||
uni.hideLoading();
|
||||
|
@ -592,18 +707,8 @@
|
|||
content: '配网失败,请选择2.4GWiFi连接并确保密码正确',
|
||||
showCancel: false ,//是否显示取消按钮
|
||||
success:function(res) {
|
||||
let systemInfo = uni.getSystemInfoSync();
|
||||
if (systemInfo.platform == 'android') {
|
||||
// 当前设备是 Android
|
||||
uni.navigateBack()
|
||||
} else if (systemInfo.platform == 'ios') {
|
||||
// 当前设备是 iOS
|
||||
uni.navigateBack({
|
||||
delta:2
|
||||
})
|
||||
}
|
||||
wx.closeBLEConnection({
|
||||
deviceId: this.objlist.deviceId,
|
||||
uni.reLaunch({
|
||||
url:'/pages/index/index'
|
||||
})
|
||||
}
|
||||
});
|
||||
|
@ -615,23 +720,18 @@
|
|||
this.textwifi = '连接'
|
||||
uni.showModal({
|
||||
title: '温馨提示',
|
||||
content: `连接成功`,
|
||||
content: `配网成功`,
|
||||
showCancel: false,
|
||||
success: function(res) {
|
||||
uni.hideLoading()
|
||||
let systemInfo = uni.getSystemInfoSync();
|
||||
if (systemInfo.platform == 'android') {
|
||||
// 当前设备是 Android
|
||||
uni.navigateBack()
|
||||
} else if (systemInfo.platform == 'ios') {
|
||||
// 当前设备是 iOS
|
||||
uni.navigateBack({
|
||||
delta:2
|
||||
if(uni.getStorageSync('lianjie')){
|
||||
uni.reLaunch({
|
||||
url:'/page_components/bindsztwo'
|
||||
})
|
||||
}else{
|
||||
uni.reLaunch({
|
||||
url:'/pages/index/index'
|
||||
})
|
||||
}
|
||||
wx.closeBLEConnection({
|
||||
deviceId: this.objlist.deviceId,
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -650,7 +750,6 @@
|
|||
break;
|
||||
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_INIT_ESP32_RESULT:
|
||||
uni.hideLoading();
|
||||
if (options.result) {
|
||||
console.log('初始化成功');
|
||||
} else {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<view class="page">
|
||||
<u-navbar title="添加设备" :border-bottom="false" :background="bgc" title-color='#262B37' title-size='38'
|
||||
<u-navbar title="添加设备" :border-bottom="false" :background="bgc" title-color='#262B37' title-size='38' :custom-back="btnzhuce"
|
||||
height='50'></u-navbar>
|
||||
<view class="iptbox" @click="backpage()">
|
||||
|
||||
|
@ -180,6 +180,11 @@
|
|||
|
||||
},
|
||||
methods: {
|
||||
btnzhuce(){
|
||||
uni.reLaunch({
|
||||
url:'/page_fenbao/zhuce'
|
||||
})
|
||||
},
|
||||
confirm(e) {
|
||||
// console.log(e);
|
||||
this.banben = e[0].label
|
||||
|
@ -250,9 +255,9 @@
|
|||
duration: 2000
|
||||
});
|
||||
setTimeout(() => {
|
||||
uni.navigateBack({
|
||||
delta: 1 // delta值为1时表示返回的页面层数
|
||||
});
|
||||
uni.reLaunch({
|
||||
url:'/page_fenbao/zhuce'
|
||||
})
|
||||
}, 2000)
|
||||
} else {
|
||||
uni.showToast({
|
||||
|
@ -286,7 +291,7 @@
|
|||
deviceId: this.deviceId,
|
||||
})
|
||||
setTimeout(()=>{
|
||||
uni.navigateTo({
|
||||
uni.reLaunch({
|
||||
url:'/page_user/wifijoint/index?sn=' + this.storeId
|
||||
})
|
||||
},1500)
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
<view class="right">
|
||||
<image src="https://api.ccttiot.com/smartmeter/img/static/uraUDWkEx5OvJB29kMnS" mode="aspectFit"
|
||||
@click="mapFun(item)"></image>
|
||||
<text>{{String(item.distance).split('.')[0]}}m</text>
|
||||
<text>{{item.distance}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="" v-if="gxlist.length == 0" style="width: 100%;height: 200rpx;margin: auto;margin-top: 230rpx;text-align: center;">
|
||||
|
@ -225,7 +225,7 @@
|
|||
this.longitude = Number(res.longitude.toFixed(5)) + 0.005
|
||||
this.setMapScale()
|
||||
// 请求附近的店铺
|
||||
this.$u.get("/app/store/listNearBy?center=" + this.jinweidu + '&radius=' + 1000).then(
|
||||
this.$u.get("/app/store/listNearBy?center=" + this.jinweidu + '&radius=' + 20000).then(
|
||||
response => {
|
||||
if (response.code == 200) {
|
||||
this.listmap = response.data
|
||||
|
@ -297,15 +297,25 @@
|
|||
},
|
||||
// 计算距离函数
|
||||
getDistance(lat1, lon1, lat2, lon2) {
|
||||
const R = 6371000 // 地球半径,单位:米
|
||||
const phi1 = lat1 * Math.PI / 180 // 纬度转为弧度
|
||||
const phi2 = lat2 * Math.PI / 180
|
||||
const deltaPhi = (lat2 - lat1) * Math.PI / 180
|
||||
const deltaLambda = (lon2 - lon1) * Math.PI / 180
|
||||
const a = Math.sin(deltaPhi / 2) * Math.sin(deltaPhi / 2) + Math.cos(phi1) * Math.cos(phi2) * Math.sin(deltaLambda / 2) * Math.sin(deltaLambda / 2)
|
||||
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a))
|
||||
const distance = R * c
|
||||
return distance
|
||||
const R = 6371000; // 地球半径,单位:米
|
||||
const phi1 = lat1 * Math.PI / 180; // 纬度转为弧度
|
||||
const phi2 = lat2 * Math.PI / 180;
|
||||
const deltaPhi = (lat2 - lat1) * Math.PI / 180;
|
||||
const deltaLambda = (lon2 - lon1) * Math.PI / 180;
|
||||
const a = Math.sin(deltaPhi / 2) * Math.sin(deltaPhi / 2) +
|
||||
Math.cos(phi1) * Math.cos(phi2) *
|
||||
Math.sin(deltaLambda / 2) * Math.sin(deltaLambda / 2);
|
||||
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
||||
const distance = R * c;
|
||||
|
||||
// 判断距离并格式化输出
|
||||
if (distance > 1000) {
|
||||
// 大于1000米,转换为千米并保留一位小数
|
||||
return (distance / 1000).toFixed(1) + 'Km';
|
||||
} else {
|
||||
// 小于等于1000米,直接用米表示
|
||||
return Math.floor(distance) + 'm';
|
||||
}
|
||||
},
|
||||
|
||||
handleMarkerClick(event) {
|
||||
|
@ -512,6 +522,7 @@
|
|||
font-size: 20rpx;
|
||||
color: #808080;
|
||||
line-height: 28rpx;
|
||||
width: 100rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<template>
|
||||
<view class="pages">
|
||||
<u-navbar title="设备录入" :border-bottom="false" :background="bgc" title-size='38' title-color='#fff'
|
||||
back-icon-color="#fff" height='50'></u-navbar>
|
||||
back-icon-color="#fff" height='50' :custom-back="btnmy"></u-navbar>
|
||||
<view class="title">
|
||||
<text>设备录入列表</text>
|
||||
<text style="font-size: 28rpx;width: 160rpx;height: 60rpx;border-radius: 20rpx;background-color: #8883F0;text-align: center;color: #fff;line-height: 60rpx;margin-top: 20rpx;" @click="btnkzt">控制台</text>
|
||||
|
@ -112,6 +112,9 @@
|
|||
this.getxingh()
|
||||
this.storeId = option.sn
|
||||
},
|
||||
onShow() {
|
||||
this.Search()
|
||||
},
|
||||
onUnload: function() {
|
||||
console.log("unload ");
|
||||
xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent);
|
||||
|
@ -139,10 +142,15 @@
|
|||
},
|
||||
methods: {
|
||||
btnkzt(){
|
||||
uni.navigateTo({
|
||||
uni.reLaunch({
|
||||
url:'/page_user/wifijoint/index'
|
||||
})
|
||||
},
|
||||
btnmy(){
|
||||
uni.reLaunch({
|
||||
url:'/pages/my'
|
||||
})
|
||||
},
|
||||
// 扫码sn
|
||||
scanQRCode(item) {
|
||||
this.snname = item.name
|
||||
|
@ -338,7 +346,7 @@
|
|||
// 发送开关
|
||||
createBLEConnections(e) {
|
||||
let Bluetoothmac = e.name.substring(5)
|
||||
uni.navigateTo({
|
||||
uni.reLaunch({
|
||||
url:'/page_fenbao/device/joinDevice?mac='+Bluetoothmac
|
||||
})
|
||||
},
|
||||
|
|
|
@ -292,7 +292,7 @@
|
|||
this.longitude = Number(res.longitude.toFixed(5)) + 0.005
|
||||
this.setMapScale()
|
||||
// 请求附近的店铺
|
||||
this.$u.get("/app/store/listNearBy?center=" + this.jinweidu + '&radius=' + 1000).then(
|
||||
this.$u.get("/app/store/listNearBy?center=" + this.jinweidu + '&radius=' + 20000).then(
|
||||
res => {
|
||||
if (res.code == 200) {
|
||||
this.listmap = res.data
|
||||
|
|
|
@ -210,7 +210,7 @@
|
|||
</view>
|
||||
<image class="jt" src="https://api.ccttiot.com/smartmeter/img/static/ukdy921M8MNe9XDid0WI" mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="cont" @click="btnfirmware">
|
||||
<!-- <view class="cont" @click="btnfirmware">
|
||||
<view class="top" style="border: 0;">
|
||||
<image style="width: 44rpx;height: 44rpx;"
|
||||
src="https://api.ccttiot.com/smartmeter/img/static/uOUM2aclDz2ZnRxOll9g" mode="aspectFit">
|
||||
|
@ -218,7 +218,7 @@
|
|||
<view class="bot">固件更新</view>
|
||||
</view>
|
||||
<image class="jt" src="https://api.ccttiot.com/smartmeter/img/static/ukdy921M8MNe9XDid0WI" mode="aspectFit"></image>
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
</view>
|
||||
<view class="cont_box" style="padding-left: 30rpx;"></view>
|
||||
|
@ -266,7 +266,7 @@
|
|||
<view class="qx" @click="btnlyqx">
|
||||
取消
|
||||
</view>
|
||||
<view class="cx" @click="topage(5)">
|
||||
<view class="cx" @click="btnkq">
|
||||
重新连接
|
||||
</view>
|
||||
</view>
|
||||
|
@ -291,7 +291,7 @@
|
|||
<view v-if="btnmsk"
|
||||
style="width: 100%;height: 100vh;position: fixed;top: 0;left: 0;background-color: #000;opacity: .1;z-index: 999;">
|
||||
</view>
|
||||
|
||||
<view class="maskss" v-if="ljljflag"></view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
@ -367,6 +367,8 @@
|
|||
intervalId: null,
|
||||
sklist:{},
|
||||
sklistflag:false,
|
||||
ljtype:'2',
|
||||
ljljflag:false
|
||||
}
|
||||
},
|
||||
onLoad(option) {
|
||||
|
@ -450,6 +452,7 @@
|
|||
})
|
||||
},
|
||||
onShow() {
|
||||
this.shibaiflag = false
|
||||
this.getshuax()
|
||||
this.getQiniuToken()
|
||||
// if (!this.intervalId) {
|
||||
|
@ -460,6 +463,89 @@
|
|||
this.drawCanvas()
|
||||
},
|
||||
methods: {
|
||||
// 拿到mac调用查询附近设备进行匹配
|
||||
Binddevice() {
|
||||
uni.showLoading({
|
||||
title: '蓝牙连接中..'
|
||||
})
|
||||
xBlufi.initXBlufi(1);
|
||||
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent);
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': true
|
||||
})
|
||||
// 两秒后停止蓝牙搜索
|
||||
setTimeout(() => {
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': false
|
||||
});
|
||||
setTimeout(() => {
|
||||
if (this.devicesList.length == 0) {
|
||||
uni.showToast({
|
||||
title: '暂无发现对应设备,请重试',
|
||||
icon: 'none'
|
||||
});
|
||||
} else {
|
||||
let uniqueDevicesList = Array.from(new Set(this.devicesList));
|
||||
this.devicesList = uniqueDevicesList;
|
||||
// console.log(this.devicesList,'this.devicesListthis.devicesList');
|
||||
this.devicesList.forEach(device => {
|
||||
let macFromName = device.name.substring(device.name.length - 12);
|
||||
console.log(macFromName, 'macFromNamemacFromName');
|
||||
// 与 this.mac 进行比较
|
||||
if (macFromName == this.qrResult) {
|
||||
// 如果相同,则将 this.ishave 设置为 true
|
||||
console.log(device);
|
||||
this.deviceInfoss = device
|
||||
this.createBLEConnection(device)
|
||||
console.log('对比正确1111111111');
|
||||
} else {
|
||||
console.log('对比错误');
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}, 200)
|
||||
}, 2000)
|
||||
},
|
||||
// 匹配到了之后进行连接
|
||||
createBLEConnection(e) {
|
||||
console.log('调用了');
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': false
|
||||
});
|
||||
console.log(e, '蓝牙信息')
|
||||
const deviceId = e.deviceId
|
||||
this.deviceId = e.deviceId
|
||||
this.Bluetoothmac = e.localName.substring(5) //从第七位开始截取 只取后面的mac号
|
||||
console.log(this.Bluetoothmac, '11111');
|
||||
let name = e.name;
|
||||
console.log('点击了,蓝牙准备连接的deviceId:' + e.deviceId);
|
||||
xBlufi.notifyConnectBle({
|
||||
isStart: true,
|
||||
deviceId: e.deviceId,
|
||||
name
|
||||
});
|
||||
},
|
||||
// 匹配的同时定义一个匹配失败处理
|
||||
getljlj(){
|
||||
setTimeout(() =>{
|
||||
if(this.ver_data == ''){
|
||||
uni.showModal({
|
||||
title: '温馨提示',
|
||||
content: '蓝牙连接失败,请重新连接',
|
||||
showCancel: false,
|
||||
success: function(res) {
|
||||
this.ljljflag = false
|
||||
}
|
||||
})
|
||||
}else{
|
||||
console.log('32751212');
|
||||
}
|
||||
},15000)
|
||||
},
|
||||
|
||||
|
||||
|
||||
groupChange(n) {
|
||||
console.log('groupChange', n);
|
||||
},
|
||||
|
@ -579,6 +665,7 @@
|
|||
this.shibaiflag = false
|
||||
this.bluetoothflag = false
|
||||
},
|
||||
|
||||
// 开启和关闭
|
||||
btnkq() {
|
||||
if(this.deviceInfo.allowSwitch == true){
|
||||
|
@ -628,39 +715,30 @@
|
|||
}
|
||||
} else {
|
||||
if (this.setMode == null) {
|
||||
this.btnmsk = false
|
||||
this.shibaiflag = false
|
||||
this.bluetoothflag = true
|
||||
xBlufi.initXBlufi(1)
|
||||
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': true
|
||||
})
|
||||
// this.btnmsk = false
|
||||
// this.shibaiflag = false
|
||||
// this.bluetoothflag = true
|
||||
// xBlufi.initXBlufi(1)
|
||||
// xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
|
||||
// xBlufi.notifyStartDiscoverBle({
|
||||
// 'isStart': true
|
||||
// })
|
||||
this.ljljflag = true
|
||||
this.Binddevice()
|
||||
this.getljlj()
|
||||
// 停止蓝牙搜索
|
||||
setTimeout(() => {
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': false
|
||||
})
|
||||
xBlufi.notifyConnectBle({
|
||||
isStart: true,
|
||||
deviceId: this.deviceId,
|
||||
name: this.name
|
||||
})
|
||||
xBlufi.notifyInitBleEsp32({
|
||||
deviceId: this.deviceId
|
||||
})
|
||||
let name = ''
|
||||
let index = this.name.indexOf('-')
|
||||
if (index !== -1) {
|
||||
name = this.name.slice(index + 1)
|
||||
}
|
||||
if (this.deviceInfo.powerStatus == 0) {
|
||||
this.imgflag = false
|
||||
} else {
|
||||
this.imgflag = true
|
||||
}
|
||||
}, 1000)
|
||||
}, 2000)
|
||||
} else {
|
||||
this.shibaiflag = false
|
||||
// console.log(this.tdtxt,'020202')
|
||||
if (this.tdtxt == '开启') {
|
||||
let that = this
|
||||
|
@ -974,28 +1052,31 @@
|
|||
})
|
||||
} else {
|
||||
if (this.setMode == null) {
|
||||
this.btnmsk = false
|
||||
this.shibaiflag = false
|
||||
this.bluetoothflag = true
|
||||
xBlufi.initXBlufi(1)
|
||||
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': true
|
||||
})
|
||||
this.ljljflag = true
|
||||
this.Binddevice()
|
||||
this.getljlj()
|
||||
// this.btnmsk = false
|
||||
// this.shibaiflag = false
|
||||
// this.bluetoothflag = true
|
||||
// xBlufi.initXBlufi(1)
|
||||
// xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
|
||||
// xBlufi.notifyStartDiscoverBle({
|
||||
// 'isStart': true
|
||||
// })
|
||||
// 停止蓝牙搜索
|
||||
setTimeout(() => {
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': false
|
||||
})
|
||||
xBlufi.notifyConnectBle({
|
||||
isStart: true,
|
||||
deviceId: this.deviceId,
|
||||
name: this.name
|
||||
})
|
||||
xBlufi.notifyInitBleEsp32({
|
||||
deviceId: this.deviceId
|
||||
})
|
||||
}, 1000)
|
||||
// xBlufi.notifyConnectBle({
|
||||
// isStart: true,
|
||||
// deviceId: this.deviceId,
|
||||
// name: this.name
|
||||
// })
|
||||
// xBlufi.notifyInitBleEsp32({
|
||||
// deviceId: this.deviceId
|
||||
// })
|
||||
}, 2000)
|
||||
} else {
|
||||
let that = this
|
||||
uni.showModal({
|
||||
|
@ -1080,113 +1161,26 @@
|
|||
})
|
||||
} else if (num == 5) {
|
||||
this.btnmsk = false
|
||||
this.shibaiflag = false
|
||||
this.bluetoothflag = true
|
||||
console.log(this.deviceId, 'idididididdidii');
|
||||
if (this.setMode == null) {
|
||||
xBlufi.initXBlufi(1)
|
||||
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': true
|
||||
let systemInfo = uni.getSystemInfoSync()
|
||||
if (systemInfo.platform == 'android') {
|
||||
// 当前设备是 Android
|
||||
uni.navigateTo({
|
||||
url: '/page_components/wifilist/index?deviceId=' + this
|
||||
.qrResult + '&name=' + this.name
|
||||
})
|
||||
// 停止蓝牙搜索
|
||||
setTimeout(() => {
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': false
|
||||
})
|
||||
xBlufi.notifyConnectBle({
|
||||
isStart: true,
|
||||
deviceId: this.deviceId,
|
||||
name: this.name
|
||||
})
|
||||
xBlufi.notifyInitBleEsp32({
|
||||
deviceId: this.deviceId
|
||||
})
|
||||
let name = ''
|
||||
let index = this.name.indexOf('-')
|
||||
if (index !== -1) {
|
||||
name = this.name.slice(index + 1)
|
||||
}
|
||||
let data = {
|
||||
storeId: this.storeId,
|
||||
mac: this.mac
|
||||
}
|
||||
this.$u.put('/app/device/bind', data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
uni.hideLoading();
|
||||
this.shibaiflag = false
|
||||
this.bluetoothflag = false
|
||||
uni.removeStorageSync('mac');
|
||||
let systemInfo = uni.getSystemInfoSync()
|
||||
if (systemInfo.platform == 'android') {
|
||||
// 当前设备是 Android
|
||||
uni.navigateTo({
|
||||
url: '/page_components/wifilist/index?deviceId=' + this
|
||||
.deviceId + '&name=' + this.name
|
||||
})
|
||||
} else if (systemInfo.platform == 'ios') {
|
||||
// 当前设备是 iOS
|
||||
uni.navigateTo({
|
||||
url: '/page_fenbao/device/wifivideo?deviceId=' + this
|
||||
.deviceId + '&name=' + this.name
|
||||
})
|
||||
}
|
||||
} else if (res.msg == '设备编号和mac不能同时为空') {
|
||||
this.shibaiflag = true
|
||||
this.bluetoothflag = false
|
||||
}
|
||||
})
|
||||
}, 2000)
|
||||
} else {
|
||||
let name = ''
|
||||
let index = this.name.indexOf('-')
|
||||
if (index !== -1) {
|
||||
name = this.name.slice(index + 1)
|
||||
}
|
||||
let data = {
|
||||
storeId: this.storeId,
|
||||
mac: this.mac
|
||||
}
|
||||
this.$u.put('/app/device/bind', data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.shibaiflag = false
|
||||
this.bluetoothflag = false
|
||||
uni.hideLoading();
|
||||
uni.removeStorageSync('mac');
|
||||
let systemInfo = uni.getSystemInfoSync()
|
||||
if (systemInfo.platform == 'android') {
|
||||
// 当前设备是 Android
|
||||
uni.navigateTo({
|
||||
url: '/page_components/wifilist/index?deviceId=' + this.deviceId +
|
||||
'&name=' + this.name
|
||||
})
|
||||
} else if (systemInfo.platform == 'ios') {
|
||||
// 当前设备是 iOS
|
||||
uni.navigateTo({
|
||||
url: '/page_fenbao/device/wifivideo?deviceId=' + this.deviceId +
|
||||
'&name=' + this.name
|
||||
})
|
||||
}
|
||||
} else {
|
||||
if (res.msg == '设备编号和mac不能同时为空') {
|
||||
this.shibaiflag = true
|
||||
this.bluetoothflag = false
|
||||
uni.hideLoading()
|
||||
} else {
|
||||
this.shibaiflag = true
|
||||
this.bluetoothflag = false
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
// uni.navigateBack()
|
||||
}
|
||||
}
|
||||
} else if (systemInfo.platform == 'ios') {
|
||||
// 当前设备是 iOS
|
||||
uni.navigateTo({
|
||||
url: '/page_fenbao/device/wifivideo?deviceId=' + this
|
||||
.qrResult + '&name=' + this.name
|
||||
})
|
||||
}else{
|
||||
uni.showToast({
|
||||
title: '目前仅支持安卓和iOS系统',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
// }
|
||||
} else if (num == 6) {
|
||||
uni.pageScrollTo({
|
||||
scrollTop: 0,//滚动到距离顶部为0
|
||||
|
@ -1237,30 +1231,33 @@
|
|||
})
|
||||
} else {
|
||||
if (this.setMode == null) {
|
||||
this.cztime = ''
|
||||
this.danwei = ''
|
||||
this.btnmsk = false
|
||||
this.shibaiflag = false
|
||||
this.bluetoothflag = true
|
||||
xBlufi.initXBlufi(1)
|
||||
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': true
|
||||
})
|
||||
this.ljljflag = true
|
||||
this.Binddevice()
|
||||
this.getljlj()
|
||||
// this.cztime = ''
|
||||
// this.danwei = ''
|
||||
// this.btnmsk = false
|
||||
// this.shibaiflag = false
|
||||
// this.bluetoothflag = true
|
||||
// xBlufi.initXBlufi(1)
|
||||
// xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
|
||||
// xBlufi.notifyStartDiscoverBle({
|
||||
// 'isStart': true
|
||||
// })
|
||||
// 停止蓝牙搜索
|
||||
setTimeout(() => {
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': false
|
||||
})
|
||||
xBlufi.notifyConnectBle({
|
||||
isStart: true,
|
||||
deviceId: this.deviceId,
|
||||
name: this.name
|
||||
})
|
||||
xBlufi.notifyInitBleEsp32({
|
||||
deviceId: this.deviceId
|
||||
})
|
||||
}, 1000)
|
||||
// xBlufi.notifyConnectBle({
|
||||
// isStart: true,
|
||||
// deviceId: this.deviceId,
|
||||
// name: this.name
|
||||
// })
|
||||
// xBlufi.notifyInitBleEsp32({
|
||||
// deviceId: this.deviceId
|
||||
// })
|
||||
}, 2000)
|
||||
} else {
|
||||
let that = this
|
||||
uni.getNetworkType({
|
||||
|
@ -1305,8 +1302,7 @@
|
|||
60 * 60
|
||||
})
|
||||
xBlufi.notifySendCustomData({
|
||||
customData: '11time@' + that
|
||||
.cztime * 60 * 60
|
||||
customData: '11time@' + that.cztime * 60 * 60
|
||||
})
|
||||
that.getaddtime()
|
||||
}
|
||||
|
@ -1326,108 +1322,56 @@
|
|||
this.vipflag = false
|
||||
this.cztime = ''
|
||||
},
|
||||
// 蓝牙回调
|
||||
funListenDeviceMsgEvent: function(options) {
|
||||
let that = this;
|
||||
switch (options.type) {
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_MY_DATA:
|
||||
let loadPercent = options.data;
|
||||
let loadText = '文件读取中'
|
||||
// console.log("文件读取中", options.data)
|
||||
break;
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA:
|
||||
let ver_data = this.parseCustomData(options.data)
|
||||
this.setMode = Math.floor(ver_data.setMode / 60)
|
||||
this.bluetoothflag = false
|
||||
console.log("1收到设备发来的自定义数据结果:", ver_data, this.setMode)
|
||||
break;
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS:
|
||||
if (options.result) {
|
||||
let devicesarr = options.data
|
||||
console.log(devicesarr, 'devicesarrdevicesarr')
|
||||
devicesarr.forEach(device => {
|
||||
const mac = device.name.substring(5)
|
||||
// console.log(device.name,device.name(5,15), 'macmacmac')
|
||||
if (device.name.slice(5, 17) == this.qrResult) {
|
||||
this.deviceId = device.deviceId
|
||||
this.name = device.name
|
||||
this.mac = device.name.slice(5, 17)
|
||||
// console.log(this.mac, this.deviceId, this.name, 'macmacmac')
|
||||
// this.devicesList = uniqueDevicesList
|
||||
}
|
||||
this.devicesList.push(device);
|
||||
let uniqueDevicesList = Array.from(new Set(this.devicesList));
|
||||
// 将去重后的数组重新赋值给 this.devicesList
|
||||
this.devicesList = uniqueDevicesList;
|
||||
})
|
||||
}
|
||||
break;
|
||||
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_CONNECTED:
|
||||
console.log("连接回调:" + JSON.stringify(options));
|
||||
if (options.result) {
|
||||
this.bluetoothflag = false
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: '连接成功',
|
||||
icon: 'success',
|
||||
duration:2000
|
||||
})
|
||||
setTimeout(()=>{
|
||||
this.ljljflag = false
|
||||
uni.hideLoading();
|
||||
},1500)
|
||||
{
|
||||
console.log("连接回调options.data.deviceId:" + options.data.deviceId,
|
||||
"连接回调options.data.name:" + options.data.name)
|
||||
xBlufi.notifyInitBleEsp32({
|
||||
deviceId: options.data.deviceId
|
||||
});
|
||||
}
|
||||
} else {
|
||||
this.shibaiflag = true
|
||||
this.bluetoothflag = false
|
||||
uni.hideLoading()
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START:
|
||||
if (!options.result) {
|
||||
setTimeout(() => {
|
||||
uni.hideLoading()
|
||||
this.bluetoothflag = false
|
||||
}, 3000)
|
||||
console.log("蓝牙未开启", options)
|
||||
this.shibaiflag = true
|
||||
// uni.showToast({
|
||||
// title: '蓝牙未开启',
|
||||
// icon: 'none',
|
||||
// duration: 3000
|
||||
// });
|
||||
return
|
||||
} else {
|
||||
// this.searching = true
|
||||
//蓝牙搜索开始
|
||||
// _this.setData({
|
||||
// searching: true
|
||||
// });
|
||||
}
|
||||
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_MY_DATA:
|
||||
console.log("文件读取中", options.data);
|
||||
break;
|
||||
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_STOP:
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA:
|
||||
this.setMode = this.parseCustomData(options.data)
|
||||
console.log("1收到设备发来的自定义数据结果:", this.setMode);
|
||||
break;
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_INIT_ESP32_RESULT:
|
||||
if (options.result) {
|
||||
let uniqueDevicesList = Array.from(new Set(this.devicesList))
|
||||
|
||||
// 将去重后的数组重新赋值给 this.devicesList
|
||||
this.devicesList = uniqueDevicesList
|
||||
let list = []
|
||||
// filteredDevices.forEach(device => {
|
||||
// // 从设备名称中提取 MAC 地址(假设 MAC 地址是设备名称的后6个字符)
|
||||
// let macFromName = device.name.substring(device.name.length - 12)
|
||||
// this.$u.get(`/app/device/${macFromName}/isBind`).then((res) => {
|
||||
// if (res.data == false) {
|
||||
// list.push(device)
|
||||
// } else {
|
||||
|
||||
// }
|
||||
// })
|
||||
|
||||
// });
|
||||
setTimeout(() => {
|
||||
this.devicesList = list
|
||||
}, 200)
|
||||
|
||||
console.log('蓝牙停止搜索ok')
|
||||
console.log('初始化成功');
|
||||
} else {
|
||||
//蓝牙停止搜索失败
|
||||
console.log('蓝牙停止搜索失败')
|
||||
console.log('初始化失败');
|
||||
break;
|
||||
}
|
||||
this.searching = false
|
||||
break
|
||||
|
||||
break;
|
||||
}
|
||||
},
|
||||
parseCustomData(data) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<template>
|
||||
<view class="">
|
||||
<u-navbar title="设备控制" :border-bottom="false" :background="bgc" title-color='#262B37' back-icon-color="#262B37" title-size='36'
|
||||
height='50'></u-navbar>
|
||||
height='50' :custom-back="btnmy"></u-navbar>
|
||||
<view class="title">
|
||||
控制台
|
||||
</view>
|
||||
|
@ -94,6 +94,11 @@
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
btnmy(){
|
||||
uni.reLaunch({
|
||||
url:'/pages/my'
|
||||
})
|
||||
},
|
||||
qrcode() {
|
||||
uni.scanCode({
|
||||
onlyFromCamera: true,
|
||||
|
@ -153,7 +158,9 @@
|
|||
|
||||
// 返回录入
|
||||
btnfh(){
|
||||
uni.navigateBack()
|
||||
uni.reLaunch({
|
||||
url:'/page_fenbao/zhuce'
|
||||
})
|
||||
},
|
||||
|
||||
// 开启
|
||||
|
|
|
@ -316,10 +316,14 @@
|
|||
}
|
||||
},
|
||||
onLoad() {
|
||||
|
||||
|
||||
},
|
||||
|
||||
onShow() {
|
||||
if(uni.getStorageSync('lianjie')){
|
||||
uni.removeStorageSync({
|
||||
key: 'lianjie'
|
||||
})
|
||||
}
|
||||
this.gettanc()
|
||||
this.pagenum = 1
|
||||
// this.curtitidx = 0
|
||||
|
|
|
@ -308,7 +308,7 @@
|
|||
|
||||
// 跳转设备录入
|
||||
btnsblr(){
|
||||
uni.navigateTo({
|
||||
uni.reLaunch({
|
||||
url:'/page_fenbao/zhuce'
|
||||
})
|
||||
},
|
||||
|
|
|
@ -273,7 +273,6 @@
|
|||
}
|
||||
})
|
||||
},
|
||||
|
||||
startNetworkCheck() {
|
||||
this.networkInterval = setInterval(() => {
|
||||
uni.getNetworkType({
|
||||
|
@ -559,7 +558,7 @@
|
|||
this.longitude = Number(res.longitude.toFixed(5)) + 0.005
|
||||
this.setMapScale()
|
||||
// 请求附近的店铺
|
||||
this.$u.get("/app/store/listNearBy?center=" + this.jinweidu + '&radius=' + 1000).then(
|
||||
this.$u.get("/app/store/listNearBy?center=" + this.jinweidu + '&radius=' + 20000).then(
|
||||
res => {
|
||||
if (res.code == 200) {
|
||||
this.listmap = res.data
|
||||
|
|
121
pages/tj.vue
121
pages/tj.vue
|
@ -142,7 +142,7 @@
|
|||
},
|
||||
onLoad() {
|
||||
|
||||
|
||||
|
||||
// setTimeout(() => {
|
||||
|
||||
// this.initChart()
|
||||
|
@ -156,7 +156,7 @@
|
|||
onShow() {
|
||||
this.timelist = []
|
||||
setTimeout(() => {
|
||||
// console.log(this.$refs)
|
||||
console.log(this.$refs)
|
||||
this.$refs.canvas.init(this.initChart)
|
||||
}, 500)
|
||||
this.recharge = 0
|
||||
|
@ -178,7 +178,7 @@
|
|||
this.yeartime = e
|
||||
this.gettime()
|
||||
setTimeout(() => {
|
||||
// console.log(this.$refs)
|
||||
console.log(this.$refs)
|
||||
this.$refs.canvas.init(this.initChart)
|
||||
}, 500)
|
||||
},
|
||||
|
@ -291,23 +291,6 @@
|
|||
show: false,
|
||||
},
|
||||
},
|
||||
visualMap: {
|
||||
type: 'piecewise',
|
||||
show: false,
|
||||
dimension: 0,
|
||||
seriesIndex: 0,
|
||||
pieces: [{
|
||||
gt: 1,
|
||||
lt: 3,
|
||||
color: 'rgba(0, 0, 180, 0.4)',
|
||||
},
|
||||
{
|
||||
gt: 5,
|
||||
lt: 7,
|
||||
color: 'rgba(0, 0, 180, 0.4)',
|
||||
},
|
||||
],
|
||||
},
|
||||
series: [{
|
||||
type: 'line',
|
||||
smooth: 0.6,
|
||||
|
@ -338,104 +321,6 @@
|
|||
chart.setOption(option)
|
||||
return chart
|
||||
},
|
||||
|
||||
|
||||
async initCharts() {
|
||||
// console.log('111111');
|
||||
let that = this
|
||||
// let _this = this
|
||||
const option = {
|
||||
grid: {
|
||||
left: 60,
|
||||
right: 10,
|
||||
top: 10,
|
||||
bottom: 30,
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
boundaryGap: false,
|
||||
axisLine: {
|
||||
show: false,
|
||||
},
|
||||
axisTick: {
|
||||
show: false,
|
||||
},
|
||||
axisLabel: {
|
||||
show: true,
|
||||
color: '#fff',
|
||||
fontSize: 11,
|
||||
rotate: 0,
|
||||
},
|
||||
splitLine: {
|
||||
show: false,
|
||||
},
|
||||
data: that.chartday,
|
||||
},
|
||||
yAxis: {
|
||||
show: true,
|
||||
axisLine: {
|
||||
show: false,
|
||||
},
|
||||
axisTick: {
|
||||
show: false,
|
||||
},
|
||||
axisLabel: {
|
||||
show: true,
|
||||
color: '#fff',
|
||||
fontSize: 11,
|
||||
formatter: function(value) {
|
||||
// 保留两位小数,没有小数时显示00
|
||||
return value + '度'
|
||||
},
|
||||
},
|
||||
splitLine: {
|
||||
show: false,
|
||||
},
|
||||
},
|
||||
visualMap: {
|
||||
type: 'piecewise',
|
||||
show: false,
|
||||
dimension: 0,
|
||||
seriesIndex: 0,
|
||||
pieces: [{
|
||||
gt: 1,
|
||||
lt: 3,
|
||||
color: 'rgba(0, 0, 180, 0.4)',
|
||||
},
|
||||
{
|
||||
gt: 5,
|
||||
lt: 7,
|
||||
color: 'rgba(0, 0, 180, 0.4)',
|
||||
},
|
||||
],
|
||||
},
|
||||
series: [{
|
||||
type: 'line',
|
||||
smooth: 0.6,
|
||||
symbol: 'none',
|
||||
lineStyle: {
|
||||
color: '#E0DBFF',
|
||||
width: 4,
|
||||
},
|
||||
areaStyle: {
|
||||
normal: {
|
||||
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
|
||||
offset: 0,
|
||||
color: '#B4B0F7'
|
||||
}, ]),
|
||||
},
|
||||
},
|
||||
data: that.chartData,
|
||||
}],
|
||||
};
|
||||
const chart = await that.$refs.charts.init(echarts)
|
||||
console.log(option, '111');
|
||||
// 给折线图赋值
|
||||
// option.series[0].data = that.chartData
|
||||
option.xAxis.data = that.chartday
|
||||
chart.setOption(option)
|
||||
return chart
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue
Block a user