浇花器

This commit is contained in:
3321822538@qq.com 2025-02-20 11:29:45 +08:00
parent 516e9c3da9
commit f5b6a50aed
2 changed files with 517 additions and 349 deletions

View File

@ -1,18 +1,18 @@
<template>
<view>
<u-navbar :is-back="true" title='定时管理' title-color="#000" :border-bottom="false" :background="bgc"
id="navbar">
<u-navbar :is-back="true" title='定时管理' title-color="#000" :border-bottom="false" :background="bgc" id="navbar">
</u-navbar>
<image class="bj" src="https://api.ccttiot.com/smartmeter/img/static/urqUoIyCCEBykZ2oG8eO" mode=""></image>
<view class="" v-if="list.length > 0 || list != null">
<view class="list">
<view class="" v-if="pre == 'WATER'">
<view class="list" v-if="list.length > 0 || list != null">
<view class="list_val" v-for="(values, key, index) in list" :key="key">
<view class="lt" @click="btnitem(key,index,values)">
<view class="one">{{ formattedTime(values[0], values[1]) }}</view>
<view class="two">P{{ index + 1 }} <text></text> {{ formatTime(values[2]) }}</view>
</view>
<view class="rt">
<u-switch v-model="values[3]" @change="btnchange(key,index,values)" active-color="#48893B" inactive-color="#BDBCBC"></u-switch>
<u-switch v-model="values[3]" @change="btnchange(key,index,values)" active-color="#48893B"
inactive-color="#BDBCBC"></u-switch>
</view>
</view>
</view>
@ -51,7 +51,26 @@
<view class="mask" style="z-index: 9999;" v-if="kgflag"></view>
</view>
<view class="" style="width: 100%;padding-top: 80rpx;text-align: center;color: #000;font-size: 36rpx;">
<view class="choushuiben" v-else>
<view class="name">
<text>抽水泵启动时间/</text> <input type="text" v-model="shi"/>
</view>
<view class="name">
<text>抽水泵启动时间/</text><input type="text" v-model="fen"/>
</view>
<view class="name">
<text>抽水泵工作时长/</text><input type="text" v-model="miao"/>
</view>
<view class="name">
<text>抽水泵间隔时间/</text><input type="text" v-model="tian"/>
</view>
<view class="baocun" @click="btnbc">
保存
</view>
</view>
<view class="" v-if="pre == 'WATER'" style="width: 100%;padding-top: 80rpx;text-align: center;color: #000;font-size: 36rpx;">
没有更多定时浇水啦...
</view>
</view>
@ -99,7 +118,13 @@
devicehour: '',
deviceminute: '',
kgflag: false,
xctime:''
xctime: '',
csbobj:{},
pre:'',
shi:'',
fen:'',
miao:'',
tian:''
}
},
//
@ -119,7 +144,12 @@
},
onLoad(option) {
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
if(option.list){ //
xBlufi.notifySendCustomData({
customData: "11get"
})
if (option.list.length > 0) { //
this.pre = option.pre
if (option.pre == 'WATER') {
this.list = JSON.parse(option.list)
for (let key in this.list) {
if (this.list.hasOwnProperty(key)) {
@ -134,6 +164,13 @@
}
}
console.log(this.list)
} else {
this.csbobj = JSON.parse(option.list)
this.shi = this.csbobj.hour
this.fen = this.csbobj.minute
this.miao = this.csbobj.second
this.tian = this.csbobj.day
}
} else {
xBlufi.notifySendCustomData({
customData: "11get"
@ -165,7 +202,8 @@
this.deviceflag = 1
}
}
let cucun = '11num' + this.deviceindex + '@' + this.devicehour + '@' + this.deviceminute + '@' + this.devicemiao + '@' + this.deviceflag + '@'
let cucun = '11num' + this.deviceindex + '@' + this.devicehour + '@' + this.deviceminute + '@' + this
.devicemiao + '@' + this.deviceflag + '@'
xBlufi.notifySendCustomData({
customData: cucun
})
@ -237,6 +275,37 @@
})
}, 1000)
},
btnbc(){
if(this.shi >= 24){
uni.showToast({
title: '最大值为23时',
icon: 'none',
duration:2000
})
}else if(this.fen >= 60){
uni.showToast({
title: '最大值为59分钟',
icon: 'none',
duration:2000
})
}else{
this.timeflag = false
let cucun = '11num0' + '@' + this.shi + '@' + this.fen + '@' + this.miao + '@' + this.tian + '@'
xBlufi.notifySendCustomData({
customData: cucun
})
uni.showToast({
title: '保存成功',
icon: 'success',
duration:2000
})
setTimeout(() => {
xBlufi.notifySendCustomData({
customData: "11get"
})
}, 1000)
}
},
//
confirm(e) {
this.hour = e.hour
@ -263,6 +332,7 @@
console.log("1收到设备发来的自定义数据结果", options.data)
const inputString = options.data.slice(0, -1) + ";"
console.log(inputString, '12121212100')
if (this.pre == 'WATER') {
const pairs = inputString.split(';')
const showObject = {}
const pSetObjects = {}
@ -278,6 +348,7 @@
this.list = pSetObjects //
const ver_Data = this.list
function secondsToMinutesAndSeconds(seconds) {
const minutes = Math.floor(seconds / 60)
const remainingSeconds = seconds % 60
@ -299,7 +370,10 @@
const diffMinutes = Math.floor(diffSeconds / 60)
const diffHours = Math.floor(diffMinutes / 60)
const remainingMinutes = diffMinutes % 60
return { hours: diffHours, minutes: remainingMinutes }
return {
hours: diffHours,
minutes: remainingMinutes
}
}
// ver_Data
let nextTimeDiff = null
@ -315,13 +389,15 @@
const diff = timeDifference(timeDate, now)
//
if (timeDate > now) {
if (!nextTime || diff.hours * 60 + diff.minutes < nextTimeDiff.hours * 60 + nextTimeDiff.minutes) {
if (!nextTime || diff.hours * 60 + diff.minutes < nextTimeDiff.hours * 60 +
nextTimeDiff.minutes) {
nextTimeDiff = diff
nextTime = timeDate
nextWaterDuration = secondsToMinutesAndSeconds(timeArray[2]) //
}
} else {
if (!prevTime || (now.getTime() - timeDate.getTime()) < (now.getTime() - prevTime.getTime())) {
if (!prevTime || (now.getTime() - timeDate.getTime()) < (now.getTime() -
prevTime.getTime())) {
prevTimeDiff = timeDifference(now, timeDate) //
prevTime = timeDate
}
@ -342,6 +418,25 @@
}
}
}
} else {
const input = options.data.slice(0, -1) + ";"
//
const parts = input.replace(";", "").split(":")
//
const timeParts = parts[1].split(",")
//
this.csbobj = {
hour: parseInt(timeParts[0]), //
minute: parseInt(timeParts[1]), //
second: parseInt(timeParts[2]), //
day: parseInt(timeParts[3]) //
}
console.log(this.csbobj);
this.shi = this.csbobj.hour
this.fen = this.csbobj.minute
this.miao = this.csbobj.second
this.tian = this.csbobj.day
}
break
}
},
@ -353,9 +448,37 @@
/deep/ .u-title {
margin-bottom: 22rpx;
}
/deep/ .uicon-nav-back {
margin-bottom: 22rpx;
}
.choushuiben{
.baocun{
margin: auto;
width: 630rpx;
height: 100rpx;
margin-top: 50rpx;
text-align: center;
line-height: 100rpx;
border-radius: 20rpx;
background-color: #7FAD76;
color: #fff;
font-size: 32rpx;
}
.name{
display: flex;
height: 100rpx;
line-height: 100rpx;
text{
width: 300rpx;
}
input{
border-bottom: 1px solid #ccc;
height: 100rpx;
line-height: 100rpx;
}
}
}
.jiaoshui {
position: fixed;
top: 366rpx;
@ -366,6 +489,7 @@
background: #FFFFFF;
border-radius: 24rpx 24rpx 24rpx 24rpx;
z-index: 99;
.top {
margin-top: 42rpx;
width: 100%;
@ -374,6 +498,7 @@
color: #3D3D3D;
font-weight: 600;
}
.ts {
margin-top: 30rpx;
width: 100%;
@ -382,6 +507,7 @@
color: #808080;
font-weight: 600;
}
.shifen {
width: 512rpx;
height: 128rpx;
@ -394,12 +520,14 @@
line-height: 128rpx;
padding: 0 102rpx;
box-sizing: border-box;
text {
font-size: 44rpx;
color: #3D3D3D;
font-weight: 600;
}
}
.jssc {
font-size: 32rpx;
color: #808080;
@ -407,12 +535,14 @@
margin-top: 58rpx;
margin-left: 96rpx;
}
.anniu {
display: flex;
justify-content: space-between;
margin-top: 58rpx;
padding: 0 44rpx;
box-sizing: border-box;
.qx {
width: 278rpx;
height: 80rpx;
@ -424,6 +554,7 @@
line-height: 80rpx;
text-align: center;
}
.qd {
width: 278rpx;
height: 80rpx;
@ -437,6 +568,7 @@
}
}
}
.mask {
width: 100%;
height: 100vh;
@ -447,6 +579,7 @@
left: 0;
z-index: 98;
}
.list {
.list_val {
width: 678rpx;
@ -461,17 +594,21 @@
display: flex;
justify-content: space-between;
margin-top: 30rpx;
.lt {
width: 100%;
.one {
font-size: 72rpx;
color: #50565A;
font-weight: 600;
}
.two {
font-size: 32rpx;
color: #50565A;
margin-top: 12rpx;
text {
display: inline-block;
width: 1rpx;
@ -482,18 +619,21 @@
}
}
}
.rt {
padding-top: 70rpx;
box-sizing: border-box;
}
}
}
page {
width: 100%;
padding: 20rpx 30rpx;
box-sizing: border-box;
background-color: #fff;
}
.bj {
width: 100%;
height: 100vh;
@ -502,5 +642,4 @@
left: 0;
z-index: -1;
}
</style>

View File

@ -77,7 +77,7 @@
</view>
</view> -->
</view>
<view class="deviceweek">
<view class="deviceweek" v-if="pre == 'WATER'">
<view class="weeklist">
<view class="kg" v-if="ver_data.p_set0[3] == 0">
OFF
@ -193,10 +193,15 @@
</view>
</view>
</view>
<view class="" v-else>
<view class="">抽水泵启动时间{{csbobj.hour == undefined ? '--' : csbobj.hour + '时'}}{{csbobj.minute == undefined ? '' : csbobj.minute + '分'}}</view>
<view class="">抽水泵工作时长/{{csbobj.second == undefined ? '--' : csbobj.second + '秒'}}</view>
<view class="">抽水泵间隔时间/{{csbobj.day == undefined ? '--' : csbobj.day + '天'}}</view>
</view>
</view>
<!-- 开关选择 -->
<view class="switchbox">
<view class="switch_he">
<view class="switch_he" v-if="pre == 'WATER'">
<image src="https://api.ccttiot.com/smartmeter/img/static/u7NwkNOoQYYsvHVMkDlu" mode=""></image>
<view class="yushui">
雨水感应
@ -206,7 +211,7 @@
inactive-color="#7FAD76" size="40"></u-switch>
</view>
</view>
<view class="switch_he">
<view class="switch_he" v-if="pre == 'WATER'">
<image src="https://api.ccttiot.com/smartmeter/img/static/u7kd92ocUgDN052nhp4R" mode=""></image>
<view class="yushui">
儿童锁 <u-switch v-if="etchecked" v-model="two" @change="btnertong" inactive-color="#eee"
@ -220,7 +225,7 @@
<!-- 定时 -->
<view class="dingshi_he" @click="btntime">
<view class="naoz">
<image src="https://api.ccttiot.com/smartmeter/img/static/uJPgzMejk9gaogWnCO9M" mode=""></image> 6
<image src="https://api.ccttiot.com/smartmeter/img/static/uJPgzMejk9gaogWnCO9M" mode=""></image> <text v-if="pre == 'WATER'">6组</text>
</view>
<view class="dstime">
定时管理 <image src="https://api.ccttiot.com/smartmeter/img/static/uagx3wGa7RYvqKqoSymy" mode="">
@ -241,7 +246,7 @@
</view>
</view>
<!-- 浇水日志 -->
<view class="wateringlogbox" @click="btnjs">
<view class="wateringlogbox" v-if="pre == 'WATER'" @click="btnjs">
<view class="wateringlogtop">
<image src="https://api.ccttiot.com/smartmeter/img/static/uGh3pRM7mMRSHdmvtzv3" mode=""></image>
浇水日志
@ -363,7 +368,9 @@
devicesarr:[],
intervalId: null,
imgflag:true,
ver:''
ver:'',
pre:'',
csbobj:{}
}
},
//
@ -497,6 +504,7 @@
this.bjflag = false
this.devicelist = res.data
this.mac = res.data[0].mac
this.pre = res.data[0].pre
this.deviceId = res.data[0].mac.match(/.{2}/g).reverse().join(':')
this.user = res.data[0]
this.shebid = res.data[0].deviceId
@ -683,7 +691,7 @@
})
}else{
uni.navigateTo({
url: '/page_user/dingshi?list=' + JSON.stringify(this.ver_data)
url: '/page_user/dingshi?list=' + JSON.stringify(this.ver_data) + '&pre=' + this.pre
})
}
},
@ -845,6 +853,7 @@
this.$u.get(`/app/getDeviceInfo/${this.shebid}`).then(res => {
if(res.code == 200){
this.mac = res.data.mac
this.pre = res.data.pre
this.deviceId = res.data.mac.match(/.{2}/g).reverse().join(':')
this.user = res.data
}
@ -899,7 +908,11 @@
console.log("1收到设备发来的自定义数据结果", options.data,options.data.length)
this.datalist = options.data.slice(0, -1) + ";"
this.vardataflag = 3
if(this.pre == 'WATER'){
this.getchuli()
}else{
this.getcsbshuju()
}
break
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START:
if (!options.result) {
@ -929,7 +942,23 @@
console.log("定时器已清除");
}
},
//
getcsbshuju(){
const input = this.datalist
//
const parts = input.replace(";", "").split(":")
//
const timeParts = parts[1].split(",")
//
this.csbobj = {
hour: parseInt(timeParts[0]), //
minute: parseInt(timeParts[1]), //
second: parseInt(timeParts[2]), //
day: parseInt(timeParts[3]) //
}
this.ver_data = this.csbobj
console.log(this.csbobj);
},
//
getchuli() {
const inputString = this.datalist