devicePhoto.vue 24 KB

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