| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467 |
- <template>
- <view>
- <view class="status_bar"></view>
- <view class="" style="position: relative;top: 40px;">
- <view style="position: fixed;z-index: 100;width: 100%;">
- <uni-nav-bar @clickLeft="clickLeft" left-icon="back" left-text="返回" title="设备详情"></uni-nav-bar>
- </view>
- <view class="info">
- <view class="info_item">
- <image :src="eqinfo.item.is_online==1?'http://www.hnyfwlw.com:8006/bigdata_app/image/cb/onBg.png':'http://www.hnyfwlw.com:8006/bigdata_app/image/cb/offBg.png'"
- mode="" class="bgi"></image>
- <p style="font-size: 32rpx;" @click="copy(eqinfo.item)">设备 ID:{{eqinfo.item.equip_id||eqinfo.item.device_id}}
- <image src="http://www.hnyfwlw.com:8006/bigdata_app/image/environment/fuzhi.png" mode="" class="tishi"></image>
- </p>
- <p>设备名称:{{eqinfo.item.equip_name?eqinfo.item.equip_name:"无"}}</p>
- <p>最近上报时间:{{eqinfo.item.uptime|timeFormat()}}</p>
- <p>地址:{{city==""?"--":city}}</p>
- </view>
- </view>
- <view class="control">
- <view class="control_item" v-if="kongtf" @click="control">
- <image :src="'http://www.hnyfwlw.com:8006/bigdata_app'+'/image/environment/8.png'" mode=""></image>
- <p>设备控制</p>
- </view>
- <view class="control_item" @click="repairs">
- <image :src="'http://www.hnyfwlw.com:8006/bigdata_app'+'/image/environment/7.png'" mode=""></image>
- <p>一键报修</p>
- </view>
- <view class="control_item" v-if="shujutf" @click="charts">
- <image :src="'http://www.hnyfwlw.com:8006/bigdata_app'+'/image/environment/10.png'" mode=""></image>
- <p>历史数据</p>
- </view>
- </view>
- <view class="realtime">
- <p class="realtime_title"><span v-if="realtimeTF">实时数据</span><span v-else>实时数据(暂无数据)</span></p>
- <view class="realtime_text">
- <view class="realtime_text_item">
- <view class="realtime_text_item_info" v-for="(item,index) in olddata.conf" :key="index" v-if="olddata.dat[index][1]&&item" @click="oneday(item,index)">
- <view class="item_info_img" :style="{'background-color':olddatas[Math.floor(Math.random()*(5-0+1))]}">
- <image :src="'http://www.hnyfwlw.com:8006/bigdata_app'+'/image/environment/icon_'+olddata.dat[index][1]+'.png'"
- mode=""></image>
- </view>
- <view class="item_info_text">
- <p>{{item}}</p>
- <p style="margin-top: 20rpx;">{{parseFloat(olddata.dat[index][0]) == -99.99 ?'N/A':parseFloat(olddata.dat[index])}}</p>
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- <u-modal v-model="show" :title-style="{color: 'red'}" :mask-close-able="true" title="24小时数据">
- <p class="tishiTF" v-if="tishiTF">暂无24小时数据</p>
- <view class="slot-content" v-else>
- <canvas canvas-id="canvasColumnA" id="canvasColumnA" class="charts" @touchstart="touchLineA($event)"
- @touchmove="moveLineA($event)" @touchend="touchEndLineA($event)" disable-scroll=true :style="{'width':cWidth*pixelRatio+'px','height':cHeight*pixelRatio+'px', 'transform': 'scale('+(1/pixelRatio)+')','margin-left':-cWidth*(pixelRatio-1)/2+'px','margin-top':-cHeight*(pixelRatio-1)/2+'px'}"></canvas>
- <view class="maxdata">
- <view class="maxdata_box">
- <p class="dian"></p>
- <p>当天最大值:{{onedatasMax}}  {{onedatasMaxtime|timeFormat()}}</p>
- </view>
- <view class="maxdata_box">
- <p class="dian diantwo"></p>
- <p>当天最小值:{{onedatasMin}}  {{onedatasMintime|timeFormat()}}</p>
- </view>
- </view>
- </view>
- </u-modal>
- </view>
- </template>
- <script>
- import uCharts from '../../components/js_sdk/u-charts/u-charts/u-charts.js';
- var canvasColumnA = null;
- export default {
- data() {
- return {
- eqinfo: {
- item:{
-
- }
- },
- olddata: {},
- olddatas: ["#fba825", "#53d67c", "#008cf2", "#fb504d", "#d87ffc", "#4ec5f0"],
- city: "",
- kongtf: false,
- daydatatf: false,
- shujutf: false,
- onedatas: [],
- canvastishiTF: true,
- cWidth: '300',
- cHeight: '200',
- pixelRatio: 1,
- show: false,
- onedatasMax: 0,
- onedatasMin: 0,
- onedatasMaxtime:"",
- onedatasMintime:"",
- tishiTF:false,
- realtimeTF:false
- }
- },
- methods: {
- clickLeft() {
- uni.navigateBack({
- delta: 1
- })
- },
- async history() { //设备列表
- const res = await this.$myRequest({
- url: '/api/api_gateway?method=weather.weather.qxz_status',
- data: {
- device_id: this.eqinfo.item.equip_id || this.eqinfo.item.device_id
- }
- })
- this.olddata = res
- var arr = []
- for (var key in this.olddata.conf) {
- if (this.olddata.conf[key].indexOf("#") != -1) {
- this.olddata.conf[key] = this.olddata.conf[key].replace("#", "(") + ")"
- }
- this.olddata.dat[key] = this.olddata.dat[key].split("#")
- arr.push(this.olddata.dat[key][0])
- }
- console.log(this.olddata.conf)
- console.log(arr)
- this.realtimeTF = arr.some(function(item){
- return item!=""
- })
- console.log(this.realtimeTF)
- },
- // weather.weather.qxz_data_chart 一天的数据
- async onehistory() { //设备列表
- var newtime = +new Date()/1000
- var oldtime = newtime-24*60*60
- const res = await this.$myRequest({
- url: '/api/api_gateway?method=weather.weather.qxz_data_chart',
- data: {
- device_id: this.eqinfo.item.equip_id || this.eqinfo.item.device_id,
- begin: parseInt(oldtime),
- end: parseInt(newtime)
- }
- })
- this.onedatas = res.data
- console.log(this.onedatas)
- },
- control() { //设备控制
- uni.navigateTo({
- url: "./contros?id=" + this.eqinfo.item.d_id
- })
- },
- charts() { //历史数据
- uni.navigateTo({
- url: "./history?device_id=" + this.eqinfo.item.equip_id
- })
- },
- reverseGeocode(lat, lng) {
- uni.request({
- type: "GET",
- url: "https://restapi.amap.com/v3/geocode/regeo?output=JSON&location=" + lng + "," + lat +
- "&key=27273b81090f78759e4057f94474516f&radius=1000&extensions=all",
- dataType: "json",
- complete: ress => {
- console.log(ress)
- this.city = ress.data.regeocode.formatted_address
- }
- });
- },
- copy(item) {
- uni.setClipboardData({
- data: item.equip_id || item.device_id,
- success: function() {
- console.log('success');
- }
- });
- },
- repairs() {
- console.log(this.eqinfo.item)
- var device_id = this.eqinfo.item.equip_id || this.eqinfo.item.device_id
- uni.navigateTo({
- url: "../afterSale/addafter?device_id=" + device_id + "&device_type=" + 5
- })
- },
- oneday(item, index) {
- console.log(item, index)
- var obj = {
- name: item,
- data: [],
- }
- var xtitle = []
- var linearr = []
- var arr = []
- var timearr = []
- for (var i = 0; i < this.onedatas.length; i++) {
- if(Number(this.onedatas[i].dat[index].slice(0, this.onedatas[i].dat[index].indexOf("#")))!=-99.99){
- obj.data.unshift(Number(this.onedatas[i].dat[index].slice(0, this.onedatas[i].dat[index].indexOf("#"))))
- arr.unshift(Number(this.onedatas[i].dat[index].slice(0, this.onedatas[i].dat[index].indexOf("#"))))
- var times = new Date(this.onedatas[i].time * 1000)
- xtitle.unshift(times.getMonth() + 1 + "/" + times.getDate() + "-" + times.getHours() + ":" + times.getMinutes())
- timearr.unshift(+new Date(times)/1000)
- }
- }
- arr.sort(function(a, b) {
- return a - b
- })
- this.onedatasMin = arr[0]
- this.onedatasMax = arr[arr.length - 1]
- for(var i = 0; i < obj.data.length; i++){
- if(this.onedatasMax==obj.data[i]){
- this.onedatasMaxtime = timearr[i]
- }
- if(this.onedatasMin==obj.data[i]){
- this.onedatasMintime = timearr[i]
- }
- }
- linearr.push(obj)
- if(obj.data.length==0){
- this.tishiTF = true
- }else{
- this.tishiTF = false
- }
- this.show = true
- this.showColumn("canvasColumnA", xtitle, linearr)
- },
- showColumn(id, xtitle, xinfo) {
- var _self = this
- canvasColumnA = new uCharts({
- canvasId: id,
- type: 'line',
- legend: {
- position: "top"
- },
- fontSize: 11,
- background: '#FFFFFF',
- pixelRatio: 1,
- animation: true,
- dataLabel: false,
- categories: xtitle,
- series: xinfo,
- enableScroll: true, //开启图表拖拽功能
- xAxis: {
- disableGrid: true,
- type: 'grid',
- gridType: 'dash',
- itemCount: 4, //x轴单屏显示数据的数量,默认为5个
- scrollShow: true, //新增是否显示滚动条,默认false
- // scrollAlign: 'left', //滚动条初始位置
- scrollBackgroundColor: '#F7F7FF', //默认为 #EFEBEF
- scrollColor: '#DEE7F7', //默认为 #A6A6A6
- },
- yAxis: {
- format:(val)=>{return val.toFixed(2)}
- },
- width: _self.cWidth * 1,
- height: _self.cHeight * 1,
- extra: {
- line: {
- type: 'curve'
- },
- },
- });
- },
- touchLineA(e) {
- canvasColumnA.scrollStart(e);
- },
- moveLineA(e) {
- canvasColumnA.scroll(e);
- },
- touchEndLineA(e) {
- canvasColumnA.scrollEnd(e);
- //下面是toolTip事件,如果滚动后不需要显示,可不填写
- canvasColumnA.showToolTip(e, {
- format: function(item, category) {
- return category + ' ' + item.name + ':' + item.data
- }
- });
- },
- },
- onLoad(option) {
- this.$forceUpdate()
- this.eqinfo.item = JSON.parse(option.shebei)
- console.log(JSON.parse(option.shebei))
- this.history()
- this.onehistory()
- if (this.eqinfo.item.lat == '' || this.eqinfo.item.lng == "") {
- console.log(1)
- } else {
- this.reverseGeocode(this.eqinfo.item.lat, this.eqinfo.item.lng)
- }
- uni.getStorage({
- key: "jurisdiction",
- success: (res) => {
- console.log(JSON.parse(res.data))
- let items = JSON.parse(res.data).filter((item) => {
- return item.purview_name == "环境监测系统"
- })
- let items2 = items[0].children.filter((item) => {
- return item.purview_name == "环境监测"
- })
- var arr = items2[0].children
- console.log(arr)
- for (var i = 0; i < arr.length; i++) {
- switch (arr[i].purview_name) {
- case "设备控制":
- this.kongtf = true
- break
- case "24小时数据":
- this.daydatatf = true
- break
- case "历史数据":
- this.shujutf = true
- break
- }
- }
- },
- })
- }
- }
- </script>
- <style lang="scss">
- .info {
- width: 100%;
- position: absolute;
- top: 44px;
- .info_item {
- width: 90%;
- margin: 0 auto;
- height: 250rpx;
- padding: 26rpx 50rpx;
- position: relative;
- box-sizing: border-box;
- .bgi {
- width: 100%;
- height: 250rpx;
- position: absolute;
- top: 0;
- left: 0;
- z-index: -1;
- }
- p {
- font-size: 24rpx;
- color: #FFFFFF;
- margin-bottom: 10rpx;
- .tishi {
- width: 30rpx;
- height: 30rpx;
- margin: 0rpx 0 0 20rpx;
- }
- }
- }
- }
- .control {
- width: 90%;
- position: absolute;
- top: 372rpx;
- left: 5%;
- display: flex;
- text-align: center;
- // padding: 0 30rpx;
- box-sizing: border-box;
- .control_item {
- width: 128rpx;
- height: 120rpx;
- width: 33%;
- image {
- width: 70rpx;
- height: 70rpx;
- }
- p {
- font-size: 24rpx;
- }
- }
- }
- .realtime {
- width: 100%;
- position: absolute;
- top: 500rpx;
- .realtime_title {
- font-weight: 700;
- width: 90%;
- margin: 0 auto;
- }
- .realtime_text {
- width: 90%;
- margin: 0 auto;
- .realtime_text_item {
- width: 100%;
- display: flex;
- justify-content: space-between;
- flex-wrap: wrap;
- margin-bottom: 50rpx;
- .realtime_text_item_info {
- width: 48%;
- box-shadow: 0 0 10rpx #bcb9ca;
- margin-top: 20rpx;
- display: flex;
- padding: 20rpx 0rpx 20rpx 20rpx;
- box-sizing: border-box;
- .item_info_img {
- width: 90rpx;
- text-align: center;
- margin-right: 28rpx;
- border-radius: 50%;
- height: 90rpx;
- image {
- width: 64rpx;
- height: 64rpx;
- margin-top: 15rpx
- }
- }
- .item_info_text {
- font-size: 24rpx;
- }
- }
- }
- }
- }
- .charts {
- // width: 650upx;
- // height: 400upx;
- background-color: #FFFFFF;
- }
- .tishiTF{
- text-align: center;
- margin-top: 20rpx;
- }
- .maxdata {
- font-size: 26rpx;
- .maxdata_box {
- display: flex;
- padding-left: 30rpx;
- box-sizing: border-box;
- }
- .dian {
- width: 20rpx;
- height: 20rpx;
- background-color: red;
- margin: 8rpx 10rpx 0 0;
- border-radius: 50%;
- }
- .diantwo {
- background-color: #16c60d;
- }
- }
- </style>
|