imgpage.vue 7.8 KB

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