imgpage.vue 15 KB

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