imgpage.vue 13 KB

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