devicePhoto.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910
  1. <template>
  2. <view class="device-photo-page">
  3. <!-- 顶部导航栏 -->
  4. <view class="device-detail__header">
  5. <u-icon
  6. size="36"
  7. class="arrow-left"
  8. name="arrow-left"
  9. @click="handleBack"
  10. ></u-icon>
  11. {{ title }}
  12. </view>
  13. <!-- 日期选择器 -->
  14. <view class="date-container">
  15. <!-- <view class="select-year">
  16. <view class="select-year-item" @click="showPicker = true">
  17. {{ currentYear }}
  18. <u-icon name="arrow-down" size="18" class="arrow-down"></u-icon>
  19. </view>
  20. </view> -->
  21. <view class="date-picker" @click="show = true">
  22. <view class="date-input">
  23. <text class="date-label">{{ time_begin || '-' }}</text>
  24. </view>
  25. <!-- <view class="date-separator">-</view>
  26. <view class="date-input">
  27. <text class="date-label">{{ time_end || '-' }}</text>
  28. </view> -->
  29. <u-icon name="calendar" class="calendar"></u-icon>
  30. </view>
  31. </view>
  32. <!-- 主图片区域 -->
  33. <view class="main-photo" v-if="currentImg.addr">
  34. <movable-area class="movable-area" :style="{ height: containerHeight }">
  35. <movable-view
  36. class="movable-view"
  37. direction="all"
  38. scale="true"
  39. scale-min="1"
  40. scale-max="5"
  41. >
  42. <view class="image-container">
  43. <!-- 原图 -->
  44. <image
  45. :src="currentImg.addr"
  46. class="main-photo-image"
  47. mode="widthFix"
  48. @load="onImageLoad"
  49. />
  50. <!-- 虫子标记层 -->
  51. <view class="bug-markers" v-if="bugMarkers.length > 0">
  52. <view
  53. v-for="(marker, index) in bugMarkers"
  54. :key="index"
  55. class="bug-marker"
  56. :style="{
  57. left: marker.x + '%',
  58. top: marker.y + '%',
  59. width: marker.width + '%',
  60. height: marker.height + '%',
  61. borderColor: marker.color
  62. }"
  63. >
  64. <view class="bug-label" :style="{ color: marker.color }">
  65. {{ getPestName(marker.id) }}
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. </movable-view>
  71. </movable-area>
  72. <view class="photo-timestamp">{{ formatDate(currentImg.addtime) }}</view>
  73. </view>
  74. <!-- 缩略图预览 -->
  75. <view class="thumbnail-preview">
  76. <view class="thumbnail-scroll">
  77. <view
  78. class="thumbnail-item"
  79. v-for="(item, index) in thumbnails"
  80. :key="index"
  81. :class="{ active: img_id == item.ids }"
  82. @click="selectThumbnail(item)"
  83. >
  84. <image
  85. :src="item.addr"
  86. class="thumbnail-image"
  87. />
  88. </view>
  89. </view>
  90. </view>
  91. <!-- 识别结果 -->
  92. <view class="recognition-result" v-if="pestList.length">
  93. <view class="result-title">当前图片识别结果</view>
  94. <!-- 一类害虫 -->
  95. <view>
  96. <view class="pest-category" v-for="(pest,index) in pestList" :key="index">
  97. <view class="category-header">
  98. <text class="category-title">{{ pest[0] }}</text>
  99. <text class="category-count">数量</text>
  100. </view>
  101. <view class="pest-item" v-for="(p, i) in pest[1]" :key="i">
  102. <view class="pest-info">
  103. <view class="pest-color" :style="{ backgroundColor: getPestColor(p.pest_name) }"></view>
  104. <text class="pest-name">{{ p.pest_name }}</text>
  105. </view>
  106. <text class="pest-count">{{ p.pest_num }}</text>
  107. </view>
  108. </view>
  109. </view>
  110. <!-- <view v-else>
  111. <view class="pest-category" v-for="(pest,index) in pestList" :key="index">
  112. <view class="pest-item">
  113. <view class="pest-info">
  114. <view class="pest-color" :style="{ backgroundColor: getPestColor(pest[1].text) }"></view>
  115. <text class="pest-name">{{ pest[1].text }}</text>
  116. </view>
  117. <text class="pest-count">{{ pest[1].value }}</text>
  118. </view>
  119. </view>
  120. </view> -->
  121. </view>
  122. <u-empty v-else text="暂无数据"></u-empty>
  123. <u-calendar
  124. v-model="show"
  125. :mode="mode"
  126. @change="handleChange"
  127. range-color="#999"
  128. btn-type="success"
  129. active-bg-color="#0BBC58"
  130. range-bg-color="rgba(11,188,88,0.13)"
  131. :defaultDate="defaultDate"
  132. ></u-calendar>
  133. <u-picker v-model="showPicker" mode="selector" :range="selectorRange" range-key="id" :default-selector="[0]" @confirm="confirmHandler"></u-picker>
  134. </view>
  135. </template>
  136. <script>
  137. export default {
  138. data() {
  139. return {
  140. show: false,
  141. mode: 'date',
  142. maxDate: this.formatTime(new Date()),
  143. minDate: this.formatTime(new Date(new Date().getFullYear(), 0, 1)),
  144. defaultDate: this.formatTime(new Date(new Date().getFullYear(), 0, 1)),
  145. showPicker: false,
  146. selectorRange: [],
  147. title: '查看图片',
  148. currentThumbnail: 2,
  149. pestYype:{},
  150. is_mark:0,
  151. device_id: '',
  152. time_begin: this.formatTime(new Date(new Date().getFullYear(), 0, 1)),
  153. time_end: this.formatTime(new Date()),
  154. img_id: '',
  155. pest_list:[],
  156. pestList:[],
  157. colors:[
  158. '#FF5951',
  159. '#66EDED',
  160. '#E67B3E',
  161. '#6DE28B',
  162. '#FFC97A',
  163. '#E7EB4B',
  164. '#1561F3',
  165. '#FA73F5',
  166. '#159AFF',
  167. '#FA73F5'
  168. ],
  169. currentYear:'',
  170. pest_list_arr:[],
  171. thumbnails: [],
  172. addtime:'',
  173. currentImg:{},
  174. bugMarkers: [],
  175. imageWidth: 0,
  176. imageHeight: 0,
  177. imgOld_id:'',
  178. containerHeight: '300px',
  179. device_type_id:'',
  180. cmd:'sy',
  181. pestDict: {}, // 虫子字典 {id: name}
  182. pestColorMap: {}, // 害虫颜色映射 {pestName: color}
  183. };
  184. },
  185. async onLoad(options) {
  186. const {cmd,img_id,currentYear,addtime,device_type_id,device_id} = options
  187. this.device_id = device_id
  188. this.imgOld_id = img_id
  189. this.currentYear = currentYear
  190. this.addtime = addtime;
  191. this.device_type_id = device_type_id;
  192. this.time_begin = this.addtime;
  193. console.log(this.time_begin,'thistime_begin')
  194. this.defaultDate = this.addtime;
  195. this.time_end = this.addtime;
  196. this.selectorRange = [];
  197. this.cmd = cmd;
  198. const nowYear = new Date().getFullYear();
  199. for(let i = 0;i<50;i++){
  200. const item = {
  201. label: nowYear - i,
  202. id: nowYear - i
  203. }
  204. this.selectorRange.push(item);
  205. }
  206. this.pestList = [];
  207. await this.getPestDict();
  208. await this.getPestLevelMap();
  209. await this.getPestList();
  210. // this.getDevicePhotoDetails();
  211. },
  212. methods: {
  213. getPestName(id){
  214. if(this.is_mark == 0){
  215. return this.pestDict[id] || id;
  216. }
  217. return id;
  218. },
  219. async confirmHandler(e){
  220. this.currentYear = this.selectorRange[e].id;
  221. if(this.currentYear == new Date().getFullYear()){
  222. this.time_begin = this.formatTime(new Date(new Date().getFullYear(), 0, 1));
  223. this.time_end = this.formatTime(new Date());
  224. this.maxDate = this.formatTime(new Date());
  225. this.minDate = this.formatTime(new Date(new Date().getFullYear(), 0, 1));
  226. }else{
  227. this.time_begin = this.formatTime(new Date(this.currentYear, 0, 1));
  228. this.time_end = this.formatTime(new Date(this.currentYear, 11, 31));
  229. this.maxDate = this.formatTime(new Date(this.currentYear, 11, 31));
  230. this.minDate = this.formatTime(new Date(this.currentYear, 0, 1));
  231. this.defaultDate = this.minDate;
  232. }
  233. this.showPicker = false;
  234. this.pestList = [];
  235. this.thumbnails = [];
  236. await this.getPestList();
  237. },
  238. async handleChange(e){
  239. console.log(e,'e')
  240. this.time_begin = e.result;
  241. this.time_end = e.result;
  242. this.pestList = [];
  243. await this.getPestList()
  244. this.currentImg = {};
  245. },
  246. getPestColor(pestName) {
  247. // 如果该害虫已有颜色,直接返回
  248. if (this.pestColorMap[pestName]) {
  249. return this.pestColorMap[pestName];
  250. }
  251. // 为新害虫分配颜色
  252. const usedColors = Object.values(this.pestColorMap);
  253. // 找一个未使用的颜色
  254. let color;
  255. for (const c of this.colors) {
  256. if (!usedColors.includes(c)) {
  257. color = c;
  258. break;
  259. }
  260. }
  261. // 如果所有颜色都用完了,使用哈希值确定颜色
  262. if (!color) {
  263. const hash = pestName.split('').reduce((acc, char) => acc + char.charCodeAt(0), 0);
  264. color = this.colors[hash % this.colors.length];
  265. }
  266. this.pestColorMap[pestName] = color;
  267. return color;
  268. },
  269. getLevelDisplayName(level) {
  270. const levelMap = {
  271. '-1': '其他害虫',
  272. 1: '一类害虫',
  273. 2: '二类害虫',
  274. 3: '三类害虫',
  275. 4: '四类害虫',
  276. 5: '五类害虫'
  277. };
  278. return levelMap[String(level)] || `${level}`;
  279. },
  280. formatMinute(date,type){
  281. // 转成毫秒数
  282. if(type == 'start'){
  283. //转成开始时间的毫秒数
  284. date.setHours(0, 0, 0, 0);
  285. }else{
  286. //转成结束时间的毫秒数
  287. date.setHours(23, 59, 59, 999);
  288. }
  289. const minute = Math.floor(date.getTime() / 1000);
  290. return minute;
  291. },
  292. async getPestList() {
  293. const res = await this.$myRequest({
  294. url: '/api/api_gateway?method=new_gateway.photo_info.photo_list',
  295. method: 'POST',
  296. data: {
  297. page:1,
  298. page_size:500,
  299. id: this.device_id,
  300. start: this.formatMinute(new Date(this.time_begin),'start'),
  301. end: this.formatMinute(new Date(this.time_end),'end'),
  302. device_type_id: this.device_type_id,
  303. },
  304. });
  305. this.thumbnails = res?.data || [];
  306. this.currentImg = {};
  307. //如果和旧的id相同,就用旧的id不然就用第一个
  308. if(this.thumbnails.find(item => item.ids == this.imgOld_id)){
  309. this.img_id = this.imgOld_id
  310. }else{
  311. this.img_id = this.thumbnails[0].ids
  312. }
  313. this.getDevicePhotoDetails();
  314. },
  315. formatTime(dateString) {
  316. const date = new Date(dateString);
  317. const year = date.getFullYear();
  318. const month = String(date.getMonth() + 1).padStart(2, '0');
  319. const day = String(date.getDate()).padStart(2, '0');
  320. return `${year}-${month}-${day}`;
  321. },
  322. async getPestLevelMap() {
  323. const res = await this.$myRequest({
  324. url: '/api/api_gateway?method=forecast.new_cbd.pest_level_map',
  325. method: 'POST',
  326. });
  327. const pestYype = {}
  328. for(let key in res){
  329. pestYype[this.getLevelDisplayName(key)] = res[key]
  330. }
  331. this.pestYype = pestYype
  332. },
  333. // 获取虫子字典
  334. async getPestDict() {
  335. try {
  336. const res = await this.$myRequest({
  337. url: '/api/api_gateway?method=forecast.pest_info.pest_dict',
  338. method: 'POST',
  339. data:{
  340. type_name: '1'
  341. }
  342. });
  343. this.pestDict = res || {};
  344. } catch (error) {
  345. console.error('获取虫子字典失败:', error);
  346. this.pestDict = {};
  347. }
  348. },
  349. formatDate(dateString) {
  350. const date = new Date(dateString*1000);
  351. const year = date.getFullYear();
  352. const month = String(date.getMonth() + 1).padStart(2, '0');
  353. const day = String(date.getDate()).padStart(2, '0');
  354. const hour = String(date.getHours()).padStart(2, '0');
  355. const minute = String(date.getMinutes()).padStart(2, '0');
  356. const second = String(date.getSeconds()).padStart(2, '0');
  357. return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
  358. },
  359. async getDevicePhotoDetails() {
  360. const res = await this.$myRequest({
  361. url: '/api/api_gateway?method=forecast.forecast_system.device_photo_details',
  362. method: 'POST',
  363. data: {
  364. identify_model:'B',
  365. cmd:this.cmd,
  366. img_id: this.img_id,
  367. },
  368. });
  369. this.currentImg = res;
  370. // 处理label参数生成bugMarkers
  371. this.processBugMarkers();
  372. const pest_list = res.pest_list
  373. const pestArr = new Map()
  374. const pesAlltList = []
  375. for(let key in this.pestYype){
  376. for(let j in this.pestYype[key]){
  377. const pestName = this.pestYype[key][j]
  378. pesAlltList.push(pestName)
  379. pest_list.forEach(item => {
  380. if(item.pest_name == pestName){
  381. if(pestArr.has(key)){
  382. pestArr.get(key).push(item)
  383. }else{
  384. pestArr.set(key, [item])
  385. }
  386. }
  387. })
  388. }
  389. }
  390. pest_list.forEach(item => {
  391. if(!pesAlltList.includes(item.pest_name)){
  392. if(pestArr.has('其他害虫')){
  393. pestArr.get('其他害虫').push(item)
  394. }else{
  395. pestArr.set('其他害虫', [item])
  396. }
  397. }
  398. })
  399. const pestList = []
  400. for(let key of pestArr){
  401. pestList.push(key)
  402. }
  403. if (this.currentImg.is_mark != 0) {
  404. this.processBugMarkers();
  405. }
  406. this.pestList = pestList
  407. },
  408. onImageLoad(e) {
  409. this.imageWidth = e.detail.width;
  410. this.imageHeight = e.detail.height;
  411. // 计算容器显示高度(根据屏幕宽度和图片宽高比)
  412. const systemInfo = uni.getSystemInfoSync();
  413. const screenWidth = systemInfo.windowWidth;
  414. const containerWidth = screenWidth - 24; // 减去左右margin (24rpx ≈ 12px)
  415. const displayHeight = (containerWidth / this.imageWidth) * this.imageHeight;
  416. this.containerHeight = displayHeight + 'px';
  417. console.log('图片尺寸:', this.imageWidth, this.imageHeight, '容器高度:', this.containerHeight);
  418. // 图片加载完成后处理bugMarkers
  419. this.processBugMarkers();
  420. },
  421. processBugMarkers() {
  422. if (this.currentImg.is_mark === 0) {
  423. if (!this.currentImg.label) {
  424. console.log('没有label参数');
  425. this.bugMarkers = [];
  426. return;
  427. }
  428. // 如果没有图片尺寸,先设置默认值
  429. if (!this.imageWidth || !this.imageHeight) {
  430. console.log('没有图片尺寸,使用默认值');
  431. this.imageWidth = 1000;
  432. this.imageHeight = 1000;
  433. }
  434. try {
  435. // 根据原图宽度计算缩放比例
  436. let scaleRatio;
  437. if (this.imageWidth >= 5000) {
  438. scaleRatio = 1;
  439. } else if (this.imageWidth >= 4000) {
  440. scaleRatio = 1;
  441. } else {
  442. scaleRatio = 1;
  443. }
  444. // 处理label参数,将单引号替换为双引号
  445. let labelStr = this.currentImg.label;
  446. labelStr = labelStr.replace(/'/g, '"');
  447. console.log(labelStr,'labelStrlabelStr')
  448. const label = JSON.parse(labelStr);
  449. const markers = [];
  450. console.log('原图宽度:', this.imageWidth, '缩放比例:', scaleRatio);
  451. label.forEach(item => {
  452. for (let key in item) {
  453. const [x1, y1, x2, y2] = item[key];
  454. // 使用缩放比例计算标记位置和尺寸
  455. const x = (x1 * scaleRatio / this.imageWidth) * 100;
  456. const y = (y1 * scaleRatio / this.imageHeight) * 100;
  457. const width = ((x2 - x1) * scaleRatio / this.imageWidth) * 100;
  458. const height = ((y2 - y1) * scaleRatio / this.imageHeight) * 100;
  459. // 从字典中获取虫子名字(尝试字符串和数字两种类型)
  460. const pestName = this.pestDict[key] || this.pestDict[String(key)] || key;
  461. const color = this.getPestColor(pestName);
  462. markers.push({
  463. id: pestName, // 显示虫子名字
  464. x,
  465. y,
  466. width,
  467. height,
  468. color
  469. });
  470. }
  471. });
  472. this.bugMarkers = markers;
  473. } catch (error) {
  474. console.error('处理label参数失败:', error);
  475. this.bugMarkers = [];
  476. }
  477. } else {
  478. // this.pestList = [];
  479. const markers = [];
  480. // 根据原图宽度计算缩放比例
  481. let scaleRatio = 3.1;
  482. // if (this.imageWidth >= 5000) {
  483. // scaleRatio = 4;
  484. // } else if (this.imageWidth >= 4000) {
  485. // scaleRatio = 1;
  486. // } else {
  487. // scaleRatio = 2.5;
  488. // }
  489. // const pestArr = new Map()
  490. this.currentImg.mark.map((item, index) => {
  491. // if(pestArr.has(item.text)){
  492. // pestArr.set(item.text,{
  493. // value: pestArr.get(item.text).value+=1,
  494. // text: item.text
  495. // })
  496. // }else{
  497. // pestArr.set(item.text, {
  498. // value: 1,
  499. // text: item.text
  500. // })
  501. // }
  502. // const pestList = []
  503. // for(let key of pestArr){
  504. // pestList.push(key)
  505. // }
  506. // this.pestList = pestList
  507. this.is_mark = 1
  508. const { startX, startY,text } = item;
  509. // 使用缩放比例计算标记位置和尺寸
  510. const x = item.width > 0 ? (startX * scaleRatio / this.imageWidth) * 105 : ((startX + item.width) * scaleRatio / this.imageWidth) * 105;
  511. const y = item.height > 0 ? (startY * scaleRatio / this.imageHeight) * 105 : ((startY + item.height) * scaleRatio / this.imageHeight) * 105;
  512. const width = (item.width > 0 ? item.width : -item.width) * scaleRatio / this.imageWidth * 100;
  513. const height = (item.height > 0 ? item.height : -item.height) * scaleRatio / this.imageHeight * 100;
  514. // 从字典中获取虫子名字(尝试字符串和数字两种类型)
  515. const pestName = text;
  516. const color = this.getPestColor(text);
  517. markers.push({
  518. id: pestName, // 显示虫子名字
  519. x,
  520. y,
  521. width,
  522. height,
  523. color
  524. });
  525. });
  526. this.bugMarkers = markers;
  527. }
  528. },
  529. handleBack() {
  530. uni.navigateBack({
  531. delta: 1
  532. });
  533. },
  534. goBack() {
  535. uni.navigateBack();
  536. },
  537. selectThumbnail(item) {
  538. this.img_id = item.ids;
  539. this.getDevicePhotoDetails();
  540. }
  541. }
  542. };
  543. </script>
  544. <style lang="scss" scoped>
  545. ::v-deep .u-calendar__action{
  546. display:flex;
  547. justify-content: space-between;
  548. }
  549. ::v-deep .u-hover-class{
  550. .u-calendar__content__item__inner{
  551. color:#aaa !important;
  552. }
  553. }
  554. .device-photo-page {
  555. background-color: #F5F5F5;
  556. min-height: 100vh;
  557. width: 100%;
  558. padding-top: 112rpx;
  559. background: linear-gradient(180deg, #ffffff00 0%, #F5F6FA 23.64%, #F5F6FA 100%), linear-gradient(102deg, #BFEADD 6.77%, #B8F1E7 40.15%, #B9EEF5 84.02%);
  560. .device-detail__header {
  561. width: 100%;
  562. font-size: 28rpx;
  563. color: #999;
  564. color: #042118;
  565. font-family: 'Source Han Sans CN VF';
  566. font-weight: 700;
  567. position: relative;
  568. text-align: center;
  569. .arrow-left {
  570. position: absolute;
  571. left: 32rpx;
  572. margin-right: 12rpx;
  573. }
  574. }
  575. /* 顶部导航栏 */
  576. .nav-bar {
  577. display: flex;
  578. align-items: center;
  579. justify-content: space-between;
  580. padding: 24rpx;
  581. background-color: #E6F7EF;
  582. .nav-left {
  583. .back-icon {
  584. font-size: 36rpx;
  585. color: #042118;
  586. }
  587. }
  588. .nav-title {
  589. font-size: 32rpx;
  590. font-weight: 700;
  591. color: #042118;
  592. }
  593. .nav-right {
  594. display: flex;
  595. align-items: center;
  596. .more-icon {
  597. font-size: 32rpx;
  598. color: #042118;
  599. margin-right: 24rpx;
  600. }
  601. .eye-icon {
  602. font-size: 32rpx;
  603. }
  604. }
  605. }
  606. .date-container{
  607. padding: 0 20rpx;
  608. display: flex;
  609. align-items: center;
  610. justify-content: center;
  611. .select-year{
  612. width: 150rpx;
  613. height: 80rpx;
  614. display: flex;
  615. align-items: center;
  616. justify-content: space-around;
  617. color: #656565;
  618. font-size: 26rpx;
  619. line-height: 80rpx;
  620. text-align: center;
  621. border-radius: 48rpx;
  622. background-color: #FFFFFF;
  623. margin-right: 10rpx;
  624. padding: 0 26rpx;
  625. .select-year-item{
  626. width: 100%;
  627. display: flex;
  628. align-items: center;
  629. justify-content: space-around;
  630. }
  631. }
  632. }
  633. /* 日期选择器 */
  634. .date-picker {
  635. display: flex;
  636. align-items: center;
  637. padding: 20rpx 24rpx;
  638. background-color: #FFFFFF;
  639. margin-bottom: 24rpx;
  640. width: 100%;
  641. margin:20rpx auto;
  642. border-radius: 48rpx;
  643. position: relative;
  644. .date-input {
  645. display: flex;
  646. flex-direction: column;
  647. width: 100%;
  648. text-align: center;
  649. .date-label {
  650. font-size: 24rpx;
  651. color: #999999;
  652. margin-bottom: 8rpx;
  653. }
  654. .date-value {
  655. font-size: 28rpx;
  656. color: #042118;
  657. font-weight: 500;
  658. }
  659. }
  660. .calendar {
  661. position: absolute;
  662. right: 24rpx;
  663. top: 50%;
  664. transform: translateY(-50%);
  665. font-size: 32rpx;
  666. color: #999999;
  667. }
  668. .date-separator {
  669. margin: 0 24rpx;
  670. font-size: 28rpx;
  671. color: #999999;
  672. }
  673. }
  674. /* 主图片区域 */
  675. .main-photo {
  676. position: relative;
  677. margin: 0 24rpx 24rpx;
  678. background-color: #FFFFFF;
  679. border-radius: 16rpx;
  680. padding: 0;
  681. overflow: hidden;
  682. .movable-area {
  683. width: 100%;
  684. overflow: hidden;
  685. }
  686. .movable-view {
  687. width: 100%;
  688. }
  689. .image-container {
  690. position: relative;
  691. width: 100%;
  692. }
  693. .main-photo-image {
  694. width: 100%;
  695. display: block;
  696. }
  697. /* 虫子标记层 */
  698. .bug-markers {
  699. position: absolute;
  700. top: 0;
  701. left: 0;
  702. width: 100%;
  703. height: 100%;
  704. pointer-events: none;
  705. }
  706. /* 虫子标记 */
  707. .bug-marker {
  708. position: absolute;
  709. border: 2rpx solid;
  710. border-radius: 4rpx;
  711. }
  712. /* 虫子标记标签 */
  713. .bug-label {
  714. position: absolute;
  715. top: -24rpx;
  716. left: 0;
  717. padding: 2rpx 6rpx;
  718. border-radius: 4rpx;
  719. font-size: 20rpx;
  720. color: white;
  721. white-space: nowrap;
  722. }
  723. /* 虫子标记层 */
  724. .bug-markers {
  725. position: absolute;
  726. top: 0;
  727. left: 0;
  728. width: 100%;
  729. height: 100%;
  730. pointer-events: none;
  731. }
  732. /* 虫子标记 */
  733. .bug-marker {
  734. position: absolute;
  735. border: 2rpx solid;
  736. border-radius: 4rpx;
  737. pointer-events: auto;
  738. }
  739. /* 虫子标记标签 */
  740. .bug-label {
  741. position: absolute;
  742. top: -30rpx;
  743. left: 0;
  744. padding: 4rpx 8rpx;
  745. border-radius: 4rpx;
  746. font-size: 20rpx;
  747. font-weight: bold;
  748. }
  749. .photo-timestamp {
  750. position: absolute;
  751. bottom: 0rpx;
  752. left: 0rpx;
  753. width:100%;
  754. background-color: rgba(0, 0, 0, 0.6);
  755. color: #FFFFFF;
  756. padding: 8rpx 16rpx;
  757. border-radius: 8rpx;
  758. font-size: 24rpx;
  759. }
  760. }
  761. /* 缩略图预览 */
  762. .thumbnail-preview {
  763. margin: 0 24rpx 24rpx;
  764. .thumbnail-scroll {
  765. gap: 16rpx;
  766. padding-bottom: 16rpx;
  767. box-sizing: border-box;
  768. white-space: nowrap;
  769. overflow-x: auto;
  770. overflow-y: hidden;
  771. width: 100%;
  772. // 隐藏滚动条
  773. -ms-overflow-style: none;
  774. scrollbar-width: none;
  775. .thumbnail-item {
  776. width: 120rpx;
  777. height: 120rpx;
  778. border-radius: 8rpx;
  779. overflow: hidden;
  780. border: 2rpx solid transparent;
  781. display: inline-block;
  782. box-sizing: border-box;
  783. margin-right: 10rpx;
  784. &.active {
  785. border-color: #0BBC58;
  786. }
  787. .thumbnail-image {
  788. width: 100%;
  789. height: 100%;
  790. object-fit: cover;
  791. }
  792. }
  793. }
  794. }
  795. /* 识别结果 */
  796. .recognition-result {
  797. margin: 0 24rpx 24rpx;
  798. background-color: #FFFFFF;
  799. border-radius: 16rpx;
  800. padding: 24rpx;
  801. .result-title {
  802. font-size: 28rpx;
  803. font-weight: 700;
  804. color: #042118;
  805. margin-bottom: 24rpx;
  806. }
  807. /* 害虫类别 */
  808. .pest-category {
  809. margin-bottom: 32rpx;
  810. border: 1px solid #E4E7ED;
  811. border-radius: 16rpx;
  812. &:last-child {
  813. margin-bottom: 0;
  814. }
  815. .category-header {
  816. display: flex;
  817. justify-content: space-between;
  818. margin-bottom: 16rpx;
  819. background: #F6F8FC;
  820. padding: 18rpx 24rpx;
  821. .category-title {
  822. font-size: 24rpx;
  823. font-weight: 500;
  824. color: #042118;
  825. }
  826. .category-count {
  827. font-size: 24rpx;
  828. color: #999999;
  829. }
  830. }
  831. .pest-item {
  832. display: flex;
  833. justify-content: space-between;
  834. align-items: center;
  835. margin-bottom: 12rpx;
  836. padding: 6rpx 24rpx;
  837. &:last-child {
  838. margin-bottom: 0;
  839. }
  840. .pest-info {
  841. display: flex;
  842. align-items: center;
  843. .pest-color {
  844. width: 16rpx;
  845. height: 16rpx;
  846. border-radius: 50%;
  847. margin-right: 12rpx;
  848. }
  849. .pest-name {
  850. font-size: 24rpx;
  851. color: #042118;
  852. }
  853. }
  854. .pest-count {
  855. font-size: 24rpx;
  856. color: #042118;
  857. }
  858. }
  859. }
  860. }
  861. }
  862. </style>