imagelist.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  1. <template>
  2. <view>
  3. <!-- <view class="status_bar"></view> -->
  4. <view class="" style="position: relative; top: 5px">
  5. <!-- <view style="position: fixed;z-index: 100;">
  6. <uni-nav-bar @clickLeft="clickLeft" left-icon="back" title="查看图片"></uni-nav-bar>
  7. </view> -->
  8. <p class="tishi" v-if="tishi">暂无数据</p>
  9. <view class="selecttimes" @click="tiemshow = !tiemshow">
  10. <view class="timesbox">
  11. <image
  12. :src="
  13. $imageURL+ '/bigdata_app' +
  14. '/image/prevention/1acfe2751c01d3786cdc49b83d7e505.png'
  15. "
  16. mode=""
  17. ></image>
  18. <p>{{ timetab(timestate) }}</p>
  19. <p class="or">~</p>
  20. <p>{{ timetab(timeend) }}</p>
  21. <u-icon name="rili" custom-prefix="custom-icon" class="icon"></u-icon>
  22. </view>
  23. <u-calendar
  24. v-model="tiemshow"
  25. mode="range"
  26. @change="tiemchange"
  27. ></u-calendar>
  28. </view>
  29. <view class="imglist">
  30. <view
  31. class="imglist_box"
  32. v-for="(item, index) in imglists"
  33. :key="index"
  34. >
  35. <view class="imglist_left">
  36. <image
  37. :src="
  38. $imageURL+ '/bigdata_app' +
  39. '/image/cb/jiazai.ui.gif'
  40. "
  41. mode=""
  42. >
  43. </image>
  44. <image :src="item.addr" mode="" @click="examine(item.addr)"></image>
  45. </view>
  46. <view class="imglist_right">
  47. <view class="icon_box" @click="delimg(item.photo_id)">
  48. <p class="yficonfont icon-shanchu">删除</p>
  49. </view>
  50. <p style="color: #06b535">{{ item.addtime | timeFormat() }}</p>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. <view class="top" v-if="isTop" @click="top">
  56. <image
  57. :src="
  58. $imageURL+ '/bigdata_app' +
  59. '/image/6209a98f0cb3b5086f2ca36152c9269.png'
  60. "
  61. mode=""
  62. ></image>
  63. </view>
  64. </view>
  65. </template>
  66. <script>
  67. export default {
  68. data() {
  69. return {
  70. page: 1,
  71. imglists: [],
  72. tishi: true,
  73. d_id: '',
  74. timeend: '', //当前时间 也是搜索的结束时间
  75. timestate: '',
  76. timeshow: false,
  77. params: {
  78. year: true,
  79. month: true,
  80. day: true,
  81. hour: true,
  82. minute: true,
  83. second: false,
  84. },
  85. flag: 1,
  86. self: true,
  87. isTop: false,
  88. resultdata: {},
  89. titletext: ['24小时', '近一个月', '近半年', '近一年'],
  90. titleidnex: 0,
  91. tiemshow: false, //时间选择器
  92. disable: '',
  93. device_type: '',
  94. myuid: '',
  95. };
  96. },
  97. methods: {
  98. examine(url) {
  99. var imgarr =[]
  100. imgarr.push(url)
  101. console.log(imgarr)
  102. uni.previewImage({
  103. urls: imgarr
  104. });
  105. },
  106. //forecast.forecast_system.equip_photofo
  107. async imglistdata(time_begin, time_end) {
  108. //获取图片列表
  109. const res = await this.$myRequest({
  110. url: '/api/api_gateway?method=camera.camera_manage.camera_photo',
  111. data: {
  112. device_id: this.device_id,
  113. page: this.page,
  114. page_size: 8,
  115. start_time: time_begin, //开始时间
  116. end_time: time_end, //结束时间
  117. },
  118. });
  119. this.imglists = this.imglists.concat(res.data);
  120. console.log(this.imglists);
  121. if (this.imglists.length == 0) {
  122. this.tishi = true;
  123. } else {
  124. this.tishi = false;
  125. }
  126. },
  127. //forecast.forecast_system.equip_photo_del
  128. async del(id) {
  129. //删除图片
  130. var arr = id;
  131. const res = await this.$myRequest({
  132. url: '/api/api_gateway?method=camera.camera_manage.del_camera_photo',
  133. data: {
  134. // device_id: this.device_id,
  135. photo_id_list: JSON.stringify(arr),
  136. },
  137. });
  138. if (res) {
  139. uni.showToast({
  140. title: '删除成功!',
  141. duration: 2000,
  142. });
  143. this.page = 1;
  144. this.imglists = [];
  145. if (this.timestate != '') {
  146. this.timestate = parseInt(this.timestate);
  147. }
  148. if (this.timeend != '') {
  149. this.timeend = parseInt(this.timeend);
  150. }
  151. this.imglistdata(this.timestate, this.timeend);
  152. } else {
  153. uni.showToast({
  154. title: '删除失败!',
  155. duration: 2000,
  156. icon: 'none',
  157. });
  158. }
  159. },
  160. //forecast.forecast_system.equip_photo_species pest_list
  161. //forecast.forecast_system.equip_photo_species统计
  162. //forecast.send_control.admin_device_control 拍照
  163. clickLeft() {
  164. uni.navigateBack({
  165. delta: 1,
  166. });
  167. },
  168. delimg(id) {
  169. //删除图片
  170. uni.showModal({
  171. title: '提示',
  172. content: '是否删除此图片?',
  173. success: (res) => {
  174. if (res.confirm) {
  175. this.del(id);
  176. console.log('用户点击确定');
  177. } else if (res.cancel) {
  178. console.log('用户点击取消');
  179. }
  180. },
  181. });
  182. },
  183. top() {
  184. uni.pageScrollTo({
  185. scrollTop: 0,
  186. duration: 500,
  187. });
  188. },
  189. tiemchange(e) {
  190. this.imglists = [];
  191. this.page = 1;
  192. console.log(e);
  193. this.timestate = +new Date(e.startDate) / 1000 - 8 * 60 * 60;
  194. this.timeend = +new Date(e.endDate) / 1000 + 16 * 60 * 60;
  195. this.imglistdata(parseInt(this.timestate), parseInt(this.timeend));
  196. },
  197. timetab(e) {
  198. if (!e) return '请选择';
  199. e = new Date(e * 1000);
  200. var year = e.getFullYear();
  201. var month =
  202. e.getMonth() + 1 < 10 ? '0' + (e.getMonth() + 1) : e.getMonth() + 1;
  203. var day = e.getDate() < 10 ? '0' + e.getDate() : e.getDate();
  204. var time = year + '/' + month + '/' + day;
  205. return time;
  206. },
  207. },
  208. onLoad(option) {
  209. uni.getStorage({
  210. key: 'myuid',
  211. success: (res) => {
  212. this.myuid = res.data;
  213. console.log(this.myuid);
  214. },
  215. });
  216. // this.timeend = +new Date() / 1000
  217. // this.timestate = this.timeend - 60 * 60 * 24
  218. console.log(option);
  219. this.device_id = option.id;
  220. console.log(this.timestate);
  221. this.imglistdata('', '');
  222. },
  223. onShow() {},
  224. onReachBottom() {
  225. this.page++;
  226. console.log(this.timestate);
  227. if (this.timestate != '') {
  228. this.timestate = parseInt(this.timestate);
  229. }
  230. if (this.timeend != '') {
  231. this.timeend = parseInt(this.timeend);
  232. }
  233. this.imglistdata(this.timestate, this.timeend);
  234. },
  235. onPageScroll(e) {
  236. //nvue暂不支持滚动监听,可用bindingx代替
  237. if (e.scrollTop > 200) {
  238. //距离大于200时显示
  239. this.isTop = true;
  240. } else {
  241. //距离小于200时隐藏
  242. this.isTop = false;
  243. }
  244. },
  245. };
  246. </script>
  247. <style lang="scss">
  248. .tishi {
  249. position: absolute;
  250. top: 40px;
  251. width: 95%;
  252. left: 2.5%;
  253. text-align: center;
  254. font-size: 40rpx;
  255. }
  256. .selecttimes {
  257. width: 100%;
  258. // position: fixed;
  259. // top: 0;
  260. // left: 0;
  261. z-index: 100;
  262. background-color: #fff;
  263. padding: 10rpx 20rpx;
  264. box-sizing: border-box;
  265. .timesbox {
  266. display: flex;
  267. width:100%;
  268. margin: 0 auto;
  269. justify-content: space-around;
  270. box-shadow: 0 0 10rpx #bcb9ca;
  271. padding: 10rpx 20rpx;
  272. box-sizing: border-box;
  273. image {
  274. width: 30rpx;
  275. height: 30rpx;
  276. margin-top: 6rpx;
  277. }
  278. .icon {
  279. color: #949494;
  280. text-align: right;
  281. margin-left: 30rpx;
  282. }
  283. }
  284. ::v-deep .u-calendar__action {
  285. display: flex;
  286. justify-content: space-around;
  287. .u-calendar__action__text {
  288. line-height: 25px;
  289. }
  290. }
  291. }
  292. .timeshow {
  293. width: 96%;
  294. height: 50rpx;
  295. background-color: #ffffff;
  296. position: fixed;
  297. top: 10px;
  298. left: 2.5%;
  299. display: flex;
  300. z-index: 100;
  301. padding-top: 10px;
  302. .shuju_one_title {
  303. width: 70%;
  304. margin: 0 auto;
  305. display: flex;
  306. .tltle_text {
  307. width: 25%;
  308. border: 2rpx solid #b2b2b2;
  309. color: #b2b2b2;
  310. text-align: center;
  311. font-size: 24rpx;
  312. height: 50rpx;
  313. line-height: 50rpx;
  314. }
  315. .title_text_color {
  316. width: 25%;
  317. border: 2rpx solid #28ae4f;
  318. color: #28ae4f;
  319. text-align: center;
  320. font-size: 24rpx;
  321. height: 50rpx;
  322. line-height: 50rpx;
  323. }
  324. }
  325. .timeshow_tate,
  326. .timeshow_end {
  327. height: 50rpx;
  328. width: 45%;
  329. line-height: 50rpx;
  330. text-align: center;
  331. margin-right: 10rpx;
  332. background-color: #56c877;
  333. color: #ffffff;
  334. }
  335. }
  336. .imglist {
  337. // position: absolute;
  338. // top: 0;
  339. // width: 95%;
  340. // left: 2.5%;
  341. padding: 0 20rpx;
  342. margin-top: 10rpx;
  343. .imglist_box {
  344. display: flex;
  345. box-shadow: 0 0 10rpx #bcb9ca;
  346. padding: 20rpx;
  347. margin-bottom: 20rpx;
  348. height: 140px;
  349. }
  350. .imglist_left {
  351. width: 50%;
  352. position: relative;
  353. image {
  354. position: absolute;
  355. top: 0;
  356. left: 0;
  357. width: 100%;
  358. height: 100%;
  359. }
  360. }
  361. .imglist_right {
  362. margin-left: 40rpx;
  363. padding: 10rpx 0;
  364. .icon_box {
  365. margin-bottom: 12rpx;
  366. font-size: 24rpx;
  367. .iconfont {
  368. margin-right: 20rpx;
  369. color: #56c877;
  370. font-size: 32rpx;
  371. }
  372. }
  373. p:last-child {
  374. margin-bottom: 0;
  375. }
  376. }
  377. }
  378. .top {
  379. position: fixed;
  380. right: 30px;
  381. bottom: 100px;
  382. z-index: 100;
  383. image {
  384. width: 100rpx;
  385. height: 100rpx;
  386. }
  387. }
  388. </style>