imgpage.vue 13 KB

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