imgpage.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  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
  7. @clickLeft="clickLeft"
  8. left-icon="back"
  9. title="查看图片"
  10. rightIcon="camera"
  11. @clickRight="clickRight"
  12. ></uni-nav-bar>
  13. </view>
  14. <p class="tishi" v-if="imglists.length == 0">暂无数据</p>
  15. <u-select
  16. v-model="modelPicker"
  17. mode="single-column"
  18. @confirm="confirmModel"
  19. v-if="device_type != 7"
  20. :default-value="[identify_model]"
  21. :list="modelList"
  22. ></u-select>
  23. <view
  24. class="schedule"
  25. @click="modelPicker = !modelPicker"
  26. v-if="device_type != 7"
  27. >
  28. <p class="schedule_value">{{ modelList[identify_model].label }}</p>
  29. <!-- {{titletext[indexone]}} -->
  30. <p class="schedule_icon">
  31. <u-icon name="arrow-down"></u-icon>
  32. </p>
  33. </view>
  34. <view
  35. :class="`selecttimes ${device_type == 7 ? 'bigSelect' : ''}`"
  36. @click="tiemshow = !tiemshow"
  37. >
  38. <view class="timesbox">
  39. <image
  40. :src="
  41. $imageURL +
  42. '/bigdata_app/image/prevention/1acfe2751c01d3786cdc49b83d7e505.png'
  43. "
  44. mode=""
  45. ></image>
  46. <p>{{ timetab(timestate) }}</p>
  47. <p class="or">~</p>
  48. <p>{{ timetab(timeend) }}</p>
  49. <u-icon name="rili" custom-prefix="custom-icon" class="icon"></u-icon>
  50. </view>
  51. <u-calendar
  52. v-model="tiemshow"
  53. mode="range"
  54. @change="tiemchange"
  55. ></u-calendar>
  56. </view>
  57. <view class="imglist">
  58. <view
  59. class="imglist_box"
  60. v-for="(item, index) in imglists"
  61. :key="index"
  62. >
  63. <view class="imglist_left">
  64. <image
  65. :src="
  66. $imageURL +
  67. '/bigdata_app/image/cb/jiazai.ui.gif'
  68. "
  69. mode=""
  70. >
  71. </image>
  72. <image :src="item.addr" mode="" @click="examine(index)"></image>
  73. </view>
  74. <view class="imglist_right">
  75. <view class="icon_box" @click="delimg(item.ids)">
  76. <p class="yficonfont icon-shanchu">删除</p>
  77. </view>
  78. <view
  79. class="icon_box"
  80. @click="shibie(item.ids, item.addr)"
  81. v-if="disable == 1 && device_type != 7"
  82. >
  83. <p class="yficonfont icon-shibie">识别</p>
  84. </view>
  85. <view class="icon_box" v-else-if="disable == 2 && device_type != 7">
  86. <p class="yficonfont icon-shibie">计数:{{ item.des_nums }}只</p>
  87. </view>
  88. <p style="color: #06b535">{{ item.addtime | timeFormat() }}</p>
  89. </view>
  90. </view>
  91. </view>
  92. </view>
  93. <view class="top" v-if="isTop" @click="top">
  94. <image
  95. :src="
  96. $imageURL +
  97. '/bigdata_app/image/6209a98f0cb3b5086f2ca36152c9269.png'
  98. "
  99. mode=""
  100. ></image>
  101. </view>
  102. </view>
  103. </template>
  104. <script>
  105. export default {
  106. data() {
  107. return {
  108. modelPicker: false,
  109. identify_model: 1,
  110. modelList: [
  111. {
  112. value: 'A',
  113. label: '模型A',
  114. },
  115. {
  116. value: 'B',
  117. label: '模型B',
  118. },
  119. ],
  120. page: 1,
  121. imglists: [],
  122. tishi: true,
  123. d_id: '',
  124. timeend: null, //当前时间 也是搜索的结束时间
  125. timestate: null,
  126. timeshow: false,
  127. params: {
  128. year: true,
  129. month: true,
  130. day: true,
  131. hour: true,
  132. minute: true,
  133. second: false,
  134. },
  135. flag: 1,
  136. self: true,
  137. isTop: false,
  138. resultdata: {},
  139. titletext: ['24小时', '近一个月', '近半年', '近一年'],
  140. titleidnex: 0,
  141. tiemshow: false, //时间选择器
  142. disable: '',
  143. device_type: '',
  144. myuid: '',
  145. loading: false,
  146. };
  147. },
  148. methods: {
  149. // 切换模型
  150. confirmModel(e) {
  151. this.modelList.forEach((item, index) => {
  152. if (e[0].value == item.value) {
  153. this.identify_model = index;
  154. }
  155. });
  156. this.page = 1;
  157. this.imglists = [];
  158. this.imglistdata(parseInt(this.timestate), parseInt(this.timeend));
  159. // console.log(e)
  160. },
  161. //forecast.forecast_system.equip_photofo
  162. async imglistdata(time_begin, time_end) {
  163. //获取图片列表
  164. this.loading = true;
  165. uni.showLoading({
  166. title: '加载中',
  167. });
  168. const res = await this.$myRequest({
  169. url: '/api/api_gateway?method=forecast.forecast_system.device_photo_list',
  170. data: {
  171. device_id: this.device_id,
  172. // device_id: '861551058865205',
  173. page: this.page,
  174. status: 'no',
  175. page_size: 12,
  176. identify_model: this.modelList[this.identify_model].value,
  177. time_begin: time_begin, //开始时间
  178. time_end: time_end, //结束时间
  179. },
  180. });
  181. uni.hideLoading();
  182. // this.loading = false
  183. this.imglists = this.imglists.concat(res.data);
  184. console.log(this.imglists);
  185. },
  186. // 孢子仪的图片列表
  187. async imglistdataBzy(time_begin, time_end) {
  188. //获取图片列表
  189. const res = await this.$myRequest({
  190. url: '/api/api_gateway?method=forecast.forecast_system.equip_photo',
  191. data: {
  192. device_id: this.device_id,
  193. page: this.page,
  194. ret: 'list',
  195. page_number: 12,
  196. // identify_model: this.modelList[this.identify_model].value,
  197. time_begin: time_begin, //开始时间
  198. time_end: time_end, //结束时间
  199. },
  200. });
  201. this.imglists = this.imglists.concat(res.data);
  202. console.log(this.imglists);
  203. },
  204. //forecast.forecast_system.equip_photo_del
  205. async del(id) {
  206. //删除图片
  207. var arr = [id];
  208. const res = await this.$myRequest({
  209. url: '/api/api_gateway?method=forecast.forecast_system.equip_photo_del',
  210. data: {
  211. device_id: this.device_id,
  212. addrlist: JSON.stringify(arr),
  213. },
  214. });
  215. if (res) {
  216. uni.showToast({
  217. title: '指令下发成功!',
  218. duration: 2000,
  219. });
  220. this.page = 1;
  221. this.imglists = [];
  222. if (this.device_type == 7) {
  223. this.imglistdataBzy(parseInt(this.timestate), parseInt(this.timeend));
  224. } else {
  225. this.imglistdata(parseInt(this.timestate), parseInt(this.timeend));
  226. }
  227. // this.imglistdata(parseInt(this.timestate), parseInt(this.timeend))
  228. } else {
  229. uni.showToast({
  230. title: '指令下发失败!',
  231. duration: 2000,
  232. icon: 'none',
  233. });
  234. }
  235. },
  236. //forecast.forecast_system.equip_photo_species pest_list
  237. //forecast.forecast_system.equip_photo_species统计
  238. //forecast.send_control.admin_device_control 拍照
  239. async takephoto() {
  240. //拍照
  241. const res = await this.$myRequest({
  242. url: '/api/api_gateway?method=forecast.send_control.admin_device_control',
  243. data: {
  244. device_type_id: 3,
  245. d_id: this.d_id,
  246. cmd: 'takephoto',
  247. },
  248. });
  249. console.log(res);
  250. if (res == true) {
  251. uni.showToast({
  252. title: '指令下发成功!',
  253. duration: 2000,
  254. });
  255. var that = this;
  256. setTimeout(() => {
  257. if (that.device_type == 7) {
  258. that.imglistdataBzy(
  259. parseInt(that.timestate),
  260. parseInt(that.timeend)
  261. );
  262. } else {
  263. that.imglistdata(parseInt(that.timestate), parseInt(that.timeend));
  264. }
  265. // that.imglistdata(parseInt(that.timestate), parseInt(that.timeend))
  266. }, 1000);
  267. } else {
  268. uni.showToast({
  269. title: '指令下发失败!',
  270. duration: 2000,
  271. icon: 'none',
  272. });
  273. }
  274. },
  275. clickLeft() {
  276. uni.navigateBack({
  277. delta: 1,
  278. });
  279. },
  280. delimg(id) {
  281. //删除图片
  282. uni.showModal({
  283. title: '提示',
  284. content: '是否删除此图片?',
  285. success: (res) => {
  286. if (res.confirm) {
  287. this.del(id);
  288. console.log('用户点击确定');
  289. } else if (res.cancel) {
  290. console.log('用户点击取消');
  291. }
  292. },
  293. });
  294. },
  295. shibie(id, addr) {
  296. //识别
  297. // this.discern(id)
  298. uni.navigateTo({
  299. url:
  300. './results?id=' +
  301. id +
  302. '&addr=' +
  303. addr +
  304. '&identify_model=' +
  305. this.modelList[this.identify_model].value,
  306. });
  307. },
  308. tongji(item) {
  309. //统计
  310. // this.species(id)
  311. uni.navigateTo({
  312. url:
  313. './manualinput?id=' +
  314. item.ids +
  315. '&device_id=' +
  316. item.device_id +
  317. '&addtime=' +
  318. item.addtime,
  319. });
  320. },
  321. add(item) {
  322. uni.navigateTo({
  323. url:
  324. './addimg?id=' +
  325. item.ids +
  326. '&device_id=' +
  327. item.device_id +
  328. '&addtime=' +
  329. item.addtime,
  330. });
  331. },
  332. examine(index) {
  333. var imgarr = [];
  334. for (var i = 0; i < this.imglists.length; i++) {
  335. imgarr.push(this.imglists[i].addr);
  336. }
  337. uni.previewImage({
  338. urls: imgarr,
  339. current: index,
  340. });
  341. },
  342. clickRight() {
  343. //下发拍照指令
  344. this.takephoto();
  345. },
  346. top() {
  347. uni.pageScrollTo({
  348. scrollTop: 0,
  349. duration: 500,
  350. });
  351. },
  352. tiemchange(e) {
  353. this.imglists = [];
  354. this.page = 1;
  355. console.log(e);
  356. this.timestate = +new Date(e.startDate) / 1000 - 8 * 60 * 60;
  357. this.timeend = +new Date(e.endDate) / 1000 + 16 * 60 * 60;
  358. if (this.device_type == 7) {
  359. this.imglistdataBzy(parseInt(this.timestate), parseInt(this.timeend));
  360. } else {
  361. this.imglistdata(parseInt(this.timestate), parseInt(this.timeend));
  362. }
  363. // this.imglistdata(parseInt(this.timestate), parseInt(this.timeend))
  364. },
  365. timetab(e) {
  366. e = new Date(e * 1000);
  367. var year = e.getFullYear();
  368. var month =
  369. e.getMonth() + 1 < 10 ? '0' + (e.getMonth() + 1) : e.getMonth() + 1;
  370. var day = e.getDate() < 10 ? '0' + e.getDate() : e.getDate();
  371. var time = year + '/' + month + '/' + day;
  372. return time;
  373. },
  374. },
  375. onLoad(option) {
  376. uni.getStorage({
  377. key: 'myuid',
  378. success: (res) => {
  379. this.myuid = res.data;
  380. console.log(this.myuid);
  381. },
  382. });
  383. this.timeend = +new Date() / 1000;
  384. this.timestate = this.timeend - 60 * 60 * 24;
  385. console.log(option);
  386. this.device_id = option.device_id;
  387. this.d_id = option.d_id;
  388. this.imglists = [];
  389. this.disable = option.disable;
  390. this.device_type = option.device_type;
  391. console.log(this.timestate);
  392. if (this.device_type == 7) {
  393. this.imglistdataBzy(parseInt(this.timestate), parseInt(this.timeend));
  394. } else {
  395. this.imglistdata(parseInt(this.timestate), parseInt(this.timeend));
  396. }
  397. },
  398. onShow() {},
  399. onReachBottom() {
  400. this.page++;
  401. console.log(this.timestate);
  402. if (this.device_type == 7) {
  403. this.imglistdataBzy(parseInt(this.timestate), parseInt(this.timeend));
  404. } else {
  405. this.imglistdata(parseInt(this.timestate), parseInt(this.timeend));
  406. }
  407. },
  408. onPageScroll(e) {
  409. //nvue暂不支持滚动监听,可用bindingx代替
  410. if (e.scrollTop > 200) {
  411. //距离大于200时显示
  412. this.isTop = true;
  413. } else {
  414. //距离小于200时隐藏
  415. this.isTop = false;
  416. }
  417. },
  418. };
  419. </script>
  420. <style lang="scss">
  421. .tishi {
  422. position: absolute;
  423. top: 114px;
  424. width: 95%;
  425. left: 2.5%;
  426. text-align: center;
  427. font-size: 40rpx;
  428. }
  429. .schedule {
  430. position: fixed;
  431. top: 85px;
  432. left: 10rpx;
  433. padding: 5rpx 0;
  434. // left: 50%;
  435. // transform: translateX(-50%);
  436. z-index: 100;
  437. display: flex;
  438. width: 220rpx;
  439. margin: 0 auto;
  440. height: 50rpx;
  441. // border: 2rpx solid #F0F0F0;
  442. background-color: #fff;
  443. // border-radius: 25px;
  444. box-shadow: 0 0 10rpx #bcb9ca;
  445. .schedule_value {
  446. width: 70%;
  447. text-align: center;
  448. line-height: 50rpx;
  449. font-size: 24rpx;
  450. }
  451. .schedule_icon {
  452. width: 30%;
  453. // background-color: #F2F2F2;
  454. text-align: center;
  455. line-height: 50rpx;
  456. ::v-deep .u-icon__icon {
  457. color: rgba(0, 0, 0, 0.3);
  458. }
  459. }
  460. }
  461. .selecttimes {
  462. width: 65%;
  463. position: fixed;
  464. top: 85px;
  465. right: 10rpx;
  466. z-index: 100;
  467. background-color: #fff;
  468. // padding-top: 30rpx;
  469. .timesbox {
  470. display: flex;
  471. width: 100%;
  472. // margin: 0 auto;
  473. justify-content: space-around;
  474. box-shadow: 0 0 10rpx #bcb9ca;
  475. padding: 10rpx 20rpx;
  476. box-sizing: border-box;
  477. image {
  478. width: 30rpx;
  479. height: 30rpx;
  480. margin-top: 6rpx;
  481. }
  482. .icon {
  483. color: #949494;
  484. text-align: right;
  485. margin-left: 30rpx;
  486. }
  487. }
  488. ::v-deep .u-calendar__action {
  489. display: flex;
  490. justify-content: space-around;
  491. .u-calendar__action__text {
  492. line-height: 25px;
  493. }
  494. }
  495. }
  496. .bigSelect {
  497. width: 100%;
  498. }
  499. .timeshow {
  500. width: 96%;
  501. height: 50rpx;
  502. background-color: #ffffff;
  503. position: fixed;
  504. top: 84px;
  505. left: 2.5%;
  506. display: flex;
  507. z-index: 100;
  508. padding-top: 10px;
  509. .shuju_one_title {
  510. width: 70%;
  511. margin: 0 auto;
  512. display: flex;
  513. .tltle_text {
  514. width: 25%;
  515. border: 2rpx solid #b2b2b2;
  516. color: #b2b2b2;
  517. text-align: center;
  518. font-size: 24rpx;
  519. height: 50rpx;
  520. line-height: 50rpx;
  521. }
  522. .title_text_color {
  523. width: 25%;
  524. border: 2rpx solid #28ae4f;
  525. color: #28ae4f;
  526. text-align: center;
  527. font-size: 24rpx;
  528. height: 50rpx;
  529. line-height: 50rpx;
  530. }
  531. }
  532. .timeshow_tate,
  533. .timeshow_end {
  534. height: 50rpx;
  535. width: 45%;
  536. line-height: 50rpx;
  537. text-align: center;
  538. margin-right: 10rpx;
  539. background-color: #56c877;
  540. color: #ffffff;
  541. }
  542. }
  543. .imglist {
  544. position: absolute;
  545. top: 100px;
  546. width: 95%;
  547. left: 2.5%;
  548. .imglist_box {
  549. display: flex;
  550. box-shadow: 0 0 10rpx #bcb9ca;
  551. padding: 20rpx;
  552. margin-bottom: 20rpx;
  553. height: 140px;
  554. }
  555. .imglist_left {
  556. width: 50%;
  557. position: relative;
  558. image {
  559. position: absolute;
  560. top: 0;
  561. left: 0;
  562. width: 100%;
  563. height: 280rpx;
  564. }
  565. }
  566. .imglist_right {
  567. margin-left: 40rpx;
  568. padding: 10rpx 0;
  569. .icon_box {
  570. margin-bottom: 12rpx;
  571. font-size: 24rpx;
  572. .iconfont {
  573. margin-right: 20rpx;
  574. color: #56c877;
  575. font-size: 32rpx;
  576. }
  577. }
  578. p:last-child {
  579. margin-bottom: 0;
  580. }
  581. }
  582. }
  583. .top {
  584. position: fixed;
  585. right: 30px;
  586. bottom: 100px;
  587. z-index: 100;
  588. image {
  589. width: 100rpx;
  590. height: 100rpx;
  591. }
  592. }
  593. </style>