equipment.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <template>
  2. <view>
  3. <view class="status_bar"></view>
  4. <view class="" style="position: relative;top: 44px;">
  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?'../../static/image/cb/onBg.png':'../../static/image/cb/offBg.png'" mode=""
  11. class="bgi"></image>
  12. <p style="font-size: 32rpx;">设备 ID:{{eqinfo.item.equip_id}}</p>
  13. <p>设备名称:{{eqinfo.item.equip_name?eqinfo.item.equip_name:"无"}}</p>
  14. <p>最近上报时间:{{eqinfo.item.uptime|timeFormat()}}</p>
  15. <p>地址:{{city?city:"---"}}</p>
  16. </view>
  17. </view>
  18. <view class="control">
  19. <view class="control_item" @click="control">
  20. <image src="../../static/image/prevention/8.png" mode=""></image>
  21. <p>设备控制</p>
  22. </view>
  23. <view class="control_item" @click="information">
  24. <image src="../../static/image/environment/9.png" mode=""></image>
  25. <p>24小时数据</p>
  26. </view>
  27. <view class="control_item" @click="charts">
  28. <image src="../../static/image/environment/10.png" mode=""></image>
  29. <p>历史数据</p>
  30. </view>
  31. </view>
  32. <view class="realtime">
  33. <p class="realtime_title">实时数据</p>
  34. <view class="realtime_text">
  35. <view class="realtime_text_item">
  36. <view class="realtime_text_item_info" v-for="(item,index) in olddata.conf" :key="index" v-if="item">
  37. <view class="item_info_img" :style="{'background-color':olddatas[Math.floor(Math.random()*(5-0+1))]}">
  38. <image :src="'../../static/image/environment/icon_'+olddata.dat[index][1]+'.png'" mode=""></image>
  39. </view>
  40. <view class="item_info_text">
  41. <p>{{item}}</p>
  42. <p style="margin-top: 20rpx;">{{parseFloat(olddata.dat[index][0]) == -99.99 ?'N/A':parseFloat(olddata.dat[index])}}</p>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. export default {
  53. data() {
  54. return {
  55. eqinfo: {},
  56. olddata: {},
  57. olddatas: ["#fba825", "#53d67c", "#008cf2", "#fb504d", "#d87ffc", "#4ec5f0"],
  58. city: ""
  59. }
  60. },
  61. methods: {
  62. clickLeft() {
  63. uni.navigateBack({
  64. delta: 1
  65. })
  66. },
  67. async history() { //设备列表
  68. const res = await this.$myRequest({
  69. url: '/api/api_gateway?method=weather.weather.qxz_status',
  70. data: {
  71. device_id: this.eqinfo.item.equip_id
  72. }
  73. })
  74. this.olddata = res
  75. for (var key in this.olddata.conf) {
  76. if (this.olddata.conf[key].indexOf("#") != -1) {
  77. this.olddata.conf[key] = this.olddata.conf[key].replace("#", "(") + ")"
  78. }
  79. this.olddata.dat[key] = this.olddata.dat[key].split("#")
  80. }
  81. console.log(this.olddata)
  82. },
  83. control() { //设备控制
  84. uni.navigateTo({
  85. url: "./contros?id=" + this.eqinfo.item.d_id
  86. })
  87. },
  88. information() { //24小时数据
  89. uni.navigateTo({
  90. url: "./onedaythedata?id=" + this.eqinfo.item.equip_id
  91. })
  92. },
  93. charts() { //历史数据
  94. uni.navigateTo({
  95. url: "./history?device_id=" + this.eqinfo.item.equip_id
  96. })
  97. }
  98. },
  99. onLoad(option) {
  100. this.$forceUpdate()
  101. this.eqinfo.item = JSON.parse(option.shebei)
  102. console.log(this.eqinfo)
  103. uni.request({
  104. url: '/dpc/geocoder/v1/?location=' + this.eqinfo.item.lat + "," + this.eqinfo.item.lng +
  105. '&key=B2EBZ-2UW6P-RDJDG-LCMLE-AIQUS-CGFMJ',
  106. success: (res) => {
  107. this.city = res.data.result.address
  108. }
  109. })
  110. this.history()
  111. }
  112. }
  113. </script>
  114. <style lang="scss">
  115. .info {
  116. width: 100%;
  117. position: absolute;
  118. top: 44px;
  119. .info_item {
  120. width: 90%;
  121. margin: 0 auto;
  122. height: 260rpx;
  123. padding: 26rpx 50rpx;
  124. position: relative;
  125. .bgi {
  126. width: 100%;
  127. height: 260rpx;
  128. position: absolute;
  129. top: 0;
  130. left: 0;
  131. z-index: -1;
  132. }
  133. p {
  134. font-size: 24rpx;
  135. color: #FFFFFF;
  136. margin-bottom: 10rpx;
  137. }
  138. }
  139. }
  140. .control {
  141. width: 90%;
  142. position: absolute;
  143. top: 372rpx;
  144. left: 5%;
  145. display: flex;
  146. justify-content: space-between;
  147. text-align: center;
  148. padding: 0 30rpx;
  149. box-sizing: border-box;
  150. .control_item {
  151. width: 128rpx;
  152. height: 120rpx;
  153. image {
  154. width: 70rpx;
  155. height: 70rpx;
  156. }
  157. p {
  158. font-size: 24rpx;
  159. }
  160. }
  161. }
  162. .realtime {
  163. width: 100%;
  164. position: absolute;
  165. top: 500rpx;
  166. .realtime_title {
  167. font-weight: 700;
  168. width: 90%;
  169. margin: 0 auto;
  170. }
  171. .realtime_text {
  172. width: 90%;
  173. margin: 0 auto;
  174. .realtime_text_item {
  175. width: 100%;
  176. display: flex;
  177. justify-content: space-between;
  178. flex-wrap: wrap;
  179. margin-bottom: 50rpx;
  180. .realtime_text_item_info {
  181. width: 48%;
  182. box-shadow: 0 0 10rpx #bcb9ca;
  183. margin-top: 20rpx;
  184. display: flex;
  185. padding: 20rpx 0rpx 20rpx 20rpx;
  186. box-sizing: border-box;
  187. .item_info_img {
  188. width: 90rpx;
  189. text-align: center;
  190. margin-right: 28rpx;
  191. border-radius: 50%;
  192. height: 90rpx;
  193. image {
  194. width: 64rpx;
  195. height: 64rpx;
  196. margin-top: 15rpx
  197. }
  198. }
  199. .item_info_text {
  200. font-size: 24rpx;
  201. }
  202. }
  203. }
  204. }
  205. }
  206. </style>