dgpImagelist.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. <template>
  2. <view>
  3. <view class="" style="position: relative; top: 5px">
  4. <!-- <view style="position: fixed;z-index: 100;">
  5. <uni-nav-bar @clickLeft="clickLeft" left-icon="back" title="查看图片"></uni-nav-bar>
  6. </view> -->
  7. <p class="tishi" v-if="tishi">暂无数据</p>
  8. <view style="position: fixed; z-index: 100;">
  9. <view class="tab-box">
  10. <u-tabs :list="equipArr" :current="active" active-color="#14A478" @change="tabClick"></u-tabs>
  11. </view>
  12. <view class="selecttimes" @click="tiemshow = !tiemshow">
  13. <view class="timesbox">
  14. <image
  15. :src="
  16. $imageURL+ '/bigdata_app' +
  17. '/image/prevention/1acfe2751c01d3786cdc49b83d7e505.png'
  18. "
  19. mode=""
  20. ></image>
  21. <p>{{ timetab(timestate) }}</p>
  22. <p class="or">~</p>
  23. <p>{{ timetab(timeend) }}</p>
  24. <u-icon name="rili" custom-prefix="custom-icon" class="icon"></u-icon>
  25. </view>
  26. <u-calendar
  27. v-model="tiemshow"
  28. mode="range"
  29. @change="tiemchange"
  30. ></u-calendar>
  31. </view>
  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.photo" mode="" @click="examine(item.photo)"></image>
  49. </view>
  50. <view class="imglist_right">
  51. <view class="icon_box" @click="delimg(item.photo_id)">
  52. <i class="yficonfont icon-shanchu"></i>
  53. </view>
  54. <p>设备名称:{{ item.device_name }}</p>
  55. <p>所属场景:{{ item.index_name }}</p>
  56. <p>类型:{{ item.index_type }}</p>
  57. <p>指数:{{ item.index_value }}</p>
  58. <p >{{ item.addtime | timeFormat() }}</p>
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. <view class="top" v-if="isTop" @click="top">
  64. <image
  65. :src="
  66. $imageURL+ '/bigdata_app' +
  67. '/image/6209a98f0cb3b5086f2ca36152c9269.png'
  68. "
  69. mode=""
  70. ></image>
  71. </view>
  72. </view>
  73. </template>
  74. <script>
  75. export default {
  76. data() {
  77. return {
  78. page: 1,
  79. imglists: [],
  80. tishi: true,
  81. d_id: '',
  82. timeend: '', //当前时间 也是搜索的结束时间
  83. timestate: '',
  84. timeshow: false,
  85. params: {
  86. year: true,
  87. month: true,
  88. day: true,
  89. hour: true,
  90. minute: true,
  91. second: false,
  92. },
  93. flag: 1,
  94. self: true,
  95. isTop: false,
  96. resultdata: {},
  97. titletext: ['24小时', '近一个月', '近半年', '近一年'],
  98. titleidnex: 0,
  99. tiemshow: false, //时间选择器
  100. disable: '',
  101. device_type: '',
  102. myuid: '',
  103. active:0,
  104. equipArr:[
  105. { name: '全部', value: '全部' },
  106. { name: 'NDVI(归一化差值植被指数)', value: 'NDVI' },
  107. { name: 'GNDVI(绿度归一化差值植被指数)', value: 'GNDVI' },
  108. { name: 'OSAVI(优化土壤调节植被指数)', value: 'OSAVI' },
  109. { name: 'LCI(叶叶绿素指数)', value: 'LCI' },
  110. { name: 'NDRE(红边归一化差值植被指数)', value: 'NDRE' }
  111. ],
  112. device_type:''
  113. };
  114. },
  115. methods: {
  116. examine(url) {
  117. var imgarr =[]
  118. imgarr.push(url)
  119. console.log(imgarr)
  120. uni.previewImage({
  121. urls: imgarr
  122. });
  123. },
  124. tabClick(index) {
  125. this.page = 1
  126. this.imglists = []
  127. this.active = index;
  128. this.device_type = this.equipArr[index].value
  129. if (this.timestate != '') {
  130. this.timestate = parseInt(this.timestate);
  131. }
  132. if (this.timeend != '') {
  133. this.timeend = parseInt(this.timeend);
  134. }
  135. this.imglistdata(this.timestate, this.timeend);
  136. },
  137. async imglistdata(time_begin, time_end) {
  138. //获取图片列表
  139. const res = await this.$myRequest({
  140. url: '/api/api_gateway?method=camera.camera_manage.multi_camera_photo',
  141. data: {
  142. device_id: this.device_id,
  143. page: this.page,
  144. page_size: 8,
  145. start: time_begin, //开始时间
  146. end: time_end, //结束时间
  147. index_type: this.device_type === '全部' ? '' : this.device_type
  148. },
  149. });
  150. this.imglists = this.imglists.concat(res.data);
  151. console.log(this.imglists);
  152. if (this.imglists.length == 0) {
  153. this.tishi = true;
  154. } else {
  155. this.tishi = false;
  156. }
  157. },
  158. //forecast.forecast_system.equip_photo_del
  159. async del(id) {
  160. //删除图片
  161. const res = await this.$myRequest({
  162. url: '/api/api_gateway?method=camera.camera_manage.multi_camera_photo_delete',
  163. data: {
  164. // device_id: this.device_id,
  165. photo_id: id,
  166. },
  167. });
  168. if (res) {
  169. uni.showToast({
  170. title: '删除成功!',
  171. duration: 2000,
  172. });
  173. this.page = 1;
  174. this.imglists = [];
  175. if (this.timestate != '') {
  176. this.timestate = parseInt(this.timestate);
  177. }
  178. if (this.timeend != '') {
  179. this.timeend = parseInt(this.timeend);
  180. }
  181. this.imglistdata(this.timestate, this.timeend);
  182. } else {
  183. uni.showToast({
  184. title: '删除失败!',
  185. duration: 2000,
  186. icon: 'none',
  187. });
  188. }
  189. },
  190. //forecast.forecast_system.equip_photo_species pest_list
  191. //forecast.forecast_system.equip_photo_species统计
  192. //forecast.send_control.admin_device_control 拍照
  193. clickLeft() {
  194. uni.navigateBack({
  195. delta: 1,
  196. });
  197. },
  198. delimg(id) {
  199. //删除图片
  200. uni.showModal({
  201. title: '提示',
  202. content: '是否删除此图片?',
  203. success: (res) => {
  204. if (res.confirm) {
  205. this.del(id);
  206. console.log('用户点击确定');
  207. } else if (res.cancel) {
  208. console.log('用户点击取消');
  209. }
  210. },
  211. });
  212. },
  213. top() {
  214. uni.pageScrollTo({
  215. scrollTop: 0,
  216. duration: 500,
  217. });
  218. },
  219. tiemchange(e) {
  220. this.imglists = [];
  221. this.page = 1;
  222. console.log(e);
  223. this.timestate = +new Date(e.startDate) / 1000 - 8 * 60 * 60;
  224. this.timeend = +new Date(e.endDate) / 1000 + 16 * 60 * 60;
  225. this.imglistdata(parseInt(this.timestate), parseInt(this.timeend));
  226. },
  227. timetab(e) {
  228. if (!e) return '请选择';
  229. e = new Date(e * 1000);
  230. var year = e.getFullYear();
  231. var month =
  232. e.getMonth() + 1 < 10 ? '0' + (e.getMonth() + 1) : e.getMonth() + 1;
  233. var day = e.getDate() < 10 ? '0' + e.getDate() : e.getDate();
  234. var time = year + '/' + month + '/' + day;
  235. return time;
  236. },
  237. },
  238. onLoad(option) {
  239. uni.getStorage({
  240. key: 'myuid',
  241. success: (res) => {
  242. this.myuid = res.data;
  243. console.log(this.myuid);
  244. },
  245. });
  246. // this.timeend = +new Date() / 1000
  247. // this.timestate = this.timeend - 60 * 60 * 24
  248. console.log(option);
  249. this.device_id = option.id;
  250. console.log(this.timestate);
  251. this.imglistdata('', '');
  252. },
  253. onShow() {},
  254. onReachBottom() {
  255. this.page++;
  256. console.log(this.timestate);
  257. if (this.timestate != '') {
  258. this.timestate = parseInt(this.timestate);
  259. }
  260. if (this.timeend != '') {
  261. this.timeend = parseInt(this.timeend);
  262. }
  263. this.imglistdata(this.timestate, this.timeend);
  264. },
  265. onPageScroll(e) {
  266. //nvue暂不支持滚动监听,可用bindingx代替
  267. if (e.scrollTop > 200) {
  268. //距离大于200时显示
  269. this.isTop = true;
  270. } else {
  271. //距离小于200时隐藏
  272. this.isTop = false;
  273. }
  274. },
  275. };
  276. </script>
  277. <style lang="scss">
  278. .tishi {
  279. position: absolute;
  280. top: 45%;
  281. width: 95%;
  282. left: 2.5%;
  283. text-align: center;
  284. font-size: 40rpx;
  285. }
  286. .selecttimes {
  287. width: 100%;
  288. // position: fixed;
  289. // top: 0;
  290. // left: 0;
  291. z-index: 100;
  292. background-color: #fff;
  293. padding: 10rpx 20rpx;
  294. box-sizing: border-box;
  295. .timesbox {
  296. display: flex;
  297. width:100%;
  298. margin: 0 auto;
  299. justify-content: space-around;
  300. box-shadow: 0 0 10rpx #bcb9ca;
  301. padding: 10rpx 20rpx;
  302. box-sizing: border-box;
  303. image {
  304. width: 30rpx;
  305. height: 30rpx;
  306. margin-top: 6rpx;
  307. }
  308. .icon {
  309. color: #949494;
  310. text-align: right;
  311. margin-left: 30rpx;
  312. }
  313. }
  314. ::v-deep .u-calendar__action {
  315. display: flex;
  316. justify-content: space-around;
  317. .u-calendar__action__text {
  318. line-height: 25px;
  319. }
  320. }
  321. }
  322. .timeshow {
  323. width: 96%;
  324. height: 50rpx;
  325. background-color: #ffffff;
  326. position: fixed;
  327. top: 10px;
  328. left: 2.5%;
  329. display: flex;
  330. z-index: 100;
  331. padding-top: 10px;
  332. .shuju_one_title {
  333. width: 70%;
  334. margin: 0 auto;
  335. display: flex;
  336. .tltle_text {
  337. width: 25%;
  338. border: 2rpx solid #b2b2b2;
  339. color: #b2b2b2;
  340. text-align: center;
  341. font-size: 24rpx;
  342. height: 50rpx;
  343. line-height: 50rpx;
  344. }
  345. .title_text_color {
  346. width: 25%;
  347. border: 2rpx solid #28ae4f;
  348. color: #28ae4f;
  349. text-align: center;
  350. font-size: 24rpx;
  351. height: 50rpx;
  352. line-height: 50rpx;
  353. }
  354. }
  355. .timeshow_tate,
  356. .timeshow_end {
  357. height: 50rpx;
  358. width: 45%;
  359. line-height: 50rpx;
  360. text-align: center;
  361. margin-right: 10rpx;
  362. background-color: #56c877;
  363. color: #ffffff;
  364. }
  365. }
  366. .imglist {
  367. position: absolute;
  368. top: 95px;
  369. width: 100%;
  370. padding: 0 20rpx;
  371. box-sizing: border-box;
  372. .imglist_box {
  373. display: flex;
  374. box-shadow: 0 0 10rpx #bcb9ca;
  375. padding: 20rpx;
  376. margin-bottom: 20rpx;
  377. height: 140px;
  378. }
  379. .imglist_left {
  380. width: 50%;
  381. position: relative;
  382. image {
  383. position: absolute;
  384. top: 0;
  385. left: 0;
  386. width: 100%;
  387. height: 100%;
  388. }
  389. }
  390. .imglist_right {
  391. margin-left: 40rpx;
  392. padding-top: 26rpx;
  393. position: relative;
  394. p{
  395. line-height: 24px;
  396. }
  397. .icon_box {
  398. position: absolute;
  399. top: -12rpx;
  400. right: -42rpx;
  401. // margin-bottom: 12rpx;
  402. font-size: 24rpx;
  403. .yficonfont {
  404. margin-right: 20rpx;
  405. color: #ff5951;
  406. font-size: 32rpx;
  407. }
  408. }
  409. p:last-child {
  410. margin-bottom: 0;
  411. }
  412. }
  413. }
  414. .top {
  415. position: fixed;
  416. right: 30px;
  417. bottom: 100px;
  418. z-index: 100;
  419. image {
  420. width: 100rpx;
  421. height: 100rpx;
  422. }
  423. }
  424. .tab-box {
  425. font-size: 30rpx;
  426. line-height: 80rpx;
  427. background-color: #ffffff;
  428. width: 100vw;
  429. z-index: 2;
  430. margin-top: -10rpx;
  431. }
  432. </style>