imagelist.vue 8.1 KB

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