浇花器

This commit is contained in:
3321822538@qq.com 2025-02-11 17:33:33 +08:00
parent c283b869b7
commit b8741c148b
11 changed files with 404 additions and 737 deletions

View File

@ -21,7 +21,7 @@ const install = (Vue, vm) => {
// });
Vue.prototype.$u.http.setConfig({
baseUrl: 'https://yxd.ccttiot.com/prod-api',
// baseUrl: 'https://znb.ccttiot.com',
// baseUrl: 'http://192.168.2.56:8081',
loadingText: '努力加载中~',
loadingTime: 800,
// 设置自定义头部content-type

View File

@ -118,7 +118,7 @@ function string2buffer(str) {
}
af += s;
var n1 = parseInt('110' + af.substring(0, 5), 2);
var n2 = parseInt('110' + af.substring(5), 2);
var n2 = parseInt('110' + af.slice(-12), 2);
if (n1 > 127) n1 -= 256;
if (n2 > 127) n2 -= 256;
bytes.push(n1);
@ -1099,6 +1099,7 @@ function init() {
};
mDeviceEvent.notifyDeviceMsgEvent(obj);
});
console.log("初始化!!!!!!!!!!!!")
mDeviceEvent.listenStartDiscoverBle(true, function (options) {
if (options.isStart) {
//第一步检查蓝牙适配器是否可用
@ -1109,12 +1110,12 @@ function init() {
uni.closeBluetoothAdapter({
complete: function (res)
{
// console.log("这里蓝牙数据")
uni.openBluetoothAdapter({
console.log("这里蓝牙数据")
wx.openBluetoothAdapter({
success: function (res) {
uni.getBluetoothAdapterState({
success: function (res) {
// console.log("这里蓝牙数据222")
console.log("这里蓝牙数据222")
{
let devicesList = [];
let countsTimes = 0;
@ -1146,7 +1147,8 @@ function init() {
// && devices.devices[0].name != 'SMART_R2XS'
// )
if (devices.devices[0].name.indexOf("WATER") != -1){
// console.log("跳过",devices.devices[0].name)
// if ( devices.devices[0].name.indexOf("gjkg") != -1 ){
// console.log("跳过",devices.devices[0].name)
// isnotexist = false;
isnotexist = true;
}
@ -1170,6 +1172,13 @@ function init() {
if (isnotexist) {
devicesList.push(devices.devices[0]);
console.log("devicesList",devicesList);
// let obj = {
// 'type': mDeviceEvent.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS,
// 'result': true,
// 'data': devicesList
// };
// mDeviceEvent.notifyDeviceMsgEvent(obj);
}
} else if (devices[0]) {
if (devices[0].advertisData) {
@ -1186,6 +1195,13 @@ function init() {
if (isnotexist) {
devicesList.push(devices[0]);
console.log("devicesList",devicesList);
// let obj = {
// 'type': mDeviceEvent.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS,
// 'result': true,
// 'data': devicesList
// };
// mDeviceEvent.notifyDeviceMsgEvent(obj);
}
}

View File

@ -50,6 +50,7 @@ function initXBlufi(type) {
break;
case XMQTT_SYSTEM.WeChat:
console.log("初始化@@@@@@@")
if(once==0)
{
once = 1;
@ -175,8 +176,8 @@ function listenSendRouterSsidAndPassword(isSetListener, funtion) {
function notifySendCustomData(options) {
// console.log("设备数据",options)
mOnFire.fire(OnFireEvent.EVENT_NOFITY_SEND_CUSTON_DATA, options);
console.log("设备数据",options)
mOnFire.fire(OnFireEvent.EVENT_NOFITY_SEND_CUSTON_DATA, options);
}
/**
* 发送自定义数据

View File

@ -52,7 +52,7 @@
<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>
</view>
</template>
@ -69,7 +69,6 @@
flag:false,
checked:false,
timeflag:false,
show: false,
params: {
year: false,
@ -119,47 +118,33 @@
}
},
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);
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
if(option.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)
}else{
xBlufi.notifySendCustomData({
customData: "11get"
})
}
},
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)
@ -181,30 +166,15 @@
}
}
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('手机未连接网络')
}
}
})
xBlufi.notifySendCustomData({
customData: cucun
})
setTimeout(()=>{
this.kgflag = false
},1000)
},
//
//
btnitem(key,index,values){
this.deviceindex = index
this.timeflag = true
@ -242,7 +212,7 @@
return `${minutes}${remainingSeconds < 10 ? '0' : ''}${remainingSeconds}`;
},
//
//
btnqx(){
this.timeflag = false
this.hour = '--'
@ -250,7 +220,7 @@
this.minute = '--'
this.second = '--'
},
//
//
btnqd(){
this.timeflag = false
this.hour = '--'
@ -258,29 +228,14 @@
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('手机未连接网络')
}
}
})
xBlufi.notifySendCustomData({
customData: cucun
})
setTimeout(()=> {
xBlufi.notifySendCustomData({
customData: "11get"
})
},1000)
},
//
confirm(e){
@ -294,23 +249,14 @@
this.minute = e.minute
this.second = e.second
this.devicemiao = Number(this.minute) * 60 + Number(this.second)
console.log(this.devicemiao);
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:
@ -321,11 +267,11 @@
const showObject = {}
const pSetObjects = {}
pairs.forEach(pair => {
const [key, value] = pair.split(':');
const [key, value] = pair.split(':')
if (key === 'show') {
showObject.showArray = value.split(',').map(Number);
showObject.showArray = value.split(',').map(Number)
} else if (key.startsWith('p_set')) {
const numbers = value.split(',').map(Number);
const numbers = value.split(',').map(Number)
pSetObjects[key] = numbers
}
})
@ -333,51 +279,51 @@
const ver_Data = this.list
function secondsToMinutesAndSeconds(seconds) {
const minutes = Math.floor(seconds / 60);
const remainingSeconds = seconds % 60;
return `${minutes}${remainingSeconds}`;
const minutes = Math.floor(seconds / 60)
const remainingSeconds = seconds % 60
return `${minutes}${remainingSeconds}`
}
//
const now = new Date();
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;
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 };
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; //
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 timeArray = ver_Data[key]
const timeDate = timeArrayToDate(timeArray)
//
const diff = timeDifference(timeDate, now);
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]); //
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;
prevTimeDiff = timeDifference(now, timeDate) //
prevTime = timeDate
}
}
}
@ -387,20 +333,18 @@
for (let key in this.list) {
if (this.list.hasOwnProperty(key)) {
//
let arr = this.list[key];
let arr = this.list[key]
//
if (arr[arr.length - 1] === 0) {
arr[arr.length - 1] = false;
arr[arr.length - 1] = false
} else if (arr[arr.length - 1] === 1) {
arr[arr.length - 1] = true;
arr[arr.length - 1] = true
}
}
}
break
}
},
}
}
</script>

View File

@ -87,25 +87,7 @@
},
onLoad() {
this.getinfo()
let that = this
xBlufi.initXBlufi(1);
xBlufi.listenDeviceMsgEvent(true, that.funListenDeviceMsgEvent)
xBlufi.notifyStartDiscoverBle({
'isStart': true
})
setTimeout(() => {
xBlufi.notifyStartDiscoverBle({
'isStart': false
})
if (that.devicesList.length > 0) {
// xBlufi.notifyConnectBle({
// isStart: true,
// deviceId: that.deviceId,
// name: that.name
// })
}
}, 5000)
this.btnss()
},
methods:{
//
@ -123,7 +105,7 @@
//
btnadd(e){
console.log(e,'0101');
let mac = e.slice(5, 17)
let mac = e.slice(-12)
let data = {
mac:mac,
userId:this.userid
@ -154,7 +136,6 @@
})
this.flag = false
let that = this
xBlufi.initXBlufi(1);
xBlufi.listenDeviceMsgEvent(true, that.funListenDeviceMsgEvent)
xBlufi.notifyStartDiscoverBle({
'isStart': true
@ -165,11 +146,6 @@
})
if (that.devicesList.length > 0) {
that.flags = true
// xBlufi.notifyConnectBle({
// isStart: true,
// deviceId: that.deviceId,
// name: that.name
// })
}else{
that.flags = false
}
@ -201,7 +177,7 @@
if (options.result) {
let devicesarr = options.data
this.devicesList = devicesarr
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) {

View File

@ -61,7 +61,7 @@
btnxq(plantId){
if(plantId == null || plantId == ''){
uni.showToast({
title: '非植物信息',
title: '无非植物信息',
icon: 'none',
duration: 2000
})

View File

@ -209,7 +209,6 @@
.title {
margin-top: 23rpx;
font-size: 80rpx;
// font-weight: 400;
letter-spacing: 0rpx;
line-height: 88rpx;
color: rgba(80, 86, 90, 1);
@ -233,13 +232,10 @@
.cont_left {
display: flex;
flex-wrap: wrap;
// margin-right: 40rpx;
// align-items: baseline;
width: 50%;
.cont_left_tit {
font-size: 28rpx;
// font-weight: 400;
letter-spacing: 0.56rpx;
line-height: 36rpx;
color: #3D3D3D;
@ -249,7 +245,6 @@
margin-top: 10rpx;
width: 294rpx;
font-size: 32rpx;
// font-weight: 600;
letter-spacing: 0.64rpx;
line-height: 40rpx;
color: #50565A;
@ -289,7 +284,6 @@
}
.txt {
// margin-top: 24rpx;
width: 100%;
margin-top: 12rpx;
font-size: 32rpx;

View File

@ -17,11 +17,6 @@
<text class="one" style="margin-right: 124rpx;">MAC</text>
<text>{{user.mac == undefined ? '--' : user.mac}}</text>
</view>
<!-- <view class="wifi">
<view class="">WIFI</view>
<view class="flex">ChangteA-5G <image src="https://api.ccttiot.com/smartmeter/img/static/uiTIUYnR3ClrmqOTyF8F" mode=""></image>
</view>
</view> -->
<view class="wifi" style="margin-top: 78rpx;" @click="xpshow = true">
<view class="">息屏</view>
<view class="flex">{{xptxt}}
@ -139,8 +134,10 @@
duration: 2000
})
setTimeout(() => {
uni.navigateBack()
}, 2000)
uni.reLaunch({
url:'/pages/index/index'
})
}, 1000)
} else {
uni.showToast({
title: res.msg,

File diff suppressed because it is too large Load Diff

View File

@ -331,7 +331,6 @@
uni.showLoading({
title: '请稍后...'
})
xBlufi.initXBlufi(1);
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent);
xBlufi.notifyStartDiscoverBle({
'isStart': true

View File

@ -364,7 +364,6 @@
uni.showLoading({
title: '连接中..'
})
xBlufi.initXBlufi(1);
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent);
xBlufi.notifyStartDiscoverBle({
'isStart': true