imgList.vue 6.0 KB

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