imgpage.vue 16 KB

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