imagelist.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  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 @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(index)"></image>
  45. </view>
  46. <view class="imglist_right">
  47. <view class="icon_box" @click="delimg(item.photo_id)">
  48. <p class="iconfont 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. //forecast.forecast_system.equip_photofo
  99. async imglistdata(time_begin, time_end) {
  100. //获取图片列表
  101. const res = await this.$myRequest({
  102. url: '/api/api_gateway?method=camera.camera_manage.camera_photo',
  103. data: {
  104. device_id: this.device_id,
  105. page: this.page,
  106. page_size: 8,
  107. start_time: time_begin, //开始时间
  108. end_time: time_end, //结束时间
  109. },
  110. });
  111. this.imglists = this.imglists.concat(res.data);
  112. console.log(this.imglists);
  113. if (this.imglists.length == 0) {
  114. this.tishi = true;
  115. } else {
  116. this.tishi = false;
  117. }
  118. },
  119. //forecast.forecast_system.equip_photo_del
  120. async del(id) {
  121. //删除图片
  122. var arr = id;
  123. const res = await this.$myRequest({
  124. url: '/api/api_gateway?method=camera.camera_manage.del_camera_photo',
  125. data: {
  126. // device_id: this.device_id,
  127. photo_id_list: JSON.stringify(arr),
  128. },
  129. });
  130. if (res) {
  131. uni.showToast({
  132. title: '删除成功!',
  133. duration: 2000,
  134. });
  135. this.page = 1;
  136. this.imglists = [];
  137. if (this.timestate != '') {
  138. this.timestate = parseInt(this.timestate);
  139. }
  140. if (this.timeend != '') {
  141. this.timeend = parseInt(this.timeend);
  142. }
  143. this.imglistdata(this.timestate, this.timeend);
  144. } else {
  145. uni.showToast({
  146. title: '删除失败!',
  147. duration: 2000,
  148. icon: 'none',
  149. });
  150. }
  151. },
  152. //forecast.forecast_system.equip_photo_species pest_list
  153. //forecast.forecast_system.equip_photo_species统计
  154. //forecast.send_control.admin_device_control 拍照
  155. clickLeft() {
  156. uni.navigateBack({
  157. delta: 1,
  158. });
  159. },
  160. delimg(id) {
  161. //删除图片
  162. uni.showModal({
  163. title: '提示',
  164. content: '是否删除此图片?',
  165. success: (res) => {
  166. if (res.confirm) {
  167. this.del(id);
  168. console.log('用户点击确定');
  169. } else if (res.cancel) {
  170. console.log('用户点击取消');
  171. }
  172. },
  173. });
  174. },
  175. top() {
  176. uni.pageScrollTo({
  177. scrollTop: 0,
  178. duration: 500,
  179. });
  180. },
  181. tiemchange(e) {
  182. this.imglists = [];
  183. this.page = 1;
  184. console.log(e);
  185. this.timestate = +new Date(e.startDate) / 1000 - 8 * 60 * 60;
  186. this.timeend = +new Date(e.endDate) / 1000 + 16 * 60 * 60;
  187. this.imglistdata(parseInt(this.timestate), parseInt(this.timeend));
  188. },
  189. timetab(e) {
  190. if (!e) return '请选择';
  191. e = new Date(e * 1000);
  192. var year = e.getFullYear();
  193. var month =
  194. e.getMonth() + 1 < 10 ? '0' + (e.getMonth() + 1) : e.getMonth() + 1;
  195. var day = e.getDate() < 10 ? '0' + e.getDate() : e.getDate();
  196. var time = year + '/' + month + '/' + day;
  197. return time;
  198. },
  199. },
  200. onLoad(option) {
  201. uni.getStorage({
  202. key: 'myuid',
  203. success: (res) => {
  204. this.myuid = res.data;
  205. console.log(this.myuid);
  206. },
  207. });
  208. // this.timeend = +new Date() / 1000
  209. // this.timestate = this.timeend - 60 * 60 * 24
  210. console.log(option);
  211. this.device_id = option.id;
  212. console.log(this.timestate);
  213. this.imglistdata('', '');
  214. },
  215. onShow() {},
  216. onReachBottom() {
  217. this.page++;
  218. console.log(this.timestate);
  219. if (this.timestate != '') {
  220. this.timestate = parseInt(this.timestate);
  221. }
  222. if (this.timeend != '') {
  223. this.timeend = parseInt(this.timeend);
  224. }
  225. this.imglistdata(this.timestate, this.timeend);
  226. },
  227. onPageScroll(e) {
  228. //nvue暂不支持滚动监听,可用bindingx代替
  229. if (e.scrollTop > 200) {
  230. //距离大于200时显示
  231. this.isTop = true;
  232. } else {
  233. //距离小于200时隐藏
  234. this.isTop = false;
  235. }
  236. },
  237. };
  238. </script>
  239. <style lang="scss">
  240. .tishi {
  241. position: absolute;
  242. top: 40px;
  243. width: 95%;
  244. left: 2.5%;
  245. text-align: center;
  246. font-size: 40rpx;
  247. }
  248. .selecttimes {
  249. width: 100%;
  250. position: fixed;
  251. top: 0;
  252. left: 0;
  253. z-index: 100;
  254. background-color: #fff;
  255. padding-top: 30rpx;
  256. .timesbox {
  257. display: flex;
  258. width: 95%;
  259. margin: 0 auto;
  260. justify-content: space-around;
  261. box-shadow: 0 0 10rpx #bcb9ca;
  262. padding: 10rpx 20rpx;
  263. box-sizing: border-box;
  264. image {
  265. width: 30rpx;
  266. height: 30rpx;
  267. margin-top: 6rpx;
  268. }
  269. .icon {
  270. color: #949494;
  271. text-align: right;
  272. margin-left: 30rpx;
  273. }
  274. }
  275. ::v-deep .u-calendar__action {
  276. display: flex;
  277. justify-content: space-around;
  278. .u-calendar__action__text {
  279. line-height: 25px;
  280. }
  281. }
  282. }
  283. .timeshow {
  284. width: 96%;
  285. height: 50rpx;
  286. background-color: #ffffff;
  287. position: fixed;
  288. top: 10px;
  289. left: 2.5%;
  290. display: flex;
  291. z-index: 100;
  292. padding-top: 10px;
  293. .shuju_one_title {
  294. width: 70%;
  295. margin: 0 auto;
  296. display: flex;
  297. .tltle_text {
  298. width: 25%;
  299. border: 2rpx solid #b2b2b2;
  300. color: #b2b2b2;
  301. text-align: center;
  302. font-size: 24rpx;
  303. height: 50rpx;
  304. line-height: 50rpx;
  305. }
  306. .title_text_color {
  307. width: 25%;
  308. border: 2rpx solid #28ae4f;
  309. color: #28ae4f;
  310. text-align: center;
  311. font-size: 24rpx;
  312. height: 50rpx;
  313. line-height: 50rpx;
  314. }
  315. }
  316. .timeshow_tate,
  317. .timeshow_end {
  318. height: 50rpx;
  319. width: 45%;
  320. line-height: 50rpx;
  321. text-align: center;
  322. margin-right: 10rpx;
  323. background-color: #56c877;
  324. color: #ffffff;
  325. }
  326. }
  327. .imglist {
  328. position: absolute;
  329. top: 0;
  330. width: 95%;
  331. left: 2.5%;
  332. .imglist_box {
  333. display: flex;
  334. box-shadow: 0 0 10rpx #bcb9ca;
  335. padding: 20rpx;
  336. margin-bottom: 20rpx;
  337. height: 140px;
  338. }
  339. .imglist_left {
  340. width: 50%;
  341. position: relative;
  342. image {
  343. position: absolute;
  344. top: 0;
  345. left: 0;
  346. width: 100%;
  347. height: 280rpx;
  348. }
  349. }
  350. .imglist_right {
  351. margin-left: 40rpx;
  352. padding: 10rpx 0;
  353. .icon_box {
  354. margin-bottom: 12rpx;
  355. font-size: 24rpx;
  356. .iconfont {
  357. margin-right: 20rpx;
  358. color: #56c877;
  359. font-size: 32rpx;
  360. }
  361. }
  362. p:last-child {
  363. margin-bottom: 0;
  364. }
  365. }
  366. }
  367. .top {
  368. position: fixed;
  369. right: 30px;
  370. bottom: 100px;
  371. z-index: 100;
  372. image {
  373. width: 100rpx;
  374. height: 100rpx;
  375. }
  376. }
  377. </style>