From a88d8c7d3df6990a16789fba87ef786e8faca0b4 Mon Sep 17 00:00:00 2001 From: Lj <1095098147@qq.com> Date: Sat, 5 Jul 2025 16:43:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9B=9E=E6=94=B6=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=EF=BC=9A=E7=8E=B0=E5=9C=A8=E5=95=86=E5=93=81=E6=AF=8F?= =?UTF-8?q?=E4=B8=AA=E9=83=BD=E4=BC=9A=E5=BC=B9=E5=87=BA=E5=93=81=E7=89=8C?= =?UTF-8?q?=E9=80=89=E6=8B=A9=EF=BC=8C=E6=B2=A1=E6=9C=89isPin=3DY=E7=9A=84?= =?UTF-8?q?=E5=95=86=E5=93=81=E4=B8=8D=E9=9C=80=E8=A6=81=E5=BC=B9=E5=87=BA?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E4=B8=94=E5=93=81=E7=89=8C=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=E6=B2=A1=E6=9C=89=E5=93=81=E7=89=8C?= =?UTF-8?q?=E7=9A=84=E5=AD=97=E6=AF=8D=E4=B8=8D=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/component/recycle.vue | 103 +++++++++++++++++++++++++++++++------------- pages/manager/inspect.vue | 14 +++--- 2 files changed, 80 insertions(+), 37 deletions(-) diff --git a/pages/component/recycle.vue b/pages/component/recycle.vue index 97e87fb..07cd2e1 100644 --- a/pages/component/recycle.vue +++ b/pages/component/recycle.vue @@ -378,7 +378,6 @@ export default { }, brandList: [], brandCache: {}, // 为每个商品缓存品牌信息 { productId: [brandList] } - brandIndexList: ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'], currentLetter: 'A', scrollToView: '', brandSearch: '', @@ -579,7 +578,18 @@ export default { max: maxExtra.toFixed(2), display: `${minExtra.toFixed(2)}-${maxExtra.toFixed(2)}元` }; - } + }, + // 动态生成品牌字母索引,只显示有品牌的字母 + brandIndexList() { + const set = new Set() + this.brandList.forEach(b => { + if (b.letter && /^[A-Z]$/.test(b.letter)) set.add(b.letter) + }) + const arr = Array.from(set).sort() + // 如果没有A-Z分组,兜底显示#分组 + if (arr.length === 0 && this.brandList.length > 0) return ['#'] + return arr + }, }, methods: { showPriceInfoPopups() { @@ -688,13 +698,23 @@ export default { } // 品牌商品且数量为0且加一时 - if ((item.quantity || 0) === 0 && delta > 0) { + if (item.isPin === 'Y' && (item.quantity || 0) === 0 && delta > 0) { this.pendingBrandIndex = index this.isWaitingForBrandSelection = true; this.showRules(item); // 先显示回收规则 return } - + // 无品牌商品,数量为0且加一时,也弹规则,确认后再加数量 + if (item.isPin !== 'Y' && (item.quantity || 0) === 0 && delta > 0) { + this.pendingBrandIndex = index + this.isWaitingForBrandSelection = false; // 标记为无品牌 + this.showRules(item) + return + } + // 其它情况直接加数量 + let newQuantity = (item.quantity || 0) + delta + if (newQuantity < 0) newQuantity = 0 + this.$set(item, 'quantity', newQuantity) }, // 选择要减少的品牌 selectReduceBrand(brandInfo) { @@ -739,27 +759,42 @@ export default { }, // 显示回收规则 showRules(item) { - // 检查该商品是否已经查看过规则 - if (this.viewedRuleItems.has(item.id)) { - // 如果已经查看过,直接跳过规则弹窗,进入品牌选择 - this.isWaitingForBrandSelection = false; - this.getGoodsBrandList(item.id); - this.showBrandPopup = true; - return; - } - - // 重置滚动状态 - this.hasScrolledToBottom = false; - - // 获取回收规则富文本 - this.$api('getGoodsRecycleRule', { goodsId: item.id }, res => { - if (res.code === 200 && res.result) { - this.ruleHtml = res.result - } else { - this.ruleHtml = '
暂无回收规则
' + // isPin=Y: 弹规则,读到底部后自动弹品牌;isPin=N: 只弹规则 + if (item.isPin === 'Y') { + // 检查该商品是否已经查看过规则 + if (this.viewedRuleItems.has(item.id)) { + // 如果已经查看过,直接跳过规则弹窗,进入品牌选择 + this.isWaitingForBrandSelection = false; + this.getGoodsBrandList(item.id); + this.showBrandPopup = true; + return; } - this.showRulePopup = true - }) + // 重置滚动状态 + this.hasScrolledToBottom = false; + // 获取回收规则富文本 + this.$api('getGoodsRecycleRule', { goodsId: item.id }, res => { + if (res.code === 200 && res.result) { + this.ruleHtml = res.result + } else { + this.ruleHtml = '暂无回收规则
' + } + this.showRulePopup = true + // 规则弹窗关闭后自动弹品牌弹窗逻辑在closeRulePopup已实现 + }) + } else { + // isPin=N 只弹规则 + this.hasScrolledToBottom = false; + this.$api('getGoodsRecycleRule', { goodsId: item.id }, res => { + if (res.code === 200 && res.result) { + this.ruleHtml = res.result + } else { + this.ruleHtml = '暂无回收规则
' + } + this.showRulePopup = true + // 不弹品牌弹窗 + this.isWaitingForBrandSelection = false; + }) + } }, showMore() { uni.showToast({ @@ -980,6 +1015,15 @@ export default { this.getGoodsBrandList(item.id); this.showBrandPopup = true; // 打开品牌索引弹窗 + } else if (this.pendingBrandIndex !== null) { + // 无品牌商品,规则弹窗关闭后加数量 + const categoryId = this.categories[this.currentCategory]?.id; + const item = this.allProducts[categoryId]?.[this.pendingBrandIndex]; + if (item) { + let newQuantity = (item.quantity || 0) + 1 + this.$set(item, 'quantity', newQuantity) + } + this.pendingBrandIndex = null } }, @@ -1078,7 +1122,8 @@ export default { id: item.id, logo: item.image || '/static/brand/alexander.png', name: item.name, - letter: firstChar + letter: firstChar, + isPin: item.isPin } }) @@ -1103,12 +1148,10 @@ export default { return key.charAt(0).toUpperCase() } } - - let index = this.brandIndexList.indexOf(firstChar.toUpperCase()) - if (index != -1) { - return this.brandIndexList[index] + // 英文首字母 + if (/^[A-Za-z]$/.test(firstChar)) { + return firstChar.toUpperCase() } - return '#' }, diff --git a/pages/manager/inspect.vue b/pages/manager/inspect.vue index c44d5db..c5a60a9 100644 --- a/pages/manager/inspect.vue +++ b/pages/manager/inspect.vue @@ -404,13 +404,13 @@ export default { if (key === 'qualified') { const currentCategoryId = this.categories[this.currentCategory]?.id // 处理不可回收和质量问题 - if (item.id === 'unrecyclable-1' || item.id === 'quality-issue-1') { - const newQualified = Math.max(0, (item.qualified || 0) + delta) - this.$set(item, 'qualified', newQualified) - this.updateInspectResult(item, 'qualified', delta, currentCategoryId) - this.$forceUpdate() - return - } + if (item.id === 'unrecyclable-1' || item.id === 'quality-issue-1') { + const newQualified = Math.max(0, (item.qualified || 0) + delta) + this.$set(item, 'qualified', newQualified) + this.updateInspectResult(item, 'qualified', delta, currentCategoryId) + this.$forceUpdate() + return + } // 处理普通商品 const newQualified = Math.max(0, (item.qualified || 0) + delta) this.$set(item, 'qualified', newQualified)