Commit 19350d64 authored by zhanglw's avatar zhanglw

历史曲线、警告解除提醒接口对接

parent f389e2b7
{
"name" : "shenmu",
"appid" : "__UNI__DA9906C",
"appid" : "__UNI__093C827",
"description" : "uni-app 框架示例,一套代码,同时发行到iOS、Android、H5、小程序等多个平台,请使用手机扫码快速体验 uni-app 的强大功能",
"versionName" : "1.0.0",
"versionCode" : "100",
......@@ -69,14 +69,16 @@
/* ios打包配置 */
"ios" : {
"UIBackgroundModes" : [ "audio" ],
"urlschemewhitelist" : [ "baidumap", "iosamap" ]
"urlschemewhitelist" : [ "baidumap", "iosamap" ],
"dSYMs" : false
},
/* SDK配置 */
"sdkConfigs" : {
"speech" : {
"ifly" : {}
},
"oauth" : {}
"oauth" : {},
"ad" : {}
},
"orientation" : [ "portrait-primary" ],
"icons" : {
......
<template>
<view class="uni-container">
<view style="background-color: white;">
<uni-datetime-picker v-model="dateRange" type="daterange" />
<uni-datetime-picker v-model="dateRange" type="daterange" change="dateRangeHander" />
<uni-data-select v-model="query.item" :localdata="itemList" :clear="false" @input="loadData"
style="text-align: center"></uni-data-select>
<uni-search-bar v-model="query.name" class="uni-mt-10 margin0" radius="5" placeholder="输入设备名查询"
clearButton="auto" cancelButton="none" @confirm="loadData" />
</view>
<uni-card v-for="(item,index) in dataList" :title="item.name" :key='index' :isFull="true"
:sub-title="'检测项:'+item.item" :extra="'检测值:'+item.data" :thumbnail="incoDic[item.item]" @click="initCharts(item)">
:sub-title="'检测项:'+item.item" :extra="'检测值:'+item.data" :thumbnail="incoDic[item.item]" @click="getChartsData(item)">
<uni-row class="demo-uni-row">
<uni-col :span="12">
<view class="demo-uni-col">监测时间:</view>
......@@ -21,10 +21,10 @@
<view v-if="!dataList.length" style="text-align:center;margin-top:55upx;color:#999;font-weight:bolder;">未查询的传感器数据</view>
<uni-popup ref="chartPopup" background-color="#fff">
<view class="popup-view">
<text class="popup-title">历史监测变化曲线</text>
<text class="popup-title"近12个小时监测变化曲线 </text>
<canvas canvas-id="canvasLine" id="canvasLine" class="charts" @touchmove="moveLine"
@touchend="moveLine"></canvas>
<uni-datetime-picker v-model="chartDateRange" type="daterange" />
<!-- <uni-datetime-picker v-model="chartDateRange" type="daterange" /> -->
</view>
</uni-popup>
</view>
......@@ -48,7 +48,7 @@
export default {
data() {
return {
baseUrl: "http://192.168.3.23:8086",
// baseUrl: "http://117.34.103.191:8086",
userInfo: {},
currProInfo: {},
iconList: [online, offline],
......@@ -130,25 +130,30 @@
showpopup: true,
cWidth: '',
cHeight: '', //画布的宽高
data: {
categories: ["01时", "02时", "03时", "04时", "05时", "06时", "07时", "08时", "09时", "10时", "11时", "12时"],
series: [{
name: "温度",
data: [35, 8, 25, 37, 4, 20, 35, 8, 25, 37, 4, 20]
}]
}
data: {},
// data: {
// categories: ["01时", "02时", "03时", "04时", "05时", "06时", "07时", "08时", "09时", "10时", "11时", "12时"],
// series: [{
// name: "温度",
// data: [35, 8, 25, 37, 4, 20, 35, 8, 25, 37, 4, 20]
// }]
// }
}
},
watch: {
dateRange() {
this.loadData()
},
chartDateRange() {
_self.showLine("canvasLine", _self.data)
}
// dateRange(val) {
// console.group('监听日期改变数据')
// console.log(val);
// if(val){
// this.loadData()
// }
// },
// chartDateRange() {
// _self.showLine("canvasLine", _self.data)
// }
},
onReady() {
this.loadData()
// this.loadData()
},
onShow() {
this.dateRange = [this.getDate(Date.now()), this.getDate(Date.now())]
......@@ -159,6 +164,9 @@
this.loadData()
},
methods: {
dateRangeHander(){
this.loadData()
},
getDate(date) {
date = new Date(date)
const year = date.getFullYear()
......@@ -173,14 +181,15 @@
return num
},
initCharts(item) {
_self = this
this.$refs.chartPopup.open('bottom')
this.cWidth = uni.upx2px(750)
this.cHeight = uni.upx2px(500)
_self = this
this.chartDateRange = [
this.getDate(new Date(this.dateRange[0])),
this.getDate(new Date(this.dateRange[1]))
]
this.cHeight = uni.upx2px(500-100)
// this.chartDateRange = [
// this.getDate(new Date(this.dateRange[0])),
// this.getDate(new Date(this.dateRange[1]))
// ]
},
loadData() {
this.userInfo = JSON.parse(uni.getStorageSync('userInfo'))
......@@ -189,7 +198,7 @@
title: `历史数据-${this.currProInfo.text}`
});
uni.request({
url: `${this.baseUrl}/api/historyData/loadHistoryDataByUserid`,
url: `${this.$BASEURL}/api/historyData/loadHistoryDataByUserid`,
method: "get",
header: {
'Accept':'application/json, text/plain, */*',
......@@ -211,6 +220,28 @@
}
})
},
getChartsData(item){
this.initCharts()
uni.request({
url: `${this.$BASEURL}/api/historyData/historyDataTrendChart`,
method: "get",
header: {
'Accept':'application/json, text/plain, */*',
'Authorization':'Bearer '+this.userInfo.token
},
data: {
deviceId: item.deviceId,
time: item.time
}
}).then(result => {
let [error, res] = result
if (res.data && res.data.code==200) {
this.data = res.data.data
console.log(this.data)
this.showLine("canvasLine", this.data)
}
})
},
showLine(canvasId, chartData) {
canvaLineIns = new uCharts({ //这些配置项的意思看这:https://www.kancloud.cn/qiun/ucharts/1172125
$this: _self, //指针
......@@ -245,7 +276,7 @@
type: 'curve' //曲线 curve曲线,straight直线
}
}
});
});
},
moveLine(e) {
canvaLineIns.showToolTip(e, { //详情框
......@@ -287,7 +318,7 @@
}
.popup-view {
height: 740upx
height: 540upx
}
.popup-title {
......
......@@ -49,6 +49,7 @@
onNum: 26,
offNum: 13,
},
removeWarnId: '',
dataList: [/* {
name: '气象站7号',
type: '温度',
......@@ -128,11 +129,37 @@
this.$refs.message.open()
},
dialogConfirm() {
this.msgType = 'success',
this.messageText = `确认解除报警`
this.$refs.message.open()
if(!this.removeWarnId){
alert('请求参数不可为空')
return
}
uni.request({
url: `${this.$BASEURL}/api/nowAlarm/releaseAlarm`,
method: "PUT",
header: {
'Accept':'application/json, text/plain, */*',
'Authorization':'Bearer '+this.userInfo.token
},
data: {
warnMsgId: this.removeWarnId
}
}).then(result => {
let [error, res] = result
if (res.data && res.data.code==200) {
this.msgType = 'success',
this.messageText = `确认解除报警`
this.$refs.message.open()
// 删除本地数据
const removeIndex = this.dataList.findIndex(item=>item.warnMsgId === this.removeWarnId)
this.dataList.splice(removeIndex, 1)
}
})
},
removeAlarm(item) {
this.removeWarnId = item.warnMsgId
this.$refs.alertDialog.open()
},
onReachBottom() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment