修改密码返回登录页,

修改历史温度ui
全局分享
首页加入立即咨询
feasure-livedata
lld 2026-03-21 20:45:53 +08:00
parent 30f5b2ed28
commit 5d427dc272
9 changed files with 319 additions and 62 deletions

View File

@ -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({

View File

@ -1,23 +1,20 @@
<template>
<view class="charts-box">
<view>
<uni-row class="demo-uni-row" >
<view class="data-view">
<view class="select-box">
<uni-row >
<uni-col :span="8">
<uni-data-select v-model="imei" :localdata="agriList" @change="changeAgri"></uni-data-select>
<uni-data-select :clear="false" v-model="imei" :localdata="agriList" @change="changeAgri"></uni-data-select>
</uni-col>
<uni-col :span="16">
<uni-datetime-picker v-model="dateRange" type="datetimerange" :end="end" @change="changeDate"/>
</uni-col>
</uni-row>
</view>
<view class="charts-box">
<qiun-data-charts
type="line"
:opts="opts"
background="#fff"
background="#ffffff"
:chartData="chartData"
:canvas2d="true"
canvasId="nMPkeQGNEosMwoWKKNRBZBIEhguMoMWp"
@ -26,6 +23,12 @@
:onmovetip="true"
tooltipFormat="tooltipDemo"
/>
</view>
<view class="uni-padding-wrap uni-common-mt tag-row">
<button @click.stop="jumpDate(-1)" style="margin-right: 20rpx;" type="primary" size="mini">前一天</button>
<button :disabled="isTodayDate(dateRange[0]) || isTodayDate(dateRange[1])" @click.stop="jumpDate(1)" style="margin-right: 20rpx;" type="default" size="mini">后一天</button>
<button @click.stop="jumpDate(0)" type="warn" size="mini">回到当天</button>
</view>
<!-- 暂无数据 -->
</view>
</template>
@ -33,8 +36,7 @@
<script>
import { getHistoryData} from "../../api/system/data";
import {listAgri} from "../../api/system/assets/agri";
import store from "../../store";
import {parseTime, isIntervalMoreThanNDays, getExactDiffDays} from "../../utils/agri";
import {parseTime, isIntervalMoreThanNDays, getExactDiffDays, isTodayDate} from "../../utils/agri";
export default {
data: function () {
@ -109,10 +111,11 @@ export default {
imei:null
};
},
onReady() {
onShow() {
this.getAgriList();
},
methods: {
isTodayDate,
getServerData() {
const param = {
imei: this.imei,
@ -136,22 +139,6 @@ export default {
value: item.imei //
}));
if (store.getters && store.getters.name === 'admin') {
this.agriList.push(
{
text:"八方南棚",
value:"A"
},
{
text:"九方春棚",
value:"B"
},
{
text:"十二方棚",
value:"C"
}
)
}
this.imei = this.agriList[0].value;
this.getServerData();
}
@ -174,18 +161,78 @@ export default {
if (this.imei) {
this.getServerData();
}
},
jumpDate(days) {
// ||
// days: (-1) (1) (0)
let targetDate;
if (this.dateRange.length === 0 || getExactDiffDays(this.dateRange[0],this.dateRange[1])>1) {
this.dateRange[0] = new Date();
}
if (days === 0) {
//
targetDate = new Date();
} else {
//
const currentStartDate = new Date(this.dateRange[0]);
targetDate = new Date(currentStartDate);
targetDate.setDate(targetDate.getDate() + days);
}
// 00:00:00
const startDate = new Date(targetDate);
startDate.setHours(0, 0, 0, 0);
//
let endDate;
if (days === 0) {
//
endDate = new Date();
} else {
// 23:59:59
endDate = new Date(targetDate);
endDate.setHours(23, 59, 59, 999);
}
// dateRange
this.dateRange = [
parseTime(startDate ),
parseTime(endDate)
];
setTimeout(() => {
this.$nextTick(() => {
//
if (this.imei) {
this.getServerData();
}
})
}, 300)
}
}
};
</script>
<style scoped>
/* 请根据实际需求修改父元素尺寸,组件自动识别宽高 */
.data-view {
background: #ffffff;
}
.select-box {
margin-top: 10rpx;
}
.charts-box {
width: 100%;
height: 500px;
}
/deep/ .uni-stat__select {
/deep/ .uni-select, /deep/ .uni-date-editor--x {
background: #fff !important;
height: 68rpx;
}
.tag-row {
text-align: center;
padding-bottom: 20rpx;
}
</style>

79
pages/data/indexDemo.vue Normal file
View File

@ -0,0 +1,79 @@
<template>
<view style="height: 750rpx">
<l-echart ref="chart"></l-echart>
</view>
</template>
<script>
import * as echarts from 'echarts';
import LEchart from "../../uni_modules/lime-echart/components/l-echart/l-echart.vue";
export default {
components: {LEchart},
data() {
return {
option: {
title: {
text: 'Stacked Line' // todo
},
tooltip: {
trigger: 'axis'
},
legend: {
data: ['邮件营销', '联盟广告', '视频广告', '直接访问', '搜索引擎']
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: {
type: 'category',
boundaryGap: false,
data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
},
yAxis: {
type: 'value'
},
series: [
{
name: '邮件营销',
type: 'line',
stack: '总量',
data: [120, 132, 101, 134, 90, 230, 210]
},
{
name: '联盟广告',
type: 'line',
stack: '总量',
data: [220, 182, 191, 234, 290, 330, 310]
},
{
name: '视频广告',
type: 'line',
stack: '总量',
data: [150, 232, 201, 154, 190, 330, 410]
},
{
name: '直接访问',
type: 'line',
stack: '总量',
data: [320, 332, 301, 334, 390, 330, 320]
},
{
name: '搜索引擎',
type: 'line',
stack: '总量',
data: [820, 932, 901, 934, 1290, 1330, 1320]
}
]
}
}
},
mounted() {
this.$refs.chart.init(echarts, chart=> {
chart.setOption(this.option);
});
}
}
</script>

View File

@ -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;
}

View File

@ -26,7 +26,7 @@
</view>
<view class="input-item flex align-center" style="width: 60%;margin: 0px;" v-if="captchaEnabled">
<view class="iconfont icon-code icon"></view>
<input v-model="loginForm.code" type="number" class="input" placeholder="请输入验证码" maxlength="4" />
<input v-model="loginForm.code" style="margin-left: auto" type="number" class="input" placeholder="请输入验证码" maxlength="4" />
<view class="login-code">
<image :src="codeUrl" @click="getCode" class="login-code-img"></image>
</view>
@ -60,7 +60,10 @@
</view>
<view class="reg text-center" v-if="register">
<text class="text-grey1">没有账号</text>
<text @click="handleUserRegister" class="text-blue">立即注册</text>
<text @click="handleUserRegister" class="text-blue contact-text">立即注册</text>
<button size="mini" class="btn-cs" open-type="contact">
<text class="text-blue">点击咨询</text>
</button>
</view>
<view class="xieyi text-center">
<text class="text-grey1">登录即代表同意</text>
@ -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;
}
</style>

View File

@ -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.vuelogoutMQTT+
app.logout()
}).finally(()=>{
this.$tab.reLaunch('/pages/index')
})
},1000)
}
})
})
}

View File

@ -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,
},

View File

@ -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:ssyyyy-MM-ddISO格式等
* @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";

19
utils/share.js Normal file
View File

@ -0,0 +1,19 @@
export default {
data() {
return {}
},
//分享到微信好友
onShareAppMessage(res) {
return {
title: '小策技术,为您的农业提供智能服务,欢迎咨询!',
path: `/pages/index`
}
},
//分享到朋友圈
onShareTimeline() {
return {
title: '小策技术,为您的农业提供智能服务,欢迎咨询!',
path: `/pages/index`
}
},
}