Compare commits
3 Commits
534c1c1806
...
c72640851e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c72640851e | ||
|
|
7091da5b10 | ||
|
|
fd034c9ae6 |
@@ -1056,22 +1056,42 @@ async function openProductCard(grp1, grp2) {
|
|||||||
const colorCode = String(grp2?.colorCode || '').trim()
|
const colorCode = String(grp2?.colorCode || '').trim()
|
||||||
const secondColor = String(grp2?.secondColor || '').trim()
|
const secondColor = String(grp2?.secondColor || '').trim()
|
||||||
const listKey = buildImageKey(productCode, colorCode, secondColor)
|
const listKey = buildImageKey(productCode, colorCode, secondColor)
|
||||||
|
const codeTrim = String(productCode || '').trim().toUpperCase()
|
||||||
|
const colorTrim = String(colorCode || '').trim().toUpperCase()
|
||||||
|
const secondTrim = String(secondColor || '').trim().toUpperCase()
|
||||||
|
|
||||||
await ensureProductImage(productCode, colorCode, secondColor)
|
await ensureProductImage(productCode, colorCode, secondColor)
|
||||||
const list = Array.isArray(productImageListByCode.value[listKey]) ? productImageListByCode.value[listKey] : []
|
let list = Array.isArray(productImageListByCode.value[listKey]) ? productImageListByCode.value[listKey] : []
|
||||||
|
if (!list.length && codeTrim) {
|
||||||
|
try {
|
||||||
|
const params = { code: codeTrim, dim1: colorTrim, dim3: secondTrim }
|
||||||
|
const res = await api.get('/product-images', { params })
|
||||||
|
list = Array.isArray(res?.data) ? res.data : []
|
||||||
|
productImageListByCode.value[listKey] = list
|
||||||
|
} catch (err) {
|
||||||
|
console.warn('[ProductStockByAttributes] product card image list refetch failed', {
|
||||||
|
code: codeTrim,
|
||||||
|
color: colorTrim,
|
||||||
|
secondColor: secondTrim,
|
||||||
|
err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const images = list
|
const images = list
|
||||||
.map((item) => {
|
.map((item) => {
|
||||||
const resolved = resolveProductImageUrl(item)
|
const resolved = resolveProductImageUrl(item)
|
||||||
return resolved.contentUrl || resolved.publicUrl || ''
|
return resolved.publicUrl || resolved.contentUrl || ''
|
||||||
})
|
})
|
||||||
.filter((x) => String(x || '').trim() !== '')
|
.filter((x) => String(x || '').trim() !== '')
|
||||||
|
const uniqueImages = Array.from(new Set(images))
|
||||||
|
|
||||||
if (!images.length) {
|
if (!uniqueImages.length) {
|
||||||
const single = getProductImageUrl(productCode, colorCode, secondColor)
|
const single = getProductImageUrl(productCode, colorCode, secondColor)
|
||||||
if (single) images.push(single)
|
if (single) uniqueImages.push(single)
|
||||||
}
|
}
|
||||||
|
|
||||||
productCardImages.value = images
|
productCardImages.value = uniqueImages
|
||||||
productCardSlide.value = 0
|
productCardSlide.value = 0
|
||||||
productCardData.value = {
|
productCardData.value = {
|
||||||
productCode,
|
productCode,
|
||||||
|
|||||||
@@ -923,22 +923,42 @@ async function openProductCard(grp1, grp2) {
|
|||||||
const colorCode = String(grp2?.colorCode || '').trim()
|
const colorCode = String(grp2?.colorCode || '').trim()
|
||||||
const secondColor = String(grp2?.secondColor || '').trim()
|
const secondColor = String(grp2?.secondColor || '').trim()
|
||||||
const listKey = buildImageKey(productCode, colorCode, secondColor)
|
const listKey = buildImageKey(productCode, colorCode, secondColor)
|
||||||
|
const codeTrim = String(productCode || '').trim().toUpperCase()
|
||||||
|
const colorTrim = String(colorCode || '').trim().toUpperCase()
|
||||||
|
const secondTrim = String(secondColor || '').trim().toUpperCase()
|
||||||
|
|
||||||
await ensureProductImage(productCode, colorCode, secondColor)
|
await ensureProductImage(productCode, colorCode, secondColor)
|
||||||
const list = Array.isArray(productImageListByCode.value[listKey]) ? productImageListByCode.value[listKey] : []
|
let list = Array.isArray(productImageListByCode.value[listKey]) ? productImageListByCode.value[listKey] : []
|
||||||
|
if (!list.length && codeTrim) {
|
||||||
|
try {
|
||||||
|
const params = { code: codeTrim, dim1: colorTrim, dim3: secondTrim }
|
||||||
|
const res = await api.get('/product-images', { params })
|
||||||
|
list = Array.isArray(res?.data) ? res.data : []
|
||||||
|
productImageListByCode.value[listKey] = list
|
||||||
|
} catch (err) {
|
||||||
|
console.warn('[ProductStockQuery] product card image list refetch failed', {
|
||||||
|
code: codeTrim,
|
||||||
|
color: colorTrim,
|
||||||
|
secondColor: secondTrim,
|
||||||
|
err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const images = list
|
const images = list
|
||||||
.map((item) => {
|
.map((item) => {
|
||||||
const resolved = resolveProductImageUrl(item)
|
const resolved = resolveProductImageUrl(item)
|
||||||
return resolved.contentUrl || resolved.publicUrl || ''
|
return resolved.publicUrl || resolved.contentUrl || ''
|
||||||
})
|
})
|
||||||
.filter((x) => String(x || '').trim() !== '')
|
.filter((x) => String(x || '').trim() !== '')
|
||||||
|
const uniqueImages = Array.from(new Set(images))
|
||||||
|
|
||||||
if (!images.length) {
|
if (!uniqueImages.length) {
|
||||||
const single = getProductImageUrl(productCode, colorCode, secondColor)
|
const single = getProductImageUrl(productCode, colorCode, secondColor)
|
||||||
if (single) images.push(single)
|
if (single) uniqueImages.push(single)
|
||||||
}
|
}
|
||||||
|
|
||||||
productCardImages.value = images
|
productCardImages.value = uniqueImages
|
||||||
productCardSlide.value = 0
|
productCardSlide.value = 0
|
||||||
productCardData.value = {
|
productCardData.value = {
|
||||||
productCode,
|
productCode,
|
||||||
|
|||||||
Reference in New Issue
Block a user