photolist.vue 6.7 KB

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