imgpage.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. <template>
  2. <view>
  3. <view class="status_bar"></view>
  4. <view class="" style="position: relative;top: 44px;">
  5. <view style="position: fixed;z-index: 100;">
  6. <uni-nav-bar @clickLeft="clickLeft" left-icon="back" title="查看图片" rightIcon="camera" @clickRight="clickRight"></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>
  17. <view class="imglist">
  18. <view class="imglist_box" v-for="(item,index) in imglists" :key="index">
  19. <view class="imglist_left">
  20. <image :src="'http://www.hnyfwlw.com:8006/bigdata_app'+'/image/cb/jiazai.ui.gif'" mode=""></image>
  21. <image :src="item.addr" mode="" @click="examine(index)"></image>
  22. </view>
  23. <view class="imglist_right">
  24. <view class="icon_box" @click="delimg(item.id)">
  25. <p class="iconfont icon-shanchu">删除</p>
  26. </view>
  27. <view class="icon_box" @click="shibie(item.id)">
  28. <p class="iconfont icon-shibie">识别</p>
  29. </view>
  30. <view class="icon_box" @click="tongji(item)">
  31. <p class="iconfont icon-tongji2">手动统计</p>
  32. </view>
  33. <view class="icon_box" @click="add(item)">
  34. <p class="iconfont icon-iconzhengli_shouxieqianpi">手动添加</p>
  35. </view>
  36. <p style="color: #06B535;">{{item.addtime|timeFormat()}}</p>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="top" v-if="isTop" @click="top">
  42. <image :src="'http://www.hnyfwlw.com:8006/bigdata_app'+'/image/6209a98f0cb3b5086f2ca36152c9269.png'" mode=""></image>
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. export default {
  48. data() {
  49. return {
  50. page: 1,
  51. imglists: [],
  52. tishi: true,
  53. d_id: '',
  54. timeend: null, //当前时间 也是搜索的结束时间
  55. timestate: null,
  56. timeshow: false,
  57. params: {
  58. year: true,
  59. month: true,
  60. day: true,
  61. hour: true,
  62. minute: true,
  63. second: false
  64. },
  65. flag:1,
  66. self:true,
  67. isTop:false,
  68. resultdata:{},
  69. titletext: ["24小时", "近一个月", "近半年", "近一年"],
  70. titleidnex:0
  71. }
  72. },
  73. methods: {
  74. //forecast.forecast_system.equip_photofo
  75. async imglistdata(time_begin,time_end) { //获取图片列表
  76. const res = await this.$myRequest({
  77. url: '/api/api_gateway?method=forecast.forecast_system.equip_photo',
  78. data: {
  79. device_id: this.device_id,
  80. page: this.page,
  81. ret: "list",
  82. time_begin:time_begin,//开始时间
  83. time_end:time_end,//结束时间
  84. }
  85. })
  86. this.imglists = this.imglists.concat(res.data)
  87. console.log(this.imglists)
  88. if (this.imglists.length == 0) {
  89. this.tishi = true
  90. } else {
  91. this.tishi = false
  92. }
  93. },
  94. //forecast.forecast_system.equip_photo_del
  95. async del(id) { //删除图片
  96. const res = await this.$myRequest({
  97. url: '/api/api_gateway?method=forecast.forecast_system.equip_photo_del',
  98. data: {
  99. device_id: this.device_id,
  100. addrlist: id
  101. }
  102. })
  103. if (res) {
  104. uni.showToast({
  105. title: '指令下发成功!',
  106. duration: 2000
  107. });
  108. this.imglistdata(parseInt(this.timestate),parseInt(this.timeend))
  109. }else{
  110. uni.showToast({
  111. title: '指令下发失败!',
  112. duration: 2000,
  113. icon:"none"
  114. });
  115. }
  116. },
  117. //forecast.forecast_system.equip_photo_species pest_list
  118. //forecast.forecast_system.equip_photo_species统计
  119. //forecast.send_control.admin_device_control 拍照
  120. async takephoto() { //拍照
  121. const res = await this.$myRequest({
  122. url: '/api/api_gateway?method=forecast.send_control.admin_device_control',
  123. data: {
  124. device_type_id: 3,
  125. d_id: this.d_id,
  126. cmd: "takephoto"
  127. }
  128. })
  129. console.log(res)
  130. if (res == true) {
  131. uni.showToast({
  132. title: '指令下发成功!',
  133. duration: 2000
  134. });
  135. var that = this
  136. setTimeout(()=>{
  137. that.imglistdata(parseInt(that.timestate),parseInt(that.timeend))
  138. },1000)
  139. }else{
  140. uni.showToast({
  141. title: '指令下发失败!',
  142. duration: 2000,
  143. icon:"none"
  144. });
  145. }
  146. },
  147. clickLeft() {
  148. uni.navigateBack({
  149. delta: 1
  150. })
  151. },
  152. delimg(id) { //删除图片
  153. uni.showModal({
  154. title: '提示',
  155. content: '是否删除此图片?',
  156. success: function(res) {
  157. if (res.confirm) {
  158. this.del(id)
  159. console.log('用户点击确定');
  160. } else if (res.cancel) {
  161. console.log('用户点击取消');
  162. }
  163. }
  164. });
  165. },
  166. shibie(id) { //识别
  167. // this.discern(id)
  168. uni.navigateTo({
  169. url: "./results?id="+id
  170. })
  171. },
  172. tongji(item) { //统计
  173. // this.species(id)
  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. .shuju_one_title {
  268. width: 70%;
  269. margin: 0 auto;
  270. display: flex;
  271. .tltle_text {
  272. width: 25%;
  273. border: 2rpx solid #B2B2B2;
  274. color: #B2B2B2;
  275. text-align: center;
  276. font-size: 24rpx;
  277. height: 50rpx;
  278. line-height: 50rpx;
  279. }
  280. .title_text_color {
  281. width: 25%;
  282. border: 2rpx solid #28AE4F;
  283. color: #28AE4F;
  284. text-align: center;
  285. font-size: 24rpx;
  286. height: 50rpx;
  287. line-height: 50rpx;
  288. }
  289. }
  290. .timeshow_tate,
  291. .timeshow_end {
  292. height: 50rpx;
  293. width: 45%;
  294. line-height: 50rpx;
  295. text-align: center;
  296. margin-right: 10rpx;
  297. background-color: #56C877;
  298. color: #FFFFFF;
  299. }
  300. }
  301. .imglist {
  302. position: absolute;
  303. top: 84px;
  304. width: 95%;
  305. left: 2.5%;
  306. .imglist_box {
  307. display: flex;
  308. box-shadow: 0 0 10rpx #bcb9ca;
  309. padding: 20rpx;
  310. margin-bottom: 20rpx;
  311. }
  312. .imglist_left {
  313. width: 50%;
  314. position: relative;
  315. image {
  316. position: absolute;
  317. top: 0;
  318. left: 0;
  319. width: 100%;
  320. height: 280rpx;
  321. }
  322. }
  323. .imglist_right {
  324. margin-left: 40rpx;
  325. padding: 10rpx 0;
  326. .icon_box {
  327. margin-bottom: 12rpx;
  328. font-size: 24rpx;
  329. .iconfont {
  330. margin-right: 20rpx;
  331. color: #56C877;
  332. font-size: 32rpx;
  333. }
  334. }
  335. p:last-child {
  336. margin-bottom: 0;
  337. }
  338. }
  339. }
  340. .top {
  341. position: fixed;
  342. right: 30px;
  343. bottom: 100px;
  344. z-index: 100;
  345. image{
  346. width: 100rpx;
  347. height: 100rpx;
  348. }
  349. }
  350. </style>