photo.vue 9.2 KB

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