From 5d427dc27275cee3fa5d65f378be120937f4e9a6 Mon Sep 17 00:00:00 2001
From: lld <15027638633@163.com>
Date: Sat, 21 Mar 2026 20:45:53 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=86=E7=A0=81=E8=BF=94?=
=?UTF-8?q?=E5=9B=9E=E7=99=BB=E5=BD=95=E9=A1=B5=EF=BC=8C=20=E4=BF=AE?=
=?UTF-8?q?=E6=94=B9=E5=8E=86=E5=8F=B2=E6=B8=A9=E5=BA=A6ui=20=E5=85=A8?=
=?UTF-8?q?=E5=B1=80=E5=88=86=E4=BA=AB=20=E9=A6=96=E9=A1=B5=E5=8A=A0?=
=?UTF-8?q?=E5=85=A5=E7=AB=8B=E5=8D=B3=E5=92=A8=E8=AF=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
main.js | 3 +
pages/data/index.vue | 129 ++++++++++++------
pages/data/indexDemo.vue | 79 +++++++++++
pages/index.vue | 7 +-
pages/login.vue | 35 ++++-
pages/mine/subpages/pwd/index.vue | 15 +-
.../js_sdk/u-charts/config-ucharts.js | 22 ++-
utils/agri.js | 72 +++++++++-
utils/share.js | 19 +++
9 files changed, 319 insertions(+), 62 deletions(-)
create mode 100644 pages/data/indexDemo.vue
create mode 100644 utils/share.js
diff --git a/main.js b/main.js
index 6394e8f..d4dc378 100644
--- a/main.js
+++ b/main.js
@@ -9,6 +9,8 @@ import "./utils/uni.css";
// 引入全局TuniaoUI
import TuniaoUI from 'tuniao-ui'
import VueCompositionAPI from '@vue/composition-api'
+import share from './utils/share.js' //注意路径是上一步新建文件的路径
+
Vue.use(VueCompositionAPI)
// 引入TuniaoUI提供的vuex简写方法
let vuexStore = require('@/store/$tn.mixin.js')
@@ -19,6 +21,7 @@ Vue.prototype.$store = store
Vue.prototype.getDicts = getDicts
Vue.use(TuniaoUI)
Vue.mixin(vuexStore)
+Vue.mixin(share)
App.mpType = 'app'
const app = new Vue({
diff --git a/pages/data/index.vue b/pages/data/index.vue
index bf94fd6..7be9b34 100644
--- a/pages/data/index.vue
+++ b/pages/data/index.vue
@@ -1,31 +1,34 @@
-
-
-
-
+
+
+
-
-
+
-
-
-
+
+
+
+
+
+
+
+
@@ -33,8 +36,7 @@
\ No newline at end of file
diff --git a/pages/data/indexDemo.vue b/pages/data/indexDemo.vue
new file mode 100644
index 0000000..0356fc6
--- /dev/null
+++ b/pages/data/indexDemo.vue
@@ -0,0 +1,79 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/index.vue b/pages/index.vue
index d153a66..aa42331 100644
--- a/pages/index.vue
+++ b/pages/index.vue
@@ -220,7 +220,6 @@ export default {
this.refresh();
},
onLoad() {
-
},
onHide() {
console.info("首页在线状态注销回调")
@@ -295,7 +294,7 @@ export default {
const deviceItem = {
...item,
deviceStatus: TimeUtil.isLessThanSpecifiedSeconds(item.time, 90) ? '在线' : '离线',
- online: TimeUtil.isLessThanSpecifiedSeconds(item.time, 90) ? '在线' : '离线',
+ online: '在线',
agriName: item.agriName || '未知大棚',
imei: `${item.imei || '未知'}`,
workModeDesc: item.workMode === 0 ? '手动模式':'自动模式',
@@ -317,6 +316,7 @@ export default {
// 左上角详情
this.getDataDetails();
this.datas = [...this.listData]
+ // 下拉刷新
this.getAgriStatus();
}
}).catch(err => {
@@ -339,7 +339,6 @@ export default {
this.getListData();
},
onDeleteItem(e, item) {
- console.log(e, item)// e 是事件对象,item 是列表项数据
if (e.content.text === '重命名') { // 通过事件对象的 content.text 判断
setTimeout(() => {
this.agriName = item.agriName;
@@ -510,7 +509,7 @@ export default {
this.$refs.renameAgri.close();
},
updateAgriName() {
- if (!this.newAgriName) {
+ if (!this.newAgriName || (this.newAgriName === this.agriName)) {
this.$modal.msgError("请输入新名称!");
return;
}
diff --git a/pages/login.vue b/pages/login.vue
index 36e5303..01c6d2b 100644
--- a/pages/login.vue
+++ b/pages/login.vue
@@ -26,7 +26,7 @@
-
+
@@ -60,7 +60,10 @@
没有账号?
- 立即注册
+ 立即注册
+
登录即代表同意
@@ -424,4 +427,30 @@ import { getCodeImg } from '@/api/login'
justify-content: center;
margin: 30rpx;
}
-
+ .btn-cs {
+ font-size: 28rpx;
+ background: #FFFFFF;
+ padding: 0;
+ margin-left: 10rpx;
+ border: none;
+ outline: none;
+ box-shadow: none;
+ line-height: 1;
+ height: auto;
+ display: inline-flex;
+ align-items: center;
+ }
+ .btn-cs::after {
+ border: none;
+ }
+ button.btn-cs {
+ background-color: transparent !important;
+ border-radius: 0 !important;
+ margin: 0 !important;
+ padding: 0 !important;
+ line-height: inherit !important;
+ }
+ .contact-text {
+ margin-right: 20rpx;
+ }
+
\ No newline at end of file
diff --git a/pages/mine/subpages/pwd/index.vue b/pages/mine/subpages/pwd/index.vue
index 405dcbd..2ccc365 100644
--- a/pages/mine/subpages/pwd/index.vue
+++ b/pages/mine/subpages/pwd/index.vue
@@ -65,7 +65,20 @@
submit() {
this.$refs.form.validate().then(res => {
updateUserPwd(this.user.oldPassword, this.user.newPassword).then(response => {
- this.$modal.msgSuccess("修改成功")
+ if (response.code === 200) {
+ this.$modal.msg("修改成功,正在返回登录页面...")
+ setTimeout(() => {
+ this.$store.dispatch('LogOut').then(() => {
+ // ========== 新增:登出时断开MQTT并清空状态 ==========
+ // 1. 获取全局App实例
+ const app = getApp()
+ // 2. 调用App.vue的logout方法(断开MQTT+清空订阅列表)
+ app.logout()
+ }).finally(()=>{
+ this.$tab.reLaunch('/pages/index')
+ })
+ },1000)
+ }
})
})
}
diff --git a/uni_modules/qiun-data-charts/js_sdk/u-charts/config-ucharts.js b/uni_modules/qiun-data-charts/js_sdk/u-charts/config-ucharts.js
index 0965c75..ad3d418 100644
--- a/uni_modules/qiun-data-charts/js_sdk/u-charts/config-ucharts.js
+++ b/uni_modules/qiun-data-charts/js_sdk/u-charts/config-ucharts.js
@@ -254,7 +254,7 @@ const cfu = {
rotate: false,
rotateLock: false,
color: ["#1890FF","#91CB74","#FAC858","#EE6666","#73C0DE","#3CA272","#FC8452","#9A60B4","#ea7ccc"],
- padding: [15,10,0,15],
+ padding: [50,10,0,15],
fontSize: 13,
fontColor: "#666666",
dataLabel: false,
@@ -269,11 +269,10 @@ const cfu = {
axisLine: true,
axisLineColor: "#CCCCCC",
calibration: true,
- fontColor: "#666666",
+ fontColor: "#ffffff",
fontSize: 13,
lineHeight: 20,
marginTop: 10,
- rotateLabel: true,
rotateAngle: 45,
labelCount: 15,
itemCount: 300,
@@ -296,21 +295,20 @@ const cfu = {
},
legend: {
show: true,
- position: "top",
+ position: "bottom",
float: "center",
- padding: 5,
- margin: 5,
- backgroundColor: "rgba(0,0,0,0)",
- borderColor: "rgba(0,0,0,0)",
+ padding: 20,
+ margin: 10,
+ backgroundColor: "rgb(248,241,241)",
+ borderColor: "#2d56d8",
borderWidth: 0,
- fontSize: 13,
+ fontSize: 15,
fontColor: "#666666",
- lineHeight: 11,
+ lineHeight: 32,
hiddenColor: "#CECECE",
- itemGap: 10,
+ itemGap: 40,
// 关键:开启自动换行(uCharts 2.x+ 支持)
wrap: true,
-
// 控制每行显示数量(比如每行4个,8个系列分两行)
itemWidth: 80,
},
diff --git a/utils/agri.js b/utils/agri.js
index ec6b11d..22bbc9a 100644
--- a/utils/agri.js
+++ b/utils/agri.js
@@ -324,6 +324,76 @@ export function getExactDiffDays(time1, time2) {
return Number(diffDays.toFixed(4));
}
+export function isTodayDate(dateInput) {
+ if (!dateInput) return false;
+ let targetDate;
+ if (dateInput instanceof Date) {
+ targetDate = new Date(dateInput);
+ } else {
+ targetDate = new Date(dateInput);
+ if (isNaN(targetDate.getTime())) {
+ console.warn("输入的日期字符串格式无效:", dateInput);
+ return false;
+ }
+ }
+ const today = new Date();
+ const todayDate = new Date(today.getFullYear(), today.getMonth(), today.getDate());
+ const targetDateOnly = new Date(targetDate.getFullYear(), targetDate.getMonth(), targetDate.getDate());
+ return targetDateOnly.getTime() === todayDate.getTime();
+}
+
+/**
+ * 判断传入的日期是否是今天
+ * 支持格式:Date对象、时间戳、字符串(yyyy-MM-dd HH:mm:ss、yyyy-MM-dd、ISO格式等)
+ * @param {Date|number|string} dateInput - 要判断的日期
+ * @returns {boolean} - 是否是今天
+ */
+export function isToday(dateInput) {
+ if (!dateInput) return false;
+
+ let targetDate;
+
+ // 处理不同类型的输入
+ if (dateInput instanceof Date) {
+ targetDate = new Date(dateInput);
+ } else if (typeof dateInput === 'number') {
+ // 时间戳(秒或毫秒)
+ targetDate = dateInput.toString().length === 10
+ ? new Date(dateInput * 1000)
+ : new Date(dateInput);
+ } else if (typeof dateInput === 'string') {
+ // 字符串格式处理
+ if (/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/.test(dateInput)) {
+ // yyyy-MM-dd HH:mm:ss 格式
+ targetDate = new Date(dateInput.replace(/-/g, '/'));
+ } else if (/^\d{4}-\d{2}-\d{2}$/.test(dateInput)) {
+ // yyyy-MM-dd 格式
+ targetDate = new Date(dateInput.replace(/-/g, '/'));
+ } else {
+ // 其他格式(ISO等)
+ targetDate = new Date(dateInput);
+ }
+ } else {
+ return false;
+ }
+
+ // 验证日期有效性
+ if (isNaN(targetDate.getTime())) {
+ console.warn("输入的日期格式无效:", dateInput);
+ return false;
+ }
+
+ // 获取今天的日期(去掉时间部分)
+ const today = new Date();
+ const todayDateOnly = new Date(today.getFullYear(), today.getMonth(), today.getDate());
+
+ // 获取目标日期的日期部分(去掉时间)
+ const targetDateOnly = new Date(targetDate.getFullYear(), targetDate.getMonth(), targetDate.getDate());
+
+ return targetDateOnly.getTime() === todayDateOnly.getTime();
+}
+
+
// // 测试示例
// const start = "2026-03-01";
// const end = "2026-03-12";
@@ -340,4 +410,4 @@ const rollerList = [
// 调用(一行搞定)
const { isConflict, conflict } = checkTimeConflict(rollerList);
-console.log(isConflict ? `冲突:${JSON.stringify(conflict)}` : '无冲突');*/
+console.log(isConflict ? `冲突:${JSON.stringify(conflict)}` : '无冲突');*/
\ No newline at end of file
diff --git a/utils/share.js b/utils/share.js
new file mode 100644
index 0000000..f3432d5
--- /dev/null
+++ b/utils/share.js
@@ -0,0 +1,19 @@
+export default {
+ data() {
+ return {}
+ },
+ //分享到微信好友
+ onShareAppMessage(res) {
+ return {
+ title: '小策技术,为您的农业提供智能服务,欢迎咨询!',
+ path: `/pages/index`
+ }
+ },
+ //分享到朋友圈
+ onShareTimeline() {
+ return {
+ title: '小策技术,为您的农业提供智能服务,欢迎咨询!',
+ path: `/pages/index`
+ }
+ },
+}
\ No newline at end of file