imagelist.vue 9.1 KB

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