imgpage.vue 8.4 KB

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