imgpage.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  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) {
  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. this.imglists = this.imglists.concat(res.data);
  188. console.log(this.imglists);
  189. },
  190. // 孢子仪的图片列表
  191. async imglistdataBzy(time_begin, time_end) {
  192. //获取图片列表
  193. const res = await this.$myRequest({
  194. url: '/api/api_gateway?method=forecast.forecast_system.equip_photo',
  195. data: {
  196. device_id: this.device_id,
  197. page: this.page,
  198. ret: 'list',
  199. page_number: 12,
  200. // identify_model: this.modelList[this.identify_model].value,
  201. time_begin: time_begin, //开始时间
  202. time_end: time_end, //结束时间
  203. },
  204. });
  205. this.imglists = this.imglists.concat(res.data);
  206. console.log(this.imglists);
  207. },
  208. //forecast.forecast_system.equip_photo_del
  209. async del(id) {
  210. //删除图片
  211. var arr = [id];
  212. const res = await this.$myRequest({
  213. url: '/api/api_gateway?method=forecast.forecast_system.equip_photo_del',
  214. data: {
  215. device_id: this.device_id,
  216. addrlist: JSON.stringify(arr),
  217. },
  218. });
  219. if (res) {
  220. uni.showToast({
  221. title: '指令下发成功!',
  222. duration: 2000,
  223. });
  224. this.page = 1;
  225. this.imglists = [];
  226. if (this.device_type == 7) {
  227. this.imglistdataBzy(parseInt(this.timestate), parseInt(this.timeend));
  228. } else {
  229. this.imglistdata(parseInt(this.timestate), parseInt(this.timeend));
  230. }
  231. // this.imglistdata(parseInt(this.timestate), parseInt(this.timeend))
  232. } else {
  233. uni.showToast({
  234. title: '指令下发失败!',
  235. duration: 2000,
  236. icon: 'none',
  237. });
  238. }
  239. },
  240. //forecast.forecast_system.equip_photo_species pest_list
  241. //forecast.forecast_system.equip_photo_species统计
  242. //forecast.send_control.admin_device_control 拍照
  243. async takephoto() {
  244. //拍照
  245. const res = await this.$myRequest({
  246. url: '/api/api_gateway?method=forecast.send_control.admin_device_control',
  247. data: {
  248. device_type_id: 3,
  249. d_id: this.d_id,
  250. cmd: 'takephoto',
  251. },
  252. });
  253. console.log(res);
  254. if (res == true) {
  255. uni.showToast({
  256. title: '指令下发成功!',
  257. duration: 2000,
  258. });
  259. var that = this;
  260. setTimeout(() => {
  261. if (that.device_type == 7) {
  262. that.imglistdataBzy(
  263. parseInt(that.timestate),
  264. parseInt(that.timeend)
  265. );
  266. } else {
  267. that.imglistdata(parseInt(that.timestate), parseInt(that.timeend));
  268. }
  269. // that.imglistdata(parseInt(that.timestate), parseInt(that.timeend))
  270. }, 1000);
  271. } else {
  272. uni.showToast({
  273. title: '指令下发失败!',
  274. duration: 2000,
  275. icon: 'none',
  276. });
  277. }
  278. },
  279. clickLeft() {
  280. uni.navigateBack({
  281. delta: 1,
  282. });
  283. },
  284. delimg(id) {
  285. //删除图片
  286. uni.showModal({
  287. title: '提示',
  288. content: '是否删除此图片?',
  289. success: (res) => {
  290. if (res.confirm) {
  291. this.del(id);
  292. console.log('用户点击确定');
  293. } else if (res.cancel) {
  294. console.log('用户点击取消');
  295. }
  296. },
  297. });
  298. },
  299. shibie(id, addr) {
  300. //识别
  301. // this.discern(id)
  302. uni.navigateTo({
  303. url:
  304. './results?id=' +
  305. id +
  306. '&addr=' +
  307. addr +
  308. '&identify_model=' +
  309. this.modelList[this.identify_model].value,
  310. });
  311. },
  312. tongji(item) {
  313. //统计
  314. // this.species(id)
  315. uni.navigateTo({
  316. url:
  317. './manualinput?id=' +
  318. item.ids +
  319. '&device_id=' +
  320. item.device_id +
  321. '&addtime=' +
  322. item.addtime,
  323. });
  324. },
  325. add(item) {
  326. uni.navigateTo({
  327. url:
  328. './addimg?id=' +
  329. item.ids +
  330. '&device_id=' +
  331. item.device_id +
  332. '&addtime=' +
  333. item.addtime,
  334. });
  335. },
  336. examine(index) {
  337. var imgarr = [];
  338. for (var i = 0; i < this.imglists.length; i++) {
  339. imgarr.push(this.imglists[i].addr);
  340. }
  341. uni.previewImage({
  342. urls: imgarr,
  343. current: index,
  344. });
  345. },
  346. clickRight() {
  347. //下发拍照指令
  348. this.takephoto();
  349. },
  350. top() {
  351. uni.pageScrollTo({
  352. scrollTop: 0,
  353. duration: 500,
  354. });
  355. },
  356. tiemchange(e) {
  357. this.imglists = [];
  358. this.page = 1;
  359. console.log(e);
  360. this.timestate = +new Date(e.startDate) / 1000 - 8 * 60 * 60;
  361. this.timeend = +new Date(e.endDate) / 1000 + 16 * 60 * 60;
  362. if (this.device_type == 7) {
  363. this.imglistdataBzy(parseInt(this.timestate), parseInt(this.timeend));
  364. } else {
  365. this.imglistdata(parseInt(this.timestate), parseInt(this.timeend));
  366. }
  367. // this.imglistdata(parseInt(this.timestate), parseInt(this.timeend))
  368. },
  369. timetab(e) {
  370. e = new Date(e * 1000);
  371. var year = e.getFullYear();
  372. var month =
  373. e.getMonth() + 1 < 10 ? '0' + (e.getMonth() + 1) : e.getMonth() + 1;
  374. var day = e.getDate() < 10 ? '0' + e.getDate() : e.getDate();
  375. var time = year + '/' + month + '/' + day;
  376. return time;
  377. },
  378. },
  379. onLoad(option) {
  380. uni.getStorage({
  381. key: 'myuid',
  382. success: (res) => {
  383. this.myuid = res.data;
  384. console.log(this.myuid);
  385. },
  386. });
  387. this.timeend = +new Date() / 1000;
  388. this.timestate = this.timeend - 60 * 60 * 24;
  389. console.log(option);
  390. this.device_id = option.device_id;
  391. this.d_id = option.d_id;
  392. this.imglists = [];
  393. this.disable = option.disable;
  394. this.device_type = option.device_type;
  395. console.log(this.timestate);
  396. if (this.device_type == 7) {
  397. this.imglistdataBzy(parseInt(this.timestate), parseInt(this.timeend));
  398. } else {
  399. this.imglistdata(parseInt(this.timestate), parseInt(this.timeend));
  400. }
  401. },
  402. onShow() {},
  403. onReachBottom() {
  404. this.page++;
  405. console.log(this.timestate);
  406. if (this.device_type == 7) {
  407. this.imglistdataBzy(parseInt(this.timestate), parseInt(this.timeend));
  408. } else {
  409. this.imglistdata(parseInt(this.timestate), parseInt(this.timeend));
  410. }
  411. },
  412. onPageScroll(e) {
  413. //nvue暂不支持滚动监听,可用bindingx代替
  414. if (e.scrollTop > 200) {
  415. //距离大于200时显示
  416. this.isTop = true;
  417. } else {
  418. //距离小于200时隐藏
  419. this.isTop = false;
  420. }
  421. },
  422. };
  423. </script>
  424. <style lang="scss">
  425. .tishi {
  426. position: absolute;
  427. top: 114px;
  428. width: 95%;
  429. left: 2.5%;
  430. text-align: center;
  431. font-size: 40rpx;
  432. }
  433. .schedule {
  434. position: fixed;
  435. top: 85px;
  436. left: 10rpx;
  437. padding: 5rpx 0;
  438. // left: 50%;
  439. // transform: translateX(-50%);
  440. z-index: 100;
  441. display: flex;
  442. width: 220rpx;
  443. margin: 0 auto;
  444. height: 50rpx;
  445. // border: 2rpx solid #F0F0F0;
  446. background-color: #fff;
  447. // border-radius: 25px;
  448. box-shadow: 0 0 10rpx #bcb9ca;
  449. .schedule_value {
  450. width: 70%;
  451. text-align: center;
  452. line-height: 50rpx;
  453. font-size: 24rpx;
  454. }
  455. .schedule_icon {
  456. width: 30%;
  457. // background-color: #F2F2F2;
  458. text-align: center;
  459. line-height: 50rpx;
  460. ::v-deep .u-icon__icon {
  461. color: rgba(0, 0, 0, 0.3);
  462. }
  463. }
  464. }
  465. .selecttimes {
  466. width: 65%;
  467. position: fixed;
  468. top: 85px;
  469. right: 10rpx;
  470. z-index: 100;
  471. background-color: #fff;
  472. // padding-top: 30rpx;
  473. .timesbox {
  474. display: flex;
  475. width: 100%;
  476. // margin: 0 auto;
  477. justify-content: space-around;
  478. box-shadow: 0 0 10rpx #bcb9ca;
  479. padding: 10rpx 20rpx;
  480. box-sizing: border-box;
  481. image {
  482. width: 30rpx;
  483. height: 30rpx;
  484. margin-top: 6rpx;
  485. }
  486. .icon {
  487. color: #949494;
  488. text-align: right;
  489. margin-left: 30rpx;
  490. }
  491. }
  492. ::v-deep .u-calendar__action {
  493. display: flex;
  494. justify-content: space-around;
  495. .u-calendar__action__text {
  496. line-height: 25px;
  497. }
  498. }
  499. }
  500. .bigSelect {
  501. width: 100%;
  502. }
  503. .timeshow {
  504. width: 96%;
  505. height: 50rpx;
  506. background-color: #ffffff;
  507. position: fixed;
  508. top: 84px;
  509. left: 2.5%;
  510. display: flex;
  511. z-index: 100;
  512. padding-top: 10px;
  513. .shuju_one_title {
  514. width: 70%;
  515. margin: 0 auto;
  516. display: flex;
  517. .tltle_text {
  518. width: 25%;
  519. border: 2rpx solid #b2b2b2;
  520. color: #b2b2b2;
  521. text-align: center;
  522. font-size: 24rpx;
  523. height: 50rpx;
  524. line-height: 50rpx;
  525. }
  526. .title_text_color {
  527. width: 25%;
  528. border: 2rpx solid #28ae4f;
  529. color: #28ae4f;
  530. text-align: center;
  531. font-size: 24rpx;
  532. height: 50rpx;
  533. line-height: 50rpx;
  534. }
  535. }
  536. .timeshow_tate,
  537. .timeshow_end {
  538. height: 50rpx;
  539. width: 45%;
  540. line-height: 50rpx;
  541. text-align: center;
  542. margin-right: 10rpx;
  543. background-color: #56c877;
  544. color: #ffffff;
  545. }
  546. }
  547. .imglist {
  548. position: absolute;
  549. top: 100px;
  550. width: 95%;
  551. left: 2.5%;
  552. .imglist_box {
  553. display: flex;
  554. box-shadow: 0 0 10rpx #bcb9ca;
  555. padding: 20rpx;
  556. margin-bottom: 20rpx;
  557. height: 140px;
  558. }
  559. .imglist_left {
  560. width: 50%;
  561. position: relative;
  562. image {
  563. position: absolute;
  564. top: 0;
  565. left: 0;
  566. width: 100%;
  567. height: 280rpx;
  568. }
  569. }
  570. .imglist_right {
  571. margin-left: 40rpx;
  572. padding: 10rpx 0;
  573. .icon_box {
  574. margin-bottom: 12rpx;
  575. font-size: 24rpx;
  576. .iconfont {
  577. margin-right: 20rpx;
  578. color: #56c877;
  579. font-size: 32rpx;
  580. }
  581. }
  582. p:last-child {
  583. margin-bottom: 0;
  584. }
  585. }
  586. }
  587. .top {
  588. position: fixed;
  589. right: 30px;
  590. bottom: 100px;
  591. z-index: 100;
  592. image {
  593. width: 100rpx;
  594. height: 100rpx;
  595. }
  596. }
  597. </style>