imagelist.vue 7.9 KB

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