浇花器
This commit is contained in:
parent
f9341f88ee
commit
8bd7b1fbcc
|
@ -13,6 +13,7 @@
|
||||||
<view class="lt" @click="btnitem(key,index,values)">
|
<view class="lt" @click="btnitem(key,index,values)">
|
||||||
<view class="one">{{ formattedTime(values[0], values[1]) }}</view>
|
<view class="one">{{ formattedTime(values[0], values[1]) }}</view>
|
||||||
<view class="two">P{{ index + 1 }} <text></text> {{ formatTime(values[2]) }}</view>
|
<view class="two">P{{ index + 1 }} <text></text> {{ formatTime(values[2]) }}</view>
|
||||||
|
<view class="two">{{ formatInterval(values[4]) }}</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="rt">
|
<view class="rt">
|
||||||
<u-switch v-model="values[3]" @change="btnchange(key,index,values)" active-color="#48893B"
|
<u-switch v-model="values[3]" @change="btnchange(key,index,values)" active-color="#48893B"
|
||||||
|
@ -26,18 +27,26 @@
|
||||||
<view class="top">
|
<view class="top">
|
||||||
设置浇水
|
设置浇水
|
||||||
</view>
|
</view>
|
||||||
<view class="ts">
|
<view class="jssc">
|
||||||
请设置浇水时间
|
请设置浇水时间
|
||||||
</view>
|
</view>
|
||||||
<view class="shifen" @click="show = true">
|
<view class="shifen" @click="btnshowone">
|
||||||
<text>{{hour}}时</text> <text>{{minutekq}}分</text>
|
<text>{{hour}}时</text> <text>{{minutekq}}分</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="jssc">
|
<view class="jssc">
|
||||||
浇水时长
|
浇水时长
|
||||||
</view>
|
</view>
|
||||||
<view class="shifen" @click="shows = true">
|
<view class="shifen" @click="btnshowtwo">
|
||||||
<text>{{minute}}分</text> <text>{{second}}秒</text>
|
<text>{{minute}}分</text> <text>{{second}}秒</text>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="jiange">
|
||||||
|
<text>每几天浇一次</text>
|
||||||
|
<view class="number-input">
|
||||||
|
<text class="btn-minus" @click="changeDays(-1)">-</text>
|
||||||
|
<text class="days">{{jgtian || 1}}</text>
|
||||||
|
<text class="btn-plus" @click="changeDays(1)">+</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
<view class="anniu">
|
<view class="anniu">
|
||||||
<view class="qx" @click="btnqx">
|
<view class="qx" @click="btnqx">
|
||||||
取消
|
取消
|
||||||
|
@ -134,14 +143,9 @@
|
||||||
maxRetries: 3, // 最大重试次数
|
maxRetries: 3, // 最大重试次数
|
||||||
lastOperation: null, // 最后一次操作
|
lastOperation: null, // 最后一次操作
|
||||||
// 添加默认时间设置
|
// 添加默认时间设置
|
||||||
defaultTime: {
|
defaultTime:'',
|
||||||
hour: '00',
|
defaultTimeLength: '',
|
||||||
minute: '00'
|
jgtian: ''
|
||||||
},
|
|
||||||
defaultTimeLength: {
|
|
||||||
minute: '00',
|
|
||||||
second: '00'
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 分享到好友(会话)
|
// 分享到好友(会话)
|
||||||
|
@ -172,17 +176,14 @@
|
||||||
if (this.list.hasOwnProperty(key)) {
|
if (this.list.hasOwnProperty(key)) {
|
||||||
// 获取当前数组
|
// 获取当前数组
|
||||||
let arr = this.list[key];
|
let arr = this.list[key];
|
||||||
// 判断数组的最后一个元素,并进行替换
|
// 只转换开关状态(values[3])为布尔值
|
||||||
if (arr[arr.length - 1] === 0) {
|
arr[3] = arr[3] === 1;
|
||||||
arr[arr.length - 1] = false;
|
|
||||||
} else if (arr[arr.length - 1] === 1) {
|
|
||||||
arr[arr.length - 1] = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
console.log(this.list,'listlistlist')
|
||||||
console.log(this.list)
|
|
||||||
} else {
|
} else {
|
||||||
this.csbobj = JSON.parse(option.list)
|
this.csbobj = JSON.parse(option.list)
|
||||||
|
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
|
||||||
|
@ -198,11 +199,28 @@
|
||||||
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
// 点击选择浇水时间
|
||||||
|
btnshowone(){
|
||||||
|
this.defaultTime = (this.hour.length < 10 ? '0' + this.hour : this.hour) + ':' + (this.minutekq.length < 10 ? '0' + this.minutekq : this.minutekq)
|
||||||
|
this.show = true
|
||||||
|
},
|
||||||
|
// 点击选择浇水时长
|
||||||
|
btnshowtwo(){
|
||||||
|
console.log(this.defaultTimeLength,this.minute,this.second,'111');
|
||||||
|
this.defaultTimeLength = '00' + ':' + this.minute + ':' + this.second
|
||||||
|
console.log(this.defaultTimeLength,this.minute,this.second,'222');
|
||||||
|
this.shows = true
|
||||||
|
},
|
||||||
// 显示加载
|
// 显示加载
|
||||||
showLoading() {
|
showLoading() {
|
||||||
this.isLoading = true;
|
this.isLoading = true;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 格式化间隔天数显示
|
||||||
|
formatInterval(days) {
|
||||||
|
return days <= 1 ? '每天浇一次' : '每' + days + '天浇一次';
|
||||||
|
},
|
||||||
|
|
||||||
// 隐藏加载
|
// 隐藏加载
|
||||||
hideLoading() {
|
hideLoading() {
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
|
@ -253,16 +271,15 @@
|
||||||
array[lastIndex] = !lastElement;
|
array[lastIndex] = !lastElement;
|
||||||
this.deviceflag = lastElement ? 0 : 1;
|
this.deviceflag = lastElement ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
let flag = values[3] == 0 ? 1 : 0
|
||||||
let cucun = '11num' + this.deviceindex + '@' + this.devicehour + '@' + this.deviceminute + '@' + this.devicemiao + '@' + this.deviceflag + '@';
|
let cucun = '11p_set' + (Number(this.deviceindex) + 1)+ ':' + this.devicehour + ',' + this.deviceminute + ',' + this.devicemiao + ',' + flag + ',' + this.jgtian + ';'
|
||||||
this.lastOperation = () => {
|
this.lastOperation = () => {
|
||||||
xBlufi.notifySendCustomData({
|
xBlufi.notifySendCustomData({
|
||||||
customData: cucun
|
customData: cucun
|
||||||
});
|
})
|
||||||
};
|
}
|
||||||
this.lastOperation();
|
this.lastOperation()
|
||||||
|
await this.delay(1000)
|
||||||
await this.delay(1000);
|
|
||||||
xBlufi.notifySendCustomData({
|
xBlufi.notifySendCustomData({
|
||||||
customData: "11get"
|
customData: "11get"
|
||||||
});
|
});
|
||||||
|
@ -279,7 +296,9 @@
|
||||||
|
|
||||||
// 点击设置定时时间
|
// 点击设置定时时间
|
||||||
btnitem(key, index, values) {
|
btnitem(key, index, values) {
|
||||||
this.deviceindex = index
|
// 从 key 中提取索引号,例如从 'p_set1' 提取 '1'
|
||||||
|
const indexMatch = key.match(/p_set(\d+)/);
|
||||||
|
this.deviceindex = indexMatch ? indexMatch[1] : index;
|
||||||
this.timeflag = true
|
this.timeflag = true
|
||||||
this.hour = values[0]
|
this.hour = values[0]
|
||||||
this.minutekq = values[1]
|
this.minutekq = values[1]
|
||||||
|
@ -290,14 +309,16 @@
|
||||||
const formattedSeconds = seconds < 10 ? '0' + seconds : seconds.toString()
|
const formattedSeconds = seconds < 10 ? '0' + seconds : seconds.toString()
|
||||||
this.minute = formattedMinutes
|
this.minute = formattedMinutes
|
||||||
this.second = formattedSeconds
|
this.second = formattedSeconds
|
||||||
|
// 添加间隔天数的处理,确保为数字
|
||||||
|
this.jgtian = parseInt(values[4]) || 0
|
||||||
|
// 设置设备相关值
|
||||||
|
this.devicehour = values[0]
|
||||||
|
this.deviceminute = values[1]
|
||||||
|
this.devicemiao = values[2]
|
||||||
if (this.list.hasOwnProperty(key)) {
|
if (this.list.hasOwnProperty(key)) {
|
||||||
const array = this.list[key]
|
const array = this.list[key]
|
||||||
const lastElement = array[array.length - 1]
|
// 只转换开关状态为布尔值
|
||||||
if (lastElement) {
|
this.deviceflag = array[3] ? 1 : 0
|
||||||
this.deviceflag = 1
|
|
||||||
} else {
|
|
||||||
this.deviceflag = 0
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -326,14 +347,17 @@
|
||||||
// 确定选择设置定时时间
|
// 确定选择设置定时时间
|
||||||
async btnqd() {
|
async btnqd() {
|
||||||
try {
|
try {
|
||||||
this.showLoading();
|
this.showLoading()
|
||||||
this.timeflag = false;
|
this.timeflag = false
|
||||||
this.hour = '--';
|
this.hour = '--'
|
||||||
this.minutekq = '--';
|
this.minutekq = '--'
|
||||||
this.minute = '--';
|
this.minute = '--'
|
||||||
this.second = '--';
|
this.second = '--'
|
||||||
|
|
||||||
let cucun = '11num' + this.deviceindex + '@' + this.devicehour + '@' + this.deviceminute + '@' + this.devicemiao + '@' + this.deviceflag + '@';
|
// 确保间隔天数为数字
|
||||||
|
const intervalDays = parseInt(this.jgtian) || 0;
|
||||||
|
|
||||||
|
let cucun = '11p_set' + this.deviceindex + ':' + this.devicehour + ',' + this.deviceminute + ',' + this.devicemiao + ',' + 1 + ',' + intervalDays + ';'
|
||||||
this.lastOperation = () => {
|
this.lastOperation = () => {
|
||||||
xBlufi.notifySendCustomData({
|
xBlufi.notifySendCustomData({
|
||||||
customData: cucun
|
customData: cucun
|
||||||
|
@ -375,7 +399,7 @@
|
||||||
|
|
||||||
this.showLoading();
|
this.showLoading();
|
||||||
this.timeflag = false;
|
this.timeflag = false;
|
||||||
let cucun = '11num0' + '@' + this.shi + '@' + this.fen + '@' + this.miao + '@' + this.tian + '@';
|
let cucun = '11p_set0' + ',' + this.shi + ',' + this.fen + ',' + this.miao + ',' + this.tian + ',' + this.jgtian;
|
||||||
this.lastOperation = () => {
|
this.lastOperation = () => {
|
||||||
xBlufi.notifySendCustomData({
|
xBlufi.notifySendCustomData({
|
||||||
customData: cucun
|
customData: cucun
|
||||||
|
@ -445,6 +469,8 @@
|
||||||
const parsed = parseInt(num);
|
const parsed = parseInt(num);
|
||||||
return isNaN(parsed) ? 0 : parsed;
|
return isNaN(parsed) ? 0 : parsed;
|
||||||
});
|
});
|
||||||
|
// 只转换开关状态为布尔值
|
||||||
|
numbers[3] = numbers[3] === 1;
|
||||||
pSetObjects[key] = numbers;
|
pSetObjects[key] = numbers;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('数据解析错误:', e);
|
console.error('数据解析错误:', e);
|
||||||
|
@ -454,13 +480,6 @@
|
||||||
|
|
||||||
if (Object.keys(pSetObjects).length > 0) {
|
if (Object.keys(pSetObjects).length > 0) {
|
||||||
this.list = pSetObjects;
|
this.list = pSetObjects;
|
||||||
|
|
||||||
for (let key in this.list) {
|
|
||||||
if (this.list.hasOwnProperty(key)) {
|
|
||||||
let arr = this.list[key];
|
|
||||||
arr[arr.length - 1] = arr[arr.length - 1] === 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const input = options.data.slice(0, -1) + ";"
|
const input = options.data.slice(0, -1) + ";"
|
||||||
|
@ -490,6 +509,12 @@
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// 改变天数
|
||||||
|
changeDays(change) {
|
||||||
|
let newValue = (parseInt(this.jgtian) || 1) + change;
|
||||||
|
// 确保天数不小于1
|
||||||
|
this.jgtian = Math.max(1, newValue);
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -535,7 +560,9 @@
|
||||||
left: 50%;
|
left: 50%;
|
||||||
transform: translateX(-50%);
|
transform: translateX(-50%);
|
||||||
width: 678rpx;
|
width: 678rpx;
|
||||||
height: 800rpx;
|
max-height: 1200rpx;
|
||||||
|
padding-bottom: 30rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
background: #FFFFFF;
|
background: #FFFFFF;
|
||||||
border-radius: 24rpx 24rpx 24rpx 24rpx;
|
border-radius: 24rpx 24rpx 24rpx 24rpx;
|
||||||
z-index: 99;
|
z-index: 99;
|
||||||
|
@ -586,6 +613,49 @@
|
||||||
margin-left: 96rpx;
|
margin-left: 96rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.jiange {
|
||||||
|
width: 512rpx;
|
||||||
|
margin: 30rpx auto 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
|
||||||
|
text {
|
||||||
|
font-size: 32rpx;
|
||||||
|
color: #808080;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.number-input {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
background: #F0F0F0;
|
||||||
|
border-radius: 16rpx;
|
||||||
|
padding: 0 20rpx;
|
||||||
|
height: 80rpx;
|
||||||
|
|
||||||
|
.btn-minus, .btn-plus {
|
||||||
|
width: 60rpx;
|
||||||
|
height: 60rpx;
|
||||||
|
line-height: 60rpx;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 40rpx;
|
||||||
|
color: #48893B;
|
||||||
|
font-weight: bold;
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 8rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.days {
|
||||||
|
margin: 0 30rpx;
|
||||||
|
min-width: 60rpx;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 32rpx;
|
||||||
|
color: #3D3D3D;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.anniu {
|
.anniu {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
@ -633,7 +703,7 @@
|
||||||
.list {
|
.list {
|
||||||
.list_val {
|
.list_val {
|
||||||
width: 678rpx;
|
width: 678rpx;
|
||||||
height: 208rpx;
|
height: 248rpx;
|
||||||
background: #FFFFFF;
|
background: #FFFFFF;
|
||||||
box-shadow: 0rpx 10rpx 64rpx 0rpx rgba(0, 0, 0, 0.08);
|
box-shadow: 0rpx 10rpx 64rpx 0rpx rgba(0, 0, 0, 0.08);
|
||||||
border-radius: 20rpx;
|
border-radius: 20rpx;
|
||||||
|
|
|
@ -197,6 +197,7 @@
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
this.user = res.data
|
this.user = res.data
|
||||||
this.getbanbens()
|
this.getbanbens()
|
||||||
|
// this.file = 'https://wc.chuangtewl.com/download/water_flower(4).bin'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -232,6 +233,16 @@
|
||||||
},
|
},
|
||||||
// 选择固件版本
|
// 选择固件版本
|
||||||
gjconfirm(e) {
|
gjconfirm(e) {
|
||||||
|
// console.log('更新',this.file);
|
||||||
|
// var data = {
|
||||||
|
// sum: 100,
|
||||||
|
// http: this.file
|
||||||
|
// }
|
||||||
|
// xBlufi.notifySendCustomData({
|
||||||
|
// customData: data
|
||||||
|
// })
|
||||||
|
// this.shengjiflag = true
|
||||||
|
// this.startProgress()
|
||||||
if(this.ver != null && this.ver != this.version){
|
if(this.ver != null && this.ver != this.version){
|
||||||
if(this.file == '' || this.file == null){
|
if(this.file == '' || this.file == null){
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
|
|
|
@ -79,7 +79,7 @@
|
||||||
</view>
|
</view>
|
||||||
<view class="deviceweek" v-if="pre == 'WATER'">
|
<view class="deviceweek" v-if="pre == 'WATER'">
|
||||||
<view class="weeklist">
|
<view class="weeklist">
|
||||||
<view class="kg" v-if="ver_data.p_set0[3] == 0">
|
<view class="kg" v-if="!ver_data.p_set1 || ver_data.p_set1[3] == 0">
|
||||||
OFF
|
OFF
|
||||||
</view>
|
</view>
|
||||||
<view class="kg" style="color: #48893B;" v-else>
|
<view class="kg" style="color: #48893B;" v-else>
|
||||||
|
@ -88,27 +88,14 @@
|
||||||
<view class="weekday">
|
<view class="weekday">
|
||||||
P1
|
P1
|
||||||
</view>
|
</view>
|
||||||
<view class="">
|
<view class="time">
|
||||||
{{ver_data.p_set0[0] == undefined ? '' : ver_data.p_set0[0] + ':'}}{{ver_data.p_set0[1] == undefined ? '' : ver_data.p_set0[1]}}
|
{{ver_data.p_set1 && ver_data.p_set1[0] !== undefined ? ver_data.p_set1[0].toString().padStart(2, '0') + ':' + ver_data.p_set1[1].toString().padStart(2, '0') : '--:--'}}
|
||||||
</view>
|
</view>
|
||||||
<view class="img">
|
<view class="interval" v-if="ver_data.p_set1 && ver_data.p_set1[4] > 1">
|
||||||
<image v-if="ver_data.p_set0 && ver_data.p_set0[0] == xctimesj.slice(0,2) && ver_data.p_set0[1] == xctimesj.slice(-2)"
|
每{{ver_data.p_set1[4]}}天
|
||||||
src="https://api.ccttiot.com/smartmeter/img/static/u9iZpd6bW6bUsUay4uvH" mode="">
|
|
||||||
</image>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
<view class="interval" v-else>
|
||||||
<view class="weeklist">
|
每天
|
||||||
<view class="kg" v-if="ver_data.p_set1[3] == 0">
|
|
||||||
OFF
|
|
||||||
</view>
|
|
||||||
<view class="kg" style="color: #48893B;" v-else>
|
|
||||||
ON
|
|
||||||
</view>
|
|
||||||
<view class="weekday">
|
|
||||||
P2
|
|
||||||
</view>
|
|
||||||
<view class="">
|
|
||||||
{{ver_data.p_set1[0] == undefined ? '' : ver_data.p_set1[0] + ':'}}{{ver_data.p_set1[1] == undefined ? '' : ver_data.p_set1[1]}}
|
|
||||||
</view>
|
</view>
|
||||||
<view class="img">
|
<view class="img">
|
||||||
<image v-if="ver_data.p_set1 && ver_data.p_set1[0] == xctimesj.slice(0,2) && ver_data.p_set1[1] == xctimesj.slice(-2)"
|
<image v-if="ver_data.p_set1 && ver_data.p_set1[0] == xctimesj.slice(0,2) && ver_data.p_set1[1] == xctimesj.slice(-2)"
|
||||||
|
@ -117,17 +104,23 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="weeklist">
|
<view class="weeklist">
|
||||||
<view class="kg" v-if="ver_data.p_set2[3] == 0">
|
<view class="kg" v-if="!ver_data.p_set2 || ver_data.p_set2[3] == 0">
|
||||||
OFF
|
OFF
|
||||||
</view>
|
</view>
|
||||||
<view class="kg" style="color: #48893B;" v-else>
|
<view class="kg" style="color: #48893B;" v-else>
|
||||||
ON
|
ON
|
||||||
</view>
|
</view>
|
||||||
<view class="weekday">
|
<view class="weekday">
|
||||||
P3
|
P2
|
||||||
</view>
|
</view>
|
||||||
<view class="">
|
<view class="time">
|
||||||
{{ver_data.p_set2[0] == undefined ? '' : ver_data.p_set2[0] + ':'}}{{ver_data.p_set2[1] == undefined ? '' : ver_data.p_set2[1]}}
|
{{ver_data.p_set2 && ver_data.p_set2[0] !== undefined ? ver_data.p_set2[0].toString().padStart(2, '0') + ':' + ver_data.p_set2[1].toString().padStart(2, '0') : '--:--'}}
|
||||||
|
</view>
|
||||||
|
<view class="interval" v-if="ver_data.p_set2 && ver_data.p_set2[4] > 1">
|
||||||
|
每{{ver_data.p_set2[4]}}天
|
||||||
|
</view>
|
||||||
|
<view class="interval" v-else>
|
||||||
|
每天
|
||||||
</view>
|
</view>
|
||||||
<view class="img">
|
<view class="img">
|
||||||
<image v-if="ver_data.p_set2 && ver_data.p_set2[0] == xctimesj.slice(0,2) && ver_data.p_set2[1] == xctimesj.slice(-2)"
|
<image v-if="ver_data.p_set2 && ver_data.p_set2[0] == xctimesj.slice(0,2) && ver_data.p_set2[1] == xctimesj.slice(-2)"
|
||||||
|
@ -136,17 +129,23 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="weeklist">
|
<view class="weeklist">
|
||||||
<view class="kg" v-if="ver_data.p_set3[3] == 0">
|
<view class="kg" v-if="!ver_data.p_set3 || ver_data.p_set3[3] == 0">
|
||||||
OFF
|
OFF
|
||||||
</view>
|
</view>
|
||||||
<view class="kg" style="color: #48893B;" v-else>
|
<view class="kg" style="color: #48893B;" v-else>
|
||||||
ON
|
ON
|
||||||
</view>
|
</view>
|
||||||
<view class="weekday">
|
<view class="weekday">
|
||||||
P4
|
P3
|
||||||
</view>
|
</view>
|
||||||
<view class="">
|
<view class="time">
|
||||||
{{ver_data.p_set3[0] == undefined ? '' : ver_data.p_set3[0] + ':'}}{{ver_data.p_set3[1] == undefined ? '' : ver_data.p_set3[1]}}
|
{{ver_data.p_set3 && ver_data.p_set3[0] !== undefined ? ver_data.p_set3[0].toString().padStart(2, '0') + ':' + ver_data.p_set3[1].toString().padStart(2, '0') : '--:--'}}
|
||||||
|
</view>
|
||||||
|
<view class="interval" v-if="ver_data.p_set3 && ver_data.p_set3[4] > 1">
|
||||||
|
每{{ver_data.p_set3[4]}}天
|
||||||
|
</view>
|
||||||
|
<view class="interval" v-else>
|
||||||
|
每天
|
||||||
</view>
|
</view>
|
||||||
<view class="img">
|
<view class="img">
|
||||||
<image v-if="ver_data.p_set3 && ver_data.p_set3[0] == xctimesj.slice(0,2) && ver_data.p_set3[1] == xctimesj.slice(-2)"
|
<image v-if="ver_data.p_set3 && ver_data.p_set3[0] == xctimesj.slice(0,2) && ver_data.p_set3[1] == xctimesj.slice(-2)"
|
||||||
|
@ -155,17 +154,23 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="weeklist">
|
<view class="weeklist">
|
||||||
<view class="kg" v-if="ver_data.p_set4[3] == 0">
|
<view class="kg" v-if="!ver_data.p_set4 || ver_data.p_set4[3] == 0">
|
||||||
OFF
|
OFF
|
||||||
</view>
|
</view>
|
||||||
<view class="kg" style="color: #48893B;" v-else>
|
<view class="kg" style="color: #48893B;" v-else>
|
||||||
ON
|
ON
|
||||||
</view>
|
</view>
|
||||||
<view class="weekday">
|
<view class="weekday">
|
||||||
P5
|
P4
|
||||||
</view>
|
</view>
|
||||||
<view class="">
|
<view class="time">
|
||||||
{{ver_data.p_set4[0] == undefined ? '' : ver_data.p_set4[0] + ':'}}{{ver_data.p_set4[1] == undefined ? '' : ver_data.p_set4[1]}}
|
{{ver_data.p_set4 && ver_data.p_set4[0] !== undefined ? ver_data.p_set4[0].toString().padStart(2, '0') + ':' + ver_data.p_set4[1].toString().padStart(2, '0') : '--:--'}}
|
||||||
|
</view>
|
||||||
|
<view class="interval" v-if="ver_data.p_set4 && ver_data.p_set4[4] > 1">
|
||||||
|
每{{ver_data.p_set4[4]}}天
|
||||||
|
</view>
|
||||||
|
<view class="interval" v-else>
|
||||||
|
每天
|
||||||
</view>
|
</view>
|
||||||
<view class="img">
|
<view class="img">
|
||||||
<image v-if="ver_data.p_set4 && ver_data.p_set4[0] == xctimesj.slice(0,2) && ver_data.p_set4[1] == xctimesj.slice(-2)"
|
<image v-if="ver_data.p_set4 && ver_data.p_set4[0] == xctimesj.slice(0,2) && ver_data.p_set4[1] == xctimesj.slice(-2)"
|
||||||
|
@ -174,7 +179,32 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="weeklist">
|
<view class="weeklist">
|
||||||
<view class="kg" v-if="ver_data.p_set5[3] == 0">
|
<view class="kg" v-if="!ver_data.p_set5 || ver_data.p_set5[3] == 0">
|
||||||
|
OFF
|
||||||
|
</view>
|
||||||
|
<view class="kg" style="color: #48893B;" v-else>
|
||||||
|
ON
|
||||||
|
</view>
|
||||||
|
<view class="weekday">
|
||||||
|
P5
|
||||||
|
</view>
|
||||||
|
<view class="time">
|
||||||
|
{{ver_data.p_set5 && ver_data.p_set5[0] !== undefined ? ver_data.p_set5[0].toString().padStart(2, '0') + ':' + ver_data.p_set5[1].toString().padStart(2, '0') : '--:--'}}
|
||||||
|
</view>
|
||||||
|
<view class="interval" v-if="ver_data.p_set5 && ver_data.p_set5[4] > 1">
|
||||||
|
每{{ver_data.p_set5[4]}}天
|
||||||
|
</view>
|
||||||
|
<view class="interval" v-else>
|
||||||
|
每天
|
||||||
|
</view>
|
||||||
|
<view class="img">
|
||||||
|
<image v-if="ver_data.p_set5 && ver_data.p_set5[0] == xctimesj.slice(0,2) && ver_data.p_set5[1] == xctimesj.slice(-2)"
|
||||||
|
src="https://api.ccttiot.com/smartmeter/img/static/u9iZpd6bW6bUsUay4uvH" mode="">
|
||||||
|
</image>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="weeklist">
|
||||||
|
<view class="kg" v-if="!ver_data.p_set6 || ver_data.p_set6[3] == 0">
|
||||||
OFF
|
OFF
|
||||||
</view>
|
</view>
|
||||||
<view class="kg" style="color: #48893B;" v-else>
|
<view class="kg" style="color: #48893B;" v-else>
|
||||||
|
@ -183,11 +213,17 @@
|
||||||
<view class="weekday">
|
<view class="weekday">
|
||||||
P6
|
P6
|
||||||
</view>
|
</view>
|
||||||
<view class="">
|
<view class="time">
|
||||||
{{ver_data.p_set5[0] == undefined ? '' : ver_data.p_set5[0] + ':'}}{{ver_data.p_set5[1] == undefined ? '' : ver_data.p_set5[1]}}
|
{{ver_data.p_set6 && ver_data.p_set6[0] !== undefined ? ver_data.p_set6[0].toString().padStart(2, '0') + ':' + ver_data.p_set6[1].toString().padStart(2, '0') : '--:--'}}
|
||||||
|
</view>
|
||||||
|
<view class="interval" v-if="ver_data.p_set6 && ver_data.p_set6[4] > 1">
|
||||||
|
每{{ver_data.p_set6[4]}}天
|
||||||
|
</view>
|
||||||
|
<view class="interval" v-else>
|
||||||
|
每天
|
||||||
</view>
|
</view>
|
||||||
<view class="img">
|
<view class="img">
|
||||||
<image v-if="ver_data.p_set5 && ver_data.p_set5[0] == xctimesj.slice(0,2) && ver_data.p_set5[1] == xctimesj.slice(-2)"
|
<image v-if="ver_data.p_set6 && ver_data.p_set6[0] == xctimesj.slice(0,2) && ver_data.p_set6[1] == xctimesj.slice(-2)"
|
||||||
src="https://api.ccttiot.com/smartmeter/img/static/u9iZpd6bW6bUsUay4uvH" mode="">
|
src="https://api.ccttiot.com/smartmeter/img/static/u9iZpd6bW6bUsUay4uvH" mode="">
|
||||||
</image>
|
</image>
|
||||||
</view>
|
</view>
|
||||||
|
@ -341,7 +377,7 @@
|
||||||
},
|
},
|
||||||
minute: '--',
|
minute: '--',
|
||||||
second: '--',
|
second: '--',
|
||||||
|
hasShownVersionAlert: false,
|
||||||
devicesList: [],
|
devicesList: [],
|
||||||
deviceId: '',
|
deviceId: '',
|
||||||
name: '',
|
name: '',
|
||||||
|
@ -515,7 +551,7 @@
|
||||||
if (that.deviceId != '') {
|
if (that.deviceId != '') {
|
||||||
let systemInfo = uni.getSystemInfoSync()
|
let systemInfo = uni.getSystemInfoSync()
|
||||||
if (systemInfo.platform == 'android') {
|
if (systemInfo.platform == 'android') {
|
||||||
console.log("进入这里是IOS")
|
console.log("进入这里是Android")
|
||||||
xBlufi.notifyStartDiscoverBle({
|
xBlufi.notifyStartDiscoverBle({
|
||||||
'isStart': false
|
'isStart': false
|
||||||
})
|
})
|
||||||
|
@ -527,9 +563,8 @@
|
||||||
name: that.name
|
name: that.name
|
||||||
})
|
})
|
||||||
} else if (systemInfo.platform == 'ios') {
|
} else if (systemInfo.platform == 'ios') {
|
||||||
// 当前设备是 iOS
|
|
||||||
console.log("进入这里是IOS")
|
console.log("进入这里是IOS")
|
||||||
that.findDevice() //使用递归函数不断去匹配
|
that.findDevice()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -903,13 +938,20 @@
|
||||||
xBlufi.notifyInitBleEsp32({
|
xBlufi.notifyInitBleEsp32({
|
||||||
deviceId: this.deviceId
|
deviceId: this.deviceId
|
||||||
})
|
})
|
||||||
|
// 连接成功后立即发送一次获取数据命令
|
||||||
|
setTimeout(() => {
|
||||||
|
console.log("连接成功后发送获取数据命令")
|
||||||
|
xBlufi.notifySendCustomData({
|
||||||
|
customData: "11get"
|
||||||
|
})
|
||||||
|
}, 1000)
|
||||||
}else{
|
}else{
|
||||||
this.vardataflag = 1
|
this.vardataflag = 1
|
||||||
this.clearDisconnectTimer()
|
this.clearDisconnectTimer()
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA:
|
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA:
|
||||||
console.log("1收到设备发来的自定义数据结果:", options.data,options.data.length)
|
console.log("收到设备数据:", options.data)
|
||||||
if (options.data.indexOf("prom:") !== -1) {
|
if (options.data.indexOf("prom:") !== -1) {
|
||||||
console.log('固件升级中')
|
console.log('固件升级中')
|
||||||
var indexOld = options.data.substring(options.data.indexOf('prom:'))
|
var indexOld = options.data.substring(options.data.indexOf('prom:'))
|
||||||
|
@ -951,7 +993,7 @@
|
||||||
})
|
})
|
||||||
},1000)
|
},1000)
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
this.datalist = options.data.slice(0, -1) + ";"
|
this.datalist = options.data.slice(0, -1) + ";"
|
||||||
this.vardataflag = 3
|
this.vardataflag = 3
|
||||||
if(this.pre == 'WATER'){
|
if(this.pre == 'WATER'){
|
||||||
|
@ -974,11 +1016,11 @@
|
||||||
const that = this
|
const that = this
|
||||||
that.intervalId = setInterval(() => {
|
that.intervalId = setInterval(() => {
|
||||||
if (that.vardataflag == 3) {
|
if (that.vardataflag == 3) {
|
||||||
|
console.log("发送获取数据命令")
|
||||||
xBlufi.notifySendCustomData({
|
xBlufi.notifySendCustomData({
|
||||||
customData: "11get"
|
customData: "11get"
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
console.log("定时器一段时间执行一次")
|
|
||||||
}, 10000)
|
}, 10000)
|
||||||
},
|
},
|
||||||
// 清除定时器
|
// 清除定时器
|
||||||
|
@ -1009,41 +1051,87 @@
|
||||||
// 处理从设备接收数据
|
// 处理从设备接收数据
|
||||||
getchuli() {
|
getchuli() {
|
||||||
const inputString = this.datalist;
|
const inputString = this.datalist;
|
||||||
|
console.log('接收到的数据:', inputString);
|
||||||
|
|
||||||
// 检查是否有 @ 分隔符
|
// 检查是否有 @ 分隔符
|
||||||
const hasAtSymbol = inputString.includes('@');
|
const hasAtSymbol = inputString.includes('@');
|
||||||
let processedString;
|
let processedString;
|
||||||
|
let currentDay = 0;
|
||||||
|
|
||||||
if (hasAtSymbol) {
|
if (hasAtSymbol) {
|
||||||
const [ver, restOfString] = inputString.split('@');
|
const [ver, restOfString] = inputString.split('@');
|
||||||
this.ver = ver || '';
|
this.ver = ver || '';
|
||||||
processedString = restOfString || ''; // 如果 restOfString 是 undefined,设置为空字符串
|
processedString = restOfString || '';
|
||||||
|
|
||||||
|
// 解析当前天数
|
||||||
|
const showMatch = processedString.match(/show:([^;]+)/);
|
||||||
|
if (showMatch) {
|
||||||
|
const showValues = showMatch[1].split(',');
|
||||||
|
currentDay = parseInt(showValues[showValues.length - 1]) || 0;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
processedString = inputString; // 如果没有 @,直接使用整个字符串
|
processedString = inputString;
|
||||||
this.ver = ''; // 如果没有 @,ver 设置为空
|
this.ver = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(this.ver, processedString, 'ververver');
|
console.log('处理后的字符串:', processedString);
|
||||||
|
console.log(this.ver,'this.verthis.verthis.verthis.ver')
|
||||||
|
|
||||||
const pairs = processedString.split(';').filter(Boolean); // 过滤掉空字符串
|
const version = this.ver;
|
||||||
console.log(pairs, '10101010');
|
// 使用正则表达式提取数字部分
|
||||||
|
const versionNumber = version.match(/\d+/); // 匹配连续的数字
|
||||||
|
if (versionNumber) {
|
||||||
|
const num = parseInt(versionNumber[0], 10); // 转换为整数
|
||||||
|
if (num < 9 && !this.hasShownVersionAlert) {
|
||||||
|
this.hasShownVersionAlert = true; // 设置标记为已显示
|
||||||
|
uni.showModal({
|
||||||
|
title: "提示",
|
||||||
|
content: `您当前设备版本过低,可能无法正常使用,请点击右上角设置前去升级`,
|
||||||
|
showCancel: false, // 不显示取消按钮
|
||||||
|
confirmText: "确定", // 按钮文字
|
||||||
|
success: (res) => {
|
||||||
|
if (res.confirm) {
|
||||||
|
console.log("用户点击了确定");
|
||||||
|
this.hasShownVersionAlert = false; // 重置标记,允许下次判断
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
console.log(`版本号 ${num} 不小于 9`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log("没有找到版本号数字");
|
||||||
|
}
|
||||||
|
|
||||||
|
const pairs = processedString.split(';').filter(Boolean);
|
||||||
|
console.log('分割后的数据对:', pairs);
|
||||||
|
|
||||||
const showObject = {};
|
const showObject = {};
|
||||||
const pSetObjects = {};
|
const pSetObjects = {};
|
||||||
|
|
||||||
|
// 初始化所有p_set为默认值
|
||||||
|
for (let i = 1; i <= 6; i++) {
|
||||||
|
pSetObjects[`p_set${i}`] = [0, 0, 0, 0, 0];
|
||||||
|
}
|
||||||
|
|
||||||
// 解析字符串
|
// 解析字符串
|
||||||
pairs.forEach(pair => {
|
pairs.forEach(pair => {
|
||||||
const [key, value] = pair.split(':');
|
const [key, value] = pair.split(':');
|
||||||
if (key === 'show') {
|
if (key === 'show') {
|
||||||
showObject.showArray = value.split(',').map(Number);
|
showObject.showArray = value.split(',').map(Number);
|
||||||
} else if (key.startsWith('p_set')) {
|
} else if (key.startsWith('p_set')) {
|
||||||
pSetObjects[key] = value.split(',').map(Number);
|
const values = value.split(',').map(Number);
|
||||||
|
// 确保数组长度为5
|
||||||
|
while (values.length < 5) {
|
||||||
|
values.push(0);
|
||||||
|
}
|
||||||
|
pSetObjects[key] = values;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.ver_data = pSetObjects; // 六个浇水时间段
|
this.ver_data = pSetObjects;
|
||||||
this.jstimeobj = pSetObjects;
|
this.jstimeobj = pSetObjects;
|
||||||
this.showobj = showObject; // 雨滴,锁,等是否开启
|
this.showobj = showObject;
|
||||||
|
|
||||||
// 设置开关状态
|
// 设置开关状态
|
||||||
this.yschecked = this.showobj.showArray[1] !== 1;
|
this.yschecked = this.showobj.showArray[1] !== 1;
|
||||||
|
@ -1065,9 +1153,10 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
const getTimeFromArray = (timeArray) => {
|
const getTimeFromArray = (timeArray) => {
|
||||||
const [hour, minute, , second] = timeArray;
|
if (!timeArray || timeArray.length < 2) return null;
|
||||||
|
const [hour, minute] = timeArray;
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
date.setHours(hour, minute, second, 0); // 毫秒设为0
|
date.setHours(hour, minute, 0, 0);
|
||||||
return date;
|
return date;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1080,9 +1169,15 @@
|
||||||
if (this.ver_data.hasOwnProperty(key) && this.ver_data[key][3] === 1) {
|
if (this.ver_data.hasOwnProperty(key) && this.ver_data[key][3] === 1) {
|
||||||
const timeArray = this.ver_data[key];
|
const timeArray = this.ver_data[key];
|
||||||
const timeDate = getTimeFromArray(timeArray);
|
const timeDate = getTimeFromArray(timeArray);
|
||||||
const diff = calculateTimeDifference(timeDate, new Date());
|
if (!timeDate) continue;
|
||||||
|
|
||||||
if (timeDate > new Date()) {
|
const diff = calculateTimeDifference(timeDate, new Date());
|
||||||
|
const interval = timeArray[4] || 0;
|
||||||
|
|
||||||
|
// 检查是否应该在这一天浇水
|
||||||
|
const shouldWaterToday = interval === 0 || (currentDay % interval === 0);
|
||||||
|
|
||||||
|
if (timeDate > new Date() && shouldWaterToday) {
|
||||||
if (!nextTime || (diff.hours * 60 + diff.minutes < (nextTimeDiff?.hours || 0) * 60 + (nextTimeDiff?.minutes || 0))) {
|
if (!nextTime || (diff.hours * 60 + diff.minutes < (nextTimeDiff?.hours || 0) * 60 + (nextTimeDiff?.minutes || 0))) {
|
||||||
nextTimeDiff = diff;
|
nextTimeDiff = diff;
|
||||||
nextTime = timeDate;
|
nextTime = timeDate;
|
||||||
|
@ -1099,7 +1194,14 @@
|
||||||
this.xctimesc = nextWaterDuration || '未知';
|
this.xctimesc = nextWaterDuration || '未知';
|
||||||
this.sctimejs = prevTime ? prevTime.toTimeString().slice(0, 5) : '无上次浇水时间';
|
this.sctimejs = prevTime ? prevTime.toTimeString().slice(0, 5) : '无上次浇水时间';
|
||||||
this.xctimesj = nextTime ? nextTime.toTimeString().slice(0, 5) : '无下次浇水时间';
|
this.xctimesj = nextTime ? nextTime.toTimeString().slice(0, 5) : '无下次浇水时间';
|
||||||
console.log('下次浇水时间', this.xctimesj, '距离下次浇水时间', this.xctime, '上次浇水时间', this.sctimejs);
|
|
||||||
|
console.log('解析后的数据:', {
|
||||||
|
ver_data: this.ver_data,
|
||||||
|
showobj: this.showobj,
|
||||||
|
nextTime: this.xctimesj,
|
||||||
|
nextTimeDiff: this.xctime,
|
||||||
|
prevTime: this.sctimejs
|
||||||
|
});
|
||||||
},
|
},
|
||||||
// 初始化断开蓝牙定时器
|
// 初始化断开蓝牙定时器
|
||||||
initDisconnectTimer() {
|
initDisconnectTimer() {
|
||||||
|
@ -1464,7 +1566,7 @@
|
||||||
}
|
}
|
||||||
.devicebox {
|
.devicebox {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-height: 320rpx;
|
max-height: 400rpx;
|
||||||
background: #FFFFFF;
|
background: #FFFFFF;
|
||||||
box-shadow: 0rpx 0rpx 38rpx 0rpx rgba(128, 128, 128, 0.3);
|
box-shadow: 0rpx 0rpx 38rpx 0rpx rgba(128, 128, 128, 0.3);
|
||||||
filter: blur(0px);
|
filter: blur(0px);
|
||||||
|
@ -1489,6 +1591,17 @@
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
margin-top: 4rpx;
|
margin-top: 4rpx;
|
||||||
}
|
}
|
||||||
|
.time {
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #3D3D3D;
|
||||||
|
margin-top: 4rpx;
|
||||||
|
}
|
||||||
|
.interval {
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #3D3D3D;
|
||||||
|
font-weight: 600;
|
||||||
|
margin-top: 4rpx;
|
||||||
|
}
|
||||||
.img {
|
.img {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
image {
|
image {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user