equipment.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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: '/https://apis.map.qq.com/ws/geocoder/v1/?location='+this.eqinfo.item.lat+","+this.eqinfo.item.lng+'&key=B2EBZ-2UW6P-RDJDG-LCMLE-AIQUS-CGFMJ',
  105. success: (res) => {
  106. this.city = res.data.result.address
  107. }
  108. })
  109. this.history()
  110. }
  111. }
  112. </script>
  113. <style lang="scss">
  114. .info {
  115. width: 100%;
  116. position: absolute;
  117. top: 44px;
  118. .info_item {
  119. width: 90%;
  120. margin: 0 auto;
  121. height: 260rpx;
  122. padding: 26rpx 50rpx;
  123. position: relative;
  124. .bgi {
  125. width: 100%;
  126. height: 260rpx;
  127. position: absolute;
  128. top: 0;
  129. left: 0;
  130. z-index: -1;
  131. }
  132. p {
  133. font-size: 24rpx;
  134. color: #FFFFFF;
  135. margin-bottom: 10rpx;
  136. }
  137. }
  138. }
  139. .control {
  140. width: 90%;
  141. position: absolute;
  142. top: 372rpx;
  143. left: 5%;
  144. display: flex;
  145. justify-content: space-between;
  146. text-align: center;
  147. padding: 0 30rpx;
  148. box-sizing: border-box;
  149. .control_item {
  150. width: 128rpx;
  151. height: 120rpx;
  152. image {
  153. width: 70rpx;
  154. height: 70rpx;
  155. }
  156. p {
  157. font-size: 24rpx;
  158. }
  159. }
  160. }
  161. .realtime {
  162. width: 100%;
  163. position: absolute;
  164. top: 500rpx;
  165. .realtime_title {
  166. font-weight: 700;
  167. width: 90%;
  168. margin: 0 auto;
  169. }
  170. .realtime_text {
  171. width: 90%;
  172. margin: 0 auto;
  173. .realtime_text_item {
  174. width: 100%;
  175. display: flex;
  176. justify-content: space-between;
  177. flex-wrap: wrap;
  178. margin-bottom: 50rpx;
  179. .realtime_text_item_info {
  180. width: 48%;
  181. box-shadow: 0 0 10rpx #bcb9ca;
  182. margin-top: 20rpx;
  183. display: flex;
  184. padding: 20rpx 0rpx 20rpx 20rpx;
  185. box-sizing: border-box;
  186. .item_info_img {
  187. width: 90rpx;
  188. text-align: center;
  189. margin-right: 28rpx;
  190. border-radius: 50%;
  191. height: 90rpx;
  192. image {
  193. width: 64rpx;
  194. height: 64rpx;
  195. margin-top: 15rpx
  196. }
  197. }
  198. .item_info_text {
  199. font-size: 24rpx;
  200. }
  201. }
  202. }
  203. }
  204. }
  205. </style>