photolist.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  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 +
  20. '/bigdata_app/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+
  62. '/bigdata_app/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: 'cbd_XCT',
  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 = res.data;
  125. },
  126. top() {
  127. uni.pageScrollTo({
  128. scrollTop: 0,
  129. duration: 500,
  130. });
  131. },
  132. tiemchange(e) {
  133. // console.log(e)
  134. this.imglists = [];
  135. this.page = 1;
  136. console.log(e);
  137. this.timestate = +new Date(e.startDate) / 1000 - 8 * 60 * 60;
  138. this.timeend = +new Date(e.endDate) / 1000 + 16 * 60 * 60;
  139. this.getimglist();
  140. },
  141. async takephoto() {
  142. //拍照
  143. const res = await this.$myRequest({
  144. url: '/api/api_gateway?method=forecast.send_control.admin_device_control',
  145. data: {
  146. device_type_id: 28,
  147. d_id: this.d_id,
  148. cmd: 'takephoto',
  149. },
  150. });
  151. console.log(res);
  152. if (res == true) {
  153. uni.showToast({
  154. title: '指令下发成功!',
  155. duration: 2000,
  156. });
  157. var that = this;
  158. setTimeout(() => {
  159. that.getimglist();
  160. }, 1000);
  161. } else {
  162. uni.showToast({
  163. title: '指令下发失败!',
  164. duration: 2000,
  165. icon: 'none',
  166. });
  167. }
  168. },
  169. },
  170. onLoad(option) {
  171. this.d_id = option.d_id;
  172. this.device_id = option.device_id;
  173. this.timeend = +new Date() / 1000;
  174. this.timestate = this.timeend - 60 * 60 * 24 * 7;
  175. this.getimglist();
  176. },
  177. onReachBottom() {
  178. this.page++;
  179. this.getimglist();
  180. },
  181. onPageScroll(e) {
  182. //nvue暂不支持滚动监听,可用bindingx代替
  183. if (e.scrollTop > 200) {
  184. //距离大于200时显示
  185. this.isTop = true;
  186. } else {
  187. //距离小于200时隐藏
  188. this.isTop = false;
  189. }
  190. },
  191. };
  192. </script>
  193. <style lang="scss">
  194. .tishi {
  195. position: absolute;
  196. top: 104px;
  197. width: 95%;
  198. left: 2.5%;
  199. text-align: center;
  200. font-size: 40rpx;
  201. }
  202. .selecttimes {
  203. width: 100%;
  204. position: fixed;
  205. top: 85px;
  206. left: 0;
  207. z-index: 100;
  208. background-color: #fff;
  209. padding-top: 30rpx;
  210. .timesbox {
  211. display: flex;
  212. width: 95%;
  213. margin: 0 auto;
  214. justify-content: space-around;
  215. box-shadow: 0 0 10rpx #bcb9ca;
  216. padding: 10rpx 20rpx;
  217. box-sizing: border-box;
  218. image {
  219. width: 30rpx;
  220. height: 30rpx;
  221. margin-top: 6rpx;
  222. }
  223. .icon {
  224. color: #949494;
  225. text-align: right;
  226. margin-left: 30rpx;
  227. }
  228. }
  229. ::v-deep .u-calendar__action {
  230. display: flex;
  231. justify-content: space-around;
  232. .u-calendar__action__text {
  233. line-height: 25px;
  234. }
  235. }
  236. }
  237. .imglist {
  238. position: absolute;
  239. top: 100px;
  240. width: 95%;
  241. left: 2.5%;
  242. .imglist_box {
  243. display: flex;
  244. box-shadow: 0 0 10rpx #bcb9ca;
  245. padding: 20rpx;
  246. margin-bottom: 20rpx;
  247. height: 140px;
  248. }
  249. .imglist_left {
  250. width: 50%;
  251. position: relative;
  252. image {
  253. position: absolute;
  254. top: 0;
  255. left: 0;
  256. width: 100%;
  257. height: 280rpx;
  258. }
  259. }
  260. .imglist_right {
  261. margin-left: 40rpx;
  262. padding: 10rpx 0;
  263. .icon_box {
  264. margin-bottom: 12rpx;
  265. font-size: 24rpx;
  266. .iconfont {
  267. margin-right: 20rpx;
  268. color: #56c877;
  269. font-size: 32rpx;
  270. }
  271. }
  272. p:last-child {
  273. margin-bottom: 0;
  274. }
  275. }
  276. }
  277. .top {
  278. position: fixed;
  279. right: 30px;
  280. bottom: 100px;
  281. z-index: 100;
  282. image {
  283. width: 100rpx;
  284. height: 100rpx;
  285. }
  286. }
  287. </style>