完善 命令发送 初步
This commit is contained in:
parent
b3da673f96
commit
f6c4e7d835
|
@ -6,12 +6,12 @@
|
|||
<image class="bj" src="https://api.ccttiot.com/smartmeter/img/static/urqUoIyCCEBykZ2oG8eO" mode=""></image>
|
||||
<view class="list">
|
||||
<view class="list_val" v-for="(values, key, index) in list" :key="key">
|
||||
<view class="lt" @click="btnitem(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]" 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>
|
||||
|
@ -22,7 +22,7 @@
|
|||
设置浇水
|
||||
</view>
|
||||
<view class="ts">
|
||||
距离下次浇水时间还有20小时41分
|
||||
距离下次浇水时间还有{{xctime}}
|
||||
</view>
|
||||
<view class="shifen" @click="show = true">
|
||||
<text>{{hour}}时</text> <text>{{minutekq}}分</text>
|
||||
|
@ -48,10 +48,13 @@
|
|||
<!-- 定时时长 -->
|
||||
<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>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var xBlufi = require("@/components/blufi/xBlufi.js")
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
|
@ -86,7 +89,14 @@
|
|||
hour:'--',
|
||||
minutekq:'--',
|
||||
list:{},
|
||||
checkedStatus: {}
|
||||
checkedStatus: {},
|
||||
deviceindex:'',
|
||||
devicemiao:'',
|
||||
deviceflag:'',
|
||||
devicehour:'',
|
||||
deviceminute:'',
|
||||
kgflag:false,
|
||||
xctime:''
|
||||
}
|
||||
},
|
||||
// 分享到好友(会话)
|
||||
|
@ -105,22 +115,115 @@
|
|||
}
|
||||
},
|
||||
onLoad(option) {
|
||||
this.list = JSON.parse(option.list)
|
||||
for (let key in this.list) {
|
||||
if (this.list.hasOwnProperty(key)) {
|
||||
// 获取当前数组
|
||||
let arr = this.list[key];
|
||||
// 判断数组的最后一个元素,并进行替换
|
||||
if (arr[arr.length - 1] === 0) {
|
||||
arr[arr.length - 1] = false;
|
||||
} else if (arr[arr.length - 1] === 1) {
|
||||
arr[arr.length - 1] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log(this.list);
|
||||
// this.list = JSON.parse(option.list)
|
||||
// for (let key in this.list) {
|
||||
// if (this.list.hasOwnProperty(key)) {
|
||||
// // 获取当前数组
|
||||
// let arr = this.list[key];
|
||||
// // 判断数组的最后一个元素,并进行替换
|
||||
// if (arr[arr.length - 1] === 0) {
|
||||
// arr[arr.length - 1] = false;
|
||||
// } else if (arr[arr.length - 1] === 1) {
|
||||
// arr[arr.length - 1] = true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// console.log(this.list);
|
||||
},
|
||||
onShow() {
|
||||
xBlufi.initXBlufi(1)
|
||||
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
|
||||
uni.getNetworkType({
|
||||
success(res) {
|
||||
if (res.networkType !== 'none') {
|
||||
uni.getConnectedBluetoothDevices({
|
||||
success(res) {
|
||||
setTimeout(()=> {
|
||||
xBlufi.notifySendCustomData({
|
||||
customData: "11get"
|
||||
})
|
||||
},1000)
|
||||
},
|
||||
fail(err) {
|
||||
console.error('获取已连接蓝牙设备信息失败:',err)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
console.log('手机未连接网络')
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
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 + '@'
|
||||
uni.getNetworkType({
|
||||
success(res) {
|
||||
if (res.networkType !== 'none') {
|
||||
uni.getConnectedBluetoothDevices({
|
||||
success(res) {
|
||||
xBlufi.notifySendCustomData({
|
||||
customData: cucun
|
||||
})
|
||||
},
|
||||
fail(err) {
|
||||
console.error('获取已连接蓝牙设备信息失败:',err)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
console.log('手机未连接网络')
|
||||
}
|
||||
}
|
||||
})
|
||||
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');
|
||||
|
@ -134,29 +237,164 @@
|
|||
const remainingSeconds = seconds % 60;
|
||||
return `${minutes}分${remainingSeconds < 10 ? '0' : ''}${remainingSeconds}秒`;
|
||||
},
|
||||
|
||||
// 点击定时
|
||||
btnitem(){
|
||||
this.timeflag = true
|
||||
},
|
||||
|
||||
// 取消选择定时
|
||||
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 + '@'
|
||||
uni.getNetworkType({
|
||||
success(res) {
|
||||
if (res.networkType !== 'none') {
|
||||
uni.getConnectedBluetoothDevices({
|
||||
success(res) {
|
||||
xBlufi.notifySendCustomData({
|
||||
customData: cucun
|
||||
})
|
||||
setTimeout(()=> {
|
||||
xBlufi.notifySendCustomData({
|
||||
customData: "11get"
|
||||
})
|
||||
},1000)
|
||||
},
|
||||
fail(err) {
|
||||
console.error('获取已连接蓝牙设备信息失败:',err)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
console.log('手机未连接网络')
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
// 定时浇水时间
|
||||
confirm(e){
|
||||
this.hour = e.hour
|
||||
this.minutekq = e.minute
|
||||
this.devicehour = e.hour
|
||||
this.deviceminute = e.minute
|
||||
},
|
||||
// 定时浇水时长
|
||||
confirms(e){
|
||||
this.minute = e.minute
|
||||
this.second = e.second
|
||||
}
|
||||
this.devicemiao = Number(this.minute) * 60 + Number(this.second)
|
||||
console.log(this.devicemiao);
|
||||
},
|
||||
|
||||
funListenDeviceMsgEvent: function(options) {
|
||||
switch (options.type) {
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_STATUS_CONNECTED:
|
||||
if (!options.result) {
|
||||
uni.showModal({
|
||||
title: '很抱歉提醒你!',
|
||||
content: '小程序与设备异常断开',
|
||||
showCancel: false,
|
||||
//是否显示取消按钮
|
||||
success: function(res) {
|
||||
uni.hideLoading()
|
||||
uni.removeStorage({key:'device_key'})
|
||||
}
|
||||
})
|
||||
}
|
||||
break;
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA:
|
||||
console.log("1收到设备发来的自定义数据结果:", options.data)
|
||||
const inputString = options.data
|
||||
const pairs = inputString.split(';')
|
||||
const showObject = {}
|
||||
const pSetObjects = {}
|
||||
pairs.forEach(pair => {
|
||||
const [key, value] = pair.split(':');
|
||||
if (key === 'show') {
|
||||
showObject.showArray = value.split(',').map(Number);
|
||||
} else if (key.startsWith('p_set')) {
|
||||
const numbers = value.split(',').map(Number);
|
||||
pSetObjects[key] = numbers
|
||||
}
|
||||
})
|
||||
this.list = pSetObjects //六个浇水时间段
|
||||
|
||||
const ver_Data = this.list
|
||||
function secondsToMinutesAndSeconds(seconds) {
|
||||
const minutes = Math.floor(seconds / 60);
|
||||
const remainingSeconds = seconds % 60;
|
||||
return `${minutes}分${remainingSeconds}秒`;
|
||||
}
|
||||
// 获取当前时间
|
||||
const now = new Date();
|
||||
// 辅助函数:将时间数组转换为 Date 对象
|
||||
function timeArrayToDate(timeArray) {
|
||||
const [hour, minute, second] = timeArray.slice(0, 3);
|
||||
const date = new Date();
|
||||
date.setHours(hour, minute, second, 0); // 毫秒设为0
|
||||
return date;
|
||||
}
|
||||
// 辅助函数:计算两个时间之间的差值(以小时和分钟表示)
|
||||
function timeDifference(date1, date2) {
|
||||
const diffMs = Math.abs(date1 - date2);
|
||||
const diffSeconds = Math.floor(diffMs / 1000);
|
||||
const diffMinutes = Math.floor(diffSeconds / 60);
|
||||
const diffHours = Math.floor(diffMinutes / 60);
|
||||
const remainingMinutes = diffMinutes % 60;
|
||||
return { hours: diffHours, minutes: remainingMinutes };
|
||||
}
|
||||
// 遍历 ver_Data 对象
|
||||
let nextTimeDiff = null;
|
||||
let nextTime = null;
|
||||
let prevTimeDiff = null;
|
||||
let prevTime = null;
|
||||
let nextWaterDuration = null; // 用于存储下次浇水时长
|
||||
for (const key in ver_Data) {
|
||||
if (ver_Data.hasOwnProperty(key) && ver_Data[key][3] === 1) {
|
||||
const timeArray = ver_Data[key];
|
||||
const timeDate = timeArrayToDate(timeArray);
|
||||
// 计算与当前时间的差值
|
||||
const diff = timeDifference(timeDate, now);
|
||||
// 判断是下一次时间还是上一次时间
|
||||
if (timeDate > now) {
|
||||
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())) {
|
||||
prevTimeDiff = timeDifference(now, timeDate); // 注意这里要反过来算
|
||||
prevTime = timeDate;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 输出结果
|
||||
this.xctime = `${nextTimeDiff.hours}时${nextTimeDiff.minutes}分`
|
||||
for (let key in this.list) {
|
||||
if (this.list.hasOwnProperty(key)) {
|
||||
// 获取当前数组
|
||||
let arr = this.list[key];
|
||||
// 判断数组的最后一个元素,并进行替换
|
||||
if (arr[arr.length - 1] === 0) {
|
||||
arr[arr.length - 1] = false;
|
||||
} else if (arr[arr.length - 1] === 1) {
|
||||
arr[arr.length - 1] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,13 +57,13 @@
|
|||
</image> 手动浇水
|
||||
</view>
|
||||
<view class="shengyu">
|
||||
剩余:5分钟
|
||||
剩余:{{ sdminutes ? sdminutes + ':' : '' }}{{ sdseconds ? sdseconds : '--' }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="deviceweek">
|
||||
<view class="weeklist">
|
||||
<view class="kg" v-if="ver_data.p_set5[3] == 1">
|
||||
<view class="kg" v-if="ver_data.p_set0[3] == 0">
|
||||
OFF
|
||||
</view>
|
||||
<view class="kg" style="color: #48893B;" v-else>
|
||||
|
@ -78,7 +78,7 @@
|
|||
</view>
|
||||
</view>
|
||||
<view class="weeklist">
|
||||
<view class="kg" v-if="ver_data.p_set4[3] == 1">
|
||||
<view class="kg" v-if="ver_data.p_set1[3] == 0">
|
||||
OFF
|
||||
</view>
|
||||
<view class="kg" style="color: #48893B;" v-else>
|
||||
|
@ -93,7 +93,7 @@
|
|||
</view>
|
||||
</view>
|
||||
<view class="weeklist">
|
||||
<view class="kg" v-if="ver_data.p_set3[3] == 1">
|
||||
<view class="kg" v-if="ver_data.p_set2[3] == 0">
|
||||
OFF
|
||||
</view>
|
||||
<view class="kg" style="color: #48893B;" v-else>
|
||||
|
@ -108,7 +108,7 @@
|
|||
</view>
|
||||
</view>
|
||||
<view class="weeklist">
|
||||
<view class="kg" v-if="ver_data.p_set2[3] == 1">
|
||||
<view class="kg" v-if="ver_data.p_set3[3] == 0">
|
||||
OFF
|
||||
</view>
|
||||
<view class="kg" style="color: #48893B;" v-else>
|
||||
|
@ -123,7 +123,7 @@
|
|||
</view>
|
||||
</view>
|
||||
<view class="weeklist">
|
||||
<view class="kg" v-if="ver_data.p_set1[3] == 1">
|
||||
<view class="kg" v-if="ver_data.p_set4[3] == 0">
|
||||
OFF
|
||||
</view>
|
||||
<view class="kg" style="color: #48893B;" v-else>
|
||||
|
@ -138,7 +138,7 @@
|
|||
</view>
|
||||
</view>
|
||||
<view class="weeklist">
|
||||
<view class="kg" v-if="ver_data.p_set0[3] == 1">
|
||||
<view class="kg" v-if="ver_data.p_set5[3] == 0">
|
||||
OFF
|
||||
</view>
|
||||
<view class="kg" style="color: #48893B;" v-else>
|
||||
|
@ -225,7 +225,7 @@
|
|||
<view class="toptit">
|
||||
选择浇水时长
|
||||
</view>
|
||||
<view class="container" @click="showjs = true">
|
||||
<view class="container" @click="btnshowjs">
|
||||
<view class="">{{minute}}分</view>
|
||||
<text>:</text>
|
||||
<view class="">{{second}}秒</view>
|
||||
|
@ -250,19 +250,15 @@
|
|||
|
||||
<script>
|
||||
var xBlufi = require("@/components/blufi/xBlufi.js")
|
||||
import TimePicker from '@/components/TimePicker/index.vue'
|
||||
export default {
|
||||
components: {
|
||||
TimePicker
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
one:false,
|
||||
ones:true,
|
||||
two:false,
|
||||
twos:true,
|
||||
yschecked: '',
|
||||
etchecked: '',
|
||||
yschecked: true,
|
||||
etchecked:true,
|
||||
kgflag: false,
|
||||
activeshu: 0,
|
||||
xuanzeflag: false,
|
||||
|
@ -291,7 +287,9 @@
|
|||
xctime:'--',
|
||||
sctimejs:'--',
|
||||
xctimesc:'--',
|
||||
xctimesj:''
|
||||
xctimesj:'',
|
||||
sdminutes:'',
|
||||
sdseconds:''
|
||||
}
|
||||
},
|
||||
// 分享到好友(会话)
|
||||
|
@ -332,11 +330,15 @@
|
|||
},
|
||||
onShow() {
|
||||
this.getinfo()
|
||||
},
|
||||
mounted() {
|
||||
this.getshuju()
|
||||
|
||||
},
|
||||
methods: {
|
||||
// 点击选择时间
|
||||
btnshowjs(){
|
||||
this.showjs = true
|
||||
},
|
||||
|
||||
formattedTime(minutes, seconds) {
|
||||
// 将数字转换为字符串并补零
|
||||
const formattedMinutes = String(minutes).padStart(2, '0');
|
||||
|
@ -379,74 +381,7 @@
|
|||
}
|
||||
})
|
||||
},
|
||||
|
||||
kq(){
|
||||
uni.getNetworkType({
|
||||
success(res) {
|
||||
if (res.networkType !== 'none') {
|
||||
uni.getConnectedBluetoothDevices({
|
||||
success(res) {
|
||||
setTimeout(()=> {
|
||||
xBlufi.notifySendCustomData({
|
||||
customData:'11open'
|
||||
})
|
||||
},1500)
|
||||
},
|
||||
fail(err) {
|
||||
console.error('获取已连接蓝牙设备信息失败:',err)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
console.log('手机未连接网络')
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
gb(){
|
||||
uni.getNetworkType({
|
||||
success(res) {
|
||||
if (res.networkType !== 'none') {
|
||||
uni.getConnectedBluetoothDevices({
|
||||
success(res) {
|
||||
setTimeout(()=> {
|
||||
xBlufi.notifySendCustomData({
|
||||
customData:'11close'
|
||||
})
|
||||
},1500)
|
||||
},
|
||||
fail(err) {
|
||||
console.error('获取已连接蓝牙设备信息失败:',err)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
console.log('手机未连接网络')
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
hq(){
|
||||
uni.getNetworkType({
|
||||
success(res) {
|
||||
if (res.networkType !== 'none') {
|
||||
uni.getConnectedBluetoothDevices({
|
||||
success(res) {
|
||||
setTimeout(()=> {
|
||||
xBlufi.notifySendCustomData({
|
||||
customData:'11get'
|
||||
})
|
||||
},1500)
|
||||
},
|
||||
fail(err) {
|
||||
console.error('获取已连接蓝牙设备信息失败:',err)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
console.log('手机未连接网络')
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
// 雨水感应
|
||||
// 雨水感应开启
|
||||
btnyushui(){
|
||||
let that = this
|
||||
uni.getNetworkType({
|
||||
|
@ -471,6 +406,7 @@
|
|||
}
|
||||
})
|
||||
},
|
||||
// 雨水感应关闭
|
||||
btnyushuis(){
|
||||
let that = this
|
||||
uni.getNetworkType({
|
||||
|
@ -495,7 +431,7 @@
|
|||
}
|
||||
})
|
||||
},
|
||||
// 点击儿童锁
|
||||
// 点击儿童锁开启
|
||||
btnertong(){
|
||||
let that = this
|
||||
uni.getNetworkType({
|
||||
|
@ -520,6 +456,7 @@
|
|||
}
|
||||
})
|
||||
},
|
||||
// 点击儿童锁关闭
|
||||
btnertongs(){
|
||||
let that = this
|
||||
uni.getNetworkType({
|
||||
|
@ -570,6 +507,7 @@
|
|||
btnqx(){
|
||||
this.sdjsflag = false
|
||||
},
|
||||
// 确定选择时间
|
||||
btnqd(){
|
||||
if(this.minute == '--' || this.second == '--'){
|
||||
uni.showToast({
|
||||
|
@ -588,6 +526,7 @@
|
|||
xBlufi.notifySendCustomData({
|
||||
customData: "11time@" + that.jstime + '@'
|
||||
})
|
||||
that.startTimer(that.jstime)
|
||||
that.sdjsflag = false
|
||||
that.kgflag = true
|
||||
},1500)
|
||||
|
@ -603,8 +542,32 @@
|
|||
})
|
||||
}
|
||||
},
|
||||
|
||||
// 手动浇水定时器
|
||||
startTimer(totalSeconds) {
|
||||
let remainingSeconds = totalSeconds
|
||||
console.log(remainingSeconds,'000');
|
||||
const timer = setInterval(() => {
|
||||
// 计算分钟和秒
|
||||
const minutes = Math.floor(remainingSeconds / 60).toString()
|
||||
const secs = (remainingSeconds % 60).toString()
|
||||
// 格式化秒,确保是两位数
|
||||
this.sdseconds = secs.padStart(2, '0')
|
||||
// 如果分钟大于0,则显示分钟;否则,不显示(只显示秒)
|
||||
this.sdminutes = minutes.padStart(2, '0')
|
||||
// 更新剩余秒数
|
||||
remainingSeconds--;
|
||||
// 如果剩余秒数为0,则停止定时器
|
||||
if (remainingSeconds <= 0) {
|
||||
clearInterval(timer)
|
||||
this.btnkq()
|
||||
this.sdminutes = ''
|
||||
this.sdseconds = ''
|
||||
}
|
||||
}, 1000)
|
||||
},
|
||||
|
||||
// 关闭
|
||||
// 关闭手动浇水
|
||||
btnkq() {
|
||||
let that = this
|
||||
uni.getNetworkType({
|
||||
|
@ -681,7 +644,7 @@
|
|||
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS:
|
||||
if (options.result) {
|
||||
let devicesarr = options.data
|
||||
console.log(devicesarr,'111')
|
||||
// console.log(devicesarr,'111')
|
||||
devicesarr.forEach(device => {
|
||||
const mac = device.name.substring(4)
|
||||
if (device.name.slice(5, 17) == this.mac) {
|
||||
|
@ -740,10 +703,12 @@
|
|||
showObject.showArray = value.split(',').map(Number);
|
||||
} else if (key.startsWith('p_set')) {
|
||||
const numbers = value.split(',').map(Number);
|
||||
pSetObjects[key] = numbers;
|
||||
pSetObjects[key] = numbers
|
||||
}
|
||||
})
|
||||
this.ver_data = pSetObjects //六个浇水时间段
|
||||
console.log(this.ver_data,'002002002')
|
||||
|
||||
this.showobj = showObject //雨滴,锁,等是否开启
|
||||
if(this.showobj.showArray[1] == 1){
|
||||
this.yschecked = false
|
||||
|
@ -814,12 +779,13 @@
|
|||
this.sctimejs = timesc.slice(0,-3)
|
||||
let xcjs = nextTime.toTimeString().split(' ')[0]
|
||||
this.xctimesj = xcjs.slice(0,-3)
|
||||
console.log(xcjs,'121212',this.formattedTime(this.ver_data.p_set5[0],this.ver_data.p_set5[1]))
|
||||
// console.log('距离下次最近的时间差:', nextTimeDiff ? `${nextTimeDiff.hours}时${nextTimeDiff.minutes}分` : '无');
|
||||
// console.log('下次时间:', nextTime ? nextTime.toTimeString().split(' ')[0] : '无');
|
||||
// console.log('下次浇水时长:', nextWaterDuration || '无');
|
||||
// console.log('距离上次最近的时间差:', prevTimeDiff ? `${prevTimeDiff.hours}时${prevTimeDiff.minutes}分` : '无');
|
||||
// console.log('上次时间:', prevTime ? prevTime.toTimeString().split(' ')[0] : '无')
|
||||
|
||||
|
||||
|
||||
break
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_STOP:
|
||||
|
@ -843,8 +809,30 @@
|
|||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
// 每隔一分钟发送一次获取数据
|
||||
getshuju(){
|
||||
const intervalId = setInterval(() => {
|
||||
uni.getNetworkType({
|
||||
success(res) {
|
||||
if (res.networkType !== 'none') {
|
||||
uni.getConnectedBluetoothDevices({
|
||||
success(res) {
|
||||
setTimeout(()=> {
|
||||
xBlufi.notifySendCustomData({
|
||||
customData: "11get"
|
||||
})
|
||||
},1000)
|
||||
},
|
||||
fail(err) {
|
||||
console.error('获取已连接蓝牙设备信息失败:',err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log("定时器每分钟执行一次");
|
||||
}, 60000)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user