imgpage.vue 13 KB

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