feat: 新增工具脚本用于批量下载蔬菜水果分类实拍图并更新数据库

新增3个工具脚本:
1. check_cats.py - 检查分类数据
2. list_all_veg_fruit.py - 列出所有蔬菜水果分类
3. verify_all.php - 验证分类图片完整性
4. download_real_photos.py - 批量下载蔬菜水果真实实拍图,裁剪为240x240,同步更新数据库和uniapp静态资源
这个提交包含在:
2026-10-29 08:28:52 +08:00
父节点 f332dfd2b0
当前提交 66b9abe089
共有 167 个文件被更改,包括 703 次插入 和 25 次删除

查看文件

@@ -422,6 +422,30 @@
</view>
</view>
<!-- 二级分类搜索输入栏(支持快速搜索细分品类) -->
<view v-if="catDrawerStep === 2" class="cat-drawer__search-box">
<view class="cat-drawer__search-bar">
<view class="cat-drawer__search-icon">
<view class="cat-drawer__search-lens"></view>
</view>
<input
class="cat-drawer__search-input"
v-model="catSearchKeyword"
type="text"
confirm-type="search"
:placeholder="searchPlaceholder"
placeholder-class="cat-drawer__search-ph"
/>
<view
v-if="catSearchKeyword"
class="cat-drawer__search-clear"
@click="clearCatSearch"
>
<text class="cat-drawer__search-clear-txt">✕</text>
</view>
</view>
</view>
<scroll-view class="cat-drawer__body" scroll-y :show-scrollbar="false">
<!-- 第一步:选择一级大类(蔬菜 / 水果),大图卡片便于「看图识物」 -->
<view v-if="catDrawerStep === 1" class="cat-drawer__grid cat-drawer__grid--parent">
@@ -442,35 +466,53 @@
</view>
</view>
<!-- 第二步:选择该大类下的二级品类(花菜、白菜、紫甘蓝、青甘蓝、青菜等,大图为主文字辅助) -->
<view v-else class="cat-drawer__grid">
<view
v-if="!drawerSubCategories.length"
class="cat-drawer__item cat-drawer__item--active"
@click="onSelectDrawerParentOnly"
>
<view class="cat-drawer__cover-box">
<image class="cat-drawer__cover" :src="catIcon(currentCat || {})" mode="aspectFit" />
<!-- 第二步:选择该大类下的二级品类(大图实拍为主,文字辅助) -->
<view v-else>
<!-- 无搜索词且分类下原本无二级分类时 -->
<view v-if="!catSearchKeyword && !drawerSubCategories.length" class="cat-drawer__grid">
<view
class="cat-drawer__item cat-drawer__item--active"
@click="onSelectDrawerParentOnly"
>
<view class="cat-drawer__cover-box">
<image class="cat-drawer__cover" :src="catIcon(currentCat || {})" mode="aspectFit" />
</view>
<view class="cat-drawer__caption">
<text class="cat-drawer__name">全部</text>
</view>
<view class="cat-drawer__check">✓</view>
</view>
<view class="cat-drawer__caption">
<text class="cat-drawer__name">全部</text>
</view>
<view class="cat-drawer__check">✓</view>
</view>
<view
v-for="sub in drawerSubCategories"
:key="sub.id"
class="cat-drawer__item"
:class="{ 'cat-drawer__item--active': Number(form.subCategoryId) === Number(sub.id) }"
@click="onSelectDrawerSubCat(sub)"
>
<view class="cat-drawer__cover-box">
<image class="cat-drawer__cover" :src="catIcon(sub)" mode="aspectFill" />
<!-- 搜索无匹配结果时的轻量优雅空状态 -->
<view v-else-if="filteredDrawerSubCategories.length === 0" class="cat-drawer__empty">
<view class="cat-drawer__empty-circle">
<view class="cat-drawer__empty-lens"></view>
</view>
<view class="cat-drawer__caption">
<text class="cat-drawer__name">{{ sub.name }}</text>
<text class="cat-drawer__empty-title">未找到相关品类</text>
<text class="cat-drawer__empty-tip">未搜索到匹配项,可清空搜索词查看全部</text>
<view class="cat-drawer__empty-btn" @click="clearCatSearch">
<text class="cat-drawer__empty-btn-txt">清除搜索词</text>
</view>
</view>
<!-- 二级品类网格列表 -->
<view v-else class="cat-drawer__grid">
<view
v-for="sub in filteredDrawerSubCategories"
:key="sub.id"
class="cat-drawer__item"
:class="{ 'cat-drawer__item--active': Number(form.subCategoryId) === Number(sub.id) }"
@click="onSelectDrawerSubCat(sub)"
>
<view class="cat-drawer__cover-box">
<image class="cat-drawer__cover" :src="catIcon(sub)" mode="aspectFill" />
</view>
<view class="cat-drawer__caption">
<text class="cat-drawer__name">{{ sub.name }}</text>
</view>
<view v-if="Number(form.subCategoryId) === Number(sub.id)" class="cat-drawer__check">✓</view>
</view>
<view v-if="Number(form.subCategoryId) === Number(sub.id)" class="cat-drawer__check">✓</view>
</view>
</view>
<view class="cat-drawer__space"></view>
@@ -527,6 +569,7 @@ export default {
catDrawerAnim: false,
// 分类两步选择:1 = 选一级大类,2 = 选二级品类
catDrawerStep: 1,
catSearchKeyword: '', // 分类抽屉搜索关键词
selectedAllSubCat: false, // 是否显式选中全部二级品类
customTagInput: '',
outputRangeOptions: [
@@ -714,6 +757,27 @@ export default {
drawerSubCategories() {
return (this.currentCat && Array.isArray(this.currentCat.children)) ? this.currentCat.children : []
},
/**
* 分类抽屉搜索框占位提示文本
* @returns {string}
*/
searchPlaceholder() {
const catName = this.currentCat ? this.currentCat.name.replace('专区', '') : ''
return catName ? `搜索${catName}品类,如${catName === '蔬菜' ? '黄瓜、土豆' : (catName === '水果' ? '苹果、西瓜' : '品类名称')}…` : '输入品类名称快速搜索…'
},
/**
* 分类抽屉根据关键词过滤后的二级品类列表
* @returns {Array}
*/
filteredDrawerSubCategories() {
const list = this.drawerSubCategories || []
const kw = (this.catSearchKeyword || '').trim().toLowerCase()
if (!kw) return list
return list.filter((item) => {
const name = (item.name || '').toLowerCase()
return name.includes(kw)
})
},
/**
* 分类抽屉标题(随打开的输入行切换)
* @returns {string}
@@ -1174,6 +1238,7 @@ export default {
uni.showToast({ title: '请先选择大类', icon: 'none' })
return
}
this.catSearchKeyword = ''
this.catDrawerStep = Number(step) === 2 ? 2 : 1
this.catDrawerVisible = true
setTimeout(() => {
@@ -1187,8 +1252,15 @@ export default {
this.catDrawerAnim = false
setTimeout(() => {
this.catDrawerVisible = false
this.catSearchKeyword = ''
}, 200)
},
/**
* 清空分类抽屉搜索输入框
*/
clearCatSearch() {
this.catSearchKeyword = ''
},
/**
* 选择一级大类(蔬菜 / 水果等),选中即回填并关闭
* @param {Object} c 一级大类对象
@@ -2577,6 +2649,163 @@ export default {
height: 40rpx;
}
/* 二级分类抽屉搜索框 */
.cat-drawer__search-box {
padding: 16rpx 32rpx 12rpx;
background: #ffffff;
border-bottom: 1rpx solid #f0f4f2;
}
.cat-drawer__search-bar {
display: flex;
align-items: center;
height: 76rpx;
padding: 0 24rpx;
background: #f4faf6;
border: 2rpx solid #d6f2e2;
border-radius: 38rpx;
transition: all 0.2s ease;
&:focus-within {
background: #ffffff;
border-color: #00d26a;
box-shadow: 0 4rpx 16rpx rgba(0, 210, 106, 0.12);
}
}
.cat-drawer__search-icon {
width: 32rpx;
height: 32rpx;
display: flex;
align-items: center;
justify-content: center;
margin-right: 12rpx;
flex-shrink: 0;
}
/* 纯 CSS 矢量轻氧绿放大镜(严禁 Emoji) */
.cat-drawer__search-lens {
width: 22rpx;
height: 22rpx;
border: 3rpx solid #00a854;
border-radius: 50%;
position: relative;
box-sizing: border-box;
&::after {
content: '';
position: absolute;
width: 3rpx;
height: 10rpx;
background: #00a854;
bottom: -6rpx;
right: -5rpx;
transform: rotate(-45deg);
border-radius: 2rpx;
}
}
.cat-drawer__search-input {
flex: 1;
height: 100%;
font-size: 26rpx;
color: #1e293b;
}
.cat-drawer__search-ph {
font-size: 24rpx;
color: #94a3b8;
}
.cat-drawer__search-clear {
width: 44rpx;
height: 44rpx;
border-radius: 50%;
background: #e2e8f0;
display: flex;
align-items: center;
justify-content: center;
margin-left: 10rpx;
cursor: pointer;
flex-shrink: 0;
}
.cat-drawer__search-clear-txt {
font-size: 20rpx;
color: #64748b;
line-height: 1;
}
/* 搜索结果为空状态 */
.cat-drawer__empty {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 80rpx 40rpx;
}
.cat-drawer__empty-circle {
width: 100rpx;
height: 100rpx;
border-radius: 50%;
background: #f0fdf4;
border: 2rpx dashed #bbf7d0;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 24rpx;
}
.cat-drawer__empty-lens {
width: 36rpx;
height: 36rpx;
border: 4rpx solid #86efac;
border-radius: 50%;
position: relative;
box-sizing: border-box;
&::after {
content: '';
position: absolute;
width: 4rpx;
height: 14rpx;
background: #86efac;
bottom: -9rpx;
right: -7rpx;
transform: rotate(-45deg);
border-radius: 2rpx;
}
}
.cat-drawer__empty-title {
font-size: 28rpx;
font-weight: 600;
color: #334155;
margin-bottom: 8rpx;
}
.cat-drawer__empty-tip {
font-size: 22rpx;
color: #94a3b8;
margin-bottom: 28rpx;
text-align: center;
}
.cat-drawer__empty-btn {
padding: 12rpx 32rpx;
background: #f2fef7;
border: 2rpx solid #00d26a;
border-radius: 30rpx;
cursor: pointer;
}
.cat-drawer__empty-btn-txt {
font-size: 24rpx;
font-weight: 600;
color: #00a854;
}
/* ================= 付费发布底部收银台弹窗 ================= */
.create__cashier-mask {
position: fixed;