- ${item}
2/8
${data.index + 1}/${data.total}
Description
You may also like
${data.index + 1}/${data.total}
Recently Viewed
Products list
${(function () {
return automatic_discount_list.map((item) => {
// ๆจก็็ฑปๅ
const template_type = item.discount[0].template_type;
// ๆฏๅฆๆพ็คบ่ชๅจๆๆฃ
const is_show_automatic_discount = item.discount[0].product_enabled;
// ๆฏๅฆ่ทณ่ฝฌ่ฝๅฐ้กต
const is_redirection = item.discount[0].is_redirection;
// ๆๆฃๅพๆ
const discount_icon = item.discount_icon;
// ็ฌฌไธไธช่ชๅจๆๆฃ
const first_automatic_discount = item.discount[0];
// ๆพ็คบๆๅ ๅฑ็คบ
const isFold = (item.discount[0].display_type || DISPLAY_TYPE.DTE_FOLD) === DISPLAY_TYPE.DTE_FOLD;
// ๆๆฌๆฐ็ป
const text_arr = item.discount[0].config.texts;
// ่ฝๅฐ้กต้พๆฅ
const first_landing_url = `/promotions/discount-default/${first_automatic_discount.discount_id}`;
// ่ชๅจๆๆฃๆปๆฐ
const automatic_discount_total = item.discount.length;
// ๆฏๅฆๆพ็คบๆๆฃๅพๆ
const isHasDiscountIcon = discount_icon ? true : false;
// ๆฏๅฆๆพ็คบๆๆฃๅพๆ ไธๆจก็็ฑปๅไธไธบtag
const isHasDiscountIconWithNoTag = (template_type != 'tag' && isHasDiscountIcon)? true : false;
// ๆๆฌ้ข่ฒ
let text_color = DEFAULT_CONFIG.TEXT_COLOR;
// ่ๆฏ้ข่ฒ
const bgFn = (curBg) => template_type === "text" ? "transparent" : curBg;
let bg_color = bgFn(DEFAULT_CONFIG.BG);
// ่พนๆก้ข่ฒ
const borderFn = (curBorder) => template_type == "tag" ? curBorder : "initial";
let border_color = borderFn(DEFAULT_CONFIG.BORDER_COLOR);
// ๆจก็้
็ฝฎ
let template_config = first_automatic_discount.template_config;
// ๅ
ๅบๆนๆก
try {
if(template_config.length !== 0){
template_config = JSON.parse(template_config);
text_color= isHasDiscountIconWithNoTag ? template_config.color[template_type].icon_text_color : template_config.color[template_type].text_color;
bg_color = bgFn(template_config.color[template_type].background_color);
const arrayRgba = bg_color.split(",");
arrayRgba.splice(3, 1, " 1)");
border_color = borderFn(`${arrayRgba.join(",")}`);
}
} catch (error) {
console.error('template_config_error', error);
template_config = {
color: {
[template_type]: {
icon_text_color: DEFAULT_CONFIG.TEXT_COLOR,
text_color: DEFAULT_CONFIG.TEXT_COLOR,
background_color: DEFAULT_CONFIG.BG
}
}
};
}
// ๆ ็ญพ
const isTag = template_type == 'tag';
// ๆๅญๅๆจชๅน
const isTextAndBanner = template_type == 'text' || template_type == 'banner';
// ๆๅญๆ ทๅผ
const textStyle = `color: ${text_color}; background-color: transparent; border: none;`;
// ๆ ็ญพๆ ทๅผ
const labelStyle = `color: ${text_color};border: 1px solid ${border_color};background-color:${bg_color};padding: 4px;`;
// ๆจชๅน
ๆ ทๅผ
const bannerStyle = `color: ${text_color};border: none; background-color:${bg_color}`;
// ๅคๅฑๆ ทๅผๅจๆ ็ญพๆ ทๅผไธไธๅฑ็คบ้ข่ฒ้
็ฝฎ๏ผ้คๅผๆ ็ญพ็ฑปๅ๏ผ้ข่ฒ้ฝๅฏไปฅๅจๅคๅฑ่ฆ็
let outerStyle = '';
if (template_type == 'text') {
outerStyle = textStyle;
} else if (template_type == 'tag') {
outerStyle = "border: none;";
} else if (template_type == 'banner') {
outerStyle = bannerStyle;
}
/**
* 1. ๆ ็ญพไธๅฎๆฏๅ็ฌๆ ทๅผๅฑ็คบ็
* 2. ๆๅ ๏ผๆจชๅๅธๅฑ๏ผๆๅญๅๆจชๅน
๏ผๅๅนถๆไธ่กๆๆฌ๏ผ ๆ ็ญพ๏ผๅ็ฌๆ ทๅผๅค็
* 3. ๅนณ้บ๏ผ็บตๅๅธๅฑ๏ผๆๅญใๆจชๅน
ๅๆ ็ญพ๏ผ ๆ ็ญพ๏ผๅ็ฌๆ ทๅผๅค็
*/
let txtHtml = ``;
if (isFold) {
if(isTag) {
// ๆ ็ญพ
const spanText = text_arr.map((text) => {
return `${text}`;
}).join('');
txtHtml = `
`
}
})()}
${spanText}
`;
} else {
// ๆๅญๅๆจชๅน
txtHtml = `
${first_automatic_discount.config.text}
`;
}
} else {
// ๆๅญๅๆจชๅน
, ไฝๆ ็ญพๆ่ชๅทฑ็ๆ ทๅผ
const spanText = text_arr.map((text) => {
return `${text}`;
}).join('');
// ้ฝๆฏ็บตๅๅธๅฑ๏ผๆ ็ญพๆ้ด่ท, ๅคๆดปๅจๅคๅฑ็บงๆจชๅๅธๅฑ
txtHtml = `${spanText}
`;
}
/**
* ๆพ็คบๅพๆ ็ๅคๆญ
*/
const discount_type = item.discount_type;
const isShowRebateIcon = ["DT_REBATE_CTQ_OTP", "DT_REBATE_CTQ_OTR", "DT_REBATE_CTA_OTP", "DT_REBATE_CTA_OTR", "DT_M_N_DISCOUNT"].includes(discount_type) && isTextAndBanner
const isShowBxgyIcon = ["DT_BUY_ONE_GET_ONE", "DT_BUY_X_GET_Y"].includes(discount_type)
const isShowBundleIcon = ["DT_CLASSIC_BUNDLE","DT_MIX_MATCH_BUNDLE"].includes(discount_type);
/**
* ๆธฒๆไธๆๆกๆๆฝๅฑ็ๆๆฃๅ่กจ
*/
const discount_list_html = (curItem) => {
return `
${function() {
return curItem.discount.map(childItem => {
return `
`}).join('');
}()}
`;
}
return `
`;
}).join('');
})()}
${childItem.config.text}
${childItem.config.text}