waterhis.vue 4.5 KB

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