waterhis.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <view>
  3. <view class="selecttimesbox">
  4. <view class="selecttimes" @click="tiemshow=!tiemshow">
  5. <view class="timesbox">
  6. <image
  7. src="http://www.hnyfwlw.com:8006/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="" :style="{'color':item.txt.slice(0,2)=='开启'?'#3EB984 ':'#f64a4a'}">
  27. {{item.txt}}
  28. </view>
  29. </view>
  30. <view class="item">
  31. <view class="">
  32. 操作时间
  33. </view>
  34. <view class="">
  35. {{item.uptime|timeFormat()}}
  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. console.log(res.dat)
  101. for(var i=0;i<res.dat.length;i++){
  102. var name = res.dat[i].relayName.split("/")[Number(res.dat[i].relayNum)]
  103. var state = res.dat[i].relayState == 1?"开启":"关闭"
  104. var obj = {
  105. txt:state + name,
  106. uptime:res.dat[i].uptime,
  107. user:res.dat[i].user
  108. }
  109. this.hisdatalist.push(obj)
  110. }
  111. }
  112. }
  113. }
  114. </script>
  115. <style lang="scss">
  116. page {
  117. background: $uni-bg-color-grey;
  118. }
  119. .selecttimesbox{
  120. position: fixed;
  121. width: 100%;
  122. padding: 30rpx 0;
  123. background-color: #fff;
  124. z-index: 99;
  125. }
  126. .selecttimes {
  127. width: 90%;
  128. box-shadow: 0 0 10rpx #bcb9ca;
  129. padding: 10rpx 20rpx;
  130. margin: 0 auto;
  131. box-sizing: border-box;
  132. .timesbox {
  133. display: flex;
  134. justify-content: space-around;
  135. image {
  136. width: 30rpx;
  137. height: 30rpx;
  138. margin-top: 6rpx;
  139. }
  140. .icon {
  141. color: #949494;
  142. text-align: right;
  143. margin-left: 30rpx;
  144. }
  145. }
  146. }
  147. .historicaldata{
  148. position: absolute;
  149. top: 130rpx;
  150. width: 100%;
  151. .historicaldatanone{
  152. font-size: 32rpx;
  153. width: 100%;
  154. padding: 20rpx 0;
  155. text-align: center;
  156. }
  157. .historicaldata_item{
  158. width: 100%;
  159. margin: 20rpx auto;
  160. background-color: #fff;
  161. .item{
  162. width: 90%;
  163. margin: 0rpx auto;
  164. border-bottom: 1px solid #F6F6F6 ;
  165. font-size: 32rpx;
  166. display: flex;
  167. justify-content: space-between;
  168. padding: 20rpx 0;
  169. }
  170. }
  171. }
  172. /deep/.u-calendar__action {
  173. display: flex;
  174. justify-content: space-around;
  175. .u-calendar__action__text {
  176. line-height: 25px;
  177. }
  178. }
  179. </style>