浇花器

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({ Vue.prototype.$u.http.setConfig({
baseUrl: 'https://yxd.ccttiot.com/prod-api', baseUrl: 'https://yxd.ccttiot.com/prod-api',
// baseUrl: 'https://znb.ccttiot.com', // baseUrl: 'http://192.168.2.56:8081',
loadingText: '努力加载中~', loadingText: '努力加载中~',
loadingTime: 800, loadingTime: 800,
// 设置自定义头部content-type // 设置自定义头部content-type

View File

@ -118,7 +118,7 @@ function string2buffer(str) {
} }
af += s; af += s;
var n1 = parseInt('110' + af.substring(0, 5), 2); 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 (n1 > 127) n1 -= 256;
if (n2 > 127) n2 -= 256; if (n2 > 127) n2 -= 256;
bytes.push(n1); bytes.push(n1);
@ -1099,6 +1099,7 @@ function init() {
}; };
mDeviceEvent.notifyDeviceMsgEvent(obj); mDeviceEvent.notifyDeviceMsgEvent(obj);
}); });
console.log("初始化!!!!!!!!!!!!")
mDeviceEvent.listenStartDiscoverBle(true, function (options) { mDeviceEvent.listenStartDiscoverBle(true, function (options) {
if (options.isStart) { if (options.isStart) {
//第一步检查蓝牙适配器是否可用 //第一步检查蓝牙适配器是否可用
@ -1109,12 +1110,12 @@ function init() {
uni.closeBluetoothAdapter({ uni.closeBluetoothAdapter({
complete: function (res) complete: function (res)
{ {
// console.log("这里蓝牙数据") console.log("这里蓝牙数据")
uni.openBluetoothAdapter({ wx.openBluetoothAdapter({
success: function (res) { success: function (res) {
uni.getBluetoothAdapterState({ uni.getBluetoothAdapterState({
success: function (res) { success: function (res) {
// console.log("这里蓝牙数据222") console.log("这里蓝牙数据222")
{ {
let devicesList = []; let devicesList = [];
let countsTimes = 0; let countsTimes = 0;
@ -1146,7 +1147,8 @@ function init() {
// && devices.devices[0].name != 'SMART_R2XS' // && devices.devices[0].name != 'SMART_R2XS'
// ) // )
if (devices.devices[0].name.indexOf("WATER") != -1){ 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 = false;
isnotexist = true; isnotexist = true;
} }
@ -1170,6 +1172,13 @@ function init() {
if (isnotexist) { if (isnotexist) {
devicesList.push(devices.devices[0]); 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]) { } else if (devices[0]) {
if (devices[0].advertisData) { if (devices[0].advertisData) {
@ -1186,6 +1195,13 @@ function init() {
if (isnotexist) { if (isnotexist) {
devicesList.push(devices[0]); 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; break;
case XMQTT_SYSTEM.WeChat: case XMQTT_SYSTEM.WeChat:
console.log("初始化@@@@@@@")
if(once==0) if(once==0)
{ {
once = 1; once = 1;
@ -175,8 +176,8 @@ function listenSendRouterSsidAndPassword(isSetListener, funtion) {
function notifySendCustomData(options) { function notifySendCustomData(options) {
// console.log("设备数据",options) console.log("设备数据",options)
mOnFire.fire(OnFireEvent.EVENT_NOFITY_SEND_CUSTON_DATA, 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 class="mask" style="z-index: 9999;" v-if="kgflag"></view>
</view> </view>
<view class="" style="width: 100%;padding-top: 80rpx;text-align: center;color: #000;font-size: 36rpx;"> <view class="" style="width: 100%;padding-top: 80rpx;text-align: center;color: #000;font-size: 36rpx;">
设备未连接 没有更多定时浇水啦...
</view> </view>
</view> </view>
</template> </template>
@ -69,7 +69,6 @@
flag:false, flag:false,
checked:false, checked:false,
timeflag:false, timeflag:false,
show: false, show: false,
params: { params: {
year: false, year: false,
@ -119,47 +118,33 @@
} }
}, },
onLoad(option) { onLoad(option) {
// this.list = JSON.parse(option.list) xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
// for (let key in this.list) { if(option.list){ //
// if (this.list.hasOwnProperty(key)) { this.list = JSON.parse(option.list)
// // for (let key in this.list) {
// let arr = this.list[key]; if (this.list.hasOwnProperty(key)) {
// // //
// if (arr[arr.length - 1] === 0) { let arr = this.list[key];
// arr[arr.length - 1] = false; //
// } else if (arr[arr.length - 1] === 1) { if (arr[arr.length - 1] === 0) {
// arr[arr.length - 1] = true; arr[arr.length - 1] = false;
// } } else if (arr[arr.length - 1] === 1) {
// } arr[arr.length - 1] = true;
// } }
// console.log(this.list); }
}
console.log(this.list)
}else{
xBlufi.notifySendCustomData({
customData: "11get"
})
}
}, },
onShow() { 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:{ methods:{
// //
btnchange(key,index,values){ btnchange(key,index,values){
this.kgflag = true this.kgflag = true
this.btnitem(key,index,values) this.btnitem(key,index,values)
@ -181,30 +166,15 @@
} }
} }
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 + '@'
uni.getNetworkType({ xBlufi.notifySendCustomData({
success(res) { customData: cucun
if (res.networkType !== 'none') { })
uni.getConnectedBluetoothDevices({
success(res) {
xBlufi.notifySendCustomData({
customData: cucun
})
},
fail(err) {
console.error('获取已连接蓝牙设备信息失败:',err)
}
})
} else {
console.log('手机未连接网络')
}
}
})
setTimeout(()=>{ setTimeout(()=>{
this.kgflag = false this.kgflag = false
},1000) },1000)
}, },
// //
btnitem(key,index,values){ btnitem(key,index,values){
this.deviceindex = index this.deviceindex = index
this.timeflag = true this.timeflag = true
@ -242,7 +212,7 @@
return `${minutes}${remainingSeconds < 10 ? '0' : ''}${remainingSeconds}`; return `${minutes}${remainingSeconds < 10 ? '0' : ''}${remainingSeconds}`;
}, },
// //
btnqx(){ btnqx(){
this.timeflag = false this.timeflag = false
this.hour = '--' this.hour = '--'
@ -250,7 +220,7 @@
this.minute = '--' this.minute = '--'
this.second = '--' this.second = '--'
}, },
// //
btnqd(){ btnqd(){
this.timeflag = false this.timeflag = false
this.hour = '--' this.hour = '--'
@ -258,29 +228,14 @@
this.minute = '--' this.minute = '--'
this.second = '--' this.second = '--'
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 + '@'
uni.getNetworkType({ xBlufi.notifySendCustomData({
success(res) { customData: cucun
if (res.networkType !== 'none') { })
uni.getConnectedBluetoothDevices({ setTimeout(()=> {
success(res) { xBlufi.notifySendCustomData({
xBlufi.notifySendCustomData({ customData: "11get"
customData: cucun })
}) },1000)
setTimeout(()=> {
xBlufi.notifySendCustomData({
customData: "11get"
})
},1000)
},
fail(err) {
console.error('获取已连接蓝牙设备信息失败:',err)
}
})
} else {
console.log('手机未连接网络')
}
}
})
}, },
// //
confirm(e){ confirm(e){
@ -294,23 +249,14 @@
this.minute = e.minute this.minute = e.minute
this.second = e.second this.second = e.second
this.devicemiao = Number(this.minute) * 60 + Number(this.second) this.devicemiao = Number(this.minute) * 60 + Number(this.second)
console.log(this.devicemiao); console.log(this.devicemiao)
}, },
funListenDeviceMsgEvent: function(options) { funListenDeviceMsgEvent: function(options) {
switch (options.type) { switch (options.type) {
case xBlufi.XBLUFI_TYPE.TYPE_STATUS_CONNECTED: case xBlufi.XBLUFI_TYPE.TYPE_STATUS_CONNECTED:
if (!options.result) { if (!options.result) {
// uni.showModal({
// title: '',
// content: '',
// showCancel: false,
// //
// success: function(res) {
// uni.hideLoading()
// uni.removeStorage({key:'device_key'})
// }
// })
} }
break; break;
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA: case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA:
@ -321,11 +267,11 @@
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
} }
}) })
@ -333,51 +279,51 @@
const ver_Data = this.list const ver_Data = this.list
function secondsToMinutesAndSeconds(seconds) { function secondsToMinutesAndSeconds(seconds) {
const minutes = Math.floor(seconds / 60); const minutes = Math.floor(seconds / 60)
const remainingSeconds = seconds % 60; const remainingSeconds = seconds % 60
return `${minutes}${remainingSeconds}`; 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.minutes) {
nextTimeDiff = diff; nextTimeDiff = diff
nextTime = timeDate; nextTime = timeDate
nextWaterDuration = secondsToMinutesAndSeconds(timeArray[2]); // nextWaterDuration = secondsToMinutesAndSeconds(timeArray[2]) //
} }
} else { } 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); // prevTimeDiff = timeDifference(now, timeDate) //
prevTime = timeDate; prevTime = timeDate
} }
} }
} }
@ -387,20 +333,18 @@
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 break
} }
}, },
} }
} }
</script> </script>

View File

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

View File

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

View File

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

View File

@ -17,11 +17,6 @@
<text class="one" style="margin-right: 124rpx;">MAC</text> <text class="one" style="margin-right: 124rpx;">MAC</text>
<text>{{user.mac == undefined ? '--' : user.mac}}</text> <text>{{user.mac == undefined ? '--' : user.mac}}</text>
</view> </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="wifi" style="margin-top: 78rpx;" @click="xpshow = true">
<view class="">息屏</view> <view class="">息屏</view>
<view class="flex">{{xptxt}} <view class="flex">{{xptxt}}
@ -139,8 +134,10 @@
duration: 2000 duration: 2000
}) })
setTimeout(() => { setTimeout(() => {
uni.navigateBack() uni.reLaunch({
}, 2000) url:'/pages/index/index'
})
}, 1000)
} else { } else {
uni.showToast({ uni.showToast({
title: res.msg, title: res.msg,

File diff suppressed because it is too large Load Diff

View File

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

View File

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