photo.vue 7.8 KB

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