浇花器
This commit is contained in:
parent
516e9c3da9
commit
f5b6a50aed
|
@ -1,362 +1,485 @@
|
||||||
<template>
|
<template>
|
||||||
<view>
|
<view>
|
||||||
<u-navbar :is-back="true" title='定时管理' title-color="#000" :border-bottom="false" :background="bgc"
|
<u-navbar :is-back="true" title='定时管理' title-color="#000" :border-bottom="false" :background="bgc" id="navbar">
|
||||||
id="navbar">
|
|
||||||
</u-navbar>
|
</u-navbar>
|
||||||
<image class="bj" src="https://api.ccttiot.com/smartmeter/img/static/urqUoIyCCEBykZ2oG8eO" mode=""></image>
|
<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="" v-if="pre == 'WATER'">
|
||||||
<view class="list">
|
<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="list_val" v-for="(values, key, index) in list" :key="key">
|
||||||
<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>
|
</view>
|
||||||
<view class="rt">
|
<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"
|
||||||
</view>
|
inactive-color="#BDBCBC"></u-switch>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
</view>
|
||||||
<!-- 设置浇水时间弹窗 -->
|
|
||||||
<view class="jiaoshui" v-if="timeflag">
|
<!-- 设置浇水时间弹窗 -->
|
||||||
<view class="top">
|
<view class="jiaoshui" v-if="timeflag">
|
||||||
设置浇水
|
<view class="top">
|
||||||
</view>
|
设置浇水
|
||||||
<view class="ts">
|
</view>
|
||||||
距离下次浇水时间还有{{xctime}}
|
<view class="ts">
|
||||||
</view>
|
距离下次浇水时间还有{{xctime}}
|
||||||
<view class="shifen" @click="show = true">
|
</view>
|
||||||
<text>{{hour}}时</text> <text>{{minutekq}}分</text>
|
<view class="shifen" @click="show = true">
|
||||||
</view>
|
<text>{{hour}}时</text> <text>{{minutekq}}分</text>
|
||||||
<view class="jssc">
|
</view>
|
||||||
浇水时长
|
<view class="jssc">
|
||||||
</view>
|
浇水时长
|
||||||
<view class="shifen" @click="shows = true">
|
</view>
|
||||||
<text>{{minute}}分</text> <text>{{second}}秒</text>
|
<view class="shifen" @click="shows = true">
|
||||||
</view>
|
<text>{{minute}}分</text> <text>{{second}}秒</text>
|
||||||
<view class="anniu">
|
</view>
|
||||||
<view class="qx" @click="btnqx">
|
<view class="anniu">
|
||||||
取消
|
<view class="qx" @click="btnqx">
|
||||||
</view>
|
取消
|
||||||
<view class="qd" @click="btnqd">
|
</view>
|
||||||
确定
|
<view class="qd" @click="btnqd">
|
||||||
</view>
|
确定
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="mask" v-if="timeflag"></view>
|
</view>
|
||||||
<!-- 定时时间 -->
|
<view class="mask" v-if="timeflag"></view>
|
||||||
<u-picker v-model="show" mode="time" :params="paramss" @confirm="confirm"></u-picker>
|
<!-- 定时时间 -->
|
||||||
<!-- 定时时长 -->
|
<u-picker v-model="show" mode="time" :params="paramss" @confirm="confirm"></u-picker>
|
||||||
<u-picker v-model="shows" mode="time" :params="params" @confirm="confirms"></u-picker>
|
<!-- 定时时长 -->
|
||||||
|
<u-picker v-model="shows" mode="time" :params="params" @confirm="confirms"></u-picker>
|
||||||
<view class="mask" style="z-index: 9999;" v-if="kgflag"></view>
|
|
||||||
</view>
|
<view class="mask" style="z-index: 9999;" v-if="kgflag"></view>
|
||||||
<view class="" style="width: 100%;padding-top: 80rpx;text-align: center;color: #000;font-size: 36rpx;">
|
</view>
|
||||||
|
|
||||||
|
<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>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var xBlufi = require("@/components/blufi/xBlufi.js")
|
var xBlufi = require("@/components/blufi/xBlufi.js")
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
bgc: {
|
bgc: {
|
||||||
backgroundColor: "#fff",
|
backgroundColor: "#fff",
|
||||||
},
|
},
|
||||||
active:1,
|
active: 1,
|
||||||
flag:false,
|
flag: false,
|
||||||
checked:false,
|
checked: false,
|
||||||
timeflag:false,
|
timeflag: false,
|
||||||
show: false,
|
show: false,
|
||||||
params: {
|
params: {
|
||||||
year: false,
|
year: false,
|
||||||
month: false,
|
month: false,
|
||||||
day: false,
|
day: false,
|
||||||
hour: false,
|
hour: false,
|
||||||
minute: true,
|
minute: true,
|
||||||
second: true,
|
second: true,
|
||||||
},
|
},
|
||||||
shows: false,
|
shows: false,
|
||||||
paramss: {
|
paramss: {
|
||||||
year: false,
|
year: false,
|
||||||
month: false,
|
month: false,
|
||||||
day: false,
|
day: false,
|
||||||
hour: true,
|
hour: true,
|
||||||
minute: true,
|
minute: true,
|
||||||
second: false,
|
second: false,
|
||||||
},
|
},
|
||||||
minute:'--',
|
minute: '--',
|
||||||
second:'--',
|
second: '--',
|
||||||
hour:'--',
|
hour: '--',
|
||||||
minutekq:'--',
|
minutekq: '--',
|
||||||
list:{},
|
list: {},
|
||||||
checkedStatus: {},
|
checkedStatus: {},
|
||||||
deviceindex:'',
|
deviceindex: '',
|
||||||
devicemiao:'',
|
devicemiao: '',
|
||||||
deviceflag:'',
|
deviceflag: '',
|
||||||
devicehour:'',
|
devicehour: '',
|
||||||
deviceminute:'',
|
deviceminute: '',
|
||||||
kgflag:false,
|
kgflag: false,
|
||||||
xctime:''
|
xctime: '',
|
||||||
}
|
csbobj:{},
|
||||||
},
|
pre:'',
|
||||||
// 分享到好友(会话)
|
shi:'',
|
||||||
onShareAppMessage: function() {
|
fen:'',
|
||||||
return {
|
miao:'',
|
||||||
title: '绿小能',
|
tian:''
|
||||||
path: '/pages/index/index'
|
}
|
||||||
}
|
},
|
||||||
},
|
// 分享到好友(会话)
|
||||||
// 分享到朋友圈
|
onShareAppMessage: function() {
|
||||||
onShareTimeline: function() {
|
return {
|
||||||
return {
|
title: '绿小能',
|
||||||
title: '绿小能',
|
path: '/pages/index/index'
|
||||||
query: '',
|
}
|
||||||
path: '/pages/index/index'
|
},
|
||||||
}
|
// 分享到朋友圈
|
||||||
},
|
onShareTimeline: function() {
|
||||||
onLoad(option) {
|
return {
|
||||||
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
|
title: '绿小能',
|
||||||
if(option.list){ //判断有无数据 有数据直接拿 无数据则发送命令获取数据
|
query: '',
|
||||||
|
path: '/pages/index/index'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onLoad(option) {
|
||||||
|
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
|
||||||
|
xBlufi.notifySendCustomData({
|
||||||
|
customData: "11get"
|
||||||
|
})
|
||||||
|
if (option.list.length > 0) { //判断有无数据 有数据直接拿 无数据则发送命令获取数据
|
||||||
|
this.pre = option.pre
|
||||||
|
if (option.pre == 'WATER') {
|
||||||
this.list = JSON.parse(option.list)
|
this.list = JSON.parse(option.list)
|
||||||
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];
|
||||||
// 判断数组的最后一个元素,并进行替换
|
// 判断数组的最后一个元素,并进行替换
|
||||||
if (arr[arr.length - 1] === 0) {
|
if (arr[arr.length - 1] === 0) {
|
||||||
arr[arr.length - 1] = false;
|
arr[arr.length - 1] = false;
|
||||||
} else if (arr[arr.length - 1] === 1) {
|
} else if (arr[arr.length - 1] === 1) {
|
||||||
arr[arr.length - 1] = true;
|
arr[arr.length - 1] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(this.list)
|
console.log(this.list)
|
||||||
}else{
|
} 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"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onShow() {
|
||||||
|
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// 点击开关是否开启
|
||||||
|
btnchange(key, index, values) {
|
||||||
|
this.kgflag = true
|
||||||
|
this.btnitem(key, index, values)
|
||||||
|
this.btnqx()
|
||||||
|
this.deviceindex = index
|
||||||
|
this.devicehour = values[0]
|
||||||
|
this.deviceminute = values[1]
|
||||||
|
this.devicemiao = values[2]
|
||||||
|
if (this.list.hasOwnProperty(key)) {
|
||||||
|
const array = this.list[key]
|
||||||
|
const lastIndex = array.length - 1
|
||||||
|
const lastElement = array[lastIndex]
|
||||||
|
const lastElements = array[lastIndex]
|
||||||
|
array[lastIndex] = !lastElement
|
||||||
|
if (lastElements) {
|
||||||
|
this.deviceflag = 0
|
||||||
|
} else {
|
||||||
|
this.deviceflag = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let cucun = '11num' + this.deviceindex + '@' + this.devicehour + '@' + this.deviceminute + '@' + this
|
||||||
|
.devicemiao + '@' + this.deviceflag + '@'
|
||||||
|
xBlufi.notifySendCustomData({
|
||||||
|
customData: cucun
|
||||||
|
})
|
||||||
|
setTimeout(() => {
|
||||||
|
this.kgflag = false
|
||||||
|
}, 1000)
|
||||||
|
},
|
||||||
|
|
||||||
|
// 点击设置定时时间
|
||||||
|
btnitem(key, index, values) {
|
||||||
|
this.deviceindex = index
|
||||||
|
this.timeflag = true
|
||||||
|
this.hour = values[0]
|
||||||
|
this.minutekq = values[1]
|
||||||
|
const totalSeconds = values[2]
|
||||||
|
const minutes = Math.floor(totalSeconds / 60)
|
||||||
|
const seconds = totalSeconds % 60
|
||||||
|
const formattedMinutes = minutes < 10 ? '0' + minutes : minutes.toString()
|
||||||
|
const formattedSeconds = seconds < 10 ? '0' + seconds : seconds.toString()
|
||||||
|
this.minute = formattedMinutes
|
||||||
|
this.second = formattedSeconds
|
||||||
|
if (this.list.hasOwnProperty(key)) {
|
||||||
|
const array = this.list[key]
|
||||||
|
const lastElement = array[array.length - 1]
|
||||||
|
if (lastElement) {
|
||||||
|
this.deviceflag = 1
|
||||||
|
} else {
|
||||||
|
this.deviceflag = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
formattedTime(minutes, seconds) {
|
||||||
|
// 将数字转换为字符串并补零
|
||||||
|
const formattedMinutes = String(minutes).padStart(2, '0');
|
||||||
|
const formattedSeconds = String(seconds).padStart(2, '0');
|
||||||
|
// 返回格式化后的时间字符串
|
||||||
|
return `${formattedMinutes}:${formattedSeconds}`;
|
||||||
|
},
|
||||||
|
|
||||||
|
formatTime(seconds) {
|
||||||
|
const minutes = Math.floor(seconds / 60);
|
||||||
|
const remainingSeconds = seconds % 60;
|
||||||
|
return `${minutes}分${remainingSeconds < 10 ? '0' : ''}${remainingSeconds}秒`;
|
||||||
|
},
|
||||||
|
|
||||||
|
// 取消选择设置定时时间
|
||||||
|
btnqx() {
|
||||||
|
this.timeflag = false
|
||||||
|
this.hour = '--'
|
||||||
|
this.minutekq = '--'
|
||||||
|
this.minute = '--'
|
||||||
|
this.second = '--'
|
||||||
|
},
|
||||||
|
// 确定选择设置定时时间
|
||||||
|
btnqd() {
|
||||||
|
this.timeflag = false
|
||||||
|
this.hour = '--'
|
||||||
|
this.minutekq = '--'
|
||||||
|
this.minute = '--'
|
||||||
|
this.second = '--'
|
||||||
|
let cucun = '11num' + this.deviceindex + '@' + this.devicehour + '@' + this.deviceminute + '@' + this.devicemiao + '@' + this.deviceflag + '@'
|
||||||
|
xBlufi.notifySendCustomData({
|
||||||
|
customData: cucun
|
||||||
|
})
|
||||||
|
setTimeout(() => {
|
||||||
xBlufi.notifySendCustomData({
|
xBlufi.notifySendCustomData({
|
||||||
customData: "11get"
|
customData: "11get"
|
||||||
})
|
})
|
||||||
}
|
}, 1000)
|
||||||
},
|
},
|
||||||
onShow() {
|
btnbc(){
|
||||||
|
if(this.shi >= 24){
|
||||||
},
|
uni.showToast({
|
||||||
methods:{
|
title: '最大值为23时',
|
||||||
// 点击开关是否开启
|
icon: 'none',
|
||||||
btnchange(key,index,values){
|
duration:2000
|
||||||
this.kgflag = true
|
})
|
||||||
this.btnitem(key,index,values)
|
}else if(this.fen >= 60){
|
||||||
this.btnqx()
|
uni.showToast({
|
||||||
this.deviceindex = index
|
title: '最大值为59分钟',
|
||||||
this.devicehour = values[0]
|
icon: 'none',
|
||||||
this.deviceminute = values[1]
|
duration:2000
|
||||||
this.devicemiao = values[2]
|
})
|
||||||
if (this.list.hasOwnProperty(key)) {
|
}else{
|
||||||
const array = this.list[key]
|
this.timeflag = false
|
||||||
const lastIndex = array.length - 1
|
let cucun = '11num0' + '@' + this.shi + '@' + this.fen + '@' + this.miao + '@' + this.tian + '@'
|
||||||
const lastElement = array[lastIndex]
|
|
||||||
const lastElements = array[lastIndex]
|
|
||||||
array[lastIndex] = !lastElement
|
|
||||||
if (lastElements) {
|
|
||||||
this.deviceflag = 0
|
|
||||||
} else {
|
|
||||||
this.deviceflag = 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let cucun = '11num' + this.deviceindex + '@' + this.devicehour + '@' + this.deviceminute + '@' + this.devicemiao + '@' + this.deviceflag + '@'
|
|
||||||
xBlufi.notifySendCustomData({
|
xBlufi.notifySendCustomData({
|
||||||
customData: cucun
|
customData: cucun
|
||||||
})
|
})
|
||||||
setTimeout(()=>{
|
uni.showToast({
|
||||||
this.kgflag = false
|
title: '保存成功',
|
||||||
},1000)
|
icon: 'success',
|
||||||
},
|
duration:2000
|
||||||
|
})
|
||||||
// 点击设置定时时间
|
setTimeout(() => {
|
||||||
btnitem(key,index,values){
|
|
||||||
this.deviceindex = index
|
|
||||||
this.timeflag = true
|
|
||||||
this.hour = values[0]
|
|
||||||
this.minutekq = values[1]
|
|
||||||
const totalSeconds = values[2]
|
|
||||||
const minutes = Math.floor(totalSeconds / 60)
|
|
||||||
const seconds = totalSeconds % 60
|
|
||||||
const formattedMinutes = minutes < 10 ? '0' + minutes : minutes.toString()
|
|
||||||
const formattedSeconds = seconds < 10 ? '0' + seconds : seconds.toString()
|
|
||||||
this.minute = formattedMinutes
|
|
||||||
this.second = formattedSeconds
|
|
||||||
if (this.list.hasOwnProperty(key)) {
|
|
||||||
const array = this.list[key]
|
|
||||||
const lastElement = array[array.length - 1]
|
|
||||||
if (lastElement) {
|
|
||||||
this.deviceflag = 1
|
|
||||||
} else {
|
|
||||||
this.deviceflag = 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
formattedTime(minutes, seconds) {
|
|
||||||
// 将数字转换为字符串并补零
|
|
||||||
const formattedMinutes = String(minutes).padStart(2, '0');
|
|
||||||
const formattedSeconds = String(seconds).padStart(2, '0');
|
|
||||||
// 返回格式化后的时间字符串
|
|
||||||
return `${formattedMinutes}:${formattedSeconds}`;
|
|
||||||
},
|
|
||||||
|
|
||||||
formatTime(seconds) {
|
|
||||||
const minutes = Math.floor(seconds / 60);
|
|
||||||
const remainingSeconds = seconds % 60;
|
|
||||||
return `${minutes}分${remainingSeconds < 10 ? '0' : ''}${remainingSeconds}秒`;
|
|
||||||
},
|
|
||||||
|
|
||||||
// 取消选择设置定时时间
|
|
||||||
btnqx(){
|
|
||||||
this.timeflag = false
|
|
||||||
this.hour = '--'
|
|
||||||
this.minutekq = '--'
|
|
||||||
this.minute = '--'
|
|
||||||
this.second = '--'
|
|
||||||
},
|
|
||||||
// 确定选择设置定时时间
|
|
||||||
btnqd(){
|
|
||||||
this.timeflag = false
|
|
||||||
this.hour = '--'
|
|
||||||
this.minutekq = '--'
|
|
||||||
this.minute = '--'
|
|
||||||
this.second = '--'
|
|
||||||
let cucun = '11num' + this.deviceindex + '@' + this.devicehour + '@' + this.deviceminute + '@' + this.devicemiao + '@' + this.deviceflag + '@'
|
|
||||||
xBlufi.notifySendCustomData({
|
|
||||||
customData: cucun
|
|
||||||
})
|
|
||||||
setTimeout(()=> {
|
|
||||||
xBlufi.notifySendCustomData({
|
xBlufi.notifySendCustomData({
|
||||||
customData: "11get"
|
customData: "11get"
|
||||||
})
|
})
|
||||||
},1000)
|
}, 1000)
|
||||||
},
|
}
|
||||||
// 定时浇水时间
|
},
|
||||||
confirm(e){
|
// 定时浇水时间
|
||||||
this.hour = e.hour
|
confirm(e) {
|
||||||
this.minutekq = e.minute
|
this.hour = e.hour
|
||||||
this.devicehour = e.hour
|
this.minutekq = e.minute
|
||||||
this.deviceminute = e.minute
|
this.devicehour = e.hour
|
||||||
},
|
this.deviceminute = e.minute
|
||||||
// 定时浇水时长
|
},
|
||||||
confirms(e){
|
// 定时浇水时长
|
||||||
this.minute = e.minute
|
confirms(e) {
|
||||||
this.second = e.second
|
this.minute = e.minute
|
||||||
this.devicemiao = Number(this.minute) * 60 + Number(this.second)
|
this.second = e.second
|
||||||
console.log(this.devicemiao)
|
this.devicemiao = Number(this.minute) * 60 + Number(this.second)
|
||||||
},
|
console.log(this.devicemiao)
|
||||||
|
},
|
||||||
funListenDeviceMsgEvent: function(options) {
|
|
||||||
switch (options.type) {
|
funListenDeviceMsgEvent: function(options) {
|
||||||
case xBlufi.XBLUFI_TYPE.TYPE_STATUS_CONNECTED:
|
switch (options.type) {
|
||||||
if (!options.result) {
|
case xBlufi.XBLUFI_TYPE.TYPE_STATUS_CONNECTED:
|
||||||
|
if (!options.result) {
|
||||||
}
|
|
||||||
break;
|
}
|
||||||
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA:
|
break;
|
||||||
|
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA:
|
||||||
console.log("1收到设备发来的自定义数据结果:", options.data)
|
console.log("1收到设备发来的自定义数据结果:", options.data)
|
||||||
const inputString = options.data.slice(0, -1) + ";"
|
const inputString = options.data.slice(0, -1) + ";"
|
||||||
console.log(inputString,'12121212100')
|
console.log(inputString, '12121212100')
|
||||||
const pairs = inputString.split(';')
|
if (this.pre == 'WATER') {
|
||||||
|
const pairs = inputString.split(';')
|
||||||
const showObject = {}
|
const showObject = {}
|
||||||
const pSetObjects = {}
|
const pSetObjects = {}
|
||||||
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')) {
|
||||||
const numbers = value.split(',').map(Number)
|
const numbers = value.split(',').map(Number)
|
||||||
pSetObjects[key] = numbers
|
pSetObjects[key] = numbers
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
this.list = pSetObjects //六个浇水时间段
|
this.list = pSetObjects //六个浇水时间段
|
||||||
|
|
||||||
const ver_Data = this.list
|
const ver_Data = this.list
|
||||||
function secondsToMinutesAndSeconds(seconds) {
|
|
||||||
const minutes = Math.floor(seconds / 60)
|
function secondsToMinutesAndSeconds(seconds) {
|
||||||
const remainingSeconds = seconds % 60
|
const minutes = Math.floor(seconds / 60)
|
||||||
return `${minutes}分${remainingSeconds}秒`
|
const remainingSeconds = seconds % 60
|
||||||
}
|
return `${minutes}分${remainingSeconds}秒`
|
||||||
|
}
|
||||||
// 获取当前时间
|
// 获取当前时间
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
// 辅助函数:将时间数组转换为 Date 对象
|
// 辅助函数:将时间数组转换为 Date 对象
|
||||||
function timeArrayToDate(timeArray) {
|
function timeArrayToDate(timeArray) {
|
||||||
const [hour, minute, second] = timeArray.slice(0, 3)
|
const [hour, minute, second] = timeArray.slice(0, 3)
|
||||||
const date = new Date()
|
const date = new Date()
|
||||||
date.setHours(hour, minute, second, 0) // 毫秒设为0
|
date.setHours(hour, minute, second, 0) // 毫秒设为0
|
||||||
return date
|
return date
|
||||||
}
|
}
|
||||||
// 辅助函数:计算两个时间之间的差值(以小时和分钟表示)
|
// 辅助函数:计算两个时间之间的差值(以小时和分钟表示)
|
||||||
function timeDifference(date1, date2) {
|
function timeDifference(date1, date2) {
|
||||||
const diffMs = Math.abs(date1 - date2)
|
const diffMs = Math.abs(date1 - date2)
|
||||||
const diffSeconds = Math.floor(diffMs / 1000)
|
const diffSeconds = Math.floor(diffMs / 1000)
|
||||||
const diffMinutes = Math.floor(diffSeconds / 60)
|
const diffMinutes = Math.floor(diffSeconds / 60)
|
||||||
const diffHours = Math.floor(diffMinutes / 60)
|
const diffHours = Math.floor(diffMinutes / 60)
|
||||||
const remainingMinutes = diffMinutes % 60
|
const remainingMinutes = diffMinutes % 60
|
||||||
return { hours: diffHours, minutes: remainingMinutes }
|
return {
|
||||||
}
|
hours: diffHours,
|
||||||
|
minutes: remainingMinutes
|
||||||
|
}
|
||||||
|
}
|
||||||
// 遍历 ver_Data 对象
|
// 遍历 ver_Data 对象
|
||||||
let nextTimeDiff = null
|
let nextTimeDiff = null
|
||||||
let nextTime = null
|
let nextTime = null
|
||||||
let prevTimeDiff = null
|
let prevTimeDiff = null
|
||||||
let prevTime = null
|
let prevTime = null
|
||||||
let nextWaterDuration = null // 用于存储下次浇水时长
|
let nextWaterDuration = null // 用于存储下次浇水时长
|
||||||
for (const key in ver_Data) {
|
for (const key in ver_Data) {
|
||||||
if (ver_Data.hasOwnProperty(key) && ver_Data[key][3] === 1) {
|
if (ver_Data.hasOwnProperty(key) && ver_Data[key][3] === 1) {
|
||||||
const timeArray = ver_Data[key]
|
const timeArray = ver_Data[key]
|
||||||
const timeDate = timeArrayToDate(timeArray)
|
const timeDate = timeArrayToDate(timeArray)
|
||||||
// 计算与当前时间的差值
|
// 计算与当前时间的差值
|
||||||
const diff = timeDifference(timeDate, now)
|
const diff = timeDifference(timeDate, now)
|
||||||
// 判断是下一次时间还是上一次时间
|
// 判断是下一次时间还是上一次时间
|
||||||
if (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 = diff
|
nextTimeDiff.minutes) {
|
||||||
nextTime = timeDate
|
nextTimeDiff = diff
|
||||||
nextWaterDuration = secondsToMinutesAndSeconds(timeArray[2]) // 获取并转换浇水时长
|
nextTime = timeDate
|
||||||
}
|
nextWaterDuration = secondsToMinutesAndSeconds(timeArray[2]) // 获取并转换浇水时长
|
||||||
} else {
|
}
|
||||||
if (!prevTime || (now.getTime() - timeDate.getTime()) < (now.getTime() - prevTime.getTime())) {
|
} else {
|
||||||
prevTimeDiff = timeDifference(now, timeDate) // 注意这里要反过来算
|
if (!prevTime || (now.getTime() - timeDate.getTime()) < (now.getTime() -
|
||||||
prevTime = timeDate
|
prevTime.getTime())) {
|
||||||
}
|
prevTimeDiff = timeDifference(now, timeDate) // 注意这里要反过来算
|
||||||
}
|
prevTime = timeDate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// 输出结果
|
// 输出结果
|
||||||
this.xctime = `${nextTimeDiff.hours}时${nextTimeDiff.minutes}分`
|
this.xctime = `${nextTimeDiff.hours}时${nextTimeDiff.minutes}分`
|
||||||
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]
|
||||||
// 判断数组的最后一个元素,并进行替换
|
// 判断数组的最后一个元素,并进行替换
|
||||||
if (arr[arr.length - 1] === 0) {
|
if (arr[arr.length - 1] === 0) {
|
||||||
arr[arr.length - 1] = false
|
arr[arr.length - 1] = false
|
||||||
} else if (arr[arr.length - 1] === 1) {
|
} else if (arr[arr.length - 1] === 1) {
|
||||||
arr[arr.length - 1] = true
|
arr[arr.length - 1] = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break
|
} 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
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less">
|
<style lang="less">
|
||||||
/deep/ .u-title{
|
/deep/ .u-title {
|
||||||
margin-bottom: 22rpx;
|
margin-bottom: 22rpx;
|
||||||
}
|
}
|
||||||
/deep/ .uicon-nav-back{
|
|
||||||
|
/deep/ .uicon-nav-back {
|
||||||
margin-bottom: 22rpx;
|
margin-bottom: 22rpx;
|
||||||
}
|
}
|
||||||
.jiaoshui{
|
.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;
|
position: fixed;
|
||||||
top: 366rpx;
|
top: 366rpx;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
|
@ -366,7 +489,8 @@
|
||||||
background: #FFFFFF;
|
background: #FFFFFF;
|
||||||
border-radius: 24rpx 24rpx 24rpx 24rpx;
|
border-radius: 24rpx 24rpx 24rpx 24rpx;
|
||||||
z-index: 99;
|
z-index: 99;
|
||||||
.top{
|
|
||||||
|
.top {
|
||||||
margin-top: 42rpx;
|
margin-top: 42rpx;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
@ -374,7 +498,8 @@
|
||||||
color: #3D3D3D;
|
color: #3D3D3D;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
.ts{
|
|
||||||
|
.ts {
|
||||||
margin-top: 30rpx;
|
margin-top: 30rpx;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
@ -382,7 +507,8 @@
|
||||||
color: #808080;
|
color: #808080;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
.shifen{
|
|
||||||
|
.shifen {
|
||||||
width: 512rpx;
|
width: 512rpx;
|
||||||
height: 128rpx;
|
height: 128rpx;
|
||||||
background: #F0F0F0;
|
background: #F0F0F0;
|
||||||
|
@ -394,26 +520,30 @@
|
||||||
line-height: 128rpx;
|
line-height: 128rpx;
|
||||||
padding: 0 102rpx;
|
padding: 0 102rpx;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
text{
|
|
||||||
|
text {
|
||||||
font-size: 44rpx;
|
font-size: 44rpx;
|
||||||
color: #3D3D3D;
|
color: #3D3D3D;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.jssc{
|
|
||||||
|
.jssc {
|
||||||
font-size: 32rpx;
|
font-size: 32rpx;
|
||||||
color: #808080;
|
color: #808080;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
margin-top: 58rpx;
|
margin-top: 58rpx;
|
||||||
margin-left: 96rpx;
|
margin-left: 96rpx;
|
||||||
}
|
}
|
||||||
.anniu{
|
|
||||||
|
.anniu {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
margin-top: 58rpx;
|
margin-top: 58rpx;
|
||||||
padding: 0 44rpx;
|
padding: 0 44rpx;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
.qx{
|
|
||||||
|
.qx {
|
||||||
width: 278rpx;
|
width: 278rpx;
|
||||||
height: 80rpx;
|
height: 80rpx;
|
||||||
border-radius: 10rpx 10rpx 10rpx 10rpx;
|
border-radius: 10rpx 10rpx 10rpx 10rpx;
|
||||||
|
@ -424,7 +554,8 @@
|
||||||
line-height: 80rpx;
|
line-height: 80rpx;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
.qd{
|
|
||||||
|
.qd {
|
||||||
width: 278rpx;
|
width: 278rpx;
|
||||||
height: 80rpx;
|
height: 80rpx;
|
||||||
background: #7FAD76;
|
background: #7FAD76;
|
||||||
|
@ -437,7 +568,8 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.mask{
|
|
||||||
|
.mask {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
background-color: #000;
|
background-color: #000;
|
||||||
|
@ -447,12 +579,13 @@
|
||||||
left: 0;
|
left: 0;
|
||||||
z-index: 98;
|
z-index: 98;
|
||||||
}
|
}
|
||||||
.list{
|
|
||||||
.list_val{
|
.list {
|
||||||
|
.list_val {
|
||||||
width: 678rpx;
|
width: 678rpx;
|
||||||
height: 208rpx;
|
height: 208rpx;
|
||||||
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;
|
||||||
padding-top: 16rpx;
|
padding-top: 16rpx;
|
||||||
padding-left: 42rpx;
|
padding-left: 42rpx;
|
||||||
|
@ -461,18 +594,22 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
margin-top: 30rpx;
|
margin-top: 30rpx;
|
||||||
.lt{
|
|
||||||
|
.lt {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
.one{
|
|
||||||
|
.one {
|
||||||
font-size: 72rpx;
|
font-size: 72rpx;
|
||||||
color: #50565A;
|
color: #50565A;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
.two{
|
|
||||||
|
.two {
|
||||||
font-size: 32rpx;
|
font-size: 32rpx;
|
||||||
color: #50565A;
|
color: #50565A;
|
||||||
margin-top: 12rpx;
|
margin-top: 12rpx;
|
||||||
text{
|
|
||||||
|
text {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 1rpx;
|
width: 1rpx;
|
||||||
height: 28rpx;
|
height: 28rpx;
|
||||||
|
@ -482,19 +619,22 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.rt{
|
|
||||||
|
.rt {
|
||||||
padding-top: 70rpx;
|
padding-top: 70rpx;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
page{
|
|
||||||
|
page {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 20rpx 30rpx;
|
padding: 20rpx 30rpx;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
}
|
}
|
||||||
.bj{
|
|
||||||
|
.bj {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
|
@ -502,5 +642,4 @@
|
||||||
left: 0;
|
left: 0;
|
||||||
z-index: -1;
|
z-index: -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
|
@ -77,7 +77,7 @@
|
||||||
</view>
|
</view>
|
||||||
</view> -->
|
</view> -->
|
||||||
</view>
|
</view>
|
||||||
<view class="deviceweek">
|
<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_set0[3] == 0">
|
||||||
OFF
|
OFF
|
||||||
|
@ -193,10 +193,15 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</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>
|
||||||
<!-- 开关选择 -->
|
<!-- 开关选择 -->
|
||||||
<view class="switchbox">
|
<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>
|
<image src="https://api.ccttiot.com/smartmeter/img/static/u7NwkNOoQYYsvHVMkDlu" mode=""></image>
|
||||||
<view class="yushui">
|
<view class="yushui">
|
||||||
雨水感应
|
雨水感应
|
||||||
|
@ -206,7 +211,7 @@
|
||||||
inactive-color="#7FAD76" size="40"></u-switch>
|
inactive-color="#7FAD76" size="40"></u-switch>
|
||||||
</view>
|
</view>
|
||||||
</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>
|
<image src="https://api.ccttiot.com/smartmeter/img/static/u7kd92ocUgDN052nhp4R" mode=""></image>
|
||||||
<view class="yushui">
|
<view class="yushui">
|
||||||
儿童锁 <u-switch v-if="etchecked" v-model="two" @change="btnertong" inactive-color="#eee"
|
儿童锁 <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="dingshi_he" @click="btntime">
|
||||||
<view class="naoz">
|
<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>
|
||||||
<view class="dstime">
|
<view class="dstime">
|
||||||
定时管理 <image src="https://api.ccttiot.com/smartmeter/img/static/uagx3wGa7RYvqKqoSymy" mode="">
|
定时管理 <image src="https://api.ccttiot.com/smartmeter/img/static/uagx3wGa7RYvqKqoSymy" mode="">
|
||||||
|
@ -241,13 +246,13 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- 浇水日志 -->
|
<!-- 浇水日志 -->
|
||||||
<view class="wateringlogbox" @click="btnjs">
|
<view class="wateringlogbox" v-if="pre == 'WATER'" @click="btnjs">
|
||||||
<view class="wateringlogtop">
|
<view class="wateringlogtop">
|
||||||
<image src="https://api.ccttiot.com/smartmeter/img/static/uGh3pRM7mMRSHdmvtzv3" mode=""></image>
|
<image src="https://api.ccttiot.com/smartmeter/img/static/uGh3pRM7mMRSHdmvtzv3" mode=""></image>
|
||||||
浇水日志
|
浇水日志
|
||||||
</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>
|
||||||
|
@ -363,7 +368,9 @@
|
||||||
devicesarr:[],
|
devicesarr:[],
|
||||||
intervalId: null,
|
intervalId: null,
|
||||||
imgflag:true,
|
imgflag:true,
|
||||||
ver:''
|
ver:'',
|
||||||
|
pre:'',
|
||||||
|
csbobj:{}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 分享到好友(会话)
|
// 分享到好友(会话)
|
||||||
|
@ -497,6 +504,7 @@
|
||||||
this.bjflag = false
|
this.bjflag = false
|
||||||
this.devicelist = res.data
|
this.devicelist = res.data
|
||||||
this.mac = res.data[0].mac
|
this.mac = res.data[0].mac
|
||||||
|
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
|
||||||
|
@ -683,7 +691,7 @@
|
||||||
})
|
})
|
||||||
}else{
|
}else{
|
||||||
uni.navigateTo({
|
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 => {
|
this.$u.get(`/app/getDeviceInfo/${this.shebid}`).then(res => {
|
||||||
if(res.code == 200){
|
if(res.code == 200){
|
||||||
this.mac = res.data.mac
|
this.mac = res.data.mac
|
||||||
|
this.pre = res.data.pre
|
||||||
this.deviceId = res.data.mac.match(/.{2}/g).reverse().join(':')
|
this.deviceId = res.data.mac.match(/.{2}/g).reverse().join(':')
|
||||||
this.user = res.data
|
this.user = res.data
|
||||||
}
|
}
|
||||||
|
@ -899,7 +908,11 @@
|
||||||
console.log("1收到设备发来的自定义数据结果:", options.data,options.data.length)
|
console.log("1收到设备发来的自定义数据结果:", options.data,options.data.length)
|
||||||
this.datalist = options.data.slice(0, -1) + ";"
|
this.datalist = options.data.slice(0, -1) + ";"
|
||||||
this.vardataflag = 3
|
this.vardataflag = 3
|
||||||
this.getchuli()
|
if(this.pre == 'WATER'){
|
||||||
|
this.getchuli()
|
||||||
|
}else{
|
||||||
|
this.getcsbshuju()
|
||||||
|
}
|
||||||
break
|
break
|
||||||
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START:
|
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START:
|
||||||
if (!options.result) {
|
if (!options.result) {
|
||||||
|
@ -929,7 +942,23 @@
|
||||||
console.log("定时器已清除");
|
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() {
|
getchuli() {
|
||||||
const inputString = this.datalist
|
const inputString = this.datalist
|
||||||
|
|
Loading…
Reference in New Issue
Block a user