imgList.vue 6.8 KB

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