imagelist.vue 8.0 KB

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