waterhis.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <template>
  2. <view>
  3. <view class="selecttimesbox">
  4. <view class="selecttimes" @click="tiemshow = !tiemshow">
  5. <view class="timesbox">
  6. <image
  7. :src="$imageURL+'/bigdata_app/image/prevention/1acfe2751c01d3786cdc49b83d7e505.png'"
  8. mode=""
  9. ></image>
  10. <p>{{ timetab(oldtime) }}</p>
  11. <p class="or">~</p>
  12. <p>{{ timetab(newtime) }}</p>
  13. <u-icon name="rili" custom-prefix="custom-icon" class="icon"></u-icon>
  14. </view>
  15. <u-calendar
  16. v-model="tiemshow"
  17. mode="range"
  18. @change="tiemchange"
  19. ></u-calendar>
  20. </view>
  21. </view>
  22. <view class="historicaldata">
  23. <view class="historicaldatanone" v-if="hisdatalist.length == 0">
  24. 暂无数据
  25. </view>
  26. <view
  27. class="historicaldata_item"
  28. v-for="(item, index) in hisdatalist"
  29. :key="index"
  30. >
  31. <view class="item">
  32. <view class=""> 操作内容 </view>
  33. <view class="">
  34. {{ item.relayState }}
  35. </view>
  36. </view>
  37. <view class="item">
  38. <view class=""> 操作时间 </view>
  39. <view class="">
  40. {{ item.uptime }}
  41. </view>
  42. </view>
  43. <view class="item">
  44. <view class=""> 操作账号 </view>
  45. <view class="">
  46. {{ item.user }}
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. export default {
  55. data() {
  56. return {
  57. oldtime: '',
  58. newtime: '',
  59. tiemshow: false,
  60. page: 1,
  61. device_id: '',
  62. hisdatalist: [],
  63. };
  64. },
  65. onLoad(option) {
  66. this.newtime = +new Date() / 1000;
  67. this.oldtime = (+new Date() - 24 * 60 * 60 * 1000) / 1000;
  68. this.device_id = option.device_id;
  69. this.sf_control();
  70. },
  71. onReachBottom() {
  72. // console.log("触底")
  73. this.page++;
  74. this.sf_control();
  75. },
  76. methods: {
  77. timetab(e) {
  78. e = new Date(e * 1000);
  79. var year = e.getFullYear();
  80. var month =
  81. e.getMonth() + 1 < 10 ? '0' + (e.getMonth() + 1) : e.getMonth() + 1;
  82. var day = e.getDate() < 10 ? '0' + e.getDate() : e.getDate();
  83. var time = year + '/' + month + '/' + day;
  84. return time;
  85. },
  86. tiemchange(e) {
  87. console.log(e);
  88. this.oldtime = +new Date(e.startDate) / 1000;
  89. this.newtime = +new Date(e.endDate) / 1000 + 16 * 60 * 60;
  90. this.page = 1;
  91. this.hisdatalist = [];
  92. this.sf_control();
  93. },
  94. async sf_control() {
  95. const res = await this.$myRequest({
  96. url: '/api/api_gateway?method=weather.weather.sf_control_data',
  97. data: {
  98. begin: Math.floor(this.oldtime),
  99. device_id: this.device_id,
  100. end: Math.floor(this.newtime),
  101. page: this.page,
  102. },
  103. });
  104. this.hisdatalist = res.dat;
  105. // console.log(res.dat)
  106. // for(var i=0;i<res.dat.length;i++){
  107. // var name = res.dat[i].relayName.split("/")[Number(res.dat[i].relayNum)]
  108. // var state = res.dat[i].relayState == 1?"开启":"关闭"
  109. // var obj = {
  110. // txt:state + name,
  111. // uptime:res.dat[i].uptime,
  112. // user:res.dat[i].user
  113. // }
  114. // this.hisdatalist.push(obj)
  115. // }
  116. },
  117. },
  118. };
  119. </script>
  120. <style lang="scss">
  121. page {
  122. background: $uni-bg-color-grey;
  123. }
  124. .selecttimesbox {
  125. position: fixed;
  126. width: 100%;
  127. padding: 30rpx 0;
  128. background-color: #fff;
  129. z-index: 99;
  130. }
  131. .selecttimes {
  132. width: 90%;
  133. box-shadow: 0 0 10rpx #bcb9ca;
  134. padding: 10rpx 20rpx;
  135. margin: 0 auto;
  136. box-sizing: border-box;
  137. .timesbox {
  138. display: flex;
  139. justify-content: space-around;
  140. image {
  141. width: 30rpx;
  142. height: 30rpx;
  143. margin-top: 6rpx;
  144. }
  145. .icon {
  146. color: #949494;
  147. text-align: right;
  148. margin-left: 30rpx;
  149. }
  150. }
  151. }
  152. .historicaldata {
  153. position: absolute;
  154. top: 130rpx;
  155. width: 100%;
  156. .historicaldatanone {
  157. font-size: 32rpx;
  158. width: 100%;
  159. padding: 20rpx 0;
  160. text-align: center;
  161. }
  162. .historicaldata_item {
  163. width: 100%;
  164. margin: 20rpx auto;
  165. background-color: #fff;
  166. .item {
  167. width: 90%;
  168. margin: 0rpx auto;
  169. border-bottom: 1px solid #f6f6f6;
  170. font-size: 32rpx;
  171. display: flex;
  172. justify-content: space-between;
  173. padding: 20rpx 0;
  174. }
  175. }
  176. }
  177. ::v-deep .u-calendar__action {
  178. display: flex;
  179. justify-content: space-around;
  180. .u-calendar__action__text {
  181. line-height: 25px;
  182. }
  183. }
  184. </style>