|
|
@@ -352,6 +352,7 @@ export async function renderImagesByPlans(plans, canvasList, skus) {
|
|
|
} catch (e) {
|
|
|
return resolve(null)
|
|
|
}
|
|
|
+ console.log('====== json ====', json)
|
|
|
|
|
|
const width = Number(canvasItem.width) || 395
|
|
|
const height = Number(canvasItem.height) || 600
|
|
|
@@ -497,18 +498,19 @@ export async function renderImagesByPlans(plans, canvasList, skus) {
|
|
|
}
|
|
|
|
|
|
// 2) 处理文字占位(data-type = text)
|
|
|
- const textPlaceholders = objs.filter((o) => o && o['data-type'] === 'text')
|
|
|
+ const textPlaceholders = objs.filter((o) => o && (o['data-type'] === 'text' || o['type'] === "textbox") && o['text'] )
|
|
|
+ console.log('=====textPlaceholders========', textPlaceholders)
|
|
|
|
|
|
if (textPlaceholders.length) {
|
|
|
// 通用的 key -> 文本 映射函数,
|
|
|
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
|
|
|
+ // }
|
|
|
// 兜底:去 raw 里找同名字段(支持 卖点 / 使用场景 / 其他自定义字段)
|
|
|
if ((!textVal || textVal === defaultVal) && sku.raw && sku.raw[key] != null) {
|
|
|
textVal = sku.raw[key]
|
|
|
@@ -526,7 +528,7 @@ export async function renderImagesByPlans(plans, canvasList, skus) {
|
|
|
// - 如果该 slot 没有对应货号(usedSkus[slotIndex] 为 null),则隐藏该文字层
|
|
|
const keyCounter = {}
|
|
|
textPlaceholders.forEach((obj) => {
|
|
|
- const key = obj['data-key']
|
|
|
+ const key = obj['text']
|
|
|
if (!key) return
|
|
|
const idxForKey = keyCounter[key] || 0
|
|
|
keyCounter[key] = idxForKey + 1
|
|
|
@@ -550,7 +552,7 @@ export async function renderImagesByPlans(plans, canvasList, skus) {
|
|
|
const sku = usedSkus[0]
|
|
|
if (sku) {
|
|
|
textPlaceholders.forEach((obj) => {
|
|
|
- const key = obj['data-key']
|
|
|
+ const key = obj['text']
|
|
|
if (!key) return
|
|
|
const origin = obj['data-value'] || ''
|
|
|
const textVal = mapKeyToText(sku, key, origin)
|
|
|
@@ -706,6 +708,7 @@ export async function renderImagesByPlans(plans, canvasList, skus) {
|
|
|
* }>>}
|
|
|
*/
|
|
|
export async function generateAllStyleImageBundles(canvasList, goodsList) {
|
|
|
+ console.log("====canvasList====" , canvasList)
|
|
|
const bundles = []
|
|
|
|
|
|
// 工具:把若干 dataURL 竖向拼接为一张长图
|