photolist.vue 6.6 KB

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