photo.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. <template>
  2. <view style="background-color: #f7f7f7;padding-top: 88rpx;height: calc(100vh - 88rpx);">
  3. <uni-nav-bar @clickLeft="clickLeft" left-icon="back" title="查看图片" backgroundColor="#F7F7F7"></uni-nav-bar>
  4. <view class="search-item">
  5. <u-dropdown >
  6. <u-dropdown-item @change="dropDownChange" v-model="searchObj.is_pest" title="害虫筛选" :options="pestOptions"></u-dropdown-item>
  7. </u-dropdown>
  8. <span v-if="!delShow" class="right" @click="imgOperate">
  9. 管理
  10. </span>
  11. <span v-else class="right" @click="delShow = false">
  12. 完成
  13. </span>
  14. </view>
  15. <view style="padding: 0 48rpx;" v-if="searchObj.is_pest!='2'">
  16. <u-search bg-color="#fff" height="92" shape="square" placeholder="请输入害虫名称" v-model="searchObj.pest_name" @search="dropDownChange" :show-action='false'></u-search>
  17. </view>
  18. <u-calendar v-model="calendarShow" mode="range" @maxDate="maxDate" @change="change"></u-calendar>
  19. <view class="tile-item">
  20. <view @click="calendarShow = true" class="calendar">{{start_time}} <span style="margin: 0 40rpx;"> -</span> {{end_time}}</view>
  21. <u-icon name="camera" color="#018B3F" size="52" @click="takephoto"></u-icon>
  22. </view>
  23. <view class="imglist" v-if="imglists.length>0">
  24. <view class="imglist_box" v-for="(item,index) in imglists" :key="index" >
  25. <view class="top">识别:{{item.indentify_count}}
  26. <span class="yficonfont icon-shanchu float-right" v-if="delShow" @click="delImage(item)"></span>
  27. <!-- <u-icon v-if="delShow" @click="delImage(item)" class="float-right" name="trash-fill" color="#FF5951" size="28"></u-icon> -->
  28. </view>
  29. <!-- <image class="img-flex" v-if="showPlaceholder" src="/static/images/image.png"></image> -->
  30. <image class="img-flex" @error="handleImgErr($event,index)" :src="item.addr+'?x-oss-process=image/resize,w_130/quality,q_50'" mode="" @click="imageDetail(item)"></image>
  31. <view class="bottom">{{item.addtime}}</view>
  32. </view>
  33. </view>
  34. <view v-else class="notip">
  35. 暂无数据
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import jsencrypt from '@/components/jsencrypt/jsencrypt.vue';
  41. export default {
  42. data() {
  43. return {
  44. maxDate:'2050-12-31',
  45. value1:'',
  46. value2:'',
  47. searchObj:{
  48. is_pest:'',
  49. pest_name:''
  50. },
  51. pestOptions:[
  52. {label: '全部',value: ''},
  53. {label: '有虫',value: '1'},
  54. {label: '无虫',value: '2'},
  55. ],
  56. timeend:'',
  57. timestart:'',
  58. imglists:[],
  59. page:1,
  60. device_type:'',
  61. device_id:'',
  62. d_id:'',
  63. calendarShow:false,
  64. start_time:'',
  65. end_time:'',
  66. delShow:false,
  67. loadMore:true,
  68. noImage:'/static/images/image.png'
  69. }
  70. },
  71. methods: {
  72. handleImgErr(e,index){
  73. console.log(e,'图片加载出错了')
  74. this.imglists[index].addr = this.noImage
  75. // this.showPlaceholder = true
  76. },
  77. imageDetail(item){
  78. console.log(item)
  79. if(this.delShow){
  80. return
  81. }
  82. uni.navigateTo({
  83. url: '/pages/cb/cbd/equip-set/photoResults' + '?d_id=' + this.d_id + "&device_id=" + this.device_id + "&device_type=" + this.device_type + "&time=" + item.addtime
  84. });
  85. },
  86. imgOperate(){
  87. this.delShow = true
  88. },
  89. clickLeft() {
  90. uni.navigateBack()
  91. },
  92. dropDownChange(){
  93. this.loadMore = true
  94. this.page = 1
  95. this.imglists = []
  96. this.getImgData()
  97. },
  98. change(e){
  99. this.loadMore = true
  100. console.log(e)
  101. this.start_time = e.startDate
  102. this.end_time = e.endDate
  103. this.page = 1
  104. this.imglists = []
  105. this.getImgData()
  106. },
  107. async getImgData(){
  108. const res = await this.$myRequest({
  109. url: '/api/api_gateway?method=new_gateway.photo_info.photo_list',
  110. data: {
  111. id: this.d_id,
  112. device_type_id:this.device_type,
  113. page: this.page,
  114. page_number: 12,
  115. start: +new Date(this.start_time+' 00:00:00') / 1000,
  116. end: +new Date(this.end_time+' 23:59:59') / 1000,
  117. ...this.searchObj
  118. }
  119. })
  120. if(res.data.length==0){
  121. // 加载完了
  122. this.loadMore = false
  123. return
  124. }
  125. this.imglists = this.imglists.concat(res.data)
  126. },
  127. // 删除
  128. delImage(item){
  129. uni.showModal({
  130. title: '提示',
  131. content: '确认删除?',
  132. success: async (res)=> {
  133. if (res.confirm) {
  134. const res = await this.$myRequest({
  135. url: '/api/api_gateway?method=new_gateway.photo_info.delete_photo',
  136. data: {
  137. device_type_id: this.device_type,
  138. ids: item.id
  139. }
  140. })
  141. this.delShow = false
  142. uni.showToast({
  143. title: res.msg,
  144. duration: 2000
  145. });
  146. this.imglists = []
  147. this.getImgData()
  148. } else if (res.cancel) {
  149. }
  150. }
  151. });
  152. },
  153. onReachBottom() {
  154. if(this.loadMore){
  155. this.page++
  156. this.getImgData()
  157. }
  158. },
  159. anew() {
  160. this.discern("again")
  161. this.imgbg = true
  162. },
  163. examine(url) {
  164. console.log(url)
  165. var imgarr = []
  166. imgarr.push(url.image)
  167. console.log(imgarr)
  168. uni.previewImage({
  169. urls: imgarr
  170. });
  171. },
  172. async takephoto() { //拍照
  173. const res = await this.$myRequest({
  174. url: '/api/api_gateway?method=new_gateway.device_info.send_control',
  175. data: {
  176. device_type_id: this.device_type,
  177. id: this.device_id,
  178. cmd: "0004"
  179. }
  180. })
  181. console.log(res)
  182. if (res == true) {
  183. uni.showToast({
  184. title: '指令下发成功!',
  185. duration: 2000
  186. });
  187. } else {
  188. uni.showToast({
  189. title: '指令下发失败!',
  190. duration: 2000,
  191. icon: "none"
  192. });
  193. }
  194. },
  195. },
  196. onLoad(option) {
  197. console.log('图片详情',option)
  198. this.device_id = option.device_id
  199. this.d_id = option.d_id
  200. this.device_type = option.device_type
  201. let endTime = +new Date()/1000
  202. let startTime = endTime - 60 * 60 * 24
  203. this.end_time = this.formatTime(endTime*1000,'yyyy-MM-dd')
  204. this.start_time = this.formatTime(startTime*1000,'yyyy-MM-dd')
  205. // this.imglists = []
  206. this.getImgData()
  207. },
  208. }
  209. </script>
  210. <style lang="scss" scoped>
  211. /deep/.u-calendar__action {
  212. display: flex;
  213. justify-content: space-around;
  214. .u-calendar__action__text {
  215. line-height: 25px;
  216. }
  217. }
  218. /deep/.u-flex{
  219. display: flex;
  220. }
  221. page {
  222. background: #F7F7F7;
  223. .notip{
  224. text-align: center;
  225. color: #666666;
  226. margin-top: 100rpx;
  227. }
  228. .search-item{
  229. // padding: 0rpx 48rpx;
  230. box-sizing: border-box;
  231. background: #F7F7F7;
  232. line-height: 80rpx;
  233. color: #656C74;
  234. position: relative;
  235. .right{
  236. position: absolute;
  237. z-index: 11;
  238. right: 48rpx;
  239. top: 0;
  240. }
  241. .right::before{
  242. content: '|';
  243. color: #C3CBCF;
  244. padding-right: 10rpx;
  245. }
  246. }
  247. .tile-item{
  248. margin-top: 16rpx;
  249. padding: 0rpx 48rpx;
  250. box-sizing: border-box;
  251. height: 92rpx;
  252. line-height: 92rpx;
  253. display: flex;
  254. justify-content: space-between;
  255. background: #F7F7F7;
  256. .calendar{
  257. width: 83%;
  258. background-color: #fff;
  259. border-radius: 10rpx;
  260. padding: 0 18rpx;
  261. color: #5C5C5C;
  262. text-align: center;
  263. }
  264. .camera{
  265. }
  266. }
  267. .imglist{
  268. display: flex;
  269. flex-flow: row wrap;
  270. padding: 0rpx 48rpx;
  271. box-sizing: border-box;
  272. background: #F7F7F7;
  273. margin-top: 6rpx;
  274. // justify-content: space-around;
  275. // gap: 16rpx;
  276. .imglist_box{
  277. box-sizing: border-box;
  278. flex: 0 0 33.3333%;
  279. height: 224rpx;
  280. padding: 6rpx;
  281. border-radius: 4rpx;
  282. position: relative;
  283. .top{
  284. position: absolute;
  285. top: 6rpx;
  286. left: 6rpx;
  287. background: rgba(0, 0, 0, 0.6);
  288. color: #fff;
  289. border-top-left-radius: 4rpx;
  290. border-top-right-radius: 4rpx;
  291. padding: 0 20rpx;
  292. font-size: 10px;
  293. z-index: 1;
  294. width: 75.5%;
  295. .float-right{
  296. float: right;
  297. color: #FF5951;
  298. font-size: 36rpx;
  299. }
  300. }
  301. .bottom{
  302. position: absolute;
  303. bottom: 6rpx;
  304. left: 6rpx;
  305. background: rgba(0, 0, 0, 0.6);
  306. color: #fff;
  307. border-bottom-left-radius: 4rpx;
  308. border-bottom-right-radius: 4rpx;
  309. text-align: center;
  310. font-size: 10px;
  311. width: 94.5%;
  312. padding: 4rpx 0;
  313. }
  314. .img-flex{
  315. border-radius: 4rpx;
  316. width: 100%;
  317. height: 100%;
  318. }
  319. }
  320. }
  321. }
  322. </style>