开关录入更新
This commit is contained in:
parent
90c70ceb64
commit
d5ea737449
|
@ -19,8 +19,8 @@ const install = (Vue, vm) => {
|
||||||
// },
|
// },
|
||||||
// });
|
// });
|
||||||
Vue.prototype.$u.http.setConfig({
|
Vue.prototype.$u.http.setConfig({
|
||||||
// baseUrl: 'http://192.168.2.81:10002',
|
baseUrl: 'http://192.168.2.81:10002',
|
||||||
baseUrl: 'https://kg.chuangtewl.com/prod-api',
|
// baseUrl: 'https://kg.chuangtewl.com/prod-api',
|
||||||
// loadingText: '努力加载中~',
|
// loadingText: '努力加载中~',
|
||||||
// loadingTime: 1000,
|
// loadingTime: 1000,
|
||||||
// 设置自定义头部content-type
|
// 设置自定义头部content-type
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<view class="cen">
|
<view class="cen">
|
||||||
<view class="name">
|
<view class="name">
|
||||||
<view class="">
|
<view class="">
|
||||||
状态:<text v-if="item.flags == true" style="color: red;">已录入</text> <text v-else
|
状态:<text v-if="item.flags == true" style="color: #e10328;">已录入</text> <text v-else
|
||||||
style="color:seagreen;">未录入</text>
|
style="color:seagreen;">未录入</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="" style="display: flex;">
|
<view class="" style="display: flex;">
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="rt">
|
<view class="rt">
|
||||||
<text style="margin-bottom: 10rpx;" :id="item.deviceId" @click="createBLEConnections(item)">开关</text>
|
<text style="margin-bottom: 10rpx;" :id="item.deviceId" @click="createBLEConnections(item)">{{item.lj}}</text>
|
||||||
<text @click="scanQRCode(item)" style="margin-bottom: 10rpx;">扫码</text>
|
<text @click="scanQRCode(item)" style="margin-bottom: 10rpx;">扫码</text>
|
||||||
<text :id="item.deviceId" @click="createBLEConnection(item)">录入</text>
|
<text :id="item.deviceId" @click="createBLEConnection(item)">录入</text>
|
||||||
</view>
|
</view>
|
||||||
|
@ -63,7 +63,6 @@
|
||||||
<script>
|
<script>
|
||||||
const app = getApp();
|
const app = getApp();
|
||||||
var xBlufi = require("@/page_components/blufi/xBlufi.js");
|
var xBlufi = require("@/page_components/blufi/xBlufi.js");
|
||||||
// let _this = null;
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -211,7 +210,6 @@
|
||||||
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_MY_DATA:
|
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_MY_DATA:
|
||||||
let loadPercent = options.data;
|
let loadPercent = options.data;
|
||||||
let loadText = '文件读取中'
|
let loadText = '文件读取中'
|
||||||
// console.log("文件读取中", options.data)
|
|
||||||
break;
|
break;
|
||||||
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA:
|
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA:
|
||||||
this.ver_data = this.parseCustomData(options.data)
|
this.ver_data = this.parseCustomData(options.data)
|
||||||
|
@ -236,14 +234,15 @@
|
||||||
setTimeout(()=>{
|
setTimeout(()=>{
|
||||||
this.bluetoothflag = false
|
this.bluetoothflag = false
|
||||||
},3000)
|
},3000)
|
||||||
uni.hideLoading(); {
|
{
|
||||||
console.log("连接回调options.data.deviceId:" + options.data.deviceId,
|
console.log("连接回调options.data.deviceId:" + options.data.deviceId,
|
||||||
"连接回调options.data.name:" + options.data.name)
|
"连接回调options.data.name:" + options.data.name)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.shibaiflag = true
|
this.shibaiflag = true
|
||||||
this.bluetoothflag = false
|
this.bluetoothflag = false
|
||||||
uni.hideLoading()
|
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START:
|
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START:
|
||||||
|
@ -255,7 +254,7 @@
|
||||||
title: '蓝牙未开启,请打开手机蓝牙',
|
title: '蓝牙未开启,请打开手机蓝牙',
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
duration: 3000
|
duration: 3000
|
||||||
});
|
})
|
||||||
} else {
|
} else {
|
||||||
this.searching = true
|
this.searching = true
|
||||||
}
|
}
|
||||||
|
@ -273,7 +272,7 @@
|
||||||
})
|
})
|
||||||
let devicesarr = options.data
|
let devicesarr = options.data
|
||||||
this.devicesList.forEach(device => {
|
this.devicesList.forEach(device => {
|
||||||
if (device.name.substring(0, 4) == "CTKG" || device.name.substring(0, 4) == "CTPO") {
|
if (device.name.substring(0, 4) == "CCYK") {
|
||||||
this.devicesList.push(device);
|
this.devicesList.push(device);
|
||||||
let uniqueDevicesList = Array.from(new Set(this.devicesList));
|
let uniqueDevicesList = Array.from(new Set(this.devicesList));
|
||||||
this.devicesLists = uniqueDevicesList.filter(device => {
|
this.devicesLists = uniqueDevicesList.filter(device => {
|
||||||
|
@ -283,9 +282,7 @@
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// console.log('蓝牙停止搜索ok')
|
// console.log('蓝牙停止搜索ok')
|
||||||
console.log(this.devicesLists, '蓝牙停止');
|
|
||||||
this.mengcflag = false
|
this.mengcflag = false
|
||||||
uni.hideLoading()
|
|
||||||
if (this.devicesLists.length == 0) {
|
if (this.devicesLists.length == 0) {
|
||||||
this.titleflag = true
|
this.titleflag = true
|
||||||
} else {
|
} else {
|
||||||
|
@ -304,16 +301,22 @@
|
||||||
...device,
|
...device,
|
||||||
flags, // 直接使用 flags 变量
|
flags, // 直接使用 flags 变量
|
||||||
sn: '',
|
sn: '',
|
||||||
|
lj:'连接'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
console.log(this.devicesLists,'0202');
|
console.log(this.devicesLists,'0202')
|
||||||
|
setTimeout(()=>{
|
||||||
|
uni.hideLoading()
|
||||||
|
},2000)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//蓝牙停止搜索失败
|
//蓝牙停止搜索失败
|
||||||
this.mengcflag = false
|
this.mengcflag = false
|
||||||
|
setTimeout(()=>{
|
||||||
uni.hideLoading()
|
uni.hideLoading()
|
||||||
|
},2000)
|
||||||
console.log('蓝牙停止搜索失败');
|
console.log('蓝牙停止搜索失败');
|
||||||
}
|
}
|
||||||
this.searching = false
|
this.searching = false
|
||||||
|
@ -323,9 +326,6 @@
|
||||||
|
|
||||||
// 发送开关
|
// 发送开关
|
||||||
createBLEConnections(e) {
|
createBLEConnections(e) {
|
||||||
uni.showLoading({
|
|
||||||
title: '执行中...'
|
|
||||||
})
|
|
||||||
this.arrs = ''
|
this.arrs = ''
|
||||||
this.qrResult = e.name //拿到所点击的mac号
|
this.qrResult = e.name //拿到所点击的mac号
|
||||||
if (this.ver_data == null) { //判断是否有连接蓝牙
|
if (this.ver_data == null) { //判断是否有连接蓝牙
|
||||||
|
@ -334,8 +334,29 @@
|
||||||
xBlufi.notifyStartDiscoverBle({
|
xBlufi.notifyStartDiscoverBle({
|
||||||
'isStart': true
|
'isStart': true
|
||||||
})
|
})
|
||||||
|
uni.showLoading({
|
||||||
|
title: '连接准备中...'
|
||||||
|
})
|
||||||
// 停止蓝牙搜索
|
// 停止蓝牙搜索
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
setTimeout(()=>{
|
||||||
|
uni.showLoading({
|
||||||
|
title: '连接中...'
|
||||||
|
})
|
||||||
|
setTimeout(()=>{
|
||||||
|
uni.hideLoading()
|
||||||
|
uni.showToast({
|
||||||
|
title: '连接成功',
|
||||||
|
icon: 'success',
|
||||||
|
duration: 2000
|
||||||
|
})
|
||||||
|
this.devicesLists.forEach(item => {
|
||||||
|
if (item.name == this.qrResult) {
|
||||||
|
item.lj = '开关'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},2000)
|
||||||
|
},500)
|
||||||
xBlufi.notifyStartDiscoverBle({
|
xBlufi.notifyStartDiscoverBle({
|
||||||
'isStart': false
|
'isStart': false
|
||||||
})
|
})
|
||||||
|
@ -349,6 +370,9 @@
|
||||||
})
|
})
|
||||||
}, 1000)
|
}, 1000)
|
||||||
}else{ //有连接则发送命令
|
}else{ //有连接则发送命令
|
||||||
|
uni.showLoading({
|
||||||
|
title: '执行中...'
|
||||||
|
})
|
||||||
let that = this //改变this指向
|
let that = this //改变this指向
|
||||||
uni.getNetworkType({
|
uni.getNetworkType({
|
||||||
success(res) {
|
success(res) {
|
||||||
|
@ -370,6 +394,11 @@
|
||||||
wx.closeBLEConnection({
|
wx.closeBLEConnection({
|
||||||
deviceId: that.deviceId,
|
deviceId: that.deviceId,
|
||||||
})
|
})
|
||||||
|
that.devicesLists.forEach(item => {
|
||||||
|
if (item.name == that.qrResult) {
|
||||||
|
item.lj = '连接'
|
||||||
|
}
|
||||||
|
})
|
||||||
// console.log('guanbi');
|
// console.log('guanbi');
|
||||||
},1000)
|
},1000)
|
||||||
},2000)
|
},2000)
|
||||||
|
@ -473,15 +502,16 @@
|
||||||
},
|
},
|
||||||
// 点击重新搜索
|
// 点击重新搜索
|
||||||
Search() {
|
Search() {
|
||||||
// console.log(1);
|
|
||||||
// if (this.status) {
|
// if (this.status) {
|
||||||
this.mengcflag = true
|
this.mengcflag = true
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: '请稍后...'
|
title: '请稍后...'
|
||||||
})
|
})
|
||||||
|
xBlufi.initXBlufi(1);
|
||||||
|
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent);
|
||||||
xBlufi.notifyStartDiscoverBle({
|
xBlufi.notifyStartDiscoverBle({
|
||||||
'isStart': true
|
'isStart': true
|
||||||
});
|
})
|
||||||
// 重新搜索清空蓝牙数组
|
// 重新搜索清空蓝牙数组
|
||||||
this.bluthlist = []
|
this.bluthlist = []
|
||||||
this.devicesList = []
|
this.devicesList = []
|
||||||
|
@ -493,7 +523,7 @@
|
||||||
this.texts = '正在扫描蓝牙设备...'
|
this.texts = '正在扫描蓝牙设备...'
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.statusflag = false
|
this.statusflag = false
|
||||||
if (this.searching) {
|
// if (this.searching) {
|
||||||
xBlufi.notifyStartDiscoverBle({
|
xBlufi.notifyStartDiscoverBle({
|
||||||
'isStart': false
|
'isStart': false
|
||||||
});
|
});
|
||||||
|
@ -504,11 +534,11 @@
|
||||||
} else {
|
} else {
|
||||||
this.texts = '扫描到以下设备,请点击录入!'
|
this.texts = '扫描到以下设备,请点击录入!'
|
||||||
}
|
}
|
||||||
} else {
|
// } else {
|
||||||
xBlufi.notifyStartDiscoverBle({
|
// xBlufi.notifyStartDiscoverBle({
|
||||||
'isStart': true
|
// 'isStart': true
|
||||||
});
|
// })
|
||||||
}
|
// }
|
||||||
}, 2000)
|
}, 2000)
|
||||||
// }
|
// }
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue
Block a user