imgpage.vue 13 KB

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