imgpage.vue 9.6 KB

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