imgpage.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  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"></u-select>
  11. <view class="schedule" @click="modelPicker=!modelPicker">
  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="'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="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="'http://www.hnyfwlw.com:8006/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.id)">
  44. <p class="iconfont icon-shanchu">删除</p>
  45. </view>
  46. <view class="icon_box" @click="shibie(item.id,item.addr)" v-if="disable==1 && device_type!=7">
  47. <p class="iconfont icon-shibie">识别</p>
  48. </view>
  49. <view class="icon_box" v-else-if="disable==2 && device_type!=7">
  50. <p class="iconfont icon-shibie">计数:{{item.des_nums}}只</p>
  51. </view>
  52. <!-- <view class="icon_box" @click="tongji(item)" v-if="device_type!=7">
  53. <p class="iconfont icon-tongji2">手动统计</p>
  54. </view>
  55. <view class="icon_box" @click="add(item)" v-if="device_type!=7">
  56. <p class="iconfont 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="'http://www.hnyfwlw.com:8006/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. //forecast.forecast_system.equip_photo_del
  143. async del(id) { //删除图片
  144. var arr = [id]
  145. const res = await this.$myRequest({
  146. url: '/api/api_gateway?method=forecast.forecast_system.equip_photo_del',
  147. data: {
  148. device_id: this.device_id,
  149. addrlist: JSON.stringify(arr)
  150. }
  151. })
  152. if (res) {
  153. uni.showToast({
  154. title: '指令下发成功!',
  155. duration: 2000
  156. });
  157. this.page = 1
  158. this.imglists = []
  159. this.imglistdata(parseInt(this.timestate), parseInt(this.timeend))
  160. } else {
  161. uni.showToast({
  162. title: '指令下发失败!',
  163. duration: 2000,
  164. icon: "none"
  165. });
  166. }
  167. },
  168. //forecast.send_control.admin_device_control 拍照
  169. async takephoto() { //统计
  170. const res = await this.$myRequest({
  171. url: '/api/api_gateway?method=forecast.send_control.admin_device_control',
  172. data: {
  173. device_type_id: 3,
  174. d_id: this.d_id,
  175. cmd: "takephoto"
  176. }
  177. })
  178. console.log(res)
  179. if (res == true) {
  180. uni.showToast({
  181. title: '指令下发成功!',
  182. duration: 2000
  183. });
  184. var that = this
  185. setTimeout(() => {
  186. that.imglistdata(parseInt(that.timestate), parseInt(that.timeend))
  187. }, 1000)
  188. } else {
  189. uni.showToast({
  190. title: '指令下发失败!',
  191. duration: 2000,
  192. icon: "none"
  193. });
  194. }
  195. },
  196. clickLeft() {
  197. uni.navigateBack({
  198. delta: 1
  199. })
  200. },
  201. delimg(id) { //删除图片
  202. uni.showModal({
  203. title: '提示',
  204. content: '是否删除此图片?',
  205. success: (res) => {
  206. if (res.confirm) {
  207. this.del(id)
  208. console.log('用户点击确定');
  209. } else if (res.cancel) {
  210. console.log('用户点击取消');
  211. }
  212. }
  213. });
  214. },
  215. shibie(id, addr) { //识别
  216. // this.discern(id)
  217. uni.navigateTo({
  218. url: "./results?id=" + id + "&addr=" + addr
  219. })
  220. },
  221. tongji(item) { //统计
  222. uni.navigateTo({
  223. url: "./manualinput?id=" + item.id + "&device_id=" + item.device_id + "&addtime=" + item
  224. .addtime
  225. })
  226. },
  227. add(item) {
  228. uni.navigateTo({
  229. url: "./addimg?id=" + item.id + "&device_id=" + item.device_id + "&addtime=" + item.addtime
  230. })
  231. },
  232. examine(index) {
  233. var imgarr = []
  234. for (var i = 0; i < this.imglists.length; i++) {
  235. imgarr.push(this.imglists[i].addr)
  236. }
  237. console.log(imgarr)
  238. uni.previewImage({
  239. urls: imgarr,
  240. current: index
  241. });
  242. },
  243. clickRight() { //下发拍照指令
  244. this.takephoto()
  245. },
  246. top() {
  247. uni.pageScrollTo({
  248. scrollTop: 0,
  249. duration: 500
  250. })
  251. },
  252. tiemchange(e) {
  253. this.imglists = []
  254. this.page = 1
  255. console.log(e)
  256. this.timestate = +new Date(e.startDate) / 1000 - 8 * 60 * 60
  257. this.timeend = +new Date(e.endDate) / 1000 + 16 * 60 * 60
  258. this.imglistdata(parseInt(this.timestate), parseInt(this.timeend))
  259. },
  260. timetab(e) {
  261. e = new Date(e * 1000)
  262. var year = e.getFullYear()
  263. var month = e.getMonth() + 1 < 10 ? "0" + (e.getMonth() + 1) : e.getMonth() + 1
  264. var day = e.getDate() < 10 ? "0" + e.getDate() : e.getDate()
  265. var time = year + "/" + month + "/" + day
  266. return time
  267. },
  268. },
  269. onLoad(option) {
  270. uni.getStorage({
  271. key: "myuid",
  272. success: (res) => {
  273. this.myuid = res.data
  274. console.log(this.myuid)
  275. }
  276. })
  277. console.log(option)
  278. this.device_id = option.device_id
  279. this.d_id = option.d_id
  280. this.disable = option.disable
  281. this.timeend = +new Date() / 1000
  282. this.timestate = this.timeend - 60 * 60 * 24
  283. this.imglists = []
  284. this.device_type = option.device_type
  285. this.imglistdata(parseInt(this.timestate), parseInt(this.timeend))
  286. },
  287. onShow() {
  288. },
  289. onReachBottom() {
  290. this.page++
  291. this.imglistdata(parseInt(this.timestate), parseInt(this.timeend))
  292. },
  293. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  294. if (e.scrollTop > 200) { //距离大于200时显示
  295. this.isTop = true
  296. } else { //距离小于200时隐藏
  297. this.isTop = false
  298. }
  299. },
  300. }
  301. </script>
  302. <style lang="scss">
  303. .tishi {
  304. position: absolute;
  305. top: 104px;
  306. width: 95%;
  307. left: 2.5%;
  308. text-align: center;
  309. font-size: 40rpx;
  310. }
  311. .schedule {
  312. position: fixed;
  313. top: 84px;
  314. left: 10rpx;
  315. padding: 5rpx 0;
  316. // left: 50%;
  317. // transform: translateX(-50%);
  318. z-index: 100;
  319. display: flex;
  320. width: 180rpx;
  321. margin: 0 auto;
  322. height: 50rpx;
  323. // border: 2rpx solid #F0F0F0;
  324. background-color: #Fff;
  325. // border-radius: 25px;
  326. box-shadow: 0 0 10rpx #bcb9ca;
  327. .schedule_value {
  328. width: 70%;
  329. text-align: center;
  330. line-height: 50rpx;
  331. font-size: 24rpx;
  332. }
  333. .schedule_icon {
  334. width: 30%;
  335. // background-color: #F2F2F2;
  336. text-align: center;
  337. line-height: 50rpx;
  338. /deep/.u-icon__icon {
  339. color: rgba(0, 0, 0, 0.3);
  340. }
  341. }
  342. }
  343. .timeshow {
  344. width: 70%;
  345. height: 80rpx;
  346. background-color: #FFFFFF;
  347. position: fixed;
  348. top: 84px;
  349. right: 10rpx;
  350. display: flex;
  351. z-index: 100;
  352. .selecttimes {
  353. width: 85%;
  354. z-index: 100;
  355. background-color: #fff;
  356. .timesbox {
  357. display: flex;
  358. width: 95%;
  359. margin: 0 auto;
  360. justify-content: space-around;
  361. box-shadow: 0 0 10rpx #bcb9ca;
  362. padding: 13rpx 20rpx;
  363. box-sizing: border-box;
  364. image {
  365. width: 30rpx;
  366. height: 30rpx;
  367. margin-top: 6rpx;
  368. }
  369. .icon {
  370. color: #949494;
  371. text-align: right;
  372. margin-left: 30rpx;
  373. }
  374. }
  375. /deep/.u-calendar__action {
  376. display: flex;
  377. justify-content: space-around;
  378. .u-calendar__action__text {
  379. line-height: 25px;
  380. }
  381. }
  382. }
  383. .paizhao{
  384. position: absolute;
  385. top: 10rpx;
  386. right: 10rpx;
  387. }
  388. .shuju_one_title {
  389. width: 70%;
  390. margin: 0 auto;
  391. display: flex;
  392. .tltle_text {
  393. width: 25%;
  394. border: 2rpx solid #B2B2B2;
  395. color: #B2B2B2;
  396. text-align: center;
  397. font-size: 24rpx;
  398. height: 50rpx;
  399. line-height: 50rpx;
  400. }
  401. .title_text_color {
  402. width: 25%;
  403. border: 2rpx solid #28AE4F;
  404. color: #28AE4F;
  405. text-align: center;
  406. font-size: 24rpx;
  407. height: 50rpx;
  408. line-height: 50rpx;
  409. }
  410. }
  411. }
  412. .imglist {
  413. position: absolute;
  414. top: 104px;
  415. width: 95%;
  416. left: 2.5%;
  417. .imglist_box {
  418. display: flex;
  419. box-shadow: 0 0 10rpx #bcb9ca;
  420. padding: 20rpx;
  421. margin-bottom: 20rpx;
  422. height: 140px;
  423. }
  424. .imglist_left {
  425. width: 50%;
  426. position: relative;
  427. image {
  428. position: absolute;
  429. top: 0;
  430. left: 0;
  431. width: 100%;
  432. height: 280rpx;
  433. }
  434. }
  435. .imglist_right {
  436. margin-left: 40rpx;
  437. padding: 10rpx 0;
  438. .icon_box {
  439. margin-bottom: 12rpx;
  440. font-size: 24rpx;
  441. .iconfont {
  442. margin-right: 20rpx;
  443. color: #56C877;
  444. font-size: 32rpx;
  445. }
  446. }
  447. p:last-child {
  448. margin-bottom: 0;
  449. }
  450. }
  451. }
  452. .top {
  453. position: fixed;
  454. right: 30px;
  455. bottom: 100px;
  456. z-index: 100;
  457. image{
  458. width: 100rpx;
  459. height: 100rpx;
  460. }
  461. }
  462. </style>