|
|
@@ -498,7 +498,7 @@ export async function renderImagesByPlans(plans, canvasList, skus) {
|
|
|
}
|
|
|
|
|
|
// 2) 处理文字占位(data-type = text)
|
|
|
- const textPlaceholders = objs.filter((o) => o && (o['data-type'] === 'text' || o['type'] === "textbox") && o['text'] )
|
|
|
+ const textPlaceholders = objs.filter((o) => o && o['data-key'] && (o['data-type'] === 'text' || o['type'] === "textbox"))
|
|
|
console.log('=====textPlaceholders========', textPlaceholders)
|
|
|
|
|
|
if (textPlaceholders.length) {
|
|
|
@@ -506,11 +506,18 @@ export async function renderImagesByPlans(plans, canvasList, skus) {
|
|
|
const mapKeyToText = (sku, key, defaultVal) => {
|
|
|
if (!sku) return defaultVal
|
|
|
let textVal = defaultVal || ''
|
|
|
- // if (key === '颜色') {
|
|
|
- // textVal = sku.color || textVal
|
|
|
- // } else if (key === '货号') {
|
|
|
- // textVal = sku.sku || textVal
|
|
|
- // }
|
|
|
+ // 标准字段映射
|
|
|
+ if (key === '颜色') {
|
|
|
+ textVal = sku.color || textVal
|
|
|
+ } else if (key === '货号') {
|
|
|
+ textVal = sku.sku || textVal
|
|
|
+ } else if (key === '设计理念') {
|
|
|
+ textVal = sku.design || textVal
|
|
|
+ } else if (key === '标题') {
|
|
|
+ textVal = sku.styleNo || textVal
|
|
|
+ } else if (key === '款号') {
|
|
|
+ textVal = sku.styleNo || textVal
|
|
|
+ }
|
|
|
// 兜底:去 raw 里找同名字段(支持 卖点 / 使用场景 / 其他自定义字段)
|
|
|
if ((!textVal || textVal === defaultVal) && sku.raw && sku.raw[key] != null) {
|
|
|
textVal = sku.raw[key]
|
|
|
@@ -528,7 +535,7 @@ export async function renderImagesByPlans(plans, canvasList, skus) {
|
|
|
// - 如果该 slot 没有对应货号(usedSkus[slotIndex] 为 null),则隐藏该文字层
|
|
|
const keyCounter = {}
|
|
|
textPlaceholders.forEach((obj) => {
|
|
|
- const key = obj['text']
|
|
|
+ const key = obj['data-key']
|
|
|
if (!key) return
|
|
|
const idxForKey = keyCounter[key] || 0
|
|
|
keyCounter[key] = idxForKey + 1
|
|
|
@@ -552,7 +559,7 @@ export async function renderImagesByPlans(plans, canvasList, skus) {
|
|
|
const sku = usedSkus[0]
|
|
|
if (sku) {
|
|
|
textPlaceholders.forEach((obj) => {
|
|
|
- const key = obj['text']
|
|
|
+ const key = obj['data-key']
|
|
|
if (!key) return
|
|
|
const origin = obj['data-value'] || ''
|
|
|
const textVal = mapKeyToText(sku, key, origin)
|