From 3570f4d736c90248a35fc422202a94dab7879530 Mon Sep 17 00:00:00 2001
From: "3321822538@qq.com" <3321822538@qq.com>
Date: Thu, 17 Apr 2025 10:20:41 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B5=87=E8=8A=B1=E5=99=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
common/http.interceptor.js | 14 +--
page_user/dingshi.vue | 2 +-
page_user/lanya.vue | 17 ++-
page_user/upload.vue | 68 +++++++-----
page_user/yinsixq.vue | 10 +-
pages/index/index.vue | 209 +++++++++++++++++++------------------
pages/login/denglu.vue | 5 +-
pages/login/login.vue | 26 ++++-
pages/login/zhuce.vue | 5 +-
pages/my.vue | 21 +++-
pages/tj.vue | 2 -
11 files changed, 224 insertions(+), 155 deletions(-)
diff --git a/common/http.interceptor.js b/common/http.interceptor.js
index a0130b6..ded5d64 100644
--- a/common/http.interceptor.js
+++ b/common/http.interceptor.js
@@ -21,7 +21,7 @@ const install = (Vue, vm) => {
// });
Vue.prototype.$u.http.setConfig({
baseUrl: 'https://yxd.ccttiot.com/prod-api',
- // baseUrl: 'http://192.168.2.56:8081',
+ // baseUrl: 'http://192.168.0.107:8081',
loadingText: '努力加载中~',
loadingTime: 800,
// 设置自定义头部content-type
@@ -115,15 +115,15 @@ const install = (Vue, vm) => {
};
vm.$u.post(`/loginByopenid?jsCode=${res.code}`,data).then(res=>{
if (res.code == 10003) {
- uni.navigateTo({
- url:'/pages/login/login'
- })
+ // uni.navigateTo({
+ // url:'/pages/login/login'
+ // })
} else if (res.code == 200) {
// console.log("老用户登录",res.data)
- uni.switchTab({
- url:'/pages/index/index'
- })
+ // uni.switchTab({
+ // url:'/pages/index/index'
+ // })
}
});
diff --git a/page_user/dingshi.vue b/page_user/dingshi.vue
index e8506c0..05fcb10 100644
--- a/page_user/dingshi.vue
+++ b/page_user/dingshi.vue
@@ -23,7 +23,7 @@
设置浇水
- 距离下次浇水时间还有{{xctime}}
+ 请设置浇水时间
{{hour}}时 {{minutekq}}分
diff --git a/page_user/lanya.vue b/page_user/lanya.vue
index 8f5e91d..0b0b2ba 100644
--- a/page_user/lanya.vue
+++ b/page_user/lanya.vue
@@ -101,8 +101,18 @@
if (res.code == 200) {
this.userid = res.data.userId
}else if(res.code == 401){
- uni.navigateTo({
- url:'/pages/login/login'
+ uni.showModal({
+ title: '提示',
+ content: '您还未登录,是否前去登录?',
+ success: function (res) {
+ if (res.confirm) {
+ uni.navigateTo({
+ url:'/pages/login/login'
+ })
+ } else if (res.cancel) {
+
+ }
+ }
})
}
})
@@ -116,6 +126,7 @@
userId:this.userid,
pre:e.slice(0,5)
}
+ console.log(data);
this.$u.post(`/app/bandDevice`,data).then((res) => {
if (res.code == 200) {
uni.showToast({
@@ -152,7 +163,7 @@
'isStart': false
})
if (that.devicesList.length > 0) {
- that.flags = true
+ // that.flags = true
this.$u.get(`/app/device/isBand/${this.arr}`).then(res =>{
if(res.code == 200){
res.data.forEach(item =>{
diff --git a/page_user/upload.vue b/page_user/upload.vue
index 136b13a..7f3c5aa 100644
--- a/page_user/upload.vue
+++ b/page_user/upload.vue
@@ -118,7 +118,8 @@
file:'',
intervalId: null,
progress:0,
- shengjiflag:false
+ shengjiflag:false,
+ xctime:'--'
}
},
// 分享到好友(会话)
@@ -139,10 +140,18 @@
onLoad(option) {
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
this.deviceid = option.deviceid
- if(option.ver != undefined && option.ver != null){
- this.ver = option.ver
- this.getbanben()
+ if(option.xctime){
+ if(option.xctime != '--' && option.ver){
+ this.ver = option.ver
+ this.xctime = option.xctime
+ console.log(11);
+ }else{
+ this.ver = 1
+ this.xctime = option.xctime
+ console.log(22);
+ }
}
+
this.getshebxq()
},
methods: {
@@ -154,7 +163,7 @@
content: '您确定要解绑当前设备吗?',
success: function(res) {
if (res.confirm) {
- that.$u.delete(`//app/device/unbind/${that.deviceid}`).then(res => {
+ that.$u.delete(`/app/device/unbind/${that.deviceid}`).then(res => {
if (res.code == 200) {
uni.showToast({
title: '解绑成功',
@@ -185,6 +194,7 @@
this.$u.get(`/app/getDeviceInfo/${this.deviceid}`).then(res => {
if (res.code == 200) {
this.user = res.data
+ this.getbanbens()
}
})
},
@@ -198,11 +208,20 @@
this.xptxt = e[0].label
},
getbanben(){
- this.$u.get(`/app/getVersion?version=${this.ver.slice(3)}`).then(res => {
+ this.$u.get(`/app/model/${this.user.modelId}`).then(res => {
if (res.code == 200) {
- this.file = res.data.file
- console.log(this.file);
- // this.file = 'https://www.zenghi.com/gj/water_flower.bin'
+ this.file = res.data.asDeviceVersion.file
+ console.log(this.file)
+ // this.file = 'https://wc.chuangtewl.com/download/water_flower.bin'
+ }
+ })
+ },
+ getbanbens(){
+ this.$u.get(`/app/model/${this.user.modelId}`).then(res => {
+ if (res.code == 200) {
+ this.file = res.data.asDeviceVersion.file
+ console.log(this.file)
+ // this.file = 'https://wc.chuangtewl.com/download/water_flower.bin'
}
})
},
@@ -219,8 +238,15 @@
// 选择固件版本
gjconfirm(e) {
// this.gjtxt = e[0].label
- if(this.ver != ''){
- if(this.file != ''){
+ // if(this.ver != ''){
+ if(this.file == '' || this.file == null){
+ uni.showToast({
+ title: '暂无新版本',
+ icon: 'none',
+ duration: 2000
+ })
+ }else{
+ console.log('更新');
var data = {
sum: 100,
http: this.file
@@ -230,20 +256,14 @@
})
this.shengjiflag = true
this.startProgress()
- }else{
- uni.showToast({
- title: '暂无新版本',
- icon: 'none',
- duration: 2000
- })
}
- }else{
- uni.showToast({
- title: '请连接蓝牙获取版本号',
- icon: 'none',
- duration: 2000
- })
- }
+ // }else{
+ // uni.showToast({
+ // title: '请连接蓝牙获取版本号',
+ // icon: 'none',
+ // duration: 2000
+ // })
+ // }
},
// 点击取消修改设备名称
btnqx() {
diff --git a/page_user/yinsixq.vue b/page_user/yinsixq.vue
index 923de9e..9c0816a 100644
--- a/page_user/yinsixq.vue
+++ b/page_user/yinsixq.vue
@@ -3,10 +3,7 @@
-
-
-
-
+
@@ -29,7 +26,6 @@
path: '/pages/index/index'
}
},
-
// 分享到朋友圈
onShareTimeline: function() {
return {
@@ -55,7 +51,7 @@
}
}
-
+
\ No newline at end of file
diff --git a/pages/index/index.vue b/pages/index/index.vue
index 81c769a..6cce239 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -390,26 +390,26 @@
}
},
onLoad() {
- wx.openBluetoothAdapter({
- success: function (res) {
- console.log('蓝牙适配器初始化成功');
- },
- fail: function (err) {
- console.error('蓝牙适配器初始化失败,可能是因为没有权限', err);
- uni.showToast({
- title: '蓝牙适配器初始化失败,可能是因为没有权限',
- icon: 'none',
- duration:2000
- })
- }
- })
- this.vardataflag = 1
- xBlufi.initXBlufi(1)
- let that = this
- xBlufi.listenDeviceMsgEvent(true, that.funListenDeviceMsgEvent)
- xBlufi.notifyStartDiscoverBle({
- 'isStart': true
- })
+ wx.openBluetoothAdapter({
+ success: function (res) {
+ console.log('蓝牙适配器初始化成功');
+ },
+ fail: function (err) {
+ console.error('蓝牙适配器初始化失败,可能是因为没有权限', err);
+ uni.showToast({
+ title: '蓝牙适配器初始化失败,可能是因为没有权限',
+ icon: 'none',
+ duration:2000
+ })
+ }
+ })
+ this.vardataflag = 1
+ xBlufi.initXBlufi(1)
+ let that = this
+ xBlufi.listenDeviceMsgEvent(true, that.funListenDeviceMsgEvent)
+ xBlufi.notifyStartDiscoverBle({
+ 'isStart': true
+ })
},
onShow() {
// 请求个人信息
@@ -465,19 +465,7 @@
taht.getinfo()
uni.setStorageSync('token', res.token)
}else{
- uni.showModal({
- title: '提示',
- content: '您还未登录,是否前去登录?',
- success: function (res) {
- if (res.confirm) {
- uni.navigateTo({
- url:'/pages/login/login'
- })
- } else if (res.cancel) {
-
- }
- }
- })
+
}
})
}
@@ -801,7 +789,7 @@
btnsz() {
xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent)
uni.navigateTo({
- url: '/page_user/upload?deviceid=' + this.shebid + '&ver=' + this.ver
+ url: '/page_user/upload?deviceid=' + this.shebid + '&ver=' + this.ver + '&xctime=' + this.xctime
})
},
// 选择设备
@@ -961,78 +949,99 @@
},
// 处理从设备接收数据
getchuli() {
- const inputString = this.datalist
- const [ver, restOfString] = inputString.split('@')
- this.ver = ver || ''
- console.log(this.ver, restOfString, 'ververver')
- const processedString = restOfString
-
- const pairs = processedString.split(';')
- console.log(pairs,'10101010');
- const showObject = {}
- const pSetObjects = {}
+ const inputString = this.datalist;
+
+ // 检查是否有 @ 分隔符
+ const hasAtSymbol = inputString.includes('@');
+ let processedString;
+
+ if (hasAtSymbol) {
+ const [ver, restOfString] = inputString.split('@');
+ this.ver = ver || '';
+ processedString = restOfString || ''; // 如果 restOfString 是 undefined,设置为空字符串
+ } else {
+ processedString = inputString; // 如果没有 @,直接使用整个字符串
+ this.ver = ''; // 如果没有 @,ver 设置为空
+ }
+
+ console.log(this.ver, processedString, 'ververver');
+
+ const pairs = processedString.split(';').filter(Boolean); // 过滤掉空字符串
+ console.log(pairs, '10101010');
+
+ 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')) {
- pSetObjects[key] = value.split(',').map(Number)
+ pSetObjects[key] = value.split(',').map(Number);
}
- })
- this.ver_data = pSetObjects // 六个浇水时间段
- this.jstimeobj = pSetObjects
- this.showobj = showObject// 雨滴,锁,等是否开启
+ });
+
+ this.ver_data = pSetObjects; // 六个浇水时间段
+ this.jstimeobj = pSetObjects;
+ this.showobj = showObject; // 雨滴,锁,等是否开启
+
// 设置开关状态
- this.yschecked = this.showobj.showArray[1] !== 1
- this.etchecked = this.showobj.showArray[0] !== 1
- // 计算浇水时间
- const calculateTimeDifference = (date1, date2) => {
- const diffMs = Math.abs(date1 - date2)
- const diffMinutes = Math.floor(diffMs / (1000 * 60))
- const diffHours = Math.floor(diffMinutes / 60)
- const remainingMinutes = diffMinutes % 60
- return { hours: diffHours, minutes: remainingMinutes }
- }
- const formatTime = (seconds) => {
- const minutes = Math.floor(seconds / 60)
- const remainingSeconds = seconds % 60
- return `${minutes}分${remainingSeconds}秒`
- }
- const getTimeFromArray = (timeArray) => {
- const [hour, minute, , second] = timeArray
- const date = new Date()
- date.setHours(hour, minute, second, 0) // 毫秒设为0
- return date
- }
- let nextTime = null
- let nextTimeDiff = null
- let nextWaterDuration = null
- let prevTime = null
- for (const key in this.ver_data) {
- if (this.ver_data.hasOwnProperty(key) && this.ver_data[key][3] === 1) {
- const timeArray = this.ver_data[key]
- const timeDate = getTimeFromArray(timeArray)
- const diff = calculateTimeDifference(timeDate, new Date())
-
- if (timeDate > new Date()) {
- if (!nextTime || (diff.hours * 60 + diff.minutes < (nextTimeDiff?.hours || 0) * 60 + (nextTimeDiff?.minutes || 0))) {
- nextTimeDiff = diff
- nextTime = timeDate
- nextWaterDuration = formatTime(timeArray[2])
- }
- } else if (!prevTime || timeDate > prevTime) {
- prevTime = timeDate;
- }
- }
- }
- // 输出结果
- this.xctime = nextTime ? `${nextTimeDiff.hours}时${nextTimeDiff.minutes}分` : '无距离下次浇水时间'
- this.xctimesc = nextWaterDuration || '未知'
- this.sctimejs = prevTime ? prevTime.toTimeString().slice(0, 5) : '无上次浇水时间'
- this.xctimesj = nextTime ? nextTime.toTimeString().slice(0, 5) : '无下次浇水时间'
- console.log('下次浇水时间', this.xctimesj, '距离下次浇水时间', this.xctime, '上次浇水时间', this.sctimejs)
- }
+ this.yschecked = this.showobj.showArray[1] !== 1;
+ this.etchecked = this.showobj.showArray[0] !== 1;
+
+ // 计算浇水时间
+ const calculateTimeDifference = (date1, date2) => {
+ const diffMs = Math.abs(date1 - date2);
+ const diffMinutes = Math.floor(diffMs / (1000 * 60));
+ const diffHours = Math.floor(diffMinutes / 60);
+ const remainingMinutes = diffMinutes % 60;
+ return { hours: diffHours, minutes: remainingMinutes };
+ };
+
+ const formatTime = (seconds) => {
+ const minutes = Math.floor(seconds / 60);
+ const remainingSeconds = seconds % 60;
+ return `${minutes}分${remainingSeconds}秒`;
+ };
+
+ const getTimeFromArray = (timeArray) => {
+ const [hour, minute, , second] = timeArray;
+ const date = new Date();
+ date.setHours(hour, minute, second, 0); // 毫秒设为0
+ return date;
+ };
+
+ let nextTime = null;
+ let nextTimeDiff = null;
+ let nextWaterDuration = null;
+ let prevTime = null;
+
+ for (const key in this.ver_data) {
+ if (this.ver_data.hasOwnProperty(key) && this.ver_data[key][3] === 1) {
+ const timeArray = this.ver_data[key];
+ const timeDate = getTimeFromArray(timeArray);
+ const diff = calculateTimeDifference(timeDate, new Date());
+
+ if (timeDate > new Date()) {
+ if (!nextTime || (diff.hours * 60 + diff.minutes < (nextTimeDiff?.hours || 0) * 60 + (nextTimeDiff?.minutes || 0))) {
+ nextTimeDiff = diff;
+ nextTime = timeDate;
+ nextWaterDuration = formatTime(timeArray[2]);
+ }
+ } else if (!prevTime || timeDate > prevTime) {
+ prevTime = timeDate;
+ }
+ }
+ }
+
+ // 输出结果
+ this.xctime = nextTime ? `${nextTimeDiff.hours}时${nextTimeDiff.minutes}分` : '无距离下次浇水时间';
+ this.xctimesc = nextWaterDuration || '未知';
+ this.sctimejs = prevTime ? prevTime.toTimeString().slice(0, 5) : '无上次浇水时间';
+ this.xctimesj = nextTime ? nextTime.toTimeString().slice(0, 5) : '无下次浇水时间';
+ console.log('下次浇水时间', this.xctimesj, '距离下次浇水时间', this.xctime, '上次浇水时间', this.sctimejs);
+ },
}
}
diff --git a/pages/login/denglu.vue b/pages/login/denglu.vue
index 67aba40..c4d09bd 100644
--- a/pages/login/denglu.vue
+++ b/pages/login/denglu.vue
@@ -40,8 +40,9 @@
—————— 其他登录方式 ——————
-