equipment.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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. 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. },
  110. onLoad(option) {
  111. this.$forceUpdate()
  112. this.eqinfo.item = JSON.parse(option.shebei)
  113. console.log(JSON.parse(option.shebei))
  114. this.history()
  115. if(this.eqinfo.item.lat==''||this.eqinfo.item.lng==""){
  116. console.log(1)
  117. }else{
  118. this.reverseGeocode(this.eqinfo.item.lat,this.eqinfo.item.lng)
  119. }
  120. }
  121. }
  122. </script>
  123. <style lang="scss">
  124. .info {
  125. width: 100%;
  126. position: absolute;
  127. top: 44px;
  128. .info_item {
  129. width: 90%;
  130. margin: 0 auto;
  131. height: 260rpx;
  132. padding: 26rpx 50rpx;
  133. position: relative;
  134. box-sizing: border-box;
  135. .bgi {
  136. width: 100%;
  137. height: 260rpx;
  138. position: absolute;
  139. top: 0;
  140. left: 0;
  141. z-index: -1;
  142. }
  143. p {
  144. font-size: 24rpx;
  145. color: #FFFFFF;
  146. margin-bottom: 10rpx;
  147. }
  148. }
  149. }
  150. .control {
  151. width: 90%;
  152. position: absolute;
  153. top: 372rpx;
  154. left: 5%;
  155. display: flex;
  156. justify-content: space-between;
  157. text-align: center;
  158. padding: 0 30rpx;
  159. box-sizing: border-box;
  160. .control_item {
  161. width: 128rpx;
  162. height: 120rpx;
  163. image {
  164. width: 70rpx;
  165. height: 70rpx;
  166. }
  167. p {
  168. font-size: 24rpx;
  169. }
  170. }
  171. }
  172. .realtime {
  173. width: 100%;
  174. position: absolute;
  175. top: 500rpx;
  176. .realtime_title {
  177. font-weight: 700;
  178. width: 90%;
  179. margin: 0 auto;
  180. }
  181. .realtime_text {
  182. width: 90%;
  183. margin: 0 auto;
  184. .realtime_text_item {
  185. width: 100%;
  186. display: flex;
  187. justify-content: space-between;
  188. flex-wrap: wrap;
  189. margin-bottom: 50rpx;
  190. .realtime_text_item_info {
  191. width: 48%;
  192. box-shadow: 0 0 10rpx #bcb9ca;
  193. margin-top: 20rpx;
  194. display: flex;
  195. padding: 20rpx 0rpx 20rpx 20rpx;
  196. box-sizing: border-box;
  197. .item_info_img {
  198. width: 90rpx;
  199. text-align: center;
  200. margin-right: 28rpx;
  201. border-radius: 50%;
  202. height: 90rpx;
  203. image {
  204. width: 64rpx;
  205. height: 64rpx;
  206. margin-top: 15rpx
  207. }
  208. }
  209. .item_info_text {
  210. font-size: 24rpx;
  211. }
  212. }
  213. }
  214. }
  215. }
  216. </style>