equipment.vue 5.0 KB

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