|
|
@@ -25,11 +25,11 @@
|
|
|
<view class="histimeBox">
|
|
|
<u-icon name="calendar" color="#C1C1C1" size="24"></u-icon>
|
|
|
<view class="time" @click="calendarshow = true">
|
|
|
- {{historyTime.startDate ? historyTime.startDate : '开始'}}
|
|
|
+ {{historyTime.startDate ? historyTime.startDate : timestampToDateTime(new Date().getTime()/1000)}}
|
|
|
</view>
|
|
|
<view class="">至</view>
|
|
|
<view class="time" @click="calendarshow = true">
|
|
|
- {{historyTime.endDate ? historyTime.endDate : '结束'}}
|
|
|
+ {{historyTime.endDate ? historyTime.endDate : timestampToDateTime(new Date().getTime()/1000)}}
|
|
|
</view>
|
|
|
<u-icon name="close-circle" color="#C1C1C1" size="28" @click="historyTime={};getHistoryData()"
|
|
|
v-if="historyTime.startDate"></u-icon>
|
|
|
@@ -245,12 +245,13 @@
|
|
|
series: xinfo,
|
|
|
enableScroll: true, //开启图表拖拽功能
|
|
|
xAxis: {
|
|
|
- disableGrid: true,
|
|
|
+ disabled: true,
|
|
|
+ disableGrid: false,
|
|
|
type: 'grid',
|
|
|
gridType: 'dash',
|
|
|
- itemCount: 4, //x轴单屏显示数据的数量,默认为5个
|
|
|
+ itemCount: 15, //x轴单屏显示数据的数量,默认为5个
|
|
|
scrollShow: true, //新增是否显示滚动条,默认false
|
|
|
- // scrollAlign: 'left', //滚动条初始位置
|
|
|
+ scrollAlign: 'right', //滚动条初始位置
|
|
|
scrollBackgroundColor: '#F7F7FF', //默认为 #EFEBEF
|
|
|
scrollColor: '#DEE7F7', //默认为 #A6A6A6
|
|
|
|
|
|
@@ -284,12 +285,19 @@
|
|
|
});
|
|
|
},
|
|
|
// 时间戳转换
|
|
|
- timestampToDateTime(timestamp) {
|
|
|
+ timestampToDateTime(timestamp, isTime) {
|
|
|
var date = new Date(timestamp * 1000); // 将时间戳转换为毫秒并创建一个日期对象
|
|
|
- var year = date.getFullYear(); // 获取年份
|
|
|
- var month = ('0' + (date.getMonth() + 1)).slice(-2); // 获取月份,并补零
|
|
|
- var day = ('0' + date.getDate()).slice(-2); // 获取日期,并补零
|
|
|
- return year + '-' + month + '-' + day;
|
|
|
+ var year = date.getFullYear(); // 获取年份
|
|
|
+ var month = ('0' + (date.getMonth() + 1)).slice(-2); // 获取月份,并补零
|
|
|
+ var day = ('0' + date.getDate()).slice(-2); // 获取日期,并补零
|
|
|
+ var hours = ('0' + date.getHours()).slice(-2); // 获取小时,并补零
|
|
|
+ var minutes = ('0' + date.getMinutes()).slice(-2); // 获取分钟,并补零
|
|
|
+ var seconds = ('0' + date.getSeconds()).slice(-2); // 获取秒数,并补零
|
|
|
+ if(isTime) {
|
|
|
+ return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
|
|
+ } else {
|
|
|
+ return `${year}-${month}-${day}`;
|
|
|
+ }
|
|
|
},
|
|
|
// 历史数据
|
|
|
async getHistoryData() {
|
|
|
@@ -299,8 +307,15 @@
|
|
|
const {
|
|
|
historyTime
|
|
|
} = this;
|
|
|
- let begin = historyTime.startDate ? new Date(historyTime.startDate).getTime() / 1000 : '';
|
|
|
- let end = historyTime.endDate ? new Date(historyTime.endDate).getTime() / 1000 : '';
|
|
|
+ // 获取当前日期
|
|
|
+ var currentDate = new Date();
|
|
|
+ // 设置时间为 0 点
|
|
|
+ currentDate.setHours(0, 0, 0, 0);
|
|
|
+ let begin = historyTime.startDate ? (new Date(historyTime.startDate).getTime() / 1000) - 8*3600 : (Math.floor(currentDate.getTime() / 1000));
|
|
|
+
|
|
|
+ // 设置时间为 24 点
|
|
|
+ currentDate.setHours(24, 0, 0, 0);
|
|
|
+ let end = historyTime.endDate ? (new Date(historyTime.endDate).getTime() / 1000) - 8*3600 : (Math.floor(currentDate.getTime() / 1000));
|
|
|
//折线图数据
|
|
|
let res = await this.$myRequest({
|
|
|
url: "/api/api_gateway?method=weather.weather.sf_data_chart",
|
|
|
@@ -312,7 +327,7 @@
|
|
|
})
|
|
|
uni.hideLoading();
|
|
|
var conf = res.conf.eleName;
|
|
|
- var dat = res.dat;
|
|
|
+ var dat = res.dat.reverse();
|
|
|
//console.log(dat);
|
|
|
conf = conf.split("/");
|
|
|
// var arr1 = [];
|
|
|
@@ -329,7 +344,7 @@
|
|
|
var reddata = [];
|
|
|
dat.forEach((item, index) => {
|
|
|
if (timeList.length < dat.length) {
|
|
|
- timeList.push(this.timestampToDateTime(item.uptime));
|
|
|
+ timeList.push(this.timestampToDateTime(item.uptime, true));
|
|
|
}
|
|
|
var status = item.device_status.split(",");
|
|
|
// //console.log(status);
|
|
|
@@ -521,7 +536,7 @@
|
|
|
this.feiNum = feiNum;
|
|
|
console.log(this.facilityvalve)
|
|
|
},
|
|
|
- async getEquipcontrol(num, state,double_order) {
|
|
|
+ async getEquipcontrol(num, state, double_order) {
|
|
|
//设备控制
|
|
|
uni.showLoading({
|
|
|
title: '正在下发指令'
|