imgpage.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  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. uni.previewImage({
  189. urls: imgarr,
  190. current:index
  191. });
  192. },
  193. clickRight() { //下发拍照指令
  194. this.takephoto()
  195. },
  196. top() {
  197. uni.pageScrollTo({
  198. scrollTop: 0,
  199. duration: 500
  200. })
  201. },
  202. changeindex(index){
  203. this.imglists=[]
  204. this.page =1
  205. this.titleidnex = index
  206. var newtime = new Date()
  207. this.timeend = +new Date(newtime)/1000
  208. if(index == 0){
  209. this.timestate = (newtime - 60 * 60 * 24*1000)/1000
  210. this.imglistdata(parseInt(this.timestate),parseInt(this.timeend))
  211. }else if(index == 1){
  212. this.timestate = (newtime.setMonth(newtime.getMonth() - 1))/1000
  213. this.imglistdata(parseInt(this.timestate),parseInt(this.timeend))
  214. }else if(index == 2){
  215. this.timestate = (newtime.setMonth(newtime.getMonth() - 6))/1000
  216. this.imglistdata(parseInt(this.timestate),parseInt(this.timeend))
  217. }else if(index == 3){
  218. this.timestate = (newtime.setFullYear(newtime.getFullYear() - 1))/1000
  219. this.imglistdata(parseInt(this.timestate),parseInt(this.timeend))
  220. }
  221. }
  222. },
  223. onLoad(option) {
  224. this.timeend = +new Date() / 1000
  225. this.timestate = this.timeend - 60 * 60 * 24
  226. console.log(option)
  227. this.device_id = option.device_id
  228. this.d_id = option.d_id
  229. },
  230. onShow(){
  231. this.imglists=[]
  232. console.log(this.timestate)
  233. this.imglistdata(parseInt(this.timestate),parseInt(this.timeend))
  234. },
  235. onReachBottom() {
  236. this.page++
  237. console.log(this.timestate)
  238. this.imglistdata(parseInt(this.timestate),parseInt(this.timeend))
  239. },
  240. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  241. if (e.scrollTop > 200) { //距离大于200时显示
  242. this.isTop = true
  243. } else { //距离小于200时隐藏
  244. this.isTop = false
  245. }
  246. }
  247. }
  248. </script>
  249. <style lang="scss">
  250. .tishi {
  251. position: absolute;
  252. top: 104px;
  253. width: 95%;
  254. left: 2.5%;
  255. text-align: center;
  256. font-size: 40rpx;
  257. }
  258. .timeshow {
  259. width: 96%;
  260. height: 50rpx;
  261. background-color: #FFFFFF;
  262. position: fixed;
  263. top: 84px;
  264. left: 2.5%;
  265. display: flex;
  266. z-index: 100;
  267. padding-top: 10px;
  268. .shuju_one_title {
  269. width: 70%;
  270. margin: 0 auto;
  271. display: flex;
  272. .tltle_text {
  273. width: 25%;
  274. border: 2rpx solid #B2B2B2;
  275. color: #B2B2B2;
  276. text-align: center;
  277. font-size: 24rpx;
  278. height: 50rpx;
  279. line-height: 50rpx;
  280. }
  281. .title_text_color {
  282. width: 25%;
  283. border: 2rpx solid #28AE4F;
  284. color: #28AE4F;
  285. text-align: center;
  286. font-size: 24rpx;
  287. height: 50rpx;
  288. line-height: 50rpx;
  289. }
  290. }
  291. .timeshow_tate,
  292. .timeshow_end {
  293. height: 50rpx;
  294. width: 45%;
  295. line-height: 50rpx;
  296. text-align: center;
  297. margin-right: 10rpx;
  298. background-color: #56C877;
  299. color: #FFFFFF;
  300. }
  301. }
  302. .imglist {
  303. position: absolute;
  304. top: 84px;
  305. width: 95%;
  306. left: 2.5%;
  307. .imglist_box {
  308. display: flex;
  309. box-shadow: 0 0 10rpx #bcb9ca;
  310. padding: 20rpx;
  311. margin-bottom: 20rpx;
  312. }
  313. .imglist_left {
  314. width: 50%;
  315. position: relative;
  316. image {
  317. position: absolute;
  318. top: 0;
  319. left: 0;
  320. width: 100%;
  321. height: 280rpx;
  322. }
  323. }
  324. .imglist_right {
  325. margin-left: 40rpx;
  326. padding: 10rpx 0;
  327. .icon_box {
  328. margin-bottom: 12rpx;
  329. font-size: 24rpx;
  330. .iconfont {
  331. margin-right: 20rpx;
  332. color: #56C877;
  333. font-size: 32rpx;
  334. }
  335. }
  336. p:last-child {
  337. margin-bottom: 0;
  338. }
  339. }
  340. }
  341. .top {
  342. position: fixed;
  343. right: 30px;
  344. bottom: 100px;
  345. z-index: 100;
  346. image{
  347. width: 100rpx;
  348. height: 100rpx;
  349. }
  350. }
  351. </style>