photolist.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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="$imageURL+'/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="$imageURL+'/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="$imageURL+'/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: "xy_three",
  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 = [...this.imglists,...res.data]
  101. if(this.imglists.length == 0) {
  102. uni.showToast({
  103. title: '数据为空',
  104. duration: 2000,
  105. icon:'none'
  106. });
  107. }
  108. },
  109. top() {
  110. uni.pageScrollTo({
  111. scrollTop: 0,
  112. duration: 500
  113. })
  114. },
  115. tiemchange(e){
  116. // console.log(e)
  117. this.imglists = []
  118. this.page = 1
  119. console.log(e)
  120. this.timestate = +new Date(e.startDate) / 1000 - 8 * 60 * 60
  121. this.timeend = +new Date(e.endDate) / 1000 + 16 * 60 * 60
  122. this.getimglist()
  123. },
  124. async takephoto() { //拍照
  125. const res = await this.$myRequest({
  126. url: '/api/api_gateway?method=forecast.send_control.admin_device_control',
  127. data: {
  128. device_type_id: 8,
  129. d_id: this.d_id,
  130. cmd: "takephoto"
  131. }
  132. })
  133. console.log(res)
  134. if (res == true) {
  135. uni.showToast({
  136. title: '指令下发成功!',
  137. duration: 2000
  138. });
  139. var that = this
  140. setTimeout(() => {
  141. that.getimglist()
  142. }, 1000)
  143. } else {
  144. uni.showToast({
  145. title: '指令下发失败!',
  146. duration: 2000,
  147. icon: "none"
  148. });
  149. }
  150. },
  151. },
  152. onLoad(option) {
  153. this.d_id = option.d_id
  154. this.device_id = option.device_id
  155. this.timeend = +new Date() / 1000
  156. this.timestate = this.timeend - 60 * 60 * 24
  157. this.getimglist()
  158. },
  159. onReachBottom() {
  160. this.page++
  161. this.getimglist()
  162. },
  163. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  164. if (e.scrollTop > 200) { //距离大于200时显示
  165. this.isTop = true
  166. } else { //距离小于200时隐藏
  167. this.isTop = false
  168. }
  169. }
  170. }
  171. </script>
  172. <style lang="scss">
  173. .tishi {
  174. position: absolute;
  175. top: 104px;
  176. width: 95%;
  177. left: 2.5%;
  178. text-align: center;
  179. font-size: 40rpx;
  180. }
  181. .selecttimes {
  182. width: 100%;
  183. position: fixed;
  184. top: 85px;
  185. left: 0;
  186. z-index: 100;
  187. background-color: #fff;
  188. padding-top: 30rpx;
  189. .timesbox {
  190. display: flex;
  191. width: 95%;
  192. margin: 0 auto;
  193. justify-content: space-around;
  194. box-shadow: 0 0 10rpx #bcb9ca;
  195. padding: 10rpx 20rpx;
  196. box-sizing: border-box;
  197. image {
  198. width: 30rpx;
  199. height: 30rpx;
  200. margin-top: 6rpx;
  201. }
  202. .icon {
  203. color: #949494;
  204. text-align: right;
  205. margin-left: 30rpx;
  206. }
  207. }
  208. /deep/.u-calendar__action {
  209. display: flex;
  210. justify-content: space-around;
  211. .u-calendar__action__text {
  212. line-height: 25px;
  213. }
  214. }
  215. }
  216. .imglist {
  217. position: absolute;
  218. top: 100px;
  219. width: 95%;
  220. left: 2.5%;
  221. .imglist_box {
  222. display: flex;
  223. box-shadow: 0 0 10rpx #bcb9ca;
  224. padding: 20rpx;
  225. margin-bottom: 20rpx;
  226. height: 140px;
  227. }
  228. .imglist_left {
  229. width: 50%;
  230. position: relative;
  231. image {
  232. position: absolute;
  233. top: 0;
  234. left: 0;
  235. width: 100%;
  236. height: 280rpx;
  237. }
  238. }
  239. .imglist_right {
  240. margin-left: 40rpx;
  241. padding: 10rpx 0;
  242. .icon_box {
  243. margin-bottom: 12rpx;
  244. font-size: 24rpx;
  245. .iconfont {
  246. margin-right: 20rpx;
  247. color: #56C877;
  248. font-size: 32rpx;
  249. }
  250. }
  251. p:last-child {
  252. margin-bottom: 0;
  253. }
  254. }
  255. }
  256. .top {
  257. position: fixed;
  258. right: 30px;
  259. bottom: 100px;
  260. z-index: 100;
  261. image {
  262. width: 100rpx;
  263. height: 100rpx;
  264. }
  265. }
  266. </style>