devicePhoto.vue 25 KB

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