equipment.vue 4.6 KB

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