imgpage.vue 13 KB

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