realtimedata.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <template>
  2. <view style="padding-top: 20rpx;">
  3. <view class="datainfo">
  4. <view class="datainfo_item">
  5. <view class="">
  6. {{item.device_name}}
  7. </view>
  8. <view class="" :style="{'color':item.water_pump_switch==1?'#00B075':'#f64a4a'}">
  9. {{item.water_pump_switch==1?"已开泵":"已关泵"}}
  10. </view>
  11. </view>
  12. <view class="datainfo_item">
  13. 设备ID:{{item.device_id}}
  14. </view>
  15. <view class="datainfo_item">
  16. 设备备注:{{item.device_notes==''?"--":item.device_notes}}
  17. </view>
  18. <view class="datainfo_item">
  19. 设备状态:{{item.device_status==1?"在线":"离线"}}
  20. </view>
  21. <view class="datainfo_item">
  22. <view class="datainfo_item_1">
  23. 地址:{{item.city}}
  24. </view>
  25. <view class="">
  26. <u-icon name="map" size="40" color="#00B075" @click="selectaddress(item.city,item.device_name)">
  27. </u-icon>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="datadetails">
  32. <view class="datadetails_img">
  33. <image src="../../static/images/irrigate/yinxingqia.png" mode="" class="img"></image>
  34. </view>
  35. <view class="datadetails_box">
  36. <view class="datadetails_box_item">
  37. 用户卡号:{{data.card_no}}
  38. </view>
  39. <view class="datadetails_box_item">
  40. 当前耗水量:<span style="color:#00B075;">{{data.water_consume}}T</span>
  41. </view>
  42. <view class="datadetails_box_item">
  43. 当前耗电量:<span style="color:#00B075;">{{data.electric_consume}}Kwh</span>
  44. </view>
  45. <view class="datadetails_box_item">
  46. 刷卡使用状态:{{data.status==1?"刷卡开泵":"刷卡关泵"}}
  47. </view>
  48. <view class="datadetails_box_item">
  49. 倒计时:<span style="color:#00B075;">{{data.time_consume}}s</span>
  50. </view>
  51. <view class="datadetails_box_item">
  52. 用户卡余额:<span style="color:#f64a4a;">{{data.money_remain}}</span>
  53. </view>
  54. <view class="datadetails_box_item">
  55. 水表总耗电量:{{data.total_water}}
  56. </view>
  57. <view class="datadetails_box_item">
  58. 数据更新时间:{{data.addtime|timeFormat()}}
  59. </view>
  60. </view>
  61. </view>
  62. <u-mask :show="maskshow">
  63. <view class="loading" v-if="maskshow">
  64. <image src="../../static/images/cb/6286299.gif" mode="" class="img"></image>
  65. </view>
  66. </u-mask>
  67. </view>
  68. </template>
  69. <script>
  70. export default {
  71. data() {
  72. return {
  73. item: {},
  74. data: {},
  75. Interval: null,
  76. maskshow: false
  77. }
  78. },
  79. onLoad(option) {
  80. // console.log(JSON.parse(option.item))
  81. this.item = JSON.parse(option.item)
  82. this.getbaseinfo()
  83. this.Interval = setInterval(() => {
  84. this.getbaseinfo()
  85. }, 15000)
  86. },
  87. onHide() {
  88. // console.log("5555")
  89. // clearInterval(this.Interval)
  90. },
  91. onBackPress(e) {
  92. // console.log("5555")
  93. clearInterval(this.Interval)
  94. },
  95. methods: {
  96. async getbaseinfo(){
  97. const res = await this.$myRequest({
  98. url: '/api/api_gateway?method=irrigation_system.hydropower.hydropower_list',
  99. data: {
  100. content: this.item.device_id,
  101. }
  102. })
  103. console.log(res)
  104. this.item = res.data[0]
  105. this.tubulareqlist()
  106. },
  107. async tubulareqlist() { //实时数据
  108. this.maskshow = true
  109. const res = await this.$myRequest({
  110. url: '/api/api_gateway?method=irrigation_system.hydropower.water_pump_instant_data',
  111. data: {
  112. device_id: this.item.device_id,
  113. }
  114. })
  115. this.maskshow = false
  116. console.log(res)
  117. this.data = {}
  118. this.data = res[0]
  119. },
  120. selectaddress(city, name) { //获取分布位置
  121. uni.request({
  122. type: "GET",
  123. url: "https://restapi.amap.com/v3/geocode/geo?address=" + city +
  124. "&key=78ce288400f4fc6d9458989875c833c2",
  125. dataType: "json",
  126. complete: ress => {
  127. console.log(ress)
  128. if (ress.data.status == 1) {
  129. // ress.data.geocodes[0].location
  130. uni.navigateTo({
  131. url: "./irrmap?lnglat=" + ress.data.geocodes[0].location +
  132. "&basename=" + name
  133. })
  134. } else {
  135. uni.showToast({
  136. title: "地址编译失败",
  137. icon: "none"
  138. })
  139. }
  140. }
  141. });
  142. },
  143. }
  144. }
  145. </script>
  146. <style lang="scss">
  147. page {
  148. background: $uni-bg-color-grey;
  149. }
  150. .datainfo {
  151. width: 100%;
  152. background-color: #fff;
  153. padding: 20rpx 30rpx;
  154. box-sizing: border-box;
  155. .datainfo_item {
  156. display: flex;
  157. justify-content: space-between;
  158. height: 60rpx;
  159. font-size: 28rpx;
  160. color: #909696;
  161. .datainfo_item_1 {
  162. width: 80%;
  163. overflow: hidden; //溢出隐藏
  164. white-space: nowrap; //禁止换行
  165. text-overflow: ellipsis; //...
  166. }
  167. }
  168. .datainfo_item:first-child {
  169. font-size: 32rpx;
  170. color: #000;
  171. }
  172. }
  173. .datadetails {
  174. width: 100%;
  175. margin-top: 20rpx;
  176. background-color: #fff;
  177. padding: 20rpx 30rpx;
  178. box-sizing: border-box;
  179. display: flex;
  180. justify-content: space-between;
  181. .datadetails_img {
  182. width: 5%;
  183. height: 40rpx;
  184. .img {
  185. width: 100%;
  186. height: 100%;
  187. }
  188. }
  189. .datadetails_box {
  190. width: 92%;
  191. .datadetails_box_item {
  192. height: 60rpx;
  193. }
  194. }
  195. }
  196. .loading {
  197. position: fixed;
  198. top: 200px;
  199. width: 95%;
  200. left: 2.5%;
  201. text-align: center;
  202. .img {
  203. width: 300rpx;
  204. height: 300rpx;
  205. }
  206. }
  207. </style>