Browse Source

修改回收页面:现在商品每个都会弹出品牌选择,没有isPin=Y的商品不需要弹出,并且品牌选择的时候没有品牌的字母不显示

master
Lj 3 weeks ago
parent
commit
a88d8c7d3d
2 changed files with 80 additions and 37 deletions
  1. +73
    -30
      pages/component/recycle.vue
  2. +7
    -7
      pages/manager/inspect.vue

+ 73
- 30
pages/component/recycle.vue View File

@ -378,7 +378,6 @@ export default {
}, },
brandList: [], brandList: [],
brandCache: {}, // { productId: [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', currentLetter: 'A',
scrollToView: '', scrollToView: '',
brandSearch: '', brandSearch: '',
@ -579,7 +578,18 @@ export default {
max: maxExtra.toFixed(2), max: maxExtra.toFixed(2),
display: `${minExtra.toFixed(2)}-${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: { methods: {
showPriceInfoPopups() { showPriceInfoPopups() {
@ -688,13 +698,23 @@ export default {
} }
// 0 // 0
if ((item.quantity || 0) === 0 && delta > 0) {
if (item.isPin === 'Y' && (item.quantity || 0) === 0 && delta > 0) {
this.pendingBrandIndex = index this.pendingBrandIndex = index
this.isWaitingForBrandSelection = true; this.isWaitingForBrandSelection = true;
this.showRules(item); // this.showRules(item); //
return 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) { selectReduceBrand(brandInfo) {
@ -739,27 +759,42 @@ export default {
}, },
// //
showRules(item) { 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 = '<p>暂无回收规则</p>'
// 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 = '<p>暂无回收规则</p>'
}
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 = '<p>暂无回收规则</p>'
}
this.showRulePopup = true
//
this.isWaitingForBrandSelection = false;
})
}
}, },
showMore() { showMore() {
uni.showToast({ uni.showToast({
@ -980,6 +1015,15 @@ export default {
this.getGoodsBrandList(item.id); this.getGoodsBrandList(item.id);
this.showBrandPopup = true; // 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, id: item.id,
logo: item.image || '/static/brand/alexander.png', logo: item.image || '/static/brand/alexander.png',
name: item.name, name: item.name,
letter: firstChar
letter: firstChar,
isPin: item.isPin
} }
}) })
@ -1103,12 +1148,10 @@ export default {
return key.charAt(0).toUpperCase() 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 '#' return '#'
}, },


+ 7
- 7
pages/manager/inspect.vue View File

@ -404,13 +404,13 @@ export default {
if (key === 'qualified') { if (key === 'qualified') {
const currentCategoryId = this.categories[this.currentCategory]?.id 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) const newQualified = Math.max(0, (item.qualified || 0) + delta)
this.$set(item, 'qualified', newQualified) this.$set(item, 'qualified', newQualified)


Loading…
Cancel
Save