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