浇花器
This commit is contained in:
parent
42d9dbc722
commit
a08bf3321e
|
|
@ -21,7 +21,7 @@ const install = (Vue, vm) => {
|
||||||
// });
|
// });
|
||||||
Vue.prototype.$u.http.setConfig({
|
Vue.prototype.$u.http.setConfig({
|
||||||
baseUrl: 'https://yxd.ccttiot.com/prod-api',
|
baseUrl: 'https://yxd.ccttiot.com/prod-api',
|
||||||
// baseUrl: 'http://192.168.1.3:8081',
|
// baseUrl: 'http://192.168.1.5:8081',
|
||||||
loadingText: '努力加载中~',
|
loadingText: '努力加载中~',
|
||||||
loadingTime: 800,
|
loadingTime: 800,
|
||||||
// 设置自定义头部content-type
|
// 设置自定义头部content-type
|
||||||
|
|
|
||||||
|
|
@ -577,7 +577,7 @@ function write_cmd_program(deviceId, serviceId, characteristicId, data) {
|
||||||
var dv = 0;
|
var dv = 0;
|
||||||
let result;
|
let result;
|
||||||
console.log("更新122")
|
console.log("更新122")
|
||||||
const mtu = 212;
|
const mtu = 512;
|
||||||
uni.setBLEMTU({
|
uni.setBLEMTU({
|
||||||
deviceId: self
|
deviceId: self
|
||||||
.data
|
.data
|
||||||
|
|
@ -664,7 +664,7 @@ function write_cmd_program_dd(deviceId, serviceId, characteristicId, data) {
|
||||||
var dv = 0;
|
var dv = 0;
|
||||||
let result;
|
let result;
|
||||||
console.log("更新122")
|
console.log("更新122")
|
||||||
const mtu = 212;
|
const mtu = 512;
|
||||||
uni.setBLEMTU({
|
uni.setBLEMTU({
|
||||||
deviceId: self
|
deviceId: self
|
||||||
.data
|
.data
|
||||||
|
|
@ -752,7 +752,7 @@ function write_cmd_program_zy(deviceId, serviceId, characteristicId, data) {
|
||||||
var dv = 0;
|
var dv = 0;
|
||||||
let result;
|
let result;
|
||||||
console.log("更新122")
|
console.log("更新122")
|
||||||
const mtu = 212;
|
const mtu = 512;
|
||||||
uni.setBLEMTU({
|
uni.setBLEMTU({
|
||||||
deviceId: self
|
deviceId: self
|
||||||
.data
|
.data
|
||||||
|
|
@ -839,7 +839,7 @@ function write_cmd_program_yk(deviceId, serviceId, characteristicId, data) {
|
||||||
var dv = 0;
|
var dv = 0;
|
||||||
let result;
|
let result;
|
||||||
console.log("更新122")
|
console.log("更新122")
|
||||||
const mtu = 212;
|
const mtu = 512;
|
||||||
uni.setBLEMTU({
|
uni.setBLEMTU({
|
||||||
deviceId: self
|
deviceId: self
|
||||||
.data
|
.data
|
||||||
|
|
@ -927,7 +927,7 @@ function write_cmd_program_fg(web, deviceId, serviceId, characteristicId, data)
|
||||||
var dv = 0;
|
var dv = 0;
|
||||||
let result;
|
let result;
|
||||||
console.log("更新122")
|
console.log("更新122")
|
||||||
const mtu = 212;
|
const mtu = 512;
|
||||||
uni.setBLEMTU({
|
uni.setBLEMTU({
|
||||||
deviceId: self
|
deviceId: self
|
||||||
.data
|
.data
|
||||||
|
|
@ -1130,24 +1130,24 @@ function writeRouterSsid(deviceId, serviceId, characteristicId, data) {
|
||||||
},
|
},
|
||||||
fail: function (res) { //console.log(257);
|
fail: function (res) { //console.log(257);
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function writeDevicePwd(deviceId, serviceId, characteristicId, data) {
|
function writeDevicePwd(deviceId, serviceId, characteristicId, data) {
|
||||||
var obj = {},
|
var obj = {}
|
||||||
frameControl = 0;
|
frameControl = 0;
|
||||||
sequenceControl = parseInt(sequenceControl) + 1;
|
sequenceControl = parseInt(sequenceControl) + 1;
|
||||||
|
|
||||||
if (!util._isEmpty(data)) {
|
if (!util._isEmpty(data)) {
|
||||||
obj = util.isSubcontractor(data, self.data.isChecksum, sequenceControl, self.data.isEncrypt);
|
obj = util.isSubcontractor(data, self.data.isChecksum, sequenceControl, self.data.isEncrypt)
|
||||||
frameControl = util.getFrameCTRLValue(self.data.isEncrypt, self.data.isChecksum, util.DIRECTION_OUTPUT, false, obj.flag);
|
frameControl = util.getFrameCTRLValue(self.data.isEncrypt, self.data.isChecksum, util.DIRECTION_OUTPUT, false, obj.flag)
|
||||||
} else {
|
} else {
|
||||||
var pwdData = getCharCodeat(self.data.password);
|
var pwdData = getCharCodeat(self.data.password)
|
||||||
obj = util.isSubcontractor(pwdData, self.data.isChecksum, sequenceControl, self.data.isEncrypt);
|
obj = util.isSubcontractor(pwdData, self.data.isChecksum, sequenceControl, self.data.isEncrypt)
|
||||||
frameControl = util.getFrameCTRLValue(self.data.isEncrypt, self.data.isChecksum, util.DIRECTION_OUTPUT, false, obj.flag);
|
frameControl = util.getFrameCTRLValue(self.data.isEncrypt, self.data.isChecksum, util.DIRECTION_OUTPUT, false, obj.flag)
|
||||||
}
|
}
|
||||||
|
|
||||||
var defaultData = util.encrypt(aesjs, self.data.md5Key, sequenceControl, obj.lenData, true);
|
var defaultData = util.encrypt(aesjs, self.data.md5Key, sequenceControl, obj.lenData, true)
|
||||||
var value = util.writeData(util.PACKAGE_VALUE, util.SUBTYPE_SET_PWD, frameControl, sequenceControl, obj.len,
|
var value = util.writeData(util.PACKAGE_VALUE, util.SUBTYPE_SET_PWD, frameControl, sequenceControl, obj.len,
|
||||||
defaultData);
|
defaultData);
|
||||||
var typedArray = new Uint8Array(value);
|
var typedArray = new Uint8Array(value);
|
||||||
|
|
@ -1169,8 +1169,8 @@ function writeDevicePwd(deviceId, serviceId, characteristicId, data) {
|
||||||
|
|
||||||
function writeDeviceEnd(deviceId, serviceId, characteristicId) {
|
function writeDeviceEnd(deviceId, serviceId, characteristicId) {
|
||||||
sequenceControl = parseInt(sequenceControl) + 1;
|
sequenceControl = parseInt(sequenceControl) + 1;
|
||||||
var frameControl = util.getFrameCTRLValue(self.data.isEncrypt, false, util.DIRECTION_OUTPUT, false, false);
|
var frameControl = util.getFrameCTRLValue(self.data.isEncrypt, false, util.DIRECTION_OUTPUT, false, false)
|
||||||
var value = util.writeData(self.data.PACKAGE_CONTROL_VALUE, util.SUBTYPE_END, frameControl, sequenceControl, 0, null);
|
var value = util.writeData(self.data.PACKAGE_CONTROL_VALUE, util.SUBTYPE_END, frameControl, sequenceControl, 0, null)
|
||||||
var typedArray = new Uint8Array(value);
|
var typedArray = new Uint8Array(value);
|
||||||
uni.writeBLECharacteristicValue({
|
uni.writeBLECharacteristicValue({
|
||||||
deviceId: deviceId,
|
deviceId: deviceId,
|
||||||
|
|
@ -1244,6 +1244,7 @@ function init() {
|
||||||
// && devices.devices[0].indexOf('TOOL') == -1
|
// && devices.devices[0].indexOf('TOOL') == -1
|
||||||
&& devices.devices[0].name.indexOf('WATE') == -1
|
&& devices.devices[0].name.indexOf('WATE') == -1
|
||||||
&& devices.devices[0].name.indexOf('SMSJ') == -1
|
&& devices.devices[0].name.indexOf('SMSJ') == -1
|
||||||
|
&& devices.devices[0].name.indexOf('CCYK') == -1
|
||||||
// && devices.devices[0].name.indexOf('BBLE') == -1
|
// && devices.devices[0].name.indexOf('BBLE') == -1
|
||||||
// && devices.devices[0].name.indexOf('FXLE') == -1
|
// && devices.devices[0].name.indexOf('FXLE') == -1
|
||||||
// && devices.devices[0].name.indexOf('CCYK') == -1
|
// && devices.devices[0].name.indexOf('CCYK') == -1
|
||||||
|
|
@ -1368,7 +1369,7 @@ function init() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mDeviceEvent.listenConnectBle(true, function (options) {
|
mDeviceEvent.listenConnectBle(true, function (options) {
|
||||||
console.log("我要连接?", options.isStart);
|
console.log("我要连接?", options.isStart,options);
|
||||||
if (options.isStart) uni.createBLEConnection({
|
if (options.isStart) uni.createBLEConnection({
|
||||||
deviceId: options.deviceId,
|
deviceId: options.deviceId,
|
||||||
success: function (res) {
|
success: function (res) {
|
||||||
|
|
@ -1452,7 +1453,7 @@ function init() {
|
||||||
self.data.deviceId = options.deviceId;
|
self.data.deviceId = options.deviceId;
|
||||||
mac_id = options.deviceId;
|
mac_id = options.deviceId;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
var mtu = 212
|
var mtu = 512
|
||||||
uni.setBLEMTU({
|
uni.setBLEMTU({
|
||||||
deviceId: self
|
deviceId: self
|
||||||
.data
|
.data
|
||||||
|
|
@ -1515,7 +1516,7 @@ setTimeout(() => {
|
||||||
success: function(res) {
|
success: function(res) {
|
||||||
console.log("成功", res)
|
console.log("成功", res)
|
||||||
writeCutomsData(self.data.deviceId, self.data.service_uuid, self.data.characteristic_write_uuid, "get_fw");
|
writeCutomsData(self.data.deviceId, self.data.service_uuid, self.data.characteristic_write_uuid, "get_fw");
|
||||||
const mtu = 212;
|
const mtu = 512;
|
||||||
uni.onBLECharacteristicValueChange(function(res) {
|
uni.onBLECharacteristicValueChange(function(res) {
|
||||||
var my_str = Utf8ArrayToStr(res.value)
|
var my_str = Utf8ArrayToStr(res.value)
|
||||||
if(my_str.indexOf("wifi_ok") != -1)
|
if(my_str.indexOf("wifi_ok") != -1)
|
||||||
|
|
|
||||||
|
|
@ -201,15 +201,15 @@
|
||||||
for (let key in this.list) {
|
for (let key in this.list) {
|
||||||
if (this.list.hasOwnProperty(key)) {
|
if (this.list.hasOwnProperty(key)) {
|
||||||
// 获取当前数组
|
// 获取当前数组
|
||||||
let arr = this.list[key];
|
let arr = this.list[key]
|
||||||
// 只转换开关状态(values[3])为布尔值
|
// 只转换开关状态(values[3])为布尔值
|
||||||
arr[3] = arr[3] === 1;
|
arr[3] = arr[3] === 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(this.list,'listlistlist')
|
console.log(this.list,'listlistlist')
|
||||||
} else {
|
} else {
|
||||||
this.csbobj = JSON.parse(option.list)
|
this.csbobj = JSON.parse(option.list)
|
||||||
console.log(this.csbobj,'chobjchobj');
|
console.log(this.csbobj,'chobjchobj')
|
||||||
this.shi = this.csbobj.hour
|
this.shi = this.csbobj.hour
|
||||||
this.fen = this.csbobj.minute
|
this.fen = this.csbobj.minute
|
||||||
this.miao = this.csbobj.second
|
this.miao = this.csbobj.second
|
||||||
|
|
@ -231,13 +231,13 @@
|
||||||
this.$u.get(`/app/getDeviceInfo/${this.shebid}`).then(res => {
|
this.$u.get(`/app/getDeviceInfo/${this.shebid}`).then(res => {
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
if(this.pre != 'WATER'){
|
if(this.pre != 'WATER'){
|
||||||
this.shi = res.data.gatewayReturnParams.h.value
|
this.shi = res.data.parameters.h.value
|
||||||
this.fen = res.data.gatewayReturnParams.m.value < 10 ? '0' + res.data.gatewayReturnParams.m.value : res.data.gatewayReturnParams.m.value
|
this.fen = res.data.parameters.m.value < 10 ? '0' + res.data.parameters.m.value : res.data.parameters.m.value
|
||||||
this.miao = res.data.gatewayReturnParams.t.value
|
this.miao = res.data.parameters.t.value
|
||||||
this.tian = res.data.gatewayReturnParams.d.value
|
this.tian = res.data.parameters.d.value
|
||||||
} else {
|
} else {
|
||||||
// 单阀 WATER,从后台字段 h1/m1/s1/o1...(以及可选 d1..d6) 组装展示结构
|
// 单阀 WATER,从后台字段 h1/m1/s1/o1...(以及可选 d1..d6) 组装展示结构
|
||||||
const params = res.data.gatewayReturnParams
|
const params = res.data.parameters
|
||||||
const mapped = this.buildListFromBackend(params)
|
const mapped = this.buildListFromBackend(params)
|
||||||
// u-switch 需要布尔值,已在构建阶段转换
|
// u-switch 需要布尔值,已在构建阶段转换
|
||||||
this.list = mapped
|
this.list = mapped
|
||||||
|
|
@ -276,44 +276,43 @@
|
||||||
},
|
},
|
||||||
// 点击选择浇水时长
|
// 点击选择浇水时长
|
||||||
btnshowtwo(){
|
btnshowtwo(){
|
||||||
console.log(this.defaultTimeLength,this.minute,this.second,'111');
|
console.log(this.defaultTimeLength,this.minute,this.second,'111')
|
||||||
this.defaultTimeLength = '00' + ':' + this.minute + ':' + this.second
|
this.defaultTimeLength = '00' + ':' + this.minute + ':' + this.second
|
||||||
console.log(this.defaultTimeLength,this.minute,this.second,'222');
|
console.log(this.defaultTimeLength,this.minute,this.second,'222')
|
||||||
this.shows = true
|
this.shows = true
|
||||||
},
|
},
|
||||||
// 显示加载
|
// 显示加载
|
||||||
showLoading() {
|
showLoading() {
|
||||||
this.isLoading = true;
|
this.isLoading = true
|
||||||
},
|
},
|
||||||
|
|
||||||
// 格式化间隔天数显示
|
// 格式化间隔天数显示
|
||||||
formatInterval(days) {
|
formatInterval(days) {
|
||||||
return days <= 1 ? '每天浇一次' : '每' + days + '天浇一次';
|
return days <= 1 ? '每天浇一次' : '每' + days + '天浇一次'
|
||||||
},
|
},
|
||||||
|
|
||||||
// 隐藏加载
|
// 隐藏加载
|
||||||
hideLoading() {
|
hideLoading() {
|
||||||
this.isLoading = false;
|
this.isLoading = false
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.isLoading = false;
|
this.isLoading = false
|
||||||
}, 500);
|
}, 500)
|
||||||
},
|
},
|
||||||
|
|
||||||
// 重试机制
|
// 重试机制
|
||||||
async retryOperation() {
|
async retryOperation() {
|
||||||
if (this.retryCount < this.maxRetries) {
|
if (this.retryCount < this.maxRetries) {
|
||||||
this.retryCount++;
|
this.retryCount++
|
||||||
await this.delay(1000);
|
await this.delay(1000)
|
||||||
if (this.lastOperation) {
|
if (this.lastOperation) {
|
||||||
this.lastOperation();
|
this.lastOperation()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.hideLoading();
|
this.hideLoading()
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '操作失败,请重试',
|
title: '操作失败,请重试',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
});
|
})
|
||||||
this.retryCount = 0;
|
this.retryCount = 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,47 @@
|
||||||
<view class="devmac">
|
<view class="devmac">
|
||||||
MAC:{{item.mac == undefined ? item.name.slice(-12) : item.mac}}
|
MAC:{{item.mac == undefined ? item.name.slice(-12) : item.mac}}
|
||||||
</view>
|
</view>
|
||||||
<view class="devmac">
|
<view class="devmac" style="display: flex;align-items: center;">
|
||||||
信号:{{item.ssid == undefined ? '--' : item.ssid}}
|
信号:
|
||||||
|
<!-- 最强信号:-50 及以上(-1 到 -50) -->
|
||||||
|
<image
|
||||||
|
style="width: 30rpx;height: 20rpx;"
|
||||||
|
v-if="item.ssid >= -50"
|
||||||
|
src="https://api.ccttiot.com/smartmeter/img/static/ueeDGk0mVPLUd0DHxrWj"
|
||||||
|
mode=""
|
||||||
|
></image>
|
||||||
|
|
||||||
|
<!-- 较强信号:-51 到 -60 -->
|
||||||
|
<image
|
||||||
|
style="width: 30rpx;height: 20rpx;"
|
||||||
|
v-else-if="item.ssid >= -60 && item.ssid <= -51"
|
||||||
|
src="https://api.ccttiot.com/smartmeter/img/static/uM1obZ76ittglMRKXWLq"
|
||||||
|
mode=""
|
||||||
|
></image>
|
||||||
|
|
||||||
|
<!-- 中等信号:-61 到 -70 -->
|
||||||
|
<image
|
||||||
|
style="width: 30rpx;height: 20rpx;"
|
||||||
|
v-else-if="item.ssid >= -70 && item.ssid <= -61"
|
||||||
|
src="https://api.ccttiot.com/smartmeter/img/static/ujO9AZIuUSQvHcCBKqc4"
|
||||||
|
mode=""
|
||||||
|
></image>
|
||||||
|
|
||||||
|
<!-- 较弱信号:-71 到 -80 -->
|
||||||
|
<image
|
||||||
|
style="width: 30rpx;height: 20rpx;"
|
||||||
|
v-else-if="item.ssid >= -80 && item.ssid <= -71"
|
||||||
|
src="https://api.ccttiot.com/smartmeter/img/static/uCSlbXZvho808NMCkIQP"
|
||||||
|
mode=""
|
||||||
|
></image>
|
||||||
|
|
||||||
|
<!-- 最弱信号:-81 到 -100 -->
|
||||||
|
<image
|
||||||
|
style="width: 30rpx;height: 20rpx;"
|
||||||
|
v-else-if="item.ssid >= -100 && item.ssid <= -81"
|
||||||
|
src="https://api.ccttiot.com/smartmeter/img/static/u8bj3ZNi8Zssunk69HWc"
|
||||||
|
mode=""
|
||||||
|
></image>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="add" style="color: #ccc;border: 1px solid #ccc;" v-if="item.userId">
|
<view class="add" style="color: #ccc;border: 1px solid #ccc;" v-if="item.userId">
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,8 @@
|
||||||
xctime:'--',
|
xctime:'--',
|
||||||
version:'',
|
version:'',
|
||||||
xinpin:'',
|
xinpin:'',
|
||||||
imgpic:''
|
imgpic:'',
|
||||||
|
varflag:''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 分享到好友(会话)
|
// 分享到好友(会话)
|
||||||
|
|
@ -134,6 +135,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad(option) {
|
onLoad(option) {
|
||||||
|
this.varflag = option.varflag
|
||||||
console.log(option,'0000');
|
console.log(option,'0000');
|
||||||
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
|
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
|
||||||
xBlufi.notifySendCustomData({
|
xBlufi.notifySendCustomData({
|
||||||
|
|
@ -141,8 +143,8 @@
|
||||||
})
|
})
|
||||||
this.deviceid = option.deviceid
|
this.deviceid = option.deviceid
|
||||||
this.imgpic = option.img
|
this.imgpic = option.img
|
||||||
|
this.xinpin = option.xipin
|
||||||
if(option.xctime != '--'){
|
if(option.xctime != '--'){
|
||||||
// this.xinpin = option.xipin
|
|
||||||
if(option.xctime != '--' && option.ver){
|
if(option.xctime != '--' && option.ver){
|
||||||
this.ver = 'V' + option.ver.slice(3)
|
this.ver = 'V' + option.ver.slice(3)
|
||||||
this.xctime = option.xctime
|
this.xctime = option.xctime
|
||||||
|
|
@ -168,25 +170,51 @@
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
btnxip(){
|
btnxip(){
|
||||||
if(this.xinpin == '' || this.xinpin == null){
|
|
||||||
uni.showToast({
|
|
||||||
title: '请先连接蓝牙拿取息屏时间',
|
|
||||||
icon: 'none',
|
|
||||||
duration: 2000
|
|
||||||
})
|
|
||||||
}else{
|
|
||||||
this.xpshow = true
|
this.xpshow = true
|
||||||
}
|
// if(this.xinpin == '' || this.xinpin == null){
|
||||||
|
// uni.showToast({
|
||||||
|
// title: '请先连接蓝牙拿取息屏时间',
|
||||||
|
// icon: 'none',
|
||||||
|
// duration: 2000
|
||||||
|
// })
|
||||||
|
// }else{
|
||||||
|
// }
|
||||||
},
|
},
|
||||||
// 设置息屏时间
|
// 设置息屏时间
|
||||||
confirm(e) {
|
confirm(e) {
|
||||||
this.xinpin = Number(e.minute * 60) + Number(e.second)
|
this.xinpin = Number(e.minute * 60) + Number(e.second)
|
||||||
|
if(this.varflag == 3){
|
||||||
xBlufi.notifySendCustomData({
|
xBlufi.notifySendCustomData({
|
||||||
customData: '11sleep' + this.xinpin + '@'
|
customData: '11sleep' + this.xinpin + '@'
|
||||||
})
|
})
|
||||||
xBlufi.notifySendCustomData({
|
xBlufi.notifySendCustomData({
|
||||||
customData: '11get'
|
customData: '11get'
|
||||||
})
|
})
|
||||||
|
}else{
|
||||||
|
let parameters = {
|
||||||
|
time: this.xinpin
|
||||||
|
}
|
||||||
|
let data = {
|
||||||
|
deviceId:this.deviceid,
|
||||||
|
instructionKey:'sleep',
|
||||||
|
parameters:parameters
|
||||||
|
}
|
||||||
|
this.$u.post(`/app/sendCommandByGateway`,data).then(res => {
|
||||||
|
if (res.code == 200) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '设置成功',
|
||||||
|
icon: 'success',
|
||||||
|
duration:2000
|
||||||
|
})
|
||||||
|
}else{
|
||||||
|
uni.showToast({
|
||||||
|
title: res.msg,
|
||||||
|
icon: 'none',
|
||||||
|
duration:2000
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
// 解绑设备按钮
|
// 解绑设备按钮
|
||||||
btnjiebang() {
|
btnjiebang() {
|
||||||
|
|
@ -427,7 +455,7 @@
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
console.log(showObject,'showObjectshowObject');
|
console.log(showObject,'showObjectshowObject');
|
||||||
this.xinpin = showObject.showArray[showObject.showArray.length - 2]
|
this.xinpin = showObject.showArray[showObject.showArray.length - 1]
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START:
|
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START:
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,14 @@
|
||||||
<view class="title">
|
<view class="title">
|
||||||
<image src="https://api.ccttiot.com/smartmeter/img/static/uhRjXxrVaNwOCld2fYUl" mode=""></image>
|
<image src="https://api.ccttiot.com/smartmeter/img/static/uhRjXxrVaNwOCld2fYUl" mode=""></image>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!-- 加载状态遮罩层 -->
|
||||||
|
<view class="loading-mask" v-if="isLoading">
|
||||||
|
<view class="loading-content">
|
||||||
|
<u-loading mode="circle" size="60" color="#7FAD76"></u-loading>
|
||||||
|
<text class="loading-text">正在加载中...</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
<!-- 背景图 -->
|
<!-- 背景图 -->
|
||||||
<!-- 没设备时展示 -->
|
<!-- 没设备时展示 -->
|
||||||
<image class="bjimg" v-if="bjflag" src="https://api.ccttiot.com/smartmeter/img/static/uz8MR6BuZW2qRANnYgLu"
|
<image class="bjimg" v-if="bjflag" src="https://api.ccttiot.com/smartmeter/img/static/uz8MR6BuZW2qRANnYgLu"
|
||||||
|
|
@ -30,12 +38,15 @@
|
||||||
<view style="margin-left: 10rpx;" @click="btnlj" v-if="vardataflag == 1">
|
<view style="margin-left: 10rpx;" @click="btnlj" v-if="vardataflag == 1">
|
||||||
<image style="width: 158rpx;height: 40rpx;vertical-align: sub;" src="https://api.ccttiot.com/smartmeter/img/static/uIkBDnclZIqgUbWom2Aw" mode=""></image>
|
<image style="width: 158rpx;height: 40rpx;vertical-align: sub;" src="https://api.ccttiot.com/smartmeter/img/static/uIkBDnclZIqgUbWom2Aw" mode=""></image>
|
||||||
</view>
|
</view>
|
||||||
<view class="lj" @click="btnlj" v-if="vardataflag == 2">
|
<view class="lj" v-if="vardataflag == 2">
|
||||||
连接中
|
连接中
|
||||||
</view>
|
</view>
|
||||||
<view class="lj" style="color: #15C55D;border: 1px solid #15C55D;" @click="btnlj" v-if="vardataflag == 3">
|
<view class="lj" style="color: #15C55D;border: 1px solid #15C55D;" v-if="vardataflag == 3">
|
||||||
已连接
|
已连接
|
||||||
</view>
|
</view>
|
||||||
|
<view class="" style="font-weight: 400;font-size: 24rpx;color: #ccc;margin-left: 10rpx;" v-if="vardataflag == 2">
|
||||||
|
{{vatatxt}}
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="selectshezhi" style="display: flex;">
|
<view class="selectshezhi" style="display: flex;">
|
||||||
<image @click="btnsz" src="https://api.ccttiot.com/smartmeter/img/static/uvCJ8ro0MpfGZd53vypJ" mode=""></image>
|
<image @click="btnsz" src="https://api.ccttiot.com/smartmeter/img/static/uvCJ8ro0MpfGZd53vypJ" mode=""></image>
|
||||||
|
|
@ -323,11 +334,11 @@
|
||||||
<image style="width:32rpx;height:32rpx;margin-right: 8rpx;" src="https://api.ccttiot.com/smartmeter/img/static/uhyYG0TLfWi9XUhTQz7D" mode=""></image>
|
<image style="width:32rpx;height:32rpx;margin-right: 8rpx;" src="https://api.ccttiot.com/smartmeter/img/static/uhyYG0TLfWi9XUhTQz7D" mode=""></image>
|
||||||
启动时间
|
启动时间
|
||||||
</view>
|
</view>
|
||||||
<view class="" style="margin-top:10rpx;font-size: 36rpx;font-weight: 600;" v-if="vardataflag == 3">
|
<view class="" style="margin-top:10rpx;font-size: 36rpx;font-weight: 600;" v-if="csbobj.hour">
|
||||||
{{csbobj.hour == undefined ? '--' : csbobj.hour + ':'}}{{csbobj.minute == undefined ? '' : csbobj.minute}}
|
{{csbobj.hour == undefined ? '--' : csbobj.hour + ':'}}{{csbobj.minute == undefined ? '' : csbobj.minute}}
|
||||||
</view>
|
</view>
|
||||||
<view class="" style="margin-top:10rpx;font-size: 36rpx;font-weight: 600;" v-else>
|
<view class="" style="margin-top:10rpx;font-size: 36rpx;font-weight: 600;" v-else>
|
||||||
{{zaixianobj.h.value == undefined ? '-' : zaixianobj.h.value + ':'}}{{zaixianobj.m.value == undefined ? '-' : zaixianobj.m.value < 10 ? '0' + zaixianobj.m.value : zaixianobj.m.value}}
|
{{zaixianobj.h.value == undefined ? '-' : zaixianobj.h.value + ':'}}{{zaixianobj.m.value == undefined ? '-' : zaixianobj.m.value}}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="" style="font-size: 24rpx;color: #50565A;margin-top: 10rpx;text-align: center;">
|
<view class="" style="font-size: 24rpx;color: #50565A;margin-top: 10rpx;text-align: center;">
|
||||||
|
|
@ -335,7 +346,7 @@
|
||||||
<image style="width:32rpx;height:32rpx;margin-right: 8rpx;font-size: 36rpx;font-weight: 600;" src="https://api.ccttiot.com/smartmeter/img/static/uuQaK98cmdQQnPWus27Z" mode=""></image>
|
<image style="width:32rpx;height:32rpx;margin-right: 8rpx;font-size: 36rpx;font-weight: 600;" src="https://api.ccttiot.com/smartmeter/img/static/uuQaK98cmdQQnPWus27Z" mode=""></image>
|
||||||
工作时长
|
工作时长
|
||||||
</view>
|
</view>
|
||||||
<view class="" style="margin-top:10rpx;font-size: 36rpx;font-weight: 600;" v-if="vardataflag == 3">
|
<view class="" style="margin-top:10rpx;font-size: 36rpx;font-weight: 600;" v-if="csbobj.second">
|
||||||
{{csbobj.second == undefined ? '--' : csbobj.second + '秒'}}
|
{{csbobj.second == undefined ? '--' : csbobj.second + '秒'}}
|
||||||
</view>
|
</view>
|
||||||
<view class="" style="margin-top:10rpx;font-size: 36rpx;font-weight: 600;" v-else>
|
<view class="" style="margin-top:10rpx;font-size: 36rpx;font-weight: 600;" v-else>
|
||||||
|
|
@ -347,7 +358,7 @@
|
||||||
<image style="width:32rpx;height:32rpx;margin-right: 8rpx;font-size: 36rpx;font-weight: 600;" src="https://api.ccttiot.com/smartmeter/img/static/uM6Yz4xVqFwzW6xlTRph" mode=""></image>
|
<image style="width:32rpx;height:32rpx;margin-right: 8rpx;font-size: 36rpx;font-weight: 600;" src="https://api.ccttiot.com/smartmeter/img/static/uM6Yz4xVqFwzW6xlTRph" mode=""></image>
|
||||||
间隔天数
|
间隔天数
|
||||||
</view>
|
</view>
|
||||||
<view class="" style="margin-top:10rpx;font-size: 36rpx;font-weight: 600;" v-if="vardataflag == 3">
|
<view class="" style="margin-top:10rpx;font-size: 36rpx;font-weight: 600;" v-if="csbobj.day">
|
||||||
{{csbobj.day == undefined ? '--' : csbobj.day + '天'}}
|
{{csbobj.day == undefined ? '--' : csbobj.day + '天'}}
|
||||||
</view>
|
</view>
|
||||||
<view class="" style="margin-top:10rpx;font-size: 36rpx;font-weight: 600;" v-else>
|
<view class="" style="margin-top:10rpx;font-size: 36rpx;font-weight: 600;" v-else>
|
||||||
|
|
@ -424,9 +435,12 @@
|
||||||
</view>
|
</view>
|
||||||
<view class="wateringlogbd">
|
<view class="wateringlogbd">
|
||||||
<view class="lt" >
|
<view class="lt" >
|
||||||
<view class="">距离下次:{{xctime}}</view>
|
<!-- <view class="">距离下次:{{xctime}}</view>
|
||||||
<view class="">下次浇水时长:{{xctimesc}}</view>
|
<view class="">下次浇水时长:{{xctimesc}}</view>
|
||||||
<view class="">上次浇水:{{sctimejs}}</view>
|
<view class="">上次浇水:{{sctimejs}}</view> -->
|
||||||
|
<!-- <view class="">距离下次:{{xctime}}</view> -->
|
||||||
|
<view class="">上次浇水时长:{{jsobj.sprayingTime == undefined ? '--' : jsobj.sprayingTime + 's'}}</view>
|
||||||
|
<view class="">上次浇水:{{jsobj.lastWaterTime == undefined ? '--' : jsobj.sprayingTime}}</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="rt">
|
<view class="rt">
|
||||||
<image src="https://api.ccttiot.com/smartmeter/img/static/uagx3wGa7RYvqKqoSymy" mode=""></image>
|
<image src="https://api.ccttiot.com/smartmeter/img/static/uagx3wGa7RYvqKqoSymy" mode=""></image>
|
||||||
|
|
@ -482,11 +496,17 @@
|
||||||
</view>
|
</view>
|
||||||
<view class="manualmask" v-if="sdjsflag"></view>
|
<view class="manualmask" v-if="sdjsflag"></view>
|
||||||
<!-- 选择浇水时间-->
|
<!-- 选择浇水时间-->
|
||||||
<u-picker v-model="showjs" mode="time" :default-time="00" :params="params" @confirm="confirm"></u-picker>
|
<u-picker v-model="showjs" mode="time" :default-time="0" :params="params" @confirm="confirm"></u-picker>
|
||||||
<!-- 设置当前时间 -->
|
<!-- 设置当前时间 -->
|
||||||
<u-picker v-model="timeflag" mode="time" :params="paramss" @confirm="confirmtime"></u-picker>
|
<u-picker v-model="timeflag" mode="time" :params="paramss" @confirm="confirmtime"></u-picker>
|
||||||
<tab-bar :indexs='0'></tab-bar>
|
<tab-bar :indexs='0'></tab-bar>
|
||||||
|
|
||||||
|
<!-- <view class="">
|
||||||
|
<view class="" v-for="(item,index) in devicesarr" :key="index">
|
||||||
|
{{item.name}}
|
||||||
|
</view>
|
||||||
|
</view> -->
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
@ -496,6 +516,10 @@
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
timeflag:false,
|
timeflag:false,
|
||||||
|
// 最近一次成功上传的时间戳(毫秒)
|
||||||
|
lastUploadTs: 0,
|
||||||
|
// 最近一次获取电量的时间戳(毫秒)
|
||||||
|
lastPowerTs: 0,
|
||||||
one: false,
|
one: false,
|
||||||
ones: true,
|
ones: true,
|
||||||
two: false,
|
two: false,
|
||||||
|
|
@ -530,7 +554,6 @@
|
||||||
minute: '00',
|
minute: '00',
|
||||||
second: '10',
|
second: '10',
|
||||||
hasShownVersionAlert: false,
|
hasShownVersionAlert: false,
|
||||||
devicesList: [],
|
|
||||||
deviceId: '',
|
deviceId: '',
|
||||||
name: '',
|
name: '',
|
||||||
mac: '',
|
mac: '',
|
||||||
|
|
@ -562,7 +585,7 @@
|
||||||
disconnectTimer: null,
|
disconnectTimer: null,
|
||||||
devicetime:'',
|
devicetime:'',
|
||||||
imgpic:'',
|
imgpic:'',
|
||||||
xinp:'30',
|
xinp:'',
|
||||||
version:'',
|
version:'',
|
||||||
jiance:false,
|
jiance:false,
|
||||||
shibainum:0,
|
shibainum:0,
|
||||||
|
|
@ -574,7 +597,10 @@
|
||||||
dianya:0,
|
dianya:0,
|
||||||
sydl:'--',
|
sydl:'--',
|
||||||
zaixianobj:{},
|
zaixianobj:{},
|
||||||
modelId:''
|
modelId:'',
|
||||||
|
jsobj:{},
|
||||||
|
isLoading: false ,// 设备请求加载状态
|
||||||
|
vatatxt:''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 分享到好友(会话)
|
// 分享到好友(会话)
|
||||||
|
|
@ -595,13 +621,12 @@
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
xBlufi.initXBlufi(1)
|
xBlufi.initXBlufi(1)
|
||||||
// xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
|
|
||||||
xBlufi.notifyStartDiscoverBle({
|
|
||||||
'isStart': true
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
|
// xBlufi.notifyStartDiscoverBle({
|
||||||
|
// 'isStart': true
|
||||||
|
// })
|
||||||
|
// xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
|
||||||
// 请求个人信息
|
// 请求个人信息
|
||||||
this.getinfo()
|
this.getinfo()
|
||||||
this.getshuju() // 页面加载时启动定时器
|
this.getshuju() // 页面加载时启动定时器
|
||||||
|
|
@ -626,19 +651,26 @@
|
||||||
getsj(){
|
getsj(){
|
||||||
this.$u.get(`/app/getDeviceInfo/${this.shebid}`).then(res => {
|
this.$u.get(`/app/getDeviceInfo/${this.shebid}`).then(res => {
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
this.zaixianobj = res.data.gatewayReturnParams
|
this.zaixianobj = res.data.parameters
|
||||||
this.modelId = res.data.modelId
|
this.modelId = res.data.modelId
|
||||||
console.log(this.vardataflag,this.zaixianobj);
|
console.log(this.vardataflag,this.zaixianobj);
|
||||||
if(res.data.gatewayReturnParams.yudi.value){
|
|
||||||
this.yschecked = res.data.gatewayReturnParams.yudi.value == 0 ? true : false
|
|
||||||
}
|
|
||||||
if(res.data.gatewayReturnParams.lock.value){
|
|
||||||
this.etchecked = res.data.gatewayReturnParams.lock.value == 0 ? true : false
|
|
||||||
}
|
|
||||||
// 非蓝牙模式时,用后台数据组装渲染结构
|
// 非蓝牙模式时,用后台数据组装渲染结构
|
||||||
if(this.pre === 'WATER' && this.vardataflag != 3){
|
if(this.pre === 'WATER' && this.vardataflag != 3){
|
||||||
this.ver_data = this.buildVerDataFromBackend(this.zaixianobj)
|
this.ver_data = this.buildVerDataFromBackend(this.zaixianobj)
|
||||||
}
|
}
|
||||||
|
if(this.pre === 'pre' && this.vardataflag != 3){
|
||||||
|
this.ver_data = this.buildVerDataFromBackend(this.zaixianobj)
|
||||||
|
console.log(this.ver_data);
|
||||||
|
}
|
||||||
|
if (res.data && res.data.parameters && res.data.parameters.xinp !== undefined) {
|
||||||
|
this.xinp = res.data.parameters.xinp.value == undefined ? '--' : res.data.parameters.xinp.value
|
||||||
|
}
|
||||||
|
if (res.data && res.data.parameters && res.data.parameters.yudi !== undefined) {
|
||||||
|
this.yschecked = res.data.parameters.yudi.value == 0 ? true : false
|
||||||
|
}
|
||||||
|
if (res.data && res.data.parameters && res.data.parameters.lock !== undefined) {
|
||||||
|
this.etchecked = res.data.parameters.lock.value == 0 ? true : false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
@ -744,14 +776,18 @@
|
||||||
},
|
},
|
||||||
// 获取用户信息
|
// 获取用户信息
|
||||||
getinfo() {
|
getinfo() {
|
||||||
|
this.isLoading = true // 开始加载
|
||||||
this.$u.get(`/appVerify/profile`).then((res) => {
|
this.$u.get(`/appVerify/profile`).then((res) => {
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
this.userobj = res.data
|
this.userobj = res.data
|
||||||
// 根据用户id获取当前用户
|
// 根据用户id获取当前用户
|
||||||
this.getlist()
|
this.getlist()
|
||||||
}else if(res.code == 401){
|
}else if(res.code == 401){
|
||||||
|
this.isLoading = false // 请求失败时隐藏加载状态
|
||||||
this.jmlogin()
|
this.jmlogin()
|
||||||
}
|
}
|
||||||
|
}).catch(() => {
|
||||||
|
this.isLoading = false // 请求异常时隐藏加载状态
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
// 获取设备列表
|
// 获取设备列表
|
||||||
|
|
@ -763,28 +799,32 @@
|
||||||
this.devicelist = res.data
|
this.devicelist = res.data
|
||||||
this.imgpic = res.data[0].modelPicture
|
this.imgpic = res.data[0].modelPicture
|
||||||
this.mac = res.data[0].mac
|
this.mac = res.data[0].mac
|
||||||
setTimeout(()=>{
|
// setTimeout(()=>{
|
||||||
if(this.vardataflag == 1){
|
// if(this.vardataflag != 3){
|
||||||
this.btnlj()
|
// this.btnlj()
|
||||||
}
|
// }
|
||||||
},1000)
|
// },1000)
|
||||||
this.pre = res.data[0].pre
|
this.pre = res.data[0].pre
|
||||||
this.deviceId = res.data[0].mac.match(/.{2}/g).reverse().join(':')
|
// this.deviceId = res.data[0].mac.match(/.{2}/g).reverse().join(':')
|
||||||
this.user = res.data[0]
|
this.user = res.data[0]
|
||||||
this.shebid = res.data[0].deviceId
|
this.shebid = res.data[0].deviceId
|
||||||
this.getbanbens()
|
this.getbanbens()
|
||||||
|
this.getscjsjl()
|
||||||
setTimeout(()=>{
|
setTimeout(()=>{
|
||||||
this.getsj()
|
this.getsj()
|
||||||
},1000)
|
},1000)
|
||||||
}else{
|
}else{
|
||||||
this.bjflag = true
|
this.bjflag = true
|
||||||
}
|
}
|
||||||
|
this.isLoading = false // 请求完成后隐藏加载状态
|
||||||
}
|
}
|
||||||
|
}).catch(() => {
|
||||||
|
this.isLoading = false // 请求异常时隐藏加载状态
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
// 点击连接蓝牙函数
|
// 点击连接蓝牙函数
|
||||||
btnlj() {
|
btnlj() {
|
||||||
if(this.jiance == true){
|
this.shibainum = 0
|
||||||
xBlufi.initXBlufi(1)
|
xBlufi.initXBlufi(1)
|
||||||
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
|
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
|
||||||
xBlufi.notifyStartDiscoverBle({
|
xBlufi.notifyStartDiscoverBle({
|
||||||
|
|
@ -792,75 +832,78 @@
|
||||||
})
|
})
|
||||||
this.vardataflag = 2
|
this.vardataflag = 2
|
||||||
this.findDevice()
|
this.findDevice()
|
||||||
}else{
|
// if(this.jiance == true){
|
||||||
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
|
// xBlufi.initXBlufi(1)
|
||||||
this.vardataflag = 2
|
// xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
|
||||||
this.findDevice()
|
// xBlufi.notifyStartDiscoverBle({
|
||||||
}
|
// 'isStart': true
|
||||||
|
// })
|
||||||
|
// this.vardataflag = 2
|
||||||
|
// this.findDevice()
|
||||||
|
// }else{
|
||||||
|
// xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
|
||||||
|
// xBlufi.notifyStartDiscoverBle({ 'isStart': true })
|
||||||
|
// this.vardataflag = 2
|
||||||
|
// this.findDevice()
|
||||||
|
// }
|
||||||
},
|
},
|
||||||
// ios递归函数匹配
|
// ios递归函数匹配
|
||||||
findDevice() {
|
findDevice() {
|
||||||
// 使用 find 方法查找匹配的设备
|
let that = this;
|
||||||
const matchedDevice = this.devicesarr.find(device => {
|
const findDevices = () => {
|
||||||
console.log(device.name, this.mac, '111')
|
console.log(that.shibainum,'失败次数');
|
||||||
return device.name.slice(-12) == this.mac.slice(-12)
|
// 如果已经尝试了10次及以上,直接返回不执行
|
||||||
})
|
if (that.shibainum > 10) {
|
||||||
if (matchedDevice) {
|
that.vardataflag = 1
|
||||||
// 找到匹配的设备
|
|
||||||
xBlufi.notifyStartDiscoverBle({
|
xBlufi.notifyStartDiscoverBle({
|
||||||
'isStart': false
|
'isStart': false
|
||||||
})
|
});
|
||||||
xBlufi.notifyConnectBle({
|
// that.shibainum = 0;
|
||||||
isStart: true,
|
return;
|
||||||
deviceId: matchedDevice.deviceId,
|
|
||||||
name: matchedDevice.name
|
|
||||||
})
|
|
||||||
this.deviceId = matchedDevice.deviceId
|
|
||||||
this.name = matchedDevice.name
|
|
||||||
console.log(this.deviceId, '11221')
|
|
||||||
} else {
|
|
||||||
console.log("未找到匹配的设备,继续查找...")
|
|
||||||
setTimeout(this.findDevice.bind(this), 1000) // 使用 bind 保持 this 上下文
|
|
||||||
}
|
}
|
||||||
let that = this
|
// that.vardataflag = 2
|
||||||
const findDevices = () => {
|
that.vatatxt = '设备查找中...';
|
||||||
that.ver_dataflag = 2
|
|
||||||
const matchedDevice = that.devicesarr.find(device => {
|
const matchedDevice = that.devicesarr.find(device => {
|
||||||
if (device.name) {
|
if (device.name) {
|
||||||
return device.localName.slice(-12) == that.mac.slice(-12)
|
return device.name.slice(-12) === that.mac.slice(-12);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
if (matchedDevice) {
|
if (matchedDevice) {
|
||||||
|
// 找到设备的处理逻辑...
|
||||||
|
that.vatatxt = '查找成功,配对中...';
|
||||||
xBlufi.notifyStartDiscoverBle({
|
xBlufi.notifyStartDiscoverBle({
|
||||||
'isStart': false
|
'isStart': false
|
||||||
})
|
});
|
||||||
|
console.log(matchedDevice, '找到匹配设备');
|
||||||
xBlufi.notifyConnectBle({
|
xBlufi.notifyConnectBle({
|
||||||
isStart: true,
|
isStart: true,
|
||||||
deviceId: matchedDevice.deviceId,
|
deviceId: matchedDevice.deviceId,
|
||||||
name: matchedDevice.name
|
name: matchedDevice.name
|
||||||
})
|
});
|
||||||
that.deviceid = matchedDevice.deviceId
|
that.deviceId = matchedDevice.deviceId;
|
||||||
that.devicename = matchedDevice.name
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
console.log(this.ver_dataflag, '连接状态2');
|
console.log(that.vardataflag, '连接状态2');
|
||||||
if (that.ver_dataflag == 3) {
|
if (that.vardataflag !== 3) {
|
||||||
|
that.vardataflag = 1
|
||||||
|
that.shibainum = 0;
|
||||||
|
}
|
||||||
|
}, 4000);
|
||||||
} else {
|
} else {
|
||||||
that.ver_dataflag = 1
|
// 未找到设备,递增计数器并继续尝试
|
||||||
that.shibainum = 0
|
that.shibainum++;
|
||||||
}
|
// 只有在还没到10次时才设置定时器继续查找
|
||||||
}, 4000)
|
if (that.shibainum < 10) {
|
||||||
|
that.findDeviceTimer = setTimeout(findDevices, 1000);
|
||||||
} else {
|
} else {
|
||||||
if (that.shibainum < 3) {
|
// 达到3次尝试,重置状态
|
||||||
that.shibainum++
|
that.vardataflag = 1
|
||||||
that.findDeviceTimer = setTimeout(findDevices.bind(that), 1000) // 使用 bind 保持 this 上下文
|
that.shibainum = 0;
|
||||||
} else {
|
|
||||||
that.ver_dataflag = 1
|
|
||||||
that.shibainum = 0
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
findDevices()
|
// 重置计数器后开始查找
|
||||||
|
// that.shibainum = 0;
|
||||||
|
findDevices();
|
||||||
},
|
},
|
||||||
// 获取附近蓝牙设备列表
|
// 获取附近蓝牙设备列表
|
||||||
funListenDeviceMsgEvent: function(options) {
|
funListenDeviceMsgEvent: function(options) {
|
||||||
|
|
@ -870,11 +913,20 @@
|
||||||
this.vardataflag = 1
|
this.vardataflag = 1
|
||||||
this.clearDisconnectTimer()
|
this.clearDisconnectTimer()
|
||||||
console.log('111111111','断断断');
|
console.log('111111111','断断断');
|
||||||
|
// const pages = getCurrentPages();
|
||||||
|
// const currentPage = pages[pages.length - 1];
|
||||||
|
|
||||||
|
// console.log("当前页面路径:", currentPage.route);
|
||||||
|
// console.log("当前页面参数:", currentPage.options);
|
||||||
|
// wx.reLaunch({
|
||||||
|
// url: `/${currentPage.route}`
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS:
|
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS:
|
||||||
if (options.result) {
|
if (options.result) {
|
||||||
this.devicesarr = options.data
|
this.devicesarr = options.data
|
||||||
|
// console.log('搜索的附近设备列表',this.devicesarr);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case xBlufi.XBLUFI_TYPE.TYPE_CONNECTED:
|
case xBlufi.XBLUFI_TYPE.TYPE_CONNECTED:
|
||||||
|
|
@ -888,14 +940,18 @@
|
||||||
this.vardataflag = 3
|
this.vardataflag = 3
|
||||||
this.initDisconnectTimer()
|
this.initDisconnectTimer()
|
||||||
this.datalist = ''
|
this.datalist = ''
|
||||||
this.startDataTimeoutTimer()
|
// this.startDataTimeoutTimer()
|
||||||
xBlufi.notifySendCustomData({
|
xBlufi.notifySendCustomData({
|
||||||
customData: "11get"
|
customData: "11get"
|
||||||
})
|
})
|
||||||
}else{
|
}else{
|
||||||
|
this.vatatxt = '蓝牙服务发现失败,请重试'
|
||||||
console.log('服务发现失败:', options.data);
|
console.log('服务发现失败:', options.data);
|
||||||
this.vardataflag = 1
|
|
||||||
this.clearDisconnectTimer()
|
this.clearDisconnectTimer()
|
||||||
|
this.jiance = true
|
||||||
|
setTimeout(()=>{
|
||||||
|
this.vardataflag = 1
|
||||||
|
},5000)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case xBlufi.XBLUFI_TYPE.TYPE_INIT_ESP32_RESULT:
|
case xBlufi.XBLUFI_TYPE.TYPE_INIT_ESP32_RESULT:
|
||||||
|
|
@ -1032,6 +1088,7 @@
|
||||||
title: '设置中...'
|
title: '设置中...'
|
||||||
})
|
})
|
||||||
this.devicetime = this.getCurrentTime();
|
this.devicetime = this.getCurrentTime();
|
||||||
|
console.log(this.devicetime);
|
||||||
let parameters = {
|
let parameters = {
|
||||||
date:this.devicetime + ';'
|
date:this.devicetime + ';'
|
||||||
}
|
}
|
||||||
|
|
@ -1102,11 +1159,12 @@
|
||||||
const hours = padZero(now.getHours()); // 时 (00-23)
|
const hours = padZero(now.getHours()); // 时 (00-23)
|
||||||
const minutes = padZero(now.getMinutes()); // 分 (00-59)
|
const minutes = padZero(now.getMinutes()); // 分 (00-59)
|
||||||
const seconds = padZero(now.getSeconds()); // 秒 (00-59)
|
const seconds = padZero(now.getSeconds()); // 秒 (00-59)
|
||||||
return `${hours}:${minutes}:${seconds}`;
|
return `${hours}:${minutes}`;
|
||||||
},
|
},
|
||||||
// 点击设置当前时间
|
// 点击设置当前时间
|
||||||
confirmtime(e){
|
confirmtime(e){
|
||||||
this.devicetime = e.hour + ':' + e.minute
|
this.devicetime = e.hour + ':' + e.minute
|
||||||
|
console.log(this.devicetime);
|
||||||
if(this.vardataflag == 3){
|
if(this.vardataflag == 3){
|
||||||
this.$u.get(`/app/getModelCommand/${this.modelId}?instructionKey=date`).then(res =>{
|
this.$u.get(`/app/getModelCommand/${this.modelId}?instructionKey=date`).then(res =>{
|
||||||
if(res.code == 200){
|
if(res.code == 200){
|
||||||
|
|
@ -1371,6 +1429,27 @@
|
||||||
format(template, params) {
|
format(template, params) {
|
||||||
return template.replace(/\{(\w+)\}/g, (_, k) => params[k] ?? '');
|
return template.replace(/\{(\w+)\}/g, (_, k) => params[k] ?? '');
|
||||||
},
|
},
|
||||||
|
// 手动浇水记录
|
||||||
|
getjl(){
|
||||||
|
let that = this
|
||||||
|
let data = {
|
||||||
|
deviceId:that.shebid,
|
||||||
|
sprayingTime:that.jstime
|
||||||
|
}
|
||||||
|
that.$u.post(`/app/wateringRecord`,data).then(res =>{})
|
||||||
|
},
|
||||||
|
// 请求上次浇水记录
|
||||||
|
getscjsjl(){
|
||||||
|
this.$u.get(`/app/wateringRecord/last/${this.shebid}`).then(res =>{
|
||||||
|
if(res.code == 200){
|
||||||
|
if(res.data){
|
||||||
|
this.jsobj = res.data
|
||||||
|
}else{
|
||||||
|
this.jsobj = {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
// 确定选择时间
|
// 确定选择时间
|
||||||
btnqd() {
|
btnqd() {
|
||||||
this.handleUserAction()
|
this.handleUserAction()
|
||||||
|
|
@ -1389,6 +1468,7 @@
|
||||||
xBlufi.notifySendCustomData({
|
xBlufi.notifySendCustomData({
|
||||||
customData: '11' + this.format(res.data, {time: this.jstime})
|
customData: '11' + this.format(res.data, {time: this.jstime})
|
||||||
})
|
})
|
||||||
|
this.getjl()
|
||||||
uni.hideLoading()
|
uni.hideLoading()
|
||||||
this.startTimer(this.jstime)
|
this.startTimer(this.jstime)
|
||||||
this.sdjsflag = false
|
this.sdjsflag = false
|
||||||
|
|
@ -1417,6 +1497,7 @@
|
||||||
icon: 'success',
|
icon: 'success',
|
||||||
duration:2000
|
duration:2000
|
||||||
})
|
})
|
||||||
|
this.getjl()
|
||||||
uni.hideLoading()
|
uni.hideLoading()
|
||||||
this.startTimer(this.jstime)
|
this.startTimer(this.jstime)
|
||||||
this.sdjsflag = false
|
this.sdjsflag = false
|
||||||
|
|
@ -1536,32 +1617,36 @@
|
||||||
this.xctime = '111'
|
this.xctime = '111'
|
||||||
}
|
}
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/page_user/upload?deviceid=' + this.shebid + '&ver=' + this.ver + '&xctime=' + this.xctime + '&xipin=' + this.xinp + '&img=' + this.imgpic
|
url: '/page_user/upload?deviceid=' + this.shebid + '&ver=' + this.ver + '&xctime=' + this.xctime + '&xipin=' + this.xinp + '&img=' + this.imgpic + '&varflag=' + this.vardataflag
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
// 选择设备
|
// 选择设备
|
||||||
btnactive(deviceId,index) {
|
btnactive(deviceId,index) {
|
||||||
|
// wx.closeBLEConnection({
|
||||||
|
// deviceId: this.mac,
|
||||||
|
// })
|
||||||
|
// xBlufi.notifyConnectBle({
|
||||||
|
// isStart: false,
|
||||||
|
// deviceId: this.deviceId,
|
||||||
|
// name: this.name
|
||||||
|
// })
|
||||||
|
this.isLoading = true
|
||||||
this.shebid = deviceId
|
this.shebid = deviceId
|
||||||
this.zaixianobj = {}
|
this.zaixianobj = {}
|
||||||
|
this.ver = ''
|
||||||
|
this.jsobj = {}
|
||||||
this.btnxuanze()
|
this.btnxuanze()
|
||||||
},
|
},
|
||||||
// 选择确定设备 shebid
|
// 选择确定设备 shebid
|
||||||
btnxuanze() {
|
btnxuanze() {
|
||||||
this.$u.put(`/app/toggleDevice?userId=${this.userobj.userId}&deviceId=${this.shebid}`).then(res => {
|
this.$u.put(`/app/toggleDevice?userId=${this.userobj.userId}&deviceId=${this.shebid}`).then(res => {
|
||||||
if(res.code == 200){
|
if(res.code == 200){
|
||||||
wx.closeBLEConnection({
|
|
||||||
deviceId: this.mac,
|
|
||||||
})
|
|
||||||
xBlufi.notifyConnectBle({
|
|
||||||
isStart: false,
|
|
||||||
deviceId: this.deviceId,
|
|
||||||
name: this.name
|
|
||||||
})
|
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: res.msg,
|
title: res.msg,
|
||||||
icon: 'success',
|
icon: 'success',
|
||||||
duration: 2000
|
duration: 2000
|
||||||
})
|
})
|
||||||
|
this.csbobj = {}
|
||||||
this.datalist = ''
|
this.datalist = ''
|
||||||
this.mac = ''
|
this.mac = ''
|
||||||
this.ver_data = {}
|
this.ver_data = {}
|
||||||
|
|
@ -1576,6 +1661,7 @@
|
||||||
this.jskeds = false
|
this.jskeds = false
|
||||||
this.getshebxq()
|
this.getshebxq()
|
||||||
}else{
|
}else{
|
||||||
|
this.isLoading = false
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: res.msg,
|
title: res.msg,
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
|
|
@ -1588,20 +1674,32 @@
|
||||||
getshebxq(){
|
getshebxq(){
|
||||||
this.$u.get(`/app/getDeviceInfo/${this.shebid}`).then(res => {
|
this.$u.get(`/app/getDeviceInfo/${this.shebid}`).then(res => {
|
||||||
if(res.code == 200){
|
if(res.code == 200){
|
||||||
|
this.pre = res.data.pre
|
||||||
this.mac = res.data.mac
|
this.mac = res.data.mac
|
||||||
this.modelId = res.data.modelId
|
this.modelId = res.data.modelId
|
||||||
console.log(this.modelId,'00000');
|
console.log(this.modelId,'00000');
|
||||||
if(this.vardataflag == 1){
|
// if(this.vardataflag == 1){
|
||||||
setTimeout(()=>{
|
// setTimeout(()=>{
|
||||||
this.btnlj()
|
|
||||||
},1000)
|
|
||||||
}
|
|
||||||
this.pre = res.data.pre
|
|
||||||
this.imgpic = res.data.modelPicture
|
|
||||||
this.deviceId = res.data.mac.match(/.{2}/g).reverse().join(':')
|
|
||||||
this.user = res.data
|
|
||||||
this.getbanbens()
|
|
||||||
// this.btnlj()
|
// this.btnlj()
|
||||||
|
// },1000)
|
||||||
|
// }
|
||||||
|
this.imgpic = res.data.modelPicture
|
||||||
|
// this.deviceId = res.data.mac.match(/.{2}/g).reverse().join(':')
|
||||||
|
this.user = res.data
|
||||||
|
// setTimeout(()=>{
|
||||||
|
// this.getsj()
|
||||||
|
// },1000)
|
||||||
|
const pages = getCurrentPages();
|
||||||
|
const currentPage = pages[pages.length - 1];
|
||||||
|
this.isLoading = false
|
||||||
|
console.log("当前页面路径:", currentPage.route);
|
||||||
|
console.log("当前页面参数:", currentPage.options);
|
||||||
|
wx.reLaunch({
|
||||||
|
url: `/${currentPage.route}`
|
||||||
|
});
|
||||||
|
// this.getbanbens()
|
||||||
|
}else{
|
||||||
|
this.isLoading = false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
@ -1630,9 +1728,7 @@
|
||||||
const that = this
|
const that = this
|
||||||
that.intervalId = setInterval(() => {
|
that.intervalId = setInterval(() => {
|
||||||
if (that.vardataflag == 3) {
|
if (that.vardataflag == 3) {
|
||||||
// 发送前清空数据并开启5秒看门狗
|
|
||||||
that.datalist = ''
|
that.datalist = ''
|
||||||
that.startDataTimeoutTimer()
|
|
||||||
xBlufi.notifySendCustomData({
|
xBlufi.notifySendCustomData({
|
||||||
customData: "11get"
|
customData: "11get"
|
||||||
})
|
})
|
||||||
|
|
@ -1651,20 +1747,16 @@
|
||||||
getcsbshuju() {
|
getcsbshuju() {
|
||||||
// 1. 获取原始数据
|
// 1. 获取原始数据
|
||||||
const inputString = this.datalist;
|
const inputString = this.datalist;
|
||||||
|
|
||||||
// 2. 先处理分号(替换为逗号)
|
// 2. 先处理分号(替换为逗号)
|
||||||
const normalizedString = inputString.replace(/;/g, ',');
|
const normalizedString = inputString.replace(/;/g, ',');
|
||||||
|
|
||||||
// 3. 分割版本信息和数据部分
|
// 3. 分割版本信息和数据部分
|
||||||
const parts = normalizedString.split(':');
|
const parts = normalizedString.split(':');
|
||||||
console.log('分割结果:', parts); // 应该输出 ["ver3@p_set0", "11,5,603,99,19,9,0,"]
|
console.log('分割结果:', parts); // 应该输出 ["ver3@p_set0", "11,5,603,99,19,9,0,"]
|
||||||
|
|
||||||
// 4. 处理数据部分(移除末尾可能的多余逗号)
|
// 4. 处理数据部分(移除末尾可能的多余逗号)
|
||||||
let dataPart = parts[1];
|
let dataPart = parts[1];
|
||||||
if (dataPart.endsWith(',')) {
|
if (dataPart.endsWith(',')) {
|
||||||
dataPart = dataPart.slice(0, -1);
|
dataPart = dataPart.slice(0, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. 重新组合为期望的格式
|
// 5. 重新组合为期望的格式
|
||||||
const result = [parts[0], dataPart];
|
const result = [parts[0], dataPart];
|
||||||
console.log('最终结果:', result); // ["ver3@p_set0", "11,5,603,99,19,9,0"]
|
console.log('最终结果:', result); // ["ver3@p_set0", "11,5,603,99,19,9,0"]
|
||||||
|
|
@ -1674,26 +1766,74 @@
|
||||||
console.log(this.ver,'ververver');
|
console.log(this.ver,'ververver');
|
||||||
// 6. 继续您原来的处理逻辑
|
// 6. 继续您原来的处理逻辑
|
||||||
const timeParts = dataPart.split(',');
|
const timeParts = dataPart.split(',');
|
||||||
|
console.log(timeParts,'timePartstimePartstimePartstimePartstimePartstimePartstimePartstimePartstimePartstimePartstimePartstimePartstimePartstimePartstimePartstimePartstimePartstimePartstimeParts');
|
||||||
|
this.dianya = timeParts[timeParts.length - 1]
|
||||||
|
this.getdianliang()
|
||||||
this.csbobj = {
|
this.csbobj = {
|
||||||
hour: String(timeParts[0]).padStart(2, '0'),
|
hour: String(timeParts[0]).padStart(2, '0'),
|
||||||
minute: String(timeParts[1]).padStart(2, '0'),
|
minute: String(timeParts[1]).padStart(2, '0'),
|
||||||
second: timeParts[2],
|
second: timeParts[2],
|
||||||
day: timeParts[3]
|
day: timeParts[3]
|
||||||
};
|
};
|
||||||
|
console.log(this.csbobj,'4564654654584654564654654654654654621654652165');
|
||||||
const hours = parseInt(timeParts[4]) || 0;
|
const hours = parseInt(timeParts[4]) || 0;
|
||||||
const minutes = parseInt(timeParts[5]) || 0;
|
const minutes = parseInt(timeParts[5]) || 0;
|
||||||
this.devicetime = `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}`;
|
this.devicetime = `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}`;
|
||||||
|
|
||||||
this.ver_data = {...this.csbobj};
|
this.ver_data = {...this.csbobj};
|
||||||
|
// 生成当前时间字符串 yyyy-MM-dd HH:mm:ss
|
||||||
|
const now = new Date();
|
||||||
|
const yyyy = now.getFullYear();
|
||||||
|
const MM = String(now.getMonth() + 1).padStart(2, '0');
|
||||||
|
const dd = String(now.getDate()).padStart(2, '0');
|
||||||
|
const HH = String(now.getHours()).padStart(2, '0');
|
||||||
|
const mm = String(now.getMinutes()).padStart(2, '0');
|
||||||
|
const ss = String(now.getSeconds()).padStart(2, '0');
|
||||||
|
const at = `${yyyy}-${MM}-${dd} ${HH}:${mm}:${ss}`;
|
||||||
|
|
||||||
|
// 仅在已连接(vardataflag==3)且距离上次上传≥60秒时推送
|
||||||
|
console.log(this.ver_data);
|
||||||
|
if(this.vardataflag == 3){
|
||||||
|
const nowTs = Date.now();
|
||||||
|
if(!this.lastUploadTs || (nowTs - this.lastUploadTs) >= 2000){
|
||||||
|
let data = {
|
||||||
|
mac: this.mac,
|
||||||
|
params: {
|
||||||
|
h: {
|
||||||
|
value: String(this.ver_data.hour),
|
||||||
|
at
|
||||||
|
},
|
||||||
|
m: {
|
||||||
|
value: String(this.ver_data.minute),
|
||||||
|
at
|
||||||
|
},
|
||||||
|
t: {
|
||||||
|
value: String(this.ver_data.second),
|
||||||
|
at
|
||||||
|
},
|
||||||
|
d: {
|
||||||
|
value: String(this.ver_data.day),
|
||||||
|
at
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data.params.xinp = { value: String(this.xinp), at }
|
||||||
|
this.$u.put(`/app/updateDeviceParam`, data).then(res => {}) //上传数据
|
||||||
|
this.lastUploadTs = nowTs;
|
||||||
|
}
|
||||||
|
}
|
||||||
console.log('设备时间:', this.devicetime);
|
console.log('设备时间:', this.devicetime);
|
||||||
},
|
},
|
||||||
// 获取电量
|
// 获取电量
|
||||||
getdianliang(){
|
getdianliang(){
|
||||||
|
const nowTs = Date.now();
|
||||||
|
if(this.lastPowerTs && (nowTs - this.lastPowerTs) < 20000){
|
||||||
|
return
|
||||||
|
}
|
||||||
this.$u.get(`/app/device/remainingPower/${this.shebid}?voltage=${this.dianya / 1000}`).then(res => {
|
this.$u.get(`/app/device/remainingPower/${this.shebid}?voltage=${this.dianya / 1000}`).then(res => {
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
this.sydl = res.data
|
this.sydl = res.data
|
||||||
|
this.lastPowerTs = nowTs
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
@ -1814,6 +1954,73 @@
|
||||||
this.dianya = this.showobj.showArray[this.showobj.showArray.length - 1]
|
this.dianya = this.showobj.showArray[this.showobj.showArray.length - 1]
|
||||||
console.log('息屏',this.xinp,'电压',this.dianya);
|
console.log('息屏',this.xinp,'电压',this.dianya);
|
||||||
this.getdianliang()
|
this.getdianliang()
|
||||||
|
|
||||||
|
// 非 WATER 情况也按 { value, at } 结构上传(大量字段统一包装)
|
||||||
|
if(this.vardataflag == 3){
|
||||||
|
const now = new Date();
|
||||||
|
const yyyy = now.getFullYear();
|
||||||
|
const MM = String(now.getMonth() + 1).padStart(2, '0');
|
||||||
|
const dd = String(now.getDate()).padStart(2, '0');
|
||||||
|
const HH = String(now.getHours()).padStart(2, '0');
|
||||||
|
const mm = String(now.getMinutes()).padStart(2, '0');
|
||||||
|
const ss = String(now.getSeconds()).padStart(2, '0');
|
||||||
|
const at = `${yyyy}-${MM}-${dd} ${HH}:${mm}:${ss}`;
|
||||||
|
const nowTs = Date.now();
|
||||||
|
if(!this.lastUploadTs || (nowTs - this.lastUploadTs) >= 2000){
|
||||||
|
const wrapParams = (obj) => {
|
||||||
|
const out = {};
|
||||||
|
if(!obj || typeof obj !== 'object') return out;
|
||||||
|
Object.keys(obj).forEach((key) => {
|
||||||
|
const raw = obj[key];
|
||||||
|
const value = (raw && typeof raw === 'object' && 'value' in raw) ? raw.value : raw;
|
||||||
|
out[key] = { value: String(value == null ? '' : value), at };
|
||||||
|
});
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
// 当后台参数对象为空时,从 BLE 解析的 ver_data 构造 h1/m1/s1/o1/d1 ...
|
||||||
|
const buildParamsFromState = () => {
|
||||||
|
const params = {}
|
||||||
|
if(this.ver_data && typeof this.ver_data === 'object'){
|
||||||
|
for(let i = 1; i <= 6; i++){
|
||||||
|
const arr = this.ver_data[`p_set${i}`]
|
||||||
|
if(Array.isArray(arr) && arr.length >= 5){
|
||||||
|
params[`h${i}`] = arr[0]
|
||||||
|
params[`m${i}`] = arr[1]
|
||||||
|
params[`s${i}`] = arr[2]
|
||||||
|
params[`o${i}`] = arr[3]
|
||||||
|
params[`d${i}`] = arr[4]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return params
|
||||||
|
}
|
||||||
|
// 在 BLE 已连接场景,优先使用当前解析的 ver_data(p_set1..p_set6)
|
||||||
|
const hasVerData = (() => {
|
||||||
|
if(!this.ver_data || typeof this.ver_data !== 'object') return false;
|
||||||
|
for(let i = 1; i <= 6; i++){
|
||||||
|
const arr = this.ver_data[`p_set${i}`]
|
||||||
|
if(Array.isArray(arr) && arr.length >= 2 && (arr[0] > 0 || arr[1] > 0 || arr[2] > 0 || arr[3] > 0)){
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
})()
|
||||||
|
const hasBackend = this.zaixianobj && Object.keys(this.zaixianobj).length > 0
|
||||||
|
const chosenParams = hasVerData ? buildParamsFromState() : (hasBackend ? this.zaixianobj : {})
|
||||||
|
// 合并额外状态字段:仅保留 yudi(雨水感应)、lock(儿童锁),
|
||||||
|
// 按你的要求直接使用布尔:开启=false,关闭=true
|
||||||
|
const mergedParams = { ...chosenParams }
|
||||||
|
mergedParams.yudi = this.yschecked ? 0 : 1
|
||||||
|
mergedParams.lock = this.etchecked ? 0 : 1
|
||||||
|
let data = {
|
||||||
|
mac: this.mac,
|
||||||
|
params: wrapParams(mergedParams)
|
||||||
|
}
|
||||||
|
data.params.xinp = { value: String(this.xinp), at }
|
||||||
|
this.$u.put(`/app/updateDeviceParam`, data).then(res => {})
|
||||||
|
this.lastUploadTs = nowTs;
|
||||||
|
}
|
||||||
|
}
|
||||||
// if(this.showobj.showArray[6] != '' && this.showobj.showArray[7] != ''){
|
// if(this.showobj.showArray[6] != '' && this.showobj.showArray[7] != ''){
|
||||||
// console.log('111111111111111111111111111111111111111111111111111111111111111');
|
// console.log('111111111111111111111111111111111111111111111111111111111111111');
|
||||||
// 显式转为字符串
|
// 显式转为字符串
|
||||||
|
|
@ -1832,9 +2039,9 @@
|
||||||
initDisconnectTimer() {
|
initDisconnectTimer() {
|
||||||
this.clearDisconnectTimer()
|
this.clearDisconnectTimer()
|
||||||
this.disconnectTimer = setTimeout(() => {
|
this.disconnectTimer = setTimeout(() => {
|
||||||
if(this.vardataflag === 3) {
|
// if(this.vardataflag === 3) {
|
||||||
this.disconnectBluetooth()
|
// this.disconnectBluetooth()
|
||||||
}
|
// }
|
||||||
}, 600000)
|
}, 600000)
|
||||||
},
|
},
|
||||||
// 重置断开蓝牙定时器
|
// 重置断开蓝牙定时器
|
||||||
|
|
@ -1872,22 +2079,6 @@
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 启动5秒数据看门狗
|
|
||||||
startDataTimeoutTimer() {
|
|
||||||
if (this.dataTimeoutTimer) {
|
|
||||||
clearTimeout(this.dataTimeoutTimer)
|
|
||||||
this.dataTimeoutTimer = null
|
|
||||||
}
|
|
||||||
this.dataTimeoutTimer = setTimeout(() => {
|
|
||||||
if (this.vardataflag == 3 && !this.datalist) {
|
|
||||||
console.log('5秒未收到数据,重连蓝牙')
|
|
||||||
this.disconnectBluetooth()
|
|
||||||
setTimeout(() => {
|
|
||||||
this.btnlj()
|
|
||||||
}, 1000)
|
|
||||||
}
|
|
||||||
}, 5000)
|
|
||||||
},
|
|
||||||
// 清理5秒数据看门狗
|
// 清理5秒数据看门狗
|
||||||
clearDataTimeoutTimer() {
|
clearDataTimeoutTimer() {
|
||||||
if (this.dataTimeoutTimer) {
|
if (this.dataTimeoutTimer) {
|
||||||
|
|
@ -2504,4 +2695,36 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 加载遮罩层样式 */
|
||||||
|
.loading-mask {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100vh;
|
||||||
|
background-color: rgba(255, 255, 255, 0.8);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
z-index: 9999;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading-content {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 40rpx;
|
||||||
|
background-color: #fff;
|
||||||
|
border-radius: 20rpx;
|
||||||
|
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading-text {
|
||||||
|
margin-top: 20rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #666;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
Loading…
Reference in New Issue
Block a user