imgpage.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  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"
  7. @clickRight="clickRight"></uni-nav-bar>
  8. </view>
  9. <p class="tishi" v-if="tishi">暂无数据</p>
  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="imglist">
  23. <view class="imglist_box" v-for="(item,index) in imglists" :key="index">
  24. <view class="imglist_left">
  25. <image :src="'http://www.hnyfwlw.com:8006/bigdata_app'+'/image/cb/jiazai.ui.gif'" mode="">
  26. </image>
  27. <image :src="item.addr" mode="" @click="examine(index)"></image>
  28. </view>
  29. <view class="imglist_right">
  30. <view class="icon_box" @click="delimg(item.id)">
  31. <p class="iconfont icon-shanchu">删除</p>
  32. </view>
  33. <view class="icon_box" @click="shibie(item.id,item.addr)"
  34. v-if="disable==1 && device_type!=7">
  35. <p class="iconfont icon-shibie">识别</p>
  36. </view>
  37. <view class="icon_box" v-else-if="disable==2 && device_type!=7">
  38. <p class="iconfont icon-shibie">计数:{{item.des_nums}}只</p>
  39. </view>
  40. <p style="color: #06B535;">{{item.addtime|timeFormat()}}</p>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="top" v-if="isTop" @click="top">
  46. <image :src="'http://www.hnyfwlw.com:8006/bigdata_app'+'/image/6209a98f0cb3b5086f2ca36152c9269.png'"
  47. mode=""></image>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. export default {
  53. data() {
  54. return {
  55. page: 1,
  56. imglists: [],
  57. tishi: true,
  58. d_id: '',
  59. timeend: null, //当前时间 也是搜索的结束时间
  60. timestate: null,
  61. timeshow: false,
  62. params: {
  63. year: true,
  64. month: true,
  65. day: true,
  66. hour: true,
  67. minute: true,
  68. second: false
  69. },
  70. flag: 1,
  71. self: true,
  72. isTop: false,
  73. resultdata: {},
  74. titletext: ["24小时", "近一个月", "近半年", "近一年"],
  75. titleidnex: 0,
  76. tiemshow: false, //时间选择器
  77. disable: "",
  78. device_type: "",
  79. myuid:""
  80. }
  81. },
  82. methods: {
  83. //forecast.forecast_system.equip_photofo
  84. async imglistdata(time_begin, time_end) { //获取图片列表
  85. const res = await this.$myRequest({
  86. url: '/api/api_gateway?method=forecast.forecast_system.equip_photo',
  87. data: {
  88. device_id: this.device_id,
  89. page: this.page,
  90. ret: "list",
  91. time_begin: time_begin, //开始时间
  92. time_end: time_end, //结束时间
  93. }
  94. })
  95. this.imglists = this.imglists.concat(res.data)
  96. console.log(this.imglists)
  97. if (this.imglists.length == 0) {
  98. this.tishi = true
  99. } else {
  100. this.tishi = false
  101. }
  102. },
  103. //forecast.forecast_system.equip_photo_del
  104. async del(id) { //删除图片
  105. var arr = [id]
  106. const res = await this.$myRequest({
  107. url: '/api/api_gateway?method=forecast.forecast_system.equip_photo_del',
  108. data: {
  109. device_id: this.device_id,
  110. addrlist: JSON.stringify(arr)
  111. }
  112. })
  113. if (res) {
  114. uni.showToast({
  115. title: '指令下发成功!',
  116. duration: 2000
  117. });
  118. this.page = 1
  119. this.imglists = []
  120. this.imglistdata(parseInt(this.timestate), parseInt(this.timeend))
  121. } else {
  122. uni.showToast({
  123. title: '指令下发失败!',
  124. duration: 2000,
  125. icon: "none"
  126. });
  127. }
  128. },
  129. //forecast.forecast_system.equip_photo_species pest_list
  130. //forecast.forecast_system.equip_photo_species统计
  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: (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. // this.species(id)
  186. uni.navigateTo({
  187. url: "./manualinput?id=" + item.id + "&device_id=" + item.device_id + "&addtime=" + item
  188. .addtime
  189. })
  190. },
  191. add(item) {
  192. uni.navigateTo({
  193. url: "./addimg?id=" + item.id + "&device_id=" + item.device_id + "&addtime=" + item.addtime
  194. })
  195. },
  196. examine(index) {
  197. var imgarr = []
  198. for (var i = 0; i < this.imglists.length; i++) {
  199. imgarr.push(this.imglists[i].addr)
  200. }
  201. uni.previewImage({
  202. urls: imgarr,
  203. current: index
  204. });
  205. },
  206. clickRight() { //下发拍照指令
  207. this.takephoto()
  208. },
  209. top() {
  210. uni.pageScrollTo({
  211. scrollTop: 0,
  212. duration: 500
  213. })
  214. },
  215. tiemchange(e) {
  216. this.imglists = []
  217. this.page = 1
  218. console.log(e)
  219. this.timestate = +new Date(e.startDate) / 1000 - 8 * 60 * 60
  220. this.timeend = +new Date(e.endDate) / 1000 + 16 * 60 * 60
  221. this.imglistdata(parseInt(this.timestate), parseInt(this.timeend))
  222. },
  223. timetab(e) {
  224. e = new Date(e * 1000)
  225. var year = e.getFullYear()
  226. var month = e.getMonth() + 1 < 10 ? "0" + (e.getMonth() + 1) : e.getMonth() + 1
  227. var day = e.getDate() < 10 ? "0" + e.getDate() : e.getDate()
  228. var time = year + "/" + month + "/" + day
  229. return time
  230. },
  231. },
  232. onLoad(option) {
  233. uni.getStorage({
  234. key:"myuid",
  235. success:(res)=> {
  236. this.myuid = res.data
  237. console.log(this.myuid)
  238. }
  239. })
  240. this.timeend = +new Date() / 1000
  241. this.timestate = this.timeend - 60 * 60 * 24
  242. console.log(option)
  243. this.device_id = option.device_id
  244. this.d_id = option.d_id
  245. this.imglists = []
  246. this.disable = option.disable
  247. this.device_type = option.device_type
  248. console.log(this.timestate)
  249. this.imglistdata(parseInt(this.timestate), parseInt(this.timeend))
  250. },
  251. onShow() {
  252. },
  253. onReachBottom() {
  254. this.page++
  255. console.log(this.timestate)
  256. this.imglistdata(parseInt(this.timestate), parseInt(this.timeend))
  257. },
  258. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  259. if (e.scrollTop > 200) { //距离大于200时显示
  260. this.isTop = true
  261. } else { //距离小于200时隐藏
  262. this.isTop = false
  263. }
  264. }
  265. }
  266. </script>
  267. <style lang="scss">
  268. .tishi {
  269. position: absolute;
  270. top: 104px;
  271. width: 95%;
  272. left: 2.5%;
  273. text-align: center;
  274. font-size: 40rpx;
  275. }
  276. .selecttimes {
  277. width: 100%;
  278. position: fixed;
  279. top: 85px;
  280. left: 0;
  281. z-index: 100;
  282. background-color: #fff;
  283. padding-top: 30rpx;
  284. .timesbox {
  285. display: flex;
  286. width: 95%;
  287. margin: 0 auto;
  288. justify-content: space-around;
  289. box-shadow: 0 0 10rpx #bcb9ca;
  290. padding: 10rpx 20rpx;
  291. box-sizing: border-box;
  292. image {
  293. width: 30rpx;
  294. height: 30rpx;
  295. margin-top: 6rpx;
  296. }
  297. .icon {
  298. color: #949494;
  299. text-align: right;
  300. margin-left: 30rpx;
  301. }
  302. }
  303. /deep/.u-calendar__action {
  304. display: flex;
  305. justify-content: space-around;
  306. .u-calendar__action__text {
  307. line-height: 25px;
  308. }
  309. }
  310. }
  311. .timeshow {
  312. width: 96%;
  313. height: 50rpx;
  314. background-color: #FFFFFF;
  315. position: fixed;
  316. top: 84px;
  317. left: 2.5%;
  318. display: flex;
  319. z-index: 100;
  320. padding-top: 10px;
  321. .shuju_one_title {
  322. width: 70%;
  323. margin: 0 auto;
  324. display: flex;
  325. .tltle_text {
  326. width: 25%;
  327. border: 2rpx solid #B2B2B2;
  328. color: #B2B2B2;
  329. text-align: center;
  330. font-size: 24rpx;
  331. height: 50rpx;
  332. line-height: 50rpx;
  333. }
  334. .title_text_color {
  335. width: 25%;
  336. border: 2rpx solid #28AE4F;
  337. color: #28AE4F;
  338. text-align: center;
  339. font-size: 24rpx;
  340. height: 50rpx;
  341. line-height: 50rpx;
  342. }
  343. }
  344. .timeshow_tate,
  345. .timeshow_end {
  346. height: 50rpx;
  347. width: 45%;
  348. line-height: 50rpx;
  349. text-align: center;
  350. margin-right: 10rpx;
  351. background-color: #56C877;
  352. color: #FFFFFF;
  353. }
  354. }
  355. .imglist {
  356. position: absolute;
  357. top: 100px;
  358. width: 95%;
  359. left: 2.5%;
  360. .imglist_box {
  361. display: flex;
  362. box-shadow: 0 0 10rpx #bcb9ca;
  363. padding: 20rpx;
  364. margin-bottom: 20rpx;
  365. height: 140px;
  366. }
  367. .imglist_left {
  368. width: 50%;
  369. position: relative;
  370. image {
  371. position: absolute;
  372. top: 0;
  373. left: 0;
  374. width: 100%;
  375. height: 280rpx;
  376. }
  377. }
  378. .imglist_right {
  379. margin-left: 40rpx;
  380. padding: 10rpx 0;
  381. .icon_box {
  382. margin-bottom: 12rpx;
  383. font-size: 24rpx;
  384. .iconfont {
  385. margin-right: 20rpx;
  386. color: #56C877;
  387. font-size: 32rpx;
  388. }
  389. }
  390. p:last-child {
  391. margin-bottom: 0;
  392. }
  393. }
  394. }
  395. .top {
  396. position: fixed;
  397. right: 30px;
  398. bottom: 100px;
  399. z-index: 100;
  400. image {
  401. width: 100rpx;
  402. height: 100rpx;
  403. }
  404. }
  405. </style>