浇花器

This commit is contained in:
吴鹏 2025-09-22 15:24:01 +08:00
parent 0c19bc56db
commit 42d9dbc722
19 changed files with 1325 additions and 666 deletions

View File

@ -170,7 +170,7 @@
@import "uview-ui/index.scss";
@import "./common/css/iconfont.css";
// tabar
/deep/.u-tabbar__content__item__text{
::v-deep.u-tabbar__content__item__text{
font-size: 20rpx !important;
bottom: 10rpx !important;
}

View File

@ -21,13 +21,12 @@ const install = (Vue, vm) => {
// });
Vue.prototype.$u.http.setConfig({
baseUrl: 'https://yxd.ccttiot.com/prod-api',
// baseUrl: 'http://192.168.0.100:8081',
// baseUrl: 'http://192.168.1.3:8081',
loadingText: '努力加载中~',
loadingTime: 800,
// 设置自定义头部content-type
header: {
'content-type': 'application/json;charset=UTF-8',
},
// ......
});

View File

@ -84,11 +84,11 @@
}
</script>
<style lang="scss" scoped>
/deep/.u-tabbar__content__item__button {
::v-deep.u-tabbar__content__item__button {
top: 20rpx !important;
}
/deep/.u-tabbar {
::v-deep.u-tabbar {
.u-tabbar__content__item:nth-child(2) {
.u-tabbar__content__item__button {
width: 32rpx !important;

View File

@ -78,7 +78,7 @@
<view class="name">
<text>工作时长</text>
<view class="">
<input type="number" v-model="miao"/>
<input type="number" v-model="miao" @input="handleMiaoInput" @blur="handleMiaoBlur"/>
</view>
</view>
@ -165,7 +165,9 @@
//
defaultTime:'',
defaultTimeLength: '',
jgtian: ''
jgtian: '',
shebid:'',
zaixianobj:{}
}
},
//
@ -184,41 +186,83 @@
}
},
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)
for (let key in this.list) {
if (this.list.hasOwnProperty(key)) {
//
let arr = this.list[key];
// values[3]
arr[3] = arr[3] === 1;
}
}
console.log(this.list,'listlistlist')
} else {
this.csbobj = JSON.parse(option.list)
console.log(this.csbobj,'chobjchobj');
this.shi = this.csbobj.hour
this.fen = this.csbobj.minute
this.miao = this.csbobj.second
this.tian = this.csbobj.day
}
} else {
this.pre = option.pre
if(option.shebid){
this.shebid = option.shebid
this.getxq()
}else{
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
xBlufi.notifySendCustomData({
customData: "11get"
})
if (option.list.length > 0) { //
if (option.pre == 'WATER') {
this.list = JSON.parse(option.list)
for (let key in this.list) {
if (this.list.hasOwnProperty(key)) {
//
let arr = this.list[key];
// values[3]
arr[3] = arr[3] === 1;
}
}
console.log(this.list,'listlistlist')
} else {
this.csbobj = JSON.parse(option.list)
console.log(this.csbobj,'chobjchobj');
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: {
//
getxq(){
this.$u.get(`/app/getDeviceInfo/${this.shebid}`).then(res => {
if (res.code == 200) {
if(this.pre != 'WATER'){
this.shi = res.data.gatewayReturnParams.h.value
this.fen = res.data.gatewayReturnParams.m.value < 10 ? '0' + res.data.gatewayReturnParams.m.value : res.data.gatewayReturnParams.m.value
this.miao = res.data.gatewayReturnParams.t.value
this.tian = res.data.gatewayReturnParams.d.value
} else {
// WATER h1/m1/s1/o1...( d1..d6)
const params = res.data.gatewayReturnParams
const mapped = this.buildListFromBackend(params)
// u-switch
this.list = mapped
}
}
})
},
// ->
buildListFromBackend(params){
const result = {}
for(let i = 1; i <= 6; i++){
const h = Number(params?.[`h${i}`]?.value)
const m = Number(params?.[`m${i}`]?.value)
const s = Number(params?.[`s${i}`]?.value)
const o = Number(params?.[`o${i}`]?.value)
const d = Number(params?.[`d${i}`]?.value)
const hour = isNaN(h) ? 0 : h
const minute = isNaN(m) ? 0 : m
const second = isNaN(s) ? 0 : s
const onoff = !isNaN(o) && o === 1
const interval = isNaN(d) || d <= 0 ? 1 : d
result[`p_set${i}`] = [hour, minute, second, onoff, interval]
}
return result
},
//
confirmtime(e){
console.log(e);
@ -285,39 +329,66 @@
})
try {
this.showLoading()
// this.kgflag = true
this.btnitem(key, index, values)
this.btnqx()
// UI
this.deviceindex = index
this.devicehour = values[0] || 0 //
this.devicehour = values[0] || 0
this.deviceminute = values[1] || 0
this.devicemiao = values[2] || 0
if (this.list.hasOwnProperty(key)) {
const array = this.list[key]
const lastIndex = array.length - 1
const lastElement = array[lastIndex]
array[lastIndex] = !lastElement
this.deviceflag = lastElement ? 0 : 1
}
let flag = values[3] == 0 ? 1 : 0
let cucun = '11p_set' + (Number(this.deviceindex) + 1)+ ':' + this.devicehour + ',' + this.deviceminute + ',' + this.devicemiao + ',' + flag + ',' + this.jgtian + ';'
this.lastOperation = () => {
const prevSwitch = !!values[3]
const nextSwitch = !prevSwitch
const intervalDays = parseInt(this.jgtian) || 1
const flag = nextSwitch ? 1 : 0
const cucun = '11p_set' + (Number(this.deviceindex) + 1)+ ':' + this.devicehour + ',' + this.deviceminute + ',' + this.devicemiao + ',' + flag + ',' + intervalDays + ';'
if(this.shebid == ''){
this.lastOperation = () => {
xBlufi.notifySendCustomData({
customData: cucun
})
}
this.lastOperation()
await this.delay(1000)
xBlufi.notifySendCustomData({
customData: cucun
customData: "11get"
})
// BLE UI
setTimeout(() => {
uni.hideLoading()
this.hideLoading()
}, 1000)
}else{
let parameters = {
date:cucun
}
let data = {
deviceId:this.shebid,
instructionKey:'date',
parameters:parameters
}
this.$u.post(`/app/sendCommandByGateway`,data).then(res => {
if (res.code == 200) {
//
const keyName = `p_set${Number(this.deviceindex) + 1}`
if (this.list[keyName]) {
this.$set(this.list[keyName], 3, nextSwitch)
}
uni.showToast({
title: '设置成功',
icon: 'success',
duration:2000
})
//
}else{
//
values[3] = prevSwitch
uni.showToast({
title: res.msg,
icon: 'none',
duration:2000
})
}
})
}
this.lastOperation()
await this.delay(1000)
xBlufi.notifySendCustomData({
customData: "11get"
})
setTimeout(() => {
// this.kgflag = false
uni.hideLoading()
this.hideLoading()
}, 1000)
} catch (error) {
console.error('btnchange error:', error)
this.retryOperation()
@ -388,21 +459,56 @@
const intervalDays = parseInt(this.jgtian) || 0;
let cucun = '11p_set' + this.deviceindex + ':' + this.devicehour + ',' + this.deviceminute + ',' + this.devicemiao + ',' + 1 + ',' + intervalDays + ';'
this.lastOperation = () => {
if(this.shebid == ''){
this.lastOperation = () => {
xBlufi.notifySendCustomData({
customData: cucun
})
}
this.lastOperation()
await this.delay(1000)
xBlufi.notifySendCustomData({
customData: cucun
customData: "11get"
})
// BLE
this.hideLoading()
}else{
let parameters = {
date:cucun
}
let data = {
deviceId:this.shebid,
instructionKey:'date',
parameters:parameters
}
this.$u.post(`/app/sendCommandByGateway`,data).then(res => {
if (res.code == 200) {
uni.showToast({
title: '设置成功',
icon: 'success',
duration:2000
})
//
const key = `p_set${this.deviceindex}`
if (!this.list[key]) {
this.$set(this.list, key, [0,0,0,false,1])
}
// 使 $set
this.$set(this.list[key], 0, Number(this.devicehour) || 0)
this.$set(this.list[key], 1, Number(this.deviceminute) || 0)
this.$set(this.list[key], 2, Number(this.devicemiao) || 0)
this.$set(this.list[key], 3, true)
this.$set(this.list[key], 4, Number(intervalDays) || 1)
}else{
uni.showToast({
title: res.msg,
icon: 'none',
duration:2000
})
}
})
}
this.lastOperation()
await this.delay(1000)
xBlufi.notifySendCustomData({
customData: "11get"
});
// setTimeout(() => {
this.hideLoading()
// }, 2000)
} catch (error) {
console.error('btnqd error:', error)
this.retryOperation()
@ -427,6 +533,16 @@
return
}
// 9999
if(this.miao > 9999){
uni.showToast({
title: '工作时长最大值为9999秒',
icon: 'none',
duration:2000
})
this.miao = 9999
}
this.showLoading();
this.timeflag = false;
if(this.tian > 99){
@ -438,27 +554,48 @@
}
let tian = this.tian > 99 ? 99 : this.tian
let cucun = '11pset' + ',' + this.shi + ',' + this.fen + ',' + this.miao + ',' + tian + '@'
this.lastOperation = () => {
if(this.shebid == ''){
this.lastOperation = () => {
xBlufi.notifySendCustomData({
customData: cucun
})
};
this.lastOperation()
await this.delay(1000)
xBlufi.notifySendCustomData({
customData: cucun
customData: "11get"
})
uni.showToast({
title: '保存成功',
icon: 'success',
duration: 2000
})
};
this.lastOperation()
await this.delay(1000)
xBlufi.notifySendCustomData({
customData: "11get"
})
uni.showToast({
title: '保存成功',
icon: 'success',
duration: 2000
})
// setTimeout(() => {
this.hideLoading()
// }, 2000)
}else{
let parameters = {
date:cucun
}
let data = {
deviceId:this.shebid,
instructionKey:'date',
parameters:parameters
}
this.$u.post(`/app/sendCommandByGateway`,data).then(res => {
if (res.code == 200) {
uni.showToast({
title: '保存成功',
icon: 'success',
duration:2000
})
}else{
uni.showToast({
title: res.msg,
icon: 'none',
duration:2000
})
}
})
}
} catch (error) {
console.error('btnbc error:', error)
this.retryOperation()
@ -493,11 +630,9 @@
try {
console.log("收到设备发来的自定义数据结果:", options.data);
const inputString = options.data.slice(0, -1) + ";";
if (this.pre == 'WATER') {
const pairs = inputString.split(';');
const pSetObjects = {};
pairs.forEach(pair => {
if (!pair) return;
const [key, value] = pair.split(':');
@ -548,6 +683,43 @@
break
}
},
//
handleMiaoInput(e) {
// uni-app使e.detail.value
let value = e.detail.value || e.target.value || '';
console.log('输入值:', value); //
//
let numValue = parseInt(value) || 0;
console.log('转换后数值:', numValue); //
// 9999
if (numValue > 9999) {
numValue = 9999;
uni.showToast({
title: '工作时长最大值为9999秒',
icon: 'none',
duration: 2000
});
}
//
this.miao = numValue;
console.log('最终miao值:', this.miao); //
},
//
handleMiaoBlur(e) {
//
if (this.miao > 9999) {
this.miao = 9999;
uni.showToast({
title: '工作时长最大值为9999秒',
icon: 'none',
duration: 2000
});
}
},
//
changeDays(change) {
let newValue = (parseInt(this.jgtian) || 1) + change;
@ -559,11 +731,11 @@
</script>
<style lang="less">
/deep/ .u-title {
::v-deep .u-title {
margin-bottom: 22rpx;
}
/deep/ .uicon-nav-back {
::v-deep .uicon-nav-back {
margin-bottom: 22rpx;
}
.baocun{

View File

@ -75,10 +75,10 @@
</script>
<style lang="less">
/deep/ .u-title{
::v-deep .u-title{
margin-bottom: 22rpx;
}
/deep/ .uicon-nav-back{
::v-deep .uicon-nav-back{
margin-bottom: 22rpx;
}
.list{

View File

@ -154,10 +154,10 @@
</script>
<style lang="less">
/deep/ .u-title{
::v-deep .u-title{
margin-bottom: 22rpx;
}
/deep/ .uicon-nav-back{
::v-deep .uicon-nav-back{
margin-bottom: 22rpx;
}
.kfimg{

View File

@ -53,10 +53,10 @@
</script>
<style lang="less">
/deep/ .u-title{
::v-deep .u-title{
margin-bottom: 22rpx;
}
/deep/ .uicon-nav-back{
::v-deep .uicon-nav-back{
margin-bottom: 22rpx;
}
page{

View File

@ -1,6 +1,7 @@
<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>
<view class="page">
<!-- 有搜索到设备 -->
@ -13,7 +14,7 @@
如未找到想添加的设备点击重新搜索
</view>
<view class="list">
<view class="list_item" v-for="(item,index) in jiaohuaqi" :key="index" :class="{ show: item.show }">
<view class="list_item" v-for="(item,index) in sortedJiaohuaqi" :key="index" :class="{ show: item.show }">
<image :src="item.modelPicture" mode=""></image>
<view class="cen">
<view class="name" style="color: #ccc;" v-if="item.userId && item.userId != userid">
@ -104,6 +105,15 @@
processingQueue: false, //
}
},
computed: {
sortedJiaohuaqi() {
return this.jiaohuaqi.slice().sort((a, b) => {
if (a.ssid === undefined) return 1;
if (b.ssid === undefined) return -1;
return Math.abs(a.ssid) - Math.abs(b.ssid);
});
}
},
//
onShareAppMessage: function() {
return {
@ -380,17 +390,17 @@
</script>
<style lang="less">
/deep/ .u-input__input{
::v-deep .u-input__input{
border: 1px solid #ccc;
border-radius: 10rpx;
padding-left: 10rpx;
box-sizing: border-box;
}
/deep/ .u-title {
::v-deep .u-title {
margin-bottom: 22rpx;
}
/deep/ .uicon-nav-back {
::v-deep .uicon-nav-back {
margin-bottom: 22rpx;
}

View File

@ -216,11 +216,11 @@
</script>
<style lang="scss">
/deep/ .u-title {
::v-deep .u-title {
margin-bottom: 22rpx;
}
/deep/ .uicon-nav-back {
::v-deep .uicon-nav-back {
margin-bottom: 22rpx;
}

View File

@ -76,10 +76,10 @@
</script>
<style lang="less">
/deep/ .u-title{
::v-deep .u-title{
margin-bottom: 22rpx;
}
/deep/ .uicon-nav-back{
::v-deep .uicon-nav-back{
margin-bottom: 22rpx;
}
page{

View File

@ -138,10 +138,10 @@
</script>
<style lang="scss">
/deep/ .u-title{
::v-deep .u-title{
margin-bottom: 22rpx;
}
/deep/ .uicon-nav-back{
::v-deep .uicon-nav-back{
margin-bottom: 22rpx;
}
.about{

View File

@ -134,11 +134,15 @@
}
},
onLoad(option) {
console.log(option,'0000');
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
xBlufi.notifySendCustomData({
customData: "11get"
})
this.deviceid = option.deviceid
this.imgpic = option.img
if(option.xctime != '--'){
this.xinpin = option.xipin
// this.xinpin = option.xipin
if(option.xctime != '--' && option.ver){
this.ver = 'V' + option.ver.slice(3)
this.xctime = option.xctime
@ -156,9 +160,11 @@
},
onUnload() {
this.ver = ''
xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent)
},
onHide() {
this.ver = ''
xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent)
},
methods: {
btnxip(){
@ -178,6 +184,9 @@
xBlufi.notifySendCustomData({
customData: '11sleep' + this.xinpin + '@'
})
xBlufi.notifySendCustomData({
customData: '11get'
})
},
//
btnjiebang() {
@ -223,6 +232,8 @@
}
})
},
//
btnxianshi() {
this.nameflag = true
@ -343,7 +354,7 @@
break
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA:
// console.log("", options.data, options.data.length);
if (typeof options.data === 'string') {
console.log(options,'020202020202');
if (options.data.indexOf("prom:") !== -1) {
console.log('固件升级中')
var indexOld = options.data.substring(options.data.indexOf('prom:'))
@ -386,10 +397,38 @@
})
},1000)
}
}
} else {
console.error("options.data 不是字符串:", options.data);
}
}else{
console.log('jiexijiexi',options);
const inputString = options.data.slice(0, -1) + ";"
const hasAtSymbol = inputString.includes(',');
let processedString = inputString;
let currentDay = 0;
const pairs = processedString.split(';').filter(Boolean);
const showObject = {};
const pSetObjects = {};
// p_set
for (let i = 1; i <= 6; i++) {
pSetObjects[`p_set${i}`] = [0, 0, 0, 0, 0];
}
//
pairs.forEach(pair => {
const [key, value] = pair.split(':');
// show "ver270@show"
const cleanKey = key.includes('@') ? key.split('@')[1] : key;
if (cleanKey == 'show') {
showObject.showArray = value.split(',').map(Number);
} else if (key.startsWith('p_set')) {
const values = value.split(',').map(Number);
// 5
while (values.length < 5) {
values.push(0);
}
pSetObjects[key] = values;
}
})
console.log(showObject,'showObjectshowObject');
this.xinpin = showObject.showArray[showObject.showArray.length - 2]
}
break;
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START:
if (!options.result) {
@ -465,11 +504,11 @@
}
}
/deep/ .u-title {
::v-deep .u-title {
margin-bottom: 22rpx;
}
/deep/ .uicon-nav-back {
::v-deep .uicon-nav-back {
margin-bottom: 22rpx;
}

View File

@ -53,10 +53,10 @@
</script>
<style lang="less">
/deep/ .u-title{
::v-deep .u-title{
margin-bottom: 22rpx;
}
/deep/ .uicon-nav-back{
::v-deep .uicon-nav-back{
margin-bottom: 22rpx;
}
page{

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@
<text></text>
</view>
<view class="telsele">
<!-- <view class="telsele">
<view class="tel">
<image src="https://api.ccttiot.com/smartmeter/img/static/ucosihVOuRDfyaNn5VzX" mode=""></image> 手机号
</view>
@ -14,9 +14,9 @@
<input type="text" v-model="tel" placeholder="请输入您的手机号"/>
<image v-if="tel" @click="btnqk" style="width: 32rpx;height: 32rpx;" src="https://api.ccttiot.com/smartmeter/img/static/uE9WtCydr2ISGWek6EkS" mode=""></image>
</view>
</view>
</view> -->
<view class="telsele" style="margin-top: 36rpx;margin-bottom: 26rpx;">
<!-- <view class="telsele" style="margin-top: 36rpx;margin-bottom: 26rpx;">
<view class="tel">
<image src="https://api.ccttiot.com/smartmeter/img/static/uFiLt1SC4cHdZrIDRxeO" mode=""></image> 密码
</view>
@ -35,9 +35,9 @@
</view>
<view class="you">
没有账户 <text @click="btnljdl">立即注册</text>
</view>
</view> -->
<view class="wxlogo">
其他登录方式
登录方式
</view>
<button style="color: #ccc;margin-top: 30rpx;" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
@ -186,7 +186,7 @@
</script>
<style lang="less">
/deep/ .u-checkbox__icon-wrap{
::v-deep .u-checkbox__icon-wrap{
border: 1px solid #666666;
}
page{

View File

@ -2,12 +2,16 @@
<view>
<image src="https://api.ccttiot.com/smartmeter/img/static/uZUV03nVfyr3MvcLKUfs" class="bj" mode=""></image>
<view class="anniu">
<view class="zhuce" @click="btnzc">
<!-- <view class="zhuce" @click="btnzc">
注册
</view>
<view class="denglu" @click="denglu">
</view> -->
<!-- <view class="denglu" @click="denglu">
登录
</view>
</view> -->
<button class="denglu" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
<!-- <image src="https://api.ccttiot.com/smartmeter/img/static/uxWMldLMb888YHm0qOgN" mode=""></image> -->
快捷登录
</button>
<view class="zhuce" style="margin-top: 30rpx;" @click="denglus">
暂不登录
</view>
@ -56,6 +60,44 @@
xBlufi.initXBlufi(1)
},
methods:{
//
getPhoneNumber(e) {
this.jsCode = e.detail.code
let that = this;
const wxLoginAsync = () => {
return new Promise((resolve, reject) => {
wx.login({
success(res) {
if (res.code) {
that.mobileCode = res.code
let data = {
jsCode: e.detail.code,
mobileCode: res.code,
}
resolve(data);
} else {
reject(res.errMsg)
}
},
fail(err) {
reject(err)
}
})
})
}
wxLoginAsync().then(async (data) => {
this.$u.post(`/wxlogin?mobileCode=${this.jsCode}&jsCode=${this.mobileCode}`, data).then((res) => {
if (res.code == 200) {
wx.setStorageSync('token', res.token)
uni.switchTab({
url:'/pages/index/index'
})
}
})
}).catch((err) => {
console.error(err)
})
},
//
btnzc(){
uni.navigateTo({

View File

@ -226,10 +226,10 @@
</script>
<style lang="less">
/deep/ .u-title{
::v-deep .u-title{
margin-bottom: 22rpx;
}
/deep/ .uicon-nav-back{
::v-deep .uicon-nav-back{
margin-bottom: 22rpx;
}
page{

View File

@ -132,13 +132,28 @@
duration: 2000
})
}else{
let that = this
wx.login({
success(res) {
if (res.code) {
that.mobileCode = res.code
resolve(data);
} else {
reject(res.errMsg)
}
},
fail(err) {
reject(err)
}
})
let data = {
phone:this.tel,
phoneCode:this.yzm,
uuid:this.uuid,
password:this.password
phone:that.tel,
phoneCode:that.yzm,
uuid:that.uuid,
password:that.password,
jsCode:that.mobileCode
}
this.$u.post(`/appCodeLogin`,data).then((res) => {
that.$u.post(`/appCodeLogin`,data).then((res) => {
if (res.code == 200) {
wx.setStorageSync('token', res.token)
uni.switchTab({
@ -269,7 +284,7 @@
</script>
<style lang="less">
/deep/ .u-checkbox__icon-wrap{
::v-deep .u-checkbox__icon-wrap{
border: 1px solid #666666;
}
page{

View File

@ -89,7 +89,7 @@
</script>
<style lang="scss">
/deep/ .map{
::v-deep .map{
width: 100%;
height: 100%;
}