waterhis.vue 4.0 KB

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