Commit 19350d64 authored by zhanglw's avatar zhanglw

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

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