devicePhoto.vue 24 KB

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