photolist.vue 6.8 KB

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