| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 |
- <template>
- <view>
- <view class="status_bar"></view>
- <view class="" style="position: relative;top: 64px;">
- <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://static.yfpyx.com/bigdata_app/image/cb/onBg.png':'http://static.yfpyx.com/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://static.yfpyx.com/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://static.yfpyx.com/bigdata_app'+'/image/environment/8.png'" mode=""></image>
- <p>设备控制</p>
- </view>
- <view class="control_item" v-if="daydatatf" @click="repairs">
- <image :src="'http://static.yfpyx.com/bigdata_app'+'/image/environment/7.png'" mode=""></image>
- <p>一键报修</p>
- </view>
- <view class="control_item" v-if="shujutf" @click="charts">
- <image :src="'http://static.yfpyx.com/bigdata_app'+'/image/environment/10.png'" mode=""></image>
- <p>历史数据</p>
- </view>
- </view>
- <view class="realtime">
- <p class="realtime_title">实时数据</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="item">
- <view class="item_info_img" :style="{'background-color':olddatas[Math.floor(Math.random()*(5-0+1))]}">
- <image :src="'http://static.yfpyx.com/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>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- eqinfo: {},
- olddata: {},
- olddatas: ["#fba825", "#53d67c", "#008cf2", "#fb504d", "#d87ffc", "#4ec5f0"],
- city: "",
- kongtf:false,
- daydatatf:false,
- shujutf: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
- 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("#")
- }
- console.log(this.olddata)
- },
- 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
- })
- }
- },
- onLoad(option) {
- this.$forceUpdate()
- this.eqinfo.item = JSON.parse(option.shebei)
- console.log(JSON.parse(option.shebei))
- this.history()
- 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;
- }
- }
- }
- }
- }
- </style>
|