imgList.vue 6.7 KB

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