imgpage.vue 9.3 KB

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