equipment.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <view>
  3. <view class="status_bar"></view>
  4. <view class="" style="position: relative;top: 64px;">
  5. <view style="position: fixed;z-index: 100;width: 100%;">
  6. <uni-nav-bar @clickLeft="clickLeft" left-icon="back" left-text="返回" title="设备详情"></uni-nav-bar>
  7. </view>
  8. <view class="info">
  9. <view class="info_item">
  10. <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=""
  11. class="bgi"></image>
  12. <p style="font-size: 32rpx;" @click="copy(eqinfo.item)">设备 ID:{{eqinfo.item.equip_id||eqinfo.item.device_id}}
  13. <image src="http://static.yfpyx.com/bigdata_app/image/environment/fuzhi.png" mode="" class="tishi"></image>
  14. </p>
  15. <p>设备名称:{{eqinfo.item.equip_name?eqinfo.item.equip_name:"无"}}</p>
  16. <p>最近上报时间:{{eqinfo.item.uptime|timeFormat()}}</p>
  17. <p>地址:{{city==""?"--":city}}</p>
  18. </view>
  19. </view>
  20. <view class="control">
  21. <view class="control_item" v-if="kongtf" @click="control">
  22. <image :src="'http://static.yfpyx.com/bigdata_app'+'/image/environment/8.png'" mode=""></image>
  23. <p>设备控制</p>
  24. </view>
  25. <view class="control_item" v-if="daydatatf" @click="repairs">
  26. <image :src="'http://static.yfpyx.com/bigdata_app'+'/image/environment/7.png'" mode=""></image>
  27. <p>一键报修</p>
  28. </view>
  29. <view class="control_item" v-if="shujutf" @click="charts">
  30. <image :src="'http://static.yfpyx.com/bigdata_app'+'/image/environment/10.png'" mode=""></image>
  31. <p>历史数据</p>
  32. </view>
  33. </view>
  34. <view class="realtime">
  35. <p class="realtime_title">实时数据</p>
  36. <view class="realtime_text">
  37. <view class="realtime_text_item">
  38. <view class="realtime_text_item_info" v-for="(item,index) in olddata.conf" :key="index" v-if="item">
  39. <view class="item_info_img" :style="{'background-color':olddatas[Math.floor(Math.random()*(5-0+1))]}">
  40. <image :src="'http://static.yfpyx.com/bigdata_app'+'/image/environment/icon_'+olddata.dat[index][1]+'.png'" mode=""></image>
  41. </view>
  42. <view class="item_info_text">
  43. <p>{{item}}</p>
  44. <p style="margin-top: 20rpx;">{{parseFloat(olddata.dat[index][0]) == -99.99 ?'N/A':parseFloat(olddata.dat[index])}}</p>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. export default {
  55. data() {
  56. return {
  57. eqinfo: {},
  58. olddata: {},
  59. olddatas: ["#fba825", "#53d67c", "#008cf2", "#fb504d", "#d87ffc", "#4ec5f0"],
  60. city: "",
  61. kongtf:false,
  62. daydatatf:false,
  63. shujutf:false
  64. }
  65. },
  66. methods: {
  67. clickLeft() {
  68. uni.navigateBack({
  69. delta: 1
  70. })
  71. },
  72. async history() { //设备列表
  73. const res = await this.$myRequest({
  74. url: '/api/api_gateway?method=weather.weather.qxz_status',
  75. data: {
  76. device_id: this.eqinfo.item.equip_id || this.eqinfo.item.device_id
  77. }
  78. })
  79. this.olddata = res
  80. for (var key in this.olddata.conf) {
  81. if (this.olddata.conf[key].indexOf("#") != -1) {
  82. this.olddata.conf[key] = this.olddata.conf[key].replace("#", "(") + ")"
  83. }
  84. this.olddata.dat[key] = this.olddata.dat[key].split("#")
  85. }
  86. console.log(this.olddata)
  87. },
  88. control() { //设备控制
  89. uni.navigateTo({
  90. url: "./contros?id=" + this.eqinfo.item.d_id
  91. })
  92. },
  93. charts() { //历史数据
  94. uni.navigateTo({
  95. url: "./history?device_id=" + this.eqinfo.item.equip_id
  96. })
  97. },
  98. reverseGeocode(lat,lng){
  99. uni.request({
  100. type: "GET",
  101. url: "https://restapi.amap.com/v3/geocode/regeo?output=JSON&location=" + lng + "," +lat + "&key=27273b81090f78759e4057f94474516f&radius=1000&extensions=all",
  102. dataType: "json",
  103. complete: ress => {
  104. console.log(ress)
  105. this.city = ress.data.regeocode.formatted_address
  106. }
  107. });
  108. },
  109. copy(item){
  110. uni.setClipboardData({
  111. data: item.equip_id||item.device_id,
  112. success: function () {
  113. console.log('success');
  114. }
  115. });
  116. },
  117. repairs(){
  118. console.log(this.eqinfo.item)
  119. var device_id = this.eqinfo.item.equip_id||this.eqinfo.item.device_id
  120. uni.navigateTo({
  121. url: "../afterSale/addafter?device_id="+ device_id +"&device_type="+ 5
  122. })
  123. }
  124. },
  125. onLoad(option) {
  126. this.$forceUpdate()
  127. this.eqinfo.item = JSON.parse(option.shebei)
  128. console.log(JSON.parse(option.shebei))
  129. this.history()
  130. if(this.eqinfo.item.lat==''||this.eqinfo.item.lng==""){
  131. console.log(1)
  132. }else{
  133. this.reverseGeocode(this.eqinfo.item.lat,this.eqinfo.item.lng)
  134. }
  135. uni.getStorage({
  136. key:"jurisdiction",
  137. success:(res)=>{
  138. console.log(JSON.parse(res.data))
  139. let items = JSON.parse(res.data).filter((item)=>{
  140. return item.purview_name == "环境监测系统"
  141. })
  142. let items2 = items[0].children.filter((item)=>{
  143. return item.purview_name == "环境监测"
  144. })
  145. var arr = items2[0].children
  146. console.log(arr)
  147. for(var i =0;i<arr.length;i++){
  148. switch (arr[i].purview_name){
  149. case "设备控制":
  150. this.kongtf = true
  151. break
  152. case "24小时数据":
  153. this.daydatatf = true
  154. break
  155. case "历史数据":
  156. this.shujutf = true
  157. break
  158. }
  159. }
  160. },
  161. })
  162. }
  163. }
  164. </script>
  165. <style lang="scss">
  166. .info {
  167. width: 100%;
  168. position: absolute;
  169. top: 44px;
  170. .info_item {
  171. width: 90%;
  172. margin: 0 auto;
  173. height: 250rpx;
  174. padding: 26rpx 50rpx;
  175. position: relative;
  176. box-sizing: border-box;
  177. .bgi {
  178. width: 100%;
  179. height: 250rpx;
  180. position: absolute;
  181. top: 0;
  182. left: 0;
  183. z-index: -1;
  184. }
  185. p {
  186. font-size: 24rpx;
  187. color: #FFFFFF;
  188. margin-bottom: 10rpx;
  189. .tishi{
  190. width: 30rpx;
  191. height: 30rpx;
  192. margin: 0rpx 0 0 20rpx;
  193. }
  194. }
  195. }
  196. }
  197. .control {
  198. width: 90%;
  199. position: absolute;
  200. top: 372rpx;
  201. left: 5%;
  202. display: flex;
  203. text-align: center;
  204. // padding: 0 30rpx;
  205. box-sizing: border-box;
  206. .control_item {
  207. width: 128rpx;
  208. height: 120rpx;
  209. width: 33%;
  210. image {
  211. width: 70rpx;
  212. height: 70rpx;
  213. }
  214. p {
  215. font-size: 24rpx;
  216. }
  217. }
  218. }
  219. .realtime {
  220. width: 100%;
  221. position: absolute;
  222. top: 500rpx;
  223. .realtime_title {
  224. font-weight: 700;
  225. width: 90%;
  226. margin: 0 auto;
  227. }
  228. .realtime_text {
  229. width: 90%;
  230. margin: 0 auto;
  231. .realtime_text_item {
  232. width: 100%;
  233. display: flex;
  234. justify-content: space-between;
  235. flex-wrap: wrap;
  236. margin-bottom: 50rpx;
  237. .realtime_text_item_info {
  238. width: 48%;
  239. box-shadow: 0 0 10rpx #bcb9ca;
  240. margin-top: 20rpx;
  241. display: flex;
  242. padding: 20rpx 0rpx 20rpx 20rpx;
  243. box-sizing: border-box;
  244. .item_info_img {
  245. width: 90rpx;
  246. text-align: center;
  247. margin-right: 28rpx;
  248. border-radius: 50%;
  249. height: 90rpx;
  250. image {
  251. width: 64rpx;
  252. height: 64rpx;
  253. margin-top: 15rpx
  254. }
  255. }
  256. .item_info_text {
  257. font-size: 24rpx;
  258. }
  259. }
  260. }
  261. }
  262. }
  263. </style>