photolist.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <template>
  2. <view>
  3. <view class="status_bar"></view>
  4. <view class="" style="position: relative;top: 44px;">
  5. <view style="position: fixed;z-index: 100;">
  6. <uni-nav-bar @clickLeft="clickLeft" left-icon="back" title="查看图片" rightIcon="camera"
  7. @clickRight="clickRight"></uni-nav-bar>
  8. </view>
  9. <!-- <p class="tishi" v-if="tishi">暂无数据</p> -->
  10. <view class="selecttimes" @click="tiemshow=!tiemshow">
  11. <view class="timesbox">
  12. <image
  13. :src="'http://www.hnyfwlw.com:8006/bigdata_app'+'/image/prevention/1acfe2751c01d3786cdc49b83d7e505.png'"
  14. mode=""></image>
  15. <p>{{timetab(timestate)}}</p>
  16. <p class="or">~</p>
  17. <p>{{timetab(timeend)}}</p>
  18. <u-icon name="rili" custom-prefix="custom-icon" class="icon"></u-icon>
  19. </view>
  20. <u-calendar v-model="tiemshow" mode="range" @change="tiemchange"></u-calendar>
  21. </view>
  22. <view class="imglist">
  23. <view class="imglist_box" v-for="(item,index) in imglists" :key="index">
  24. <view class="imglist_left">
  25. <image src="http://www.hnyfwlw.com:8006/bigdata_app/image/cb/jiazai.ui.gif" mode="">
  26. </image>
  27. <image :src="item.addr" mode="" @click="examine(index)"></image>
  28. </view>
  29. <view class="imglist_right">
  30. <view class="">
  31. {{item.time}}
  32. </view>
  33. <view class="">
  34. 害虫数量:{{item.pest_counts}}
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. <view class="top" v-if="isTop" @click="top">
  41. <image :src="'http://www.hnyfwlw.com:8006/bigdata_app'+'/image/6209a98f0cb3b5086f2ca36152c9269.png'"
  42. mode=""></image>
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. export default {
  48. data() {
  49. return {
  50. tiemshow:false,
  51. timestate:"",
  52. timeend:"",
  53. isTop:false,
  54. imglists:[],
  55. device_id:"",
  56. page:1,
  57. d_id:""
  58. }
  59. },
  60. methods: {
  61. clickLeft(){
  62. uni.navigateBack({
  63. delta:1
  64. })
  65. },
  66. clickRight(){
  67. this.takephoto()
  68. },
  69. timetab(e) {
  70. e = new Date(e * 1000)
  71. var year = e.getFullYear()
  72. var month = e.getMonth() + 1 < 10 ? "0" + (e.getMonth() + 1) : e.getMonth() + 1
  73. var day = e.getDate() < 10 ? "0" + e.getDate() : e.getDate()
  74. var time = year + "/" + month + "/" + day
  75. return time
  76. },
  77. examine(index){
  78. var imgarr = []
  79. for (var i = 0; i < this.imglists.length; i++) {
  80. imgarr.push(this.imglists[i].addr)
  81. }
  82. uni.previewImage({
  83. urls: imgarr,
  84. current: index
  85. });
  86. },
  87. async getimglist(){
  88. const res = await this.$myRequest({
  89. url: '/api/api_gateway?method=forecast.forecast_system.device_photo_list',
  90. data: {
  91. cmd: "cbd_XCT",
  92. device_id: this.device_id,
  93. page: this.page,
  94. page_number: "12",
  95. time_begin: Math.floor(this.timestate),
  96. time_end: Math.floor(this.timeend),
  97. }
  98. })
  99. console.log(res)
  100. this.imglists = res.data
  101. },
  102. top() {
  103. uni.pageScrollTo({
  104. scrollTop: 0,
  105. duration: 500
  106. })
  107. },
  108. tiemchange(e){
  109. // console.log(e)
  110. this.imglists = []
  111. this.page = 1
  112. console.log(e)
  113. this.timestate = +new Date(e.startDate) / 1000 - 8 * 60 * 60
  114. this.timeend = +new Date(e.endDate) / 1000 + 16 * 60 * 60
  115. this.getimglist()
  116. },
  117. async takephoto() { //拍照
  118. const res = await this.$myRequest({
  119. url: '/api/api_gateway?method=forecast.send_control.admin_device_control',
  120. data: {
  121. device_type_id: 12,
  122. d_id: this.d_id,
  123. cmd: "takephoto"
  124. }
  125. })
  126. console.log(res)
  127. if (res == true) {
  128. uni.showToast({
  129. title: '指令下发成功!',
  130. duration: 2000
  131. });
  132. var that = this
  133. setTimeout(() => {
  134. that.getimglist()
  135. }, 1000)
  136. } else {
  137. uni.showToast({
  138. title: '指令下发失败!',
  139. duration: 2000,
  140. icon: "none"
  141. });
  142. }
  143. },
  144. },
  145. onLoad(option) {
  146. this.d_id = option.d_id
  147. this.device_id = option.device_id
  148. this.timeend = +new Date() / 1000
  149. this.timestate = this.timeend - 60 * 60 * 24
  150. this.getimglist()
  151. },
  152. onReachBottom() {
  153. this.page++
  154. this.getimglist()
  155. },
  156. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  157. if (e.scrollTop > 200) { //距离大于200时显示
  158. this.isTop = true
  159. } else { //距离小于200时隐藏
  160. this.isTop = false
  161. }
  162. }
  163. }
  164. </script>
  165. <style lang="scss">
  166. .tishi {
  167. position: absolute;
  168. top: 104px;
  169. width: 95%;
  170. left: 2.5%;
  171. text-align: center;
  172. font-size: 40rpx;
  173. }
  174. .selecttimes {
  175. width: 100%;
  176. position: fixed;
  177. top: 85px;
  178. left: 0;
  179. z-index: 100;
  180. background-color: #fff;
  181. padding-top: 30rpx;
  182. .timesbox {
  183. display: flex;
  184. width: 95%;
  185. margin: 0 auto;
  186. justify-content: space-around;
  187. box-shadow: 0 0 10rpx #bcb9ca;
  188. padding: 10rpx 20rpx;
  189. box-sizing: border-box;
  190. image {
  191. width: 30rpx;
  192. height: 30rpx;
  193. margin-top: 6rpx;
  194. }
  195. .icon {
  196. color: #949494;
  197. text-align: right;
  198. margin-left: 30rpx;
  199. }
  200. }
  201. /deep/.u-calendar__action {
  202. display: flex;
  203. justify-content: space-around;
  204. .u-calendar__action__text {
  205. line-height: 25px;
  206. }
  207. }
  208. }
  209. .imglist {
  210. position: absolute;
  211. top: 100px;
  212. width: 95%;
  213. left: 2.5%;
  214. .imglist_box {
  215. display: flex;
  216. box-shadow: 0 0 10rpx #bcb9ca;
  217. padding: 20rpx;
  218. margin-bottom: 20rpx;
  219. height: 140px;
  220. }
  221. .imglist_left {
  222. width: 50%;
  223. position: relative;
  224. image {
  225. position: absolute;
  226. top: 0;
  227. left: 0;
  228. width: 100%;
  229. height: 280rpx;
  230. }
  231. }
  232. .imglist_right {
  233. margin-left: 40rpx;
  234. padding: 10rpx 0;
  235. .icon_box {
  236. margin-bottom: 12rpx;
  237. font-size: 24rpx;
  238. .iconfont {
  239. margin-right: 20rpx;
  240. color: #56C877;
  241. font-size: 32rpx;
  242. }
  243. }
  244. p:last-child {
  245. margin-bottom: 0;
  246. }
  247. }
  248. }
  249. .top {
  250. position: fixed;
  251. right: 30px;
  252. bottom: 100px;
  253. z-index: 100;
  254. image {
  255. width: 100rpx;
  256. height: 100rpx;
  257. }
  258. }
  259. </style>