photo.vue 8.0 KB

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