|
|
@@ -12,24 +12,31 @@
|
|
|
</view>
|
|
|
|
|
|
<!-- 日期选择器 -->
|
|
|
- <view class="date-picker">
|
|
|
- <view class="date-input">
|
|
|
- <text class="date-label">开始日期</text>
|
|
|
- </view>
|
|
|
- <view class="date-separator">-</view>
|
|
|
- <view class="date-input">
|
|
|
- <text class="date-label">结束日期</text>
|
|
|
- </view>
|
|
|
- <u-icon name="calendar" class="calendar"></u-icon>
|
|
|
+ <view class="date-container">
|
|
|
+ <view class="select-year">
|
|
|
+ <view class="select-year-item" @click="showPicker = true">
|
|
|
+ {{ currentYear }}
|
|
|
+ <u-icon name="arrow-down" size="18" class="arrow-down"></u-icon>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view class="date-picker" @click="show = true">
|
|
|
+ <view class="date-input">
|
|
|
+ <text class="date-label">{{ time_begin || '-' }}</text>
|
|
|
+ </view>
|
|
|
+ <view class="date-separator">-</view>
|
|
|
+ <view class="date-input">
|
|
|
+ <text class="date-label">{{ time_end || '-' }}</text>
|
|
|
+ </view>
|
|
|
+ <u-icon name="calendar" class="calendar"></u-icon>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
-
|
|
|
<!-- 主图片区域 -->
|
|
|
<view class="main-photo">
|
|
|
<image
|
|
|
- src="https://trae-api-cn.mchost.guru/api/ide/v1/text_to_image?prompt=insects%20on%20a%20white%20surface%20with%20markers&image_size=portrait_4_3"
|
|
|
+ :src="currentImg.addr"
|
|
|
class="main-photo-image"
|
|
|
/>
|
|
|
- <view class="photo-timestamp">2025-12-28 08:00:00</view>
|
|
|
+ <view class="photo-timestamp">{{ formatDate(currentImg.addtime) }}</view>
|
|
|
</view>
|
|
|
|
|
|
<!-- 缩略图预览 -->
|
|
|
@@ -39,11 +46,11 @@
|
|
|
class="thumbnail-item"
|
|
|
v-for="(item, index) in thumbnails"
|
|
|
:key="index"
|
|
|
- :class="{ active: index === currentThumbnail }"
|
|
|
- @click="selectThumbnail(index)"
|
|
|
+ :class="{ active: img_id == item.ids }"
|
|
|
+ @click="selectThumbnail(item)"
|
|
|
>
|
|
|
<image
|
|
|
- :src="item.src"
|
|
|
+ :src="item.addr"
|
|
|
class="thumbnail-image"
|
|
|
/>
|
|
|
</view>
|
|
|
@@ -55,50 +62,22 @@
|
|
|
<view class="result-title">当前图片识别结果</view>
|
|
|
|
|
|
<!-- 一类害虫 -->
|
|
|
- <view class="pest-category">
|
|
|
+ <view class="pest-category" v-for="(pest,index) in pestList" :key="index">
|
|
|
<view class="category-header">
|
|
|
- <text class="category-title">一类害虫</text>
|
|
|
+ <text class="category-title">{{ pest[0] }}</text>
|
|
|
<text class="category-count">数量</text>
|
|
|
</view>
|
|
|
- <view class="pest-item" v-for="(pest, index) in category1Pests" :key="index">
|
|
|
+ <view class="pest-item" v-for="(p, i) in pest[1]" :key="i">
|
|
|
<view class="pest-info">
|
|
|
- <view class="pest-color" :style="{ backgroundColor: pest.color }"></view>
|
|
|
- <text class="pest-name">{{ pest.name }}</text>
|
|
|
+ <view class="pest-color" :style="{ backgroundColor: getRandomColor() }"></view>
|
|
|
+ <text class="pest-name">{{ p.pest_name }}</text>
|
|
|
</view>
|
|
|
- <text class="pest-count">{{ pest.count }}</text>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
-
|
|
|
- <!-- 二类害虫 -->
|
|
|
- <view class="pest-category">
|
|
|
- <view class="category-header">
|
|
|
- <text class="category-title">二类害虫</text>
|
|
|
- <text class="category-count">数量</text>
|
|
|
- </view>
|
|
|
- <view class="pest-item" v-for="(pest, index) in category2Pests" :key="index">
|
|
|
- <view class="pest-info">
|
|
|
- <view class="pest-color" :style="{ backgroundColor: pest.color }"></view>
|
|
|
- <text class="pest-name">{{ pest.name }}</text>
|
|
|
- </view>
|
|
|
- <text class="pest-count">{{ pest.count }}</text>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
-
|
|
|
- <!-- 三类害虫 -->
|
|
|
- <view class="pest-category">
|
|
|
- <view class="category-header">
|
|
|
- <text class="category-title">三类害虫</text>
|
|
|
- <text class="category-count">数量</text>
|
|
|
- </view>
|
|
|
- <view class="pest-item" v-for="(pest, index) in category3Pests" :key="index">
|
|
|
- <view class="pest-info">
|
|
|
- <view class="pest-color" :style="{ backgroundColor: pest.color }"></view>
|
|
|
- <text class="pest-name">{{ pest.name }}</text>
|
|
|
- </view>
|
|
|
- <text class="pest-count">{{ pest.count }}</text>
|
|
|
+ <text class="pest-count">{{ p.pest_num }}</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
+ <u-calendar v-model="show" :mode="mode" @change="handleChange" :max-date="maxDate" :min-date="minDate"></u-calendar>
|
|
|
+ <u-picker v-model="showPicker" mode="selector" :range="selectorRange" range-key="id" :default-selector="[0]" @confirm="confirmHandler"></u-picker>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
@@ -106,45 +85,185 @@
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
+ show: false,
|
|
|
+ mode: 'range',
|
|
|
+ maxDate: this.formatTime(new Date()),
|
|
|
+ minDate: this.formatTime(new Date(new Date().getFullYear(), 0, 1)),
|
|
|
+ showPicker: false,
|
|
|
+ selectorRange: [],
|
|
|
title: '查看图片',
|
|
|
currentThumbnail: 2,
|
|
|
- thumbnails: [
|
|
|
- { src: "https://trae-api-cn.mchost.guru/api/ide/v1/text_to_image?prompt=insects%20on%20white%20surface&image_size=square" },
|
|
|
- { src: "https://trae-api-cn.mchost.guru/api/ide/v1/text_to_image?prompt=insects%20on%20white%20surface&image_size=square" },
|
|
|
- { src: "https://trae-api-cn.mchost.guru/api/ide/v1/text_to_image?prompt=insects%20on%20white%20surface&image_size=square" },
|
|
|
- { src: "https://trae-api-cn.mchost.guru/api/ide/v1/text_to_image?prompt=insects%20on%20white%20surface&image_size=square" },
|
|
|
- { src: "https://trae-api-cn.mchost.guru/api/ide/v1/text_to_image?prompt=insects%20on%20white%20surface&image_size=square" },
|
|
|
- { src: "https://trae-api-cn.mchost.guru/api/ide/v1/text_to_image?prompt=insects%20on%20white%20surface&image_size=square" },
|
|
|
- { src: "https://trae-api-cn.mchost.guru/api/ide/v1/text_to_image?prompt=insects%20on%20white%20surface&image_size=square" },
|
|
|
- { src: "https://trae-api-cn.mchost.guru/api/ide/v1/text_to_image?prompt=insects%20on%20white%20surface&image_size=square" },
|
|
|
- { src: "https://trae-api-cn.mchost.guru/api/ide/v1/text_to_image?prompt=insects%20on%20white%20surface&image_size=square" },
|
|
|
- { src: "https://trae-api-cn.mchost.guru/api/ide/v1/text_to_image?prompt=insects%20on%20white%20surface&image_size=square" },
|
|
|
- { src: "https://trae-api-cn.mchost.guru/api/ide/v1/text_to_image?prompt=insects%20on%20white%20surface&image_size=square" },
|
|
|
- { src: "https://trae-api-cn.mchost.guru/api/ide/v1/text_to_image?prompt=insects%20on%20white%20surface&image_size=square" }
|
|
|
+ pestYype:{},
|
|
|
+ device_id: '',
|
|
|
+ time_begin: this.formatTime(new Date(new Date().getFullYear(), 0, 1)),
|
|
|
+ time_end: this.formatTime(new Date()),
|
|
|
+ img_id: '',
|
|
|
+ pest_list:[],
|
|
|
+ pestList:[],
|
|
|
+ colors:[
|
|
|
+ '#FF5951',
|
|
|
+ '#66EDED',
|
|
|
+ '#E67B3E',
|
|
|
+ '#6DE28B',
|
|
|
+ '#FFC97A',
|
|
|
+ '#E7EB4B',
|
|
|
+ '#1561F3',
|
|
|
+ '#FA73F5',
|
|
|
+ '#159AFF',
|
|
|
+ '#FA73F5'
|
|
|
],
|
|
|
- category1Pests: [
|
|
|
- { name: '蚜虫', color: '#FF9933', count: 3 },
|
|
|
- { name: '松墨天牛', color: '#FF3333', count: 3 },
|
|
|
- { name: '夜蛾', color: '#3366FF', count: 3 }
|
|
|
- ],
|
|
|
- category2Pests: [
|
|
|
- { name: '蚜虫', color: '#FF9933', count: 3 },
|
|
|
- { name: '松墨天牛', color: '#FF3333', count: 3 },
|
|
|
- { name: '夜蛾', color: '#3366FF', count: 3 }
|
|
|
- ],
|
|
|
- category3Pests: [
|
|
|
- { name: '蚜虫', color: '#FF9933', count: 3 },
|
|
|
- { name: '松墨天牛', color: '#FF3333', count: 3 },
|
|
|
- { name: '夜蛾', color: '#3366FF', count: 3 }
|
|
|
- ]
|
|
|
+ currentYear:'',
|
|
|
+ pest_list_arr:[],
|
|
|
+ thumbnails: [],
|
|
|
+ currentImg:{},
|
|
|
};
|
|
|
},
|
|
|
+ onLoad(options) {
|
|
|
+ const {id,img_id,currentYear} = options
|
|
|
+ this.device_id = id
|
|
|
+ this.img_id = img_id
|
|
|
+ this.currentYear = currentYear
|
|
|
+ this.time_begin = this.currentYear + '-01-01'
|
|
|
+ this.time_end = this.currentYear + '-12-31'
|
|
|
+ this.maxDate = this.formatTime(new Date())
|
|
|
+ this.minDate = this.formatTime(new Date(new Date().getFullYear(), 0, 1))
|
|
|
+ this.selectorRange = [];
|
|
|
+ const nowYear = new Date().getFullYear();
|
|
|
+ for(let i = 0;i<50;i++){
|
|
|
+ const item = {
|
|
|
+ label: nowYear - i,
|
|
|
+ id: nowYear - i
|
|
|
+ }
|
|
|
+ this.selectorRange.push(item);
|
|
|
+ }
|
|
|
+ this.getPestLevelMap();
|
|
|
+ this.getPestList();
|
|
|
+ this.getDevicePhotoDetails();
|
|
|
+ },
|
|
|
methods: {
|
|
|
+ confirmHandler(e){
|
|
|
+ this.currentYear = this.selectorRange[e].id;
|
|
|
+ if(this.currentYear == new Date().getFullYear()){
|
|
|
+ this.time_begin = this.formatTime(new Date(new Date().getFullYear(), 0, 1));
|
|
|
+ this.time_end = this.formatTime(new Date());
|
|
|
+ this.maxDate = this.formatTime(new Date());
|
|
|
+ this.minDate = this.formatTime(new Date(new Date().getFullYear(), 0, 1));
|
|
|
+ }else{
|
|
|
+ this.time_begin = this.formatTime(new Date(this.currentYear, 0, 1));
|
|
|
+ this.time_end = this.formatTime(new Date(this.currentYear, 11, 31));
|
|
|
+ this.maxDate = this.formatTime(new Date(this.currentYear, 11, 31));
|
|
|
+ this.minDate = this.formatTime(new Date(this.currentYear, 0, 1));
|
|
|
+ }
|
|
|
+ this.showPicker = false;
|
|
|
+ },
|
|
|
+ handleChange(e){
|
|
|
+ console.log(e,'e')
|
|
|
+ this.time_begin = e.startDate;
|
|
|
+ this.time_begin = e.endDate;
|
|
|
+ this.getPestList()
|
|
|
+ },
|
|
|
+ getRandomColor(){
|
|
|
+ return this.colors[Math.floor(Math.random() * this.colors.length)]
|
|
|
+ },
|
|
|
+ getLevelDisplayName(level) {
|
|
|
+ const levelMap = {
|
|
|
+ '-1': '其他害虫',
|
|
|
+ 1: '一类害虫',
|
|
|
+ 2: '二类害虫',
|
|
|
+ 3: '三类害虫',
|
|
|
+ 4: '四类害虫',
|
|
|
+ 5: '五类害虫'
|
|
|
+ };
|
|
|
+ return levelMap[String(level)] || `${level}`;
|
|
|
+ },
|
|
|
+ async getPestList() {
|
|
|
+ const res = await this.$myRequest({
|
|
|
+ url: '/api/api_gateway?method=forecast.new_cbd.photo_list',
|
|
|
+ method: 'POST',
|
|
|
+ data: {
|
|
|
+ identify_model:'B',
|
|
|
+ cmd:'cbd',
|
|
|
+ time_begin: this.time_begin + ' 00:00:00',
|
|
|
+ time_end: this.time_end + ' 23:59:59',
|
|
|
+ identify_model:'B',
|
|
|
+ device_id: this.device_id,
|
|
|
+ },
|
|
|
+ });
|
|
|
+ this.thumbnails = res?.data || [];
|
|
|
+ console.log(this.thumbnails,'resres2222res')
|
|
|
+ },
|
|
|
+ formatTime(dateString) {
|
|
|
+ const date = new Date(dateString);
|
|
|
+ const year = date.getFullYear();
|
|
|
+ const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
|
+ const day = String(date.getDate()).padStart(2, '0');
|
|
|
+ return `${year}-${month}-${day}`;
|
|
|
+ },
|
|
|
+ async getPestLevelMap() {
|
|
|
+ const res = await this.$myRequest({
|
|
|
+ url: '/api/api_gateway?method=forecast.new_cbd.pest_level_map',
|
|
|
+ method: 'POST',
|
|
|
+ });
|
|
|
+ const pestYype = {}
|
|
|
+ for(let key in res){
|
|
|
+ pestYype[this.getLevelDisplayName(key)] = res[key]
|
|
|
+ }
|
|
|
+ this.pestYype = pestYype
|
|
|
+ },
|
|
|
+ formatDate(dateString) {
|
|
|
+ const date = new Date(dateString*1000);
|
|
|
+ const year = date.getFullYear();
|
|
|
+ const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
|
+ const day = String(date.getDate()).padStart(2, '0');
|
|
|
+ const hour = String(date.getHours()).padStart(2, '0');
|
|
|
+ const minute = String(date.getMinutes()).padStart(2, '0');
|
|
|
+ const second = String(date.getSeconds()).padStart(2, '0');
|
|
|
+ return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
|
|
|
+ },
|
|
|
+ async getDevicePhotoDetails() {
|
|
|
+ const res = await this.$myRequest({
|
|
|
+ url: '/api/api_gateway?method=forecast.forecast_system.device_photo_details',
|
|
|
+ method: 'POST',
|
|
|
+ data: {
|
|
|
+ identify_model:'B',
|
|
|
+ cmd:'cbd',
|
|
|
+ img_id: this.img_id,
|
|
|
+ },
|
|
|
+ });
|
|
|
+ this.currentImg = res;
|
|
|
+ const pest_list = res.pest_list
|
|
|
+ const pestArr = new Map()
|
|
|
+ for(let key in this.pestYype){
|
|
|
+ for(let j in this.pestYype[key]){
|
|
|
+ const pestName = this.pestYype[key][j]
|
|
|
+ pest_list.forEach(item => {
|
|
|
+ if(item.pest_name == pestName){
|
|
|
+ if(pestArr.has(item.level)){
|
|
|
+ pestArr.get(key).push(item)
|
|
|
+ }else{
|
|
|
+ pestArr.set(key, [item])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const pestList = []
|
|
|
+ for(let key of pestArr){
|
|
|
+ pestList.push(key)
|
|
|
+ }
|
|
|
+ this.pestList = pestList
|
|
|
+ },
|
|
|
+ handleBack() {
|
|
|
+ uni.navigateBack({
|
|
|
+ delta: 1
|
|
|
+ });
|
|
|
+ },
|
|
|
goBack() {
|
|
|
uni.navigateBack();
|
|
|
},
|
|
|
- selectThumbnail(index) {
|
|
|
- this.currentThumbnail = index;
|
|
|
+ selectThumbnail(item) {
|
|
|
+ this.img_id = item.ids;
|
|
|
+ this.getDevicePhotoDetails();
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
@@ -209,7 +328,33 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ .date-container{
|
|
|
+ padding: 0 20rpx;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ .select-year{
|
|
|
+ width: 150rpx;
|
|
|
+ height: 80rpx;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-around;
|
|
|
+ color: #656565;
|
|
|
+ font-size: 26rpx;
|
|
|
+ line-height: 80rpx;
|
|
|
+ text-align: center;
|
|
|
+ border-radius: 48rpx;
|
|
|
+ background-color: #FFFFFF;
|
|
|
+ margin-right: 10rpx;
|
|
|
+ padding: 0 26rpx;
|
|
|
+ .select-year-item{
|
|
|
+ width: 100%;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-around;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
/* 日期选择器 */
|
|
|
.date-picker {
|
|
|
display: flex;
|