|
|
@@ -40,23 +40,24 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="selecttimes" @click="tiemshow=!tiemshow">
|
|
|
- <view class="" style="line-height: 28px;">
|
|
|
- 日期
|
|
|
- </view>
|
|
|
- <view class="timesbox">
|
|
|
- <!-- <image
|
|
|
+ <view class="" style="line-height: 28px;">
|
|
|
+ 日期
|
|
|
+ </view>
|
|
|
+ <view class="timesbox">
|
|
|
+ <!-- <image
|
|
|
:src="'http://www.hnyfwlw.com:8006/bigdata_app'+'/image/prevention/1acfe2751c01d3786cdc49b83d7e505.png'"
|
|
|
mode=""></image> -->
|
|
|
- <p>{{oldtime}}</p>
|
|
|
- <p class="or">至</p>
|
|
|
- <p>{{newtime}}</p>
|
|
|
- <!-- <u-icon name="rili" custom-prefix="custom-icon" class="icon"></u-icon> -->
|
|
|
- </view>
|
|
|
- <u-button type="primary" text="归档时间" size="mini" @click="timeshow = true">归档时间</u-button>
|
|
|
+ <p>{{oldtime}}</p>
|
|
|
+ <p class="or">至</p>
|
|
|
+ <p>{{newtime}}</p>
|
|
|
+ <!-- <u-icon name="rili" custom-prefix="custom-icon" class="icon"></u-icon> -->
|
|
|
+ </view>
|
|
|
+ <u-button type="primary" text="归档时间" size="mini" @click="timeshow = true">归档时间</u-button>
|
|
|
</view>
|
|
|
<view class="pickerBox">
|
|
|
<u-calendar v-model="tiemshow" mode="range" @change="tiemchange"></u-calendar>
|
|
|
- <u-select v-model="timeshow" mode="mutil-column" :list="list" @confirm="Hourchange" :default-value="defaultValue"></u-select>
|
|
|
+ <u-select v-model="timeshow" mode="mutil-column" :list="list" @confirm="Hourchange"
|
|
|
+ :default-value="defaultValue"></u-select>
|
|
|
</view>
|
|
|
<view class="tendency" v-show="!tiemshow && !timeshow && !pickertfone && !pickertfworm">
|
|
|
<canvas canvas-id="canvasColumnA" id="canvasColumnA" class="charts" @touchstart="touchLineA($event)"
|
|
|
@@ -148,7 +149,7 @@
|
|
|
sp_hour_st: '00:00', // 归档开始时间
|
|
|
sp_hour_ed: '00:00', // 归档结束时间
|
|
|
timeshow: false, // 归档时间设置弹框
|
|
|
- defaultValue:[0,0],
|
|
|
+ defaultValue: [0, 0],
|
|
|
list: [
|
|
|
[{
|
|
|
value: '00:00',
|
|
|
@@ -492,65 +493,86 @@
|
|
|
console.log(ringarr)
|
|
|
this.progresslist = ringarr
|
|
|
},
|
|
|
+ // 根据起始日期获取中间时间列表
|
|
|
+ getDates(startDate, endDate) {
|
|
|
+ var dates = [];
|
|
|
+ var currentDate = new Date(startDate);
|
|
|
+ endDate = new Date(endDate);
|
|
|
+
|
|
|
+ while (currentDate <= endDate) {
|
|
|
+ dates.push(currentDate.toISOString().split('T')[0].substring(5));
|
|
|
+ currentDate.setDate(currentDate.getDate() + 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ return dates;
|
|
|
+ },
|
|
|
+ // 时间戳转换为月日,并以-分割,同时确保不足两位的数字补零
|
|
|
+ formatMonthDay(timestamp) {
|
|
|
+ var date = new Date(timestamp * 1000);
|
|
|
+ var month = (date.getMonth() + 1).toString().padStart(2, '0'); // 获取月份并补零
|
|
|
+ var day = date.getDate().toString().padStart(2, '0'); // 获取日期并补零
|
|
|
+
|
|
|
+ return `${month}-${day}`;
|
|
|
+ },
|
|
|
setlineoption() {
|
|
|
var res = this.reslist
|
|
|
- var xtitle = []
|
|
|
var obj = []
|
|
|
- if (res.at_ah_info.length != 0) {
|
|
|
- var aharr = []
|
|
|
- var atarr = []
|
|
|
- var pestArr = []
|
|
|
- let indentText = 0;
|
|
|
- for (var i = 0; i < res.at_ah_info.length; i++) {
|
|
|
- var times = new Date(res.at_ah_info[i].addtime * 1000)
|
|
|
- xtitle.push(times.getMonth() + 1 + "/" + times.getDate())
|
|
|
- atarr.push(res.at_ah_info[i].at == "" ? "0" : res.at_ah_info[i].at)
|
|
|
- aharr.push(res.at_ah_info[i].ah == "" ? "0" : res.at_ah_info[i].ah)
|
|
|
- if (this.checkObj(res.char_data) && res.char_data[this.wormvalue]) {
|
|
|
- if (res.char_data[this.wormvalue][i - indentText] && (res.char_data[this.wormvalue][i -
|
|
|
- indentText
|
|
|
- ].addtime == res.at_ah_info[i].addtime)) {
|
|
|
- pestArr.push(res.char_data[this.wormvalue][i - indentText].sum)
|
|
|
- } else {
|
|
|
- indentText++
|
|
|
- pestArr.push(null)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- // console.log(this.wormvalue)
|
|
|
- // if (this.checkObj(res.char_data)) {
|
|
|
- // for (var key in res.char_data) {
|
|
|
- // if (this.wormvalue == key) {
|
|
|
- // var wormobj = {
|
|
|
- // name: key,
|
|
|
- // data: [],
|
|
|
- // }
|
|
|
- // for (var i = 0; i < res.char_data[key].length; i++) {
|
|
|
- // wormobj.data.push(res.char_data[key][i].ah == "" ? "0" : res.char_data[key][i].sum)
|
|
|
- // }
|
|
|
- // obj.push(wormobj)
|
|
|
- // }
|
|
|
- // }
|
|
|
+ let xtitle = this.getDates(this.oldtime, this.newtime)
|
|
|
+ var aharr = Array(xtitle.length).fill(null)
|
|
|
+ var atHigharr = Array(xtitle.length).fill(null) //高温
|
|
|
+ var atLowarr = Array(xtitle.length).fill(null) //低温
|
|
|
+ var pestArr = Array(xtitle.length).fill(null)
|
|
|
+ let indentText = 0;
|
|
|
+ res.at_ah_info.forEach(item => {
|
|
|
+ let index = xtitle.indexOf(this.formatMonthDay(item.addtime));
|
|
|
+ atHigharr[index] = item.height
|
|
|
+ atLowarr[index] = item.low
|
|
|
+ aharr[index] = item.ah
|
|
|
+ })
|
|
|
+ res.char_data[this.wormvalue] && res.char_data[this.wormvalue].forEach(pest => {
|
|
|
+ let index = xtitle.indexOf(this.formatMonthDay(pest.addtime));
|
|
|
+ pestArr[index] = pest.sum
|
|
|
+ })
|
|
|
+ // console.log(this.wormvalue)
|
|
|
+ // if (this.checkObj(res.char_data)) {
|
|
|
+ // for (var key in res.char_data) {
|
|
|
+ // if (this.wormvalue == key) {
|
|
|
+ // var wormobj = {
|
|
|
+ // name: key,
|
|
|
+ // data: [],
|
|
|
+ // }
|
|
|
+ // for (var i = 0; i < res.char_data[key].length; i++) {
|
|
|
+ // wormobj.data.push(res.char_data[key][i].ah == "" ? "0" : res.char_data[key][i].sum)
|
|
|
+ // }
|
|
|
+ // obj.push(wormobj)
|
|
|
+ // }
|
|
|
+ // }
|
|
|
|
|
|
- // }
|
|
|
- var atobj = {
|
|
|
- name: '温度',
|
|
|
- data: atarr,
|
|
|
- color: '#00E29D'
|
|
|
- }
|
|
|
- var ahobj = {
|
|
|
- name: '湿度',
|
|
|
- data: aharr,
|
|
|
- color: '#6CBBFF'
|
|
|
- }
|
|
|
- var pestObj = {
|
|
|
- name: this.wormvalue,
|
|
|
- data: pestArr,
|
|
|
- }
|
|
|
- obj.push(atobj)
|
|
|
- obj.push(ahobj)
|
|
|
- obj.push(pestObj)
|
|
|
+ // }
|
|
|
+ var atHighobj = {
|
|
|
+ name: '高温',
|
|
|
+ data: atHigharr,
|
|
|
+ color: '#ff0000'
|
|
|
}
|
|
|
+ var atlowobj = {
|
|
|
+ name: '低温',
|
|
|
+ data: atLowarr,
|
|
|
+ color: '#00E29D'
|
|
|
+ }
|
|
|
+ var ahobj = {
|
|
|
+ name: '湿度',
|
|
|
+ data: aharr,
|
|
|
+ color: '#6CBBFF'
|
|
|
+ }
|
|
|
+ var pestObj = {
|
|
|
+ name: this.wormvalue,
|
|
|
+ data: pestArr,
|
|
|
+ }
|
|
|
+ obj.push(atHighobj)
|
|
|
+ obj.push(atlowobj)
|
|
|
+ obj.push(ahobj)
|
|
|
+ obj.push(pestObj)
|
|
|
+ console.log(obj)
|
|
|
this.showColumn("canvasColumnA", xtitle, obj)
|
|
|
},
|
|
|
checkObj(obj) {
|
|
|
@@ -766,9 +788,12 @@
|
|
|
var date = +new Date()
|
|
|
this.oldtime = this.formatTime(date, 'yyyy-MM-dd');
|
|
|
this.newtime = this.formatTime(date, 'yyyy-MM-dd');
|
|
|
- this.sp_hour_st = uni.getStorageSync('sp_hour_st') == '' ? '00:00' : uni.getStorageSync('sp_hour_st');
|
|
|
- this.sp_hour_ed = uni.getStorageSync('sp_hour_ed') == '' ? '00:00' : uni.getStorageSync('sp_hour_ed');
|
|
|
- this.defaultValue=[this.sp_hour_st.substring(0, 1) == '0' ? this.sp_hour_st.substring(1, 2): this.sp_hour_st.substring(0, 2), this.sp_hour_ed.substring(0, 1) == '0' ? this.sp_hour_ed.substring(1, 2): this.sp_hour_ed.substring(0, 2)]
|
|
|
+ this.sp_hour_st = uni.getStorageSync('sp_hour_st') == '' ? '00:00' : uni.getStorageSync('sp_hour_st');
|
|
|
+ this.sp_hour_ed = uni.getStorageSync('sp_hour_ed') == '' ? '00:00' : uni.getStorageSync('sp_hour_ed');
|
|
|
+ this.defaultValue = [this.sp_hour_st.substring(0, 1) == '0' ? this.sp_hour_st.substring(1, 2) : this.sp_hour_st
|
|
|
+ .substring(0, 2), this.sp_hour_ed.substring(0, 1) == '0' ? this.sp_hour_ed.substring(1, 2) : this
|
|
|
+ .sp_hour_ed.substring(0, 2)
|
|
|
+ ]
|
|
|
this.cWidth = uni.upx2px(650);
|
|
|
this.cHeight = uni.upx2px(500);
|
|
|
this.getyear()
|
|
|
@@ -781,11 +806,13 @@
|
|
|
background-color: #f1f4ff;
|
|
|
padding-top: 10px;
|
|
|
}
|
|
|
- .pickerBox{
|
|
|
+
|
|
|
+ .pickerBox {
|
|
|
position: relative;
|
|
|
background: #FFFFFF;
|
|
|
z-index: 10;
|
|
|
}
|
|
|
+
|
|
|
.selecttimes {
|
|
|
// box-shadow: 0 0 10rpx #bcb9ca;
|
|
|
// padding: 10rpx 20rpx;
|