Home
/
Hot Sale ✨50% OFF ✨3D car creative car logo decoration stickers🎉4PCS🎉
Hot Sale ✨50% OFF ✨3D car creative car logo decoration stickers🎉4PCS🎉
$27.98
Save 50%
Sold 9856
${function() {
if (!data.off_ratio || data.off_ratio <= 0) return '';
const saveType = "percent";
const saveText = "Save {off_ratio}";
return `
${saveText.replace('{off_ratio}',
saveType == 'percent'
? data.off_ratio + '%'
: ` `
)}
`;
}()}
Sold 9856
Logo:
FOR AMG BRAND
${data.targetOption}
FOR AMG BRAND
FOR BMW BRAND
FOR MINI BRAND
FOR Audi BRAND
FOR Benz BRAND
FOR BOSE BRAND
FOR Camry BRAND
FOR Corolla BRAND
FOR Daewoo BRAND
FOR Jeep BRAND
FOR FIAT BRAND
FOR Octavia BRAND
FOR PERFORMANCE BRAND
FOR PRADD BRAND
FOR RAV4 BRAND
FOR TRD BRAND
FOR TYPER BRAND
FOR ABARTH BRAND
FOR Alfa Romeo BRAND
FOR Honda BRAND
FOR Peugeot BRAND
FOR Buick BRAND
FOR DACIA BRAND
FOR Volkswagen BRAND
FOR DODGE BRAND
FOR Toyota BRAND
FOR Ford BRAND
FOR Cadillac BRAND
FOR Lexus BRAND
FOR SUZUKI BRAND
FOR Mazda BRAND
FOR ACURA BRAND
FOR KIA BRAND
FOR Nissan BRAND
FOR Mitsubishi BRAND
FOR Ssangyong BRAND
FOR SUBARU BRAND
FOR Skoda BRAND
FOR Tesla BRAND
FOR Volvo BRAND
FOR HYUNDAI BRAND
FOR Chevrolet BRAND
FOR Citroen BRAND
FOR INFINITI BRAND
FOR RENALT BRAND
FOR OPEL BRAND
FOR Maserati BRAND
FOR Land rover BRAND
FOR HAVAL BRAND
FOR BYD BRAND
FOR DYNAUDIO BRAND
FOR ACCORD BRAND
FOR SONY BRAND
FOR Harman Kardon BRAND
FOR SEAT BRAND
FOR Great Wall BRAND
FOR Tank BRAND
FOR MG BRAND
FOR Renault BRAND
FOR Lincoln BRAND
FOR Smart BRAND
FOR Yamaha BRAND
Add to cart
- $13.99
-
Buy now
Exclusive car stickers are more attractive
[Product material] 3D design, aluminum
[Easy installation] The car sticker is easy to install and can be peeled off and pasted on the surface. Manual installation brings the fun of modification.
[Quality Assurance] 100% brand new, high-quality and high-quality, you deserve it.Suitable for all major models, special car LOGO
[Our Service] If you encounter any problems during the purchase of our products, you can contact us by email, and we will reply you within one day and deal with your problems.
Product description
Color:Silver
Quantity:4pcs/set
Material: Aluminum alloy
Features:
1. Refined design, top quality and durable.
2. Best decoration for your car.
3. Easy to install, removable.
Comparison before and after installation
Size:
HOW TO PAY
If you want to checkout with Credit Card. Please Click Paypal and Search for ‘Pay with Debit or Credit Card’
Enter your Payment details, your Billing Address, and your Contact Information.
Here are what our customers say.
Newest
Most liked
Highest ratings
Lowest ratings
Wow you reached the bottom
Most liked
Highest ratings
Lowest ratings
×
${function(){
const limit = typeof data === 'number' ? data : 0;
return `
Pictures/Videos (${limit || 0}/5 )
` }()}
${(function(){
const closeIcon =
'
';
if (item.type === 'image') {
return `
${closeIcon}
`
}
return `
${closeIcon}
`
})()}
Submit Comments Anonymously
class SpzCustomFileUpload extends SPZ.BaseElement {
constructor(element) {
super(element);
this.uploadCount_ = 0;
this.fileList_ = [];
}
buildCallback() {
this.action = SPZServices.actionServiceForDoc(this.element);
this.registerAction('upload', (data) => {
this.handleFileUpload_(data.event?.detail?.data || []);
});
this.registerAction('delete', (data) => {
this.handleFileDelete_(data?.args?.data);
});
this.registerAction('preview', (data) => {
this.handleFilePreview_(data?.args?.data);
});
this.registerAction('limit', (data) => {
this.handleFileLimit_();
});
this.registerAction('sizeLimit', (data) => {
this.handleFileSizeLimit_();
});
}
isLayoutSupported(layout) {
return layout == SPZCore.Layout.LOGIC;
}
setData_(count, file) {
this.uploadCount_ = count;
this.fileList_ = file;
}
handleFileUpload_(data) {
data.forEach(i => {
if(this.fileList_.some(j => j.url === i.url)) return;
this.fileList_.push(i);
})
this.uploadCount_++;
sessionStorage.setItem('fileList', JSON.stringify(this.fileList_));
this.triggerEvent_("handleFileUpload", { count: this.uploadCount_, files: this.fileList_});
if(this.fileList_.length >= 5){
document.querySelector('#review_upload').style.display = 'none';
}
if(this.fileList_.length > 0){
document.querySelector('.apps-reviews-write-anonymous-box').style.marginTop = '8px';
}
}
handleFileDelete_(index) {
this.fileList_.splice(index, 1);
this.uploadCount_--;
sessionStorage.setItem('fileList', JSON.stringify(this.fileList_));
this.triggerEvent_("handleFileDelete", { count: this.uploadCount_, files: this.fileList_});
document.querySelector('#review_upload').style.display = 'block';
if(this.fileList_?.length === 0){
document.querySelector('.apps-reviews-write-anonymous-box').style.marginTop = '132px';
}
}
handleFilePreview_(index) {
const finalPreviewData = this.fileList_[index];
const filePreviewModal = document.getElementById('filePreviewModal');
const fullScreenVideo = document.getElementById('fullScreenVideo');
const fullScreenImage = document.getElementById('fullScreenImage');
const previewModalClose = document.getElementById('previewModalClose');
const previewLoading = document.getElementById('previewLoading');
filePreviewModal.style.display = 'block';
previewLoading.style.display = 'flex';
if(finalPreviewData?.type === 'video'){
const media = this.mediaParse_(this.fileList_[index]?.url);
fullScreenVideo.addEventListener('canplaythrough', function() {
previewLoading.style.display = 'none';
});
fullScreenImage.src = '';
fullScreenImage.style.display = 'none';
fullScreenVideo.style.display = 'block';
fullScreenVideo.src = media.mp4 || '';
} else {
fullScreenImage.onload = function() {
previewLoading.style.display = 'none';
};
fullScreenVideo.src = '';
fullScreenVideo.style.display = 'none';
fullScreenImage.style.display = 'block';
fullScreenImage.src = finalPreviewData.url;
}
previewModalClose.addEventListener('click', function() {
filePreviewModal.style.display = 'none';
});
}
handleFileLimit_() {
alert(window.AppReviewsLocale.comment_file_limit || 'please do not upload files more than 5');
this.triggerEvent_("handleFileLimit");
}
handleFileSizeLimit_() {
alert(window.AppReviewsLocale.comment_file_size_limit || 'File size does not exceed 10M');
}
clear(){
this.fileList_ = [];
this.uploadCount_ = 0;
sessionStorage.setItem('fileList', JSON.stringify(this.fileList_));
this.triggerEvent_("handleClear", { count: this.uploadCount_, files: this.fileList_});
document.querySelector('#review_upload').style.display = 'block';
}
mediaParse_(url) {
var result = {};
try {
url.replace(/[?&]+([^=&]+)=([^&]*)/gi, function (str, key, value) {
try {
result[key] = decodeURIComponent(value);
} catch (e) {
result[key] = value;
}
});
result.preview_image = url.split('?')[0];
} catch (e) {};
return result;
}
triggerEvent_(name, data) {
const event = SPZUtils.Event.create(this.win, name, data);
this.action.trigger(this.element, name, event);
}
}
SPZ.defineElement('spz-custom-file-upload', SpzCustomFileUpload);
The review would not show in product details on storefront since it does not support to.
You may also like
${data.map(data => `
`).join('')}
${data.map(data => `
`).join('')}
Recently viewed
${data.map(data => `
`).join('')}
${data.map(data => `
`).join('')}
${function() {
const force_image_size = "1";
const product_hover_on = true;
const product_show_sale_label = true;
const product_save_type = "percent";
const badge1 = "";
const badge2 = "";
const badge3 = "";
const product_title_mobile_hide = false;
const product_title_style = "full";
const enable_collection_thumb_image = true;
const variantNames = ["color"];
const thumbMaxNum = 4;
const suffix_id = Math.random().toFixed(6).slice(-6);
const url = data.withinUrl;
const productId = data.id;
const price = data.price;
const productAvailable = data.available;
const productVariants = data.variants || [];
const images = data.images || [];
const image = data.image || {};
const imageWidth = image.width;
let imageHeight = image.height;
let image2 = null;
let imageHoverOn = false;
if (force_image_size !== 'natural') {
imageHeight = imageWidth * force_image_size;
}
if (product_hover_on) {
for (let i = 1; i < images.length; i++) {
const img = images[i];
if (img.src && img.src.indexOf('video=') === -1) {
image2 = img;
imageHoverOn = true;
break;
}
}
}
let compareAtPrice = data.compare_at_price;
let offRatio = data.off_ratio;
let discountMaxUrl = url;
const showFrom = data.price_min != data.price_max ? true : false;
for (let i = 0; i < productVariants.length; i++) {
const variant = productVariants[i];
if (variant.price == price && compareAtPrice < variant.compare_at_price) {
compareAtPrice = variant.compare_at_price;
offRatio = variant.off_ratio;
variant.available && (discountMaxUrl = variant.withinUrl);
}
}
const soldOutText = "Sold out";
let soldOn = false;
let saleOn = false;
if (productAvailable) {
if (product_show_sale_label && +price < +compareAtPrice) {
saleOn = true;
}
} else {
soldOn = true;
}
const diffPrice = compareAtPrice - price;
const saveLabelContent = product_save_type == 'percent' ? (offRatio + '%') : `
`;
let saveText = "Save {off_ratio}";
saveText = saveText.replace('{off_ratio}', saveLabelContent);
const productTitle = data.title;
const variantValues = [];
const showVariants = [];
if (data.need_variant_image && enable_collection_thumb_image && variantNames.length > 0) {
for (let i = 0; i < (data.options || []).length; i++) {
const option = data.options[i];
const optionName = option.name.toLowerCase();
if (variantNames.includes(optionName)) {
for (let j = 0; j < productVariants.length; j++) {
const variant = productVariants[j];
const value = variant.options[i].value;
if (!variantValues.includes(value)) {
variantValues.push(value);
showVariants.push(variant);
}
}
break;
}
}
}
return `
`;
}()}
${function() {
var thumbSwitchName = '';
return data.product.options.map((option, index) => {
const optionName = option.name || '';
const optionPosition = 'option' + (index + 1);
const values = option.values || [];
const soldOutValues = (data.soldOutValues && data.soldOutValues[optionPosition]) || {};
const variantThumbs = ["color"] || [];
var isThumbImage = false;
if (data.product.need_variant_image && thumbSwitchName == '') {
for (let i = 0; i < variantThumbs.length; i++) {
const name = variantThumbs[i].toLowerCase();
if (name == optionName.toLowerCase()) {
isThumbImage = true;
thumbSwitchName = name;
}
}
}
const thumbStyle = "image_with_text";
const thumbType = isThumbImage ? thumbStyle.replace(/_/g, '-') : 'text';
return `
${optionName.slice(0, 1).toUpperCase() + optionName.slice(1).toLowerCase()} :
${values.map(value => {
let selected = '';
let soldout = soldOutValues[value] ? 'soldout' : '';
if (data.selectedValues[optionName] == value) {
selected = 'selected';
}
let thumbImage = null;
if (isThumbImage) {
const variants = data.product.variants;
for (let i = 0; i < variants.length; i++) {
const variant = variants[i];
if (variant[optionPosition] == value && thumbImage == null) {
thumbImage = variant.image;
break;
}
}
}
return `
`;
}).join('')}
`;
}).join('');
}()}
${data.targetOption || data.defaultValue || ''}
${("Save {off_ratio}").replace('{off_ratio}',
("percent") == 'percent'
? data.variant.off_ratio + '%'
: ` `
)}
-
-
const TAG = "spz-custom-popup";
const DISPLAY_TYPE = {
POPUP: "PTT_POPUP" // 弹窗
};
const API = {
LIST: `/api/storefront/promotion/placement/list`, // 获取弹窗列表
REPORT: `/api/storefront/promotion/placement/data/report` // 上报数据
};
const DISPLAY_DEVICE = {
PC_AND_MOBILE: "PD_PC_MOBILE", // PC和移动端
PC: "PD_PC", // PC
MOBILE: "PD_MOBILE" // 移动端
};
const REPORT_EVENT = {
CLICK: "PE_CLICK", // 点击事件
IMPRESSION: "PE_IMPRESSION" // 曝光事件
};
class SpzCustomPopup extends SPZ.BaseElement {
constructor(element) {
super(element);
this.popupList_ = []; // 弹窗数据
this.popupZIndex = 1050; // 弹窗层级
// 节流处理 每5s内多次点击 算一次点击上报
this.throttleReport = this.win.SPZCore.Types.throttle(
this.win,
(data) => {
this.reportData(data)
},
5000
)
}
static deferredMount() {
return false;
}
buildCallback() {
this.action_ = SPZServices.actionServiceForDoc(this.element);
this.templates_ = SPZServices.templatesForDoc(this.element);
this.xhr_ = SPZServices.xhrFor(this.win);
this.setupAction_();
this.viewport_ = this.getViewport();
}
mountCallback() {
this.fetchData_();
}
// 接口请求,获取数据
fetchData_() {
const id = window.SHOPLAZZA.meta.page.template_type === 51 ? window.SHOPLAZZA.meta.page.resource_id : 0;
return this.xhr_.fetchJson(API.LIST, {
method: 'POST',
body: {
page_id: window.SHOPLAZZA.meta.page.template_type,
placement_type: DISPLAY_TYPE.POPUP,
discount_id: id
}
}).then((res) => {
// 请求成功 执行render
this.doRender_(res.list);
}).catch((err) => {
console.error(err);
});
}
// 渲染dom
doRender_(data) {
this.popupList_ = data || [];
if (this.popupList_.length > 0) {
this.popupList_.forEach((item) => {
item.config = JSON.parse(item.config);
})
}
return this.templates_
.findAndRenderTemplate(this.element, { list: this.popupList_ })
.then((el) => {
const children = this.element.querySelector('*:not(template)');
children && SPZCore.Dom.removeElement(children);
this.element.appendChild(el);
})
.then(() => {
// 遍历显示弹窗
this.popupList_.forEach((item) => {
this.showPopup_(item);
});
})
}
showPopup_(popup) {
// 展示弹窗 符合展示条件的弹窗
const $popup = document.querySelector(`#popup-${popup.id}`);
$popup && SPZ.whenApiDefined($popup).then((api)=> {
const isPC = this.viewport_.getWidth() >= 960;
const isMobile = this.viewport_.getWidth() < 960;
const isMatchPCDevice = popup.device === DISPLAY_DEVICE.PC_AND_MOBILE || popup.device === DISPLAY_DEVICE.PC;
const isMatchMobileDevice = popup.device == DISPLAY_DEVICE.PC_AND_MOBILE || popup.device === DISPLAY_DEVICE.MOBILE;
if((isPC && isMatchPCDevice) || (isMobile && isMatchMobileDevice)) {
// 根据推送时间 延迟展示弹窗
setTimeout(() => {
api.open();
}, popup.delay_seconds * 1000);
}
})
}
// 上报数据
async reportData(data) {
this.xhr_.fetchJson(API.REPORT, {
method: "POST",
body: {
placement_id: data.placement_id,
event: data.event
}
});
}
setupAction_() {
this.registerAction('handleTrack', async(invocation) => {
// 如果是主题编辑器则不用处理
if(window.top !== window.self) {
return;
}
const data = invocation.args;
const event = data.event;
// 点击上报 节流处理
if(event === REPORT_EVENT.CLICK) {
await this.throttleReport(data);
} else {
this.reportData(data);
}
});
}
triggerEvent_(name, data) {
const event = SPZUtils.Event.create(this.win, `${ TAG }.${ name }`, data || {});
this.action_.trigger(this.element, name, event);
}
isLayoutSupported(layout) {
return layout == SPZCore.Layout.CONTAINER;
}
}
SPZ.defineElement(TAG, SpzCustomPopup);
const TAG = "spz-custom-announcement";
const DISPLAY_TYPE = {
ANNOUNCEMENT: "PTT_BANNER" // 公告栏
};
const API = {
LIST: `/api/storefront/promotion/placement/list`, // 获取公告栏列表
REPORT: `/api/storefront/promotion/placement/data/report` // 上报数据
};
const DISPLAY_DEVICE = {
PC_AND_MOBILE: "PD_PC_MOBILE", // PC和移动端
PC: "PD_PC", // PC
MOBILE: "PD_MOBILE" // 移动端
};
const REPORT_EVENT = {
CLICK: "PE_CLICK", // 点击事件
IMPRESSION: "PE_IMPRESSION" // 曝光事件
};
const POSITION = {
TOP: "PP_TOP", // 顶部
BOTTOM: "PP_BOTTOM" // 底部
}
const MODE = {
FIXED: "PM_FIXED", // 固定
NORMAL: "PM_SCROLLING" // 滚动
}
const THEME_NAME = window.SHOPLAZZA.theme.merchant_theme_name;
class SpzCustomAnnouncement extends SPZ.BaseElement {
constructor(element) {
super(element);
this.announcementList_ = []; // 公告栏数据
}
static deferredMount() {
return false;
}
buildCallback() {
this.action_ = SPZServices.actionServiceForDoc(this.element);
this.templates_ = SPZServices.templatesForDoc(this.element);
this.xhr_ = SPZServices.xhrFor(this.win);
this.setupAction_();
this.viewport_ = this.getViewport();
}
mountCallback() {
this.fetchData_();
this.createAnnouncementDom_();
this.listenCartChange_();
}
fetchData_(type = '') {
const id = window.SHOPLAZZA.meta.page.template_type === 51 ? window.SHOPLAZZA.meta.page.resource_id : 0;
return this.xhr_.fetchJson(API.LIST, {
method: 'POST',
body: {
page_id: window.SHOPLAZZA.meta.page.template_type,
placement_type: DISPLAY_TYPE.ANNOUNCEMENT,
discount_id: id
}
}).then((res) => {
this.announcementList_ = res.list || [];
if (this.announcementList_.length > 0) {
this.announcementList_.forEach((item) => {
item.config = JSON.parse(item.config);
});
}
if(type === 'cartChange') {
this.announcementList_.forEach((item) => {
this.updateText_(item);
});
} else {
this.doRender_(this.announcementList_);
}
}).catch((error) => {
console.error(error);
})
}
doRender_(data) {
return this.templates_
.findAndRenderTemplate(this.element, { list: this.announcementList_ })
.then((el) => {
const children = this.element.querySelector('*:not(template)');
children && SPZCore.Dom.removeElement(children);
this.element.appendChild(el);
})
.then(() => {
this.announcementList_.forEach((item) => {
this.showAnnouncement_(item);
});
}).then(() => {
this.handleThemeCompatibility_();
});
}
// 更新文案
updateText_(item) {
const announcement = document.querySelector(`#announcement-${item.id}`);
const announcementText = announcement.querySelectorAll('.announcement_text');
const textArr = item.config.text_discount.replace_texts;
const textDom = textArr.map((text) => {
return `${text} `;
}).join(',');
announcementText.forEach((text) => {
text.innerHTML = textDom;
});
}
// 创建公告栏dom
createAnnouncementDom_() {
const isHero = /Hero/.test(THEME_NAME);
const isEva = /Eva/.test(THEME_NAME);
const headerEl = document.querySelector('[data-section-type="header"]');
const headerSticky = headerEl && SPZCore.Dom.computedStyle(this.win, headerEl).position === 'sticky';
// 创建滚动的底部公告栏
const announcementBottomContainer = document.createElement('div');
announcementBottomContainer.className = 'announcement__container_bottom bootstrap';
document.body.appendChild(announcementBottomContainer);
// 创建固定的底部公告栏
const announcementBottomSticky = document.createElement('ljs-sticky');
announcementBottomSticky.className = 'announcement__container_bottom-sticky';
announcementBottomSticky.setAttribute('layout', 'container');
announcementBottomSticky.setAttribute('position', 'bottom');
announcementBottomSticky.style.position = 'fixed';
announcementBottomSticky.style.bottom = '0';
announcementBottomSticky.style.left = '0';
announcementBottomSticky.style.right = '0';
announcementBottomSticky.style.zIndex = '1030';
document.body.appendChild(announcementBottomSticky);
const announcementTopContainer = document.createElement('div');
announcementTopContainer.classList.add('announcement__container_top');
if (isHero) {
announcementTopContainer.classList.add('announcement__container_top_zIndex_1030');
}
announcementTopContainer.classList.add('bootstrap');
document.body.insertBefore(announcementTopContainer, document.body.children[0]);
const announcementTopFixedContainer = document.createElement('div');
announcementTopFixedContainer.classList.add('announcement__container_top-fixed');
if (isHero) {
announcementTopFixedContainer.classList.add('announcement__container_top_zIndex_1030');
}
announcementTopFixedContainer.classList.add('bootstrap');
const insertBeforeElement = headerSticky ? headerEl : document.body;
insertBeforeElement.insertBefore(announcementTopFixedContainer, insertBeforeElement.children[0]);
if (isEva) {
const evaHeader = document.querySelector('header.header');
const isEvaMaskHeader = evaHeader && SPZCore.Dom.computedStyle(this.win, evaHeader).position === 'absolute';
let fixedBannerTopContainer = document.querySelector('.announcement__container_top-fixed');
if (isEvaMaskHeader) {
if (fixedBannerTopContainer) {
fixedBannerTopContainer.remove();
}
const newBanner = document.createElement('div');
newBanner.className = 'announcement__container_top-fixed bootstrap';
document.body.insertBefore(newBanner, document.body.firstChild);
fixedBannerTopContainer = newBanner;
} else {
if (!headerEl) return;
const observer = new MutationObserver(() => {
const isSticky = SPZCore.Dom.computedStyle(this.win, headerEl).position === 'sticky';
if (!isSticky) return;
const isTopFixedAnnouncementInHeader = headerEl.querySelector('.announcement__container_top-fixed');
if (isTopFixedAnnouncementInHeader) return;
const announcementTopFixedContainer = document.querySelector('.announcement__container_top-fixed');
if (announcementTopFixedContainer) {
announcementTopFixedContainer.remove();
headerEl.insertBefore(announcementTopFixedContainer, headerEl.children[0]);
observer.disconnect();
}
});
observer.observe(headerEl, { attributes: true, attributeFilter: ['style', 'class'] });
}
if (headerSticky && !isEvaMaskHeader && fixedBannerTopContainer) {
fixedBannerTopContainer.style.position = 'relative';
fixedBannerTopContainer.style.zIndex = '29';
}
}
}
// 展示公告栏
showAnnouncement_(item) {
const announcement = document.querySelector(`#announcement-${item.id}`);
const announcementBottomContainer = document.querySelector('.announcement__container_bottom');
const announcementBottomSticky = document.querySelector('.announcement__container_bottom-sticky');
const announcementTopContainer = document.querySelector('.announcement__container_top');
const announcementTopFixedContainer = document.querySelector('.announcement__container_top-fixed');
const isPC = this.viewport_.getWidth() >= 960;
const isMobile = this.viewport_.getWidth() < 960;
const isMatchPCDevice = item.device === DISPLAY_DEVICE.PC_AND_MOBILE || item.device === DISPLAY_DEVICE.PC;
const isMatchMobileDevice = item.device == DISPLAY_DEVICE.PC_AND_MOBILE || item.device === DISPLAY_DEVICE.MOBILE;
if((isPC && isMatchPCDevice) || (isMobile && isMatchMobileDevice)) {
if (item.position === POSITION.BOTTOM) {
if(item.mode === MODE.FIXED) {
announcementBottomSticky && announcementBottomSticky.appendChild(announcement);
} else {
announcementBottomContainer && announcementBottomContainer.appendChild(announcement);
}
} else {
if (item.mode === MODE.FIXED) {
announcementTopFixedContainer && announcementTopFixedContainer.appendChild(announcement);
} else {
announcementTopContainer && announcementTopContainer.appendChild(announcement);
}
}
this.reportData({
placement_id: item.id,
event: REPORT_EVENT.IMPRESSION
});
}
}
// 处理主题兼容
handleThemeCompatibility_() {
try {
const isBoost = /Boost/.test(THEME_NAME);
const isHyde = /Hyde/.test(THEME_NAME);
const isEva = /Eva/.test(THEME_NAME);
const boostHeader = document.querySelector('.boost-header');
const fixedBannerTopContainer = document.querySelector('.announcement__container_top-fixed');
const notFixedBannerTopContainer = document.querySelector('.announcement__container_top');
const headerEl = document.querySelector('[data-section-type="header"]');
const headerSticky = headerEl && SPZCore.Dom.computedStyle(this.win, headerEl).position === 'sticky';
const header = document.querySelector('.header__fixed') || document.querySelector('.header__wrapper');
const headerFixed = header && SPZCore.Dom.computedStyle(this.win, header).position === 'fixed';
const handleScroll = SPZCore.Types.throttle(this.win, () => {
if (isHyde) {
if (header && headerSticky) {
header.style.marginTop = `${fixedBannerTopContainer.offsetHeight}px`;
} else {
notFixedBannerTopContainer.style.marginTop = `${fixedBannerTopContainer.offsetHeight}px`;
}
}
if (isEva) {
const evaHeader = document.querySelector('header.header');
const isEvaMaskHeader = evaHeader && SPZCore.Dom.computedStyle(this.win, evaHeader).position === 'absolute';
if (!isEvaMaskHeader) return;
if (evaHeader.classList.contains('header__fixed')) {
evaHeader.style.marginTop = `${fixedBannerTopContainer.offsetHeight}px`;
} else {
notFixedBannerTopContainer.style.marginTop = `${fixedBannerTopContainer.offsetHeight}px`;
}
if(document.documentElement.scrollTop === 0) {
evaHeader.style.marginTop = '0';
}
}
if (headerSticky) return;
if (headerFixed) {
header.style.marginTop = `${fixedBannerTopContainer.offsetHeight}px`;
} else {
const observer = new MutationObserver((mutationsList, observer) => {
for (const mutation of mutationsList) {
if (mutation.type === 'childList' && fixedBannerTopContainer.childElementCount > 0) {
notFixedBannerTopContainer.style.marginTop = `${fixedBannerTopContainer.offsetHeight}px`;
observer.disconnect(); // 停止观察
break;
}
}
});
// 开始观察 fixedBannerTopContainer 的子节点变化
observer.observe(fixedBannerTopContainer, { childList: true, subtree: true });
// 初始检查
if (fixedBannerTopContainer.childElementCount > 0) {
notFixedBannerTopContainer.style.marginTop = `${fixedBannerTopContainer.offsetHeight}px`;
}
if(header) {
header.style.marginTop = '0';
}
}
if (isBoost) {
fixedBannerTopContainer.style.zIndex = '1031';
if (boostHeader && boostHeader.classList.contains('header__fixed')) {
boostHeader.style.marginTop = `${fixedBannerTopContainer.offsetHeight}px`;
} else {
notFixedBannerTopContainer.style.marginTop = `${fixedBannerTopContainer.offsetHeight}px`;
}
}
}, 16);
window.addEventListener('scroll', handleScroll);
window.dispatchEvent(new Event('scroll'));
} catch (error) {
console.error('error', error);
}
}
// 上报数据
async reportData(data) {
// 如果是主题编辑器则不用处理
if(window.top !== window.self) {
return;
}
this.xhr_.fetchJson(API.REPORT, {
method: "POST",
body: {
placement_id: data.placement_id,
event: data.event
}
});
}
// 监听购物车变化事件dj.cartChange
listenCartChange_() {
SPZUtils.Event.listen(document, 'dj.cartChange', (event) => {
this.fetchData_('cartChange');
});
}
setupAction_() {
this.registerAction('handleClose', (invocation) => {
const data = invocation.args;
const id = data.id;
const announcement = document.querySelector(`#announcement-${id}`);
announcement && SPZCore.Dom.removeElement(announcement);
window.dispatchEvent(new Event('scroll'));
});
this.registerAction('handleJumpLink', (invocation) => {
const data = invocation.args;
if(!data.show_url) return;
data.url && window.open(data.url, data.open_new_window ? '_blank' : '_self');
this.reportData({
placement_id: data.id,
event: REPORT_EVENT.CLICK
});
});
}
triggerEvent_(name, data) {
const event = SPZUtils.Event.create(this.win, `${ TAG }.${ name }`, data || {});
this.action_.trigger(this.element, name, event);
}
isLayoutSupported(layout) {
return layout == SPZCore.Layout.CONTAINER;
}
}
SPZ.defineElement(TAG, SpzCustomAnnouncement);
${function() {
return data.originData.list.map((item) => {
const background = item.config.background;
const interactive = item.config.interactive;
const textArr = item.config.text_discount.replace_texts;
const textColor = item.config.text_discount.color;
const backgroundSize = background.presentation_rule === 'fill' ? 'cover' : 'contain';
const pcImage = (background.url && background.upload) ? background.url : '';
const mobileImage = (background.mobile_url && background.upload) ? background.mobile_url : '';
const color1 = background.color;
const color2 = background.color2 || background.color;
const backgroundStyle = `background: url(//img.fantaskycdn.com/${pcImage}) center / ${backgroundSize} no-repeat, linear-gradient(to right, ${color1}, ${color2});`;
const backgroundMobileStyle = `background: url(//img.fantaskycdn.com/${mobileImage}) center / ${backgroundSize} no-repeat, linear-gradient(to right, ${color1}, ${color2});`;
return `
${textArr.map((text) => {
return `
${text}
`
}).join(',')}
${textArr.map((text) => {
return `
${text}
`
}).join(',')}
`
})
}()}
const TAG = 'spz-custom-painter-button-animation';
const MAX_ITERATION_COUNT = 99999999;
const SITE = (window.C_SETTINGS && window.C_SETTINGS.routes && window.C_SETTINGS.routes.root) || '';
const ADD_TO_CART_ANIMATION_SETTING =
`${SITE}/api/marketing_atmosphere_app/add_to_cart_btn_animation/setting`;
class SpzCustomPainterButtonAnimation extends SPZ.BaseElement {
/**@override */
static deferredMount() {
return false;
}
/** @param {!SpzElement} element */
constructor(element) {
super(element);
/** @private {!../../src/service/xhr-impl.Xhr} */
this.xhr_ = SPZServices.xhrFor(this.win);
/** @private {Object} */
this.data_ = null;
/** @private {Element} */
this.addToCartButton_ = null;
/** @private {boolean} */
this.productAvailable_ = true;
/** @private {number} */
this.timerId_ = null;
/** @private {number} */
this.animationExecutionCount_ = 0;
/** @private {boolean} */
this.selectedVariantAvailable_ = true;
/** @private {number} */
this.delay_ = 5000;
/** @private {number} */
this.iterationCount_ = 5;
/** @private {string} */
this.animationClass_ = '';
}
/** @override */
isLayoutSupported(layout) {
return layout == SPZCore.Layout.LOGIC;
}
/** @override */
buildCallback() {
this.productAvailable_ = this.element.hasAttribute('product-available');
this.selectedVariantAvailable_ = this.element.hasAttribute('selected-variant-available');
}
/** @override */
mountCallback() {
this.render_();
}
/** @private */
render_() {
if (!this.productAvailable_) {
return;
}
this.fetch_().then((data) => {
if (!data) {
return;
}
this.data_ = data;
this.animationClass_ = `painter-${data.animation_name}-animation`;
this.iterationCount_ =
data.animation_iteration_count === 'infinite'
? MAX_ITERATION_COUNT
: data.animation_iteration_count;
const animationDuration = 1;
const animationDelay = data.animation_delay || 5;
this.delay_ = (animationDuration + animationDelay) * 1000;
this.handleButtonEffect_();
});
}
/**
* @param {JsonObject} data
* @return {(null|Object)}
* @private
*/
parseJson_(data) {
try {
return JSON.parse(data);
} catch (e) {
return null;
}
}
/**
* @return {Promise}
* @private
*/
fetch_() {
return this.xhr_.fetchJson(ADD_TO_CART_ANIMATION_SETTING).then((data) => {
if (!data || !data.enabled) {
return null;
}
return this.parseJson_(data.detail);
});
}
/** @private */
getAddToCartButton_() {
this.addToCartButton_ = SPZCore.Dom.scopedQuerySelector(
document.body,
'[data-section-type="product"] [role="addToCart"], [data-section-type="product_detail"] [role="addToCart"], [data-section-type="product_detail"] [data-click="addToCart"], [data-section-type="product"] [data-click="addToCart"]'
);
}
/** @private */
restartAnimation_() {
this.addToCartButton_.classList.remove(this.animationClass_);
this.addToCartButton_./* OK */ offsetWidth;
this.addToCartButton_.classList.add(this.animationClass_);
this.animationExecutionCount_++;
}
/** @private */
clearTimer_() {
this.win.clearInterval(this.timerId_);
this.timerId_ = null;
}
/** @private */
setupTimer_() {
this.timerId_ = this.win.setInterval(() => {
this.restartAnimation_();
if (this.animationExecutionCount_ >= this.iterationCount_) {
this.removeAnimationClass_();
this.clearTimer_();
}
}, this.delay_);
}
/** @private */
restartTimer_() {
if (this.animationExecutionCount_ >= this.iterationCount_) {
this.removeAnimationClass_();
return;
}
this.setupTimer_();
}
/** @private */
listenVariantChange_() {
SPZUtils.Event.listen(self.document, 'dj.variantChange', (e) => {
const selectedVariant = e.detail && e.detail.selected;
if (!selectedVariant) {
return;
}
const {available} = selectedVariant;
if (this.selectedVariantAvailable_ !== available) {
this.selectedVariantAvailable_ = available;
this.clearTimer_();
if (available) {
this.restartTimer_();
}
}
});
}
/** @private */
removeAnimationClass_() {
this.win.setTimeout(() => {
this.addToCartButton_.classList.remove(this.animationClass_);
}, 1000);
}
/** @private */
handleButtonEffect_() {
this.getAddToCartButton_();
if (!this.addToCartButton_) {
return;
}
if (this.selectedVariantAvailable_) {
++this.animationExecutionCount_;
this.addToCartButton_.classList.add(this.animationClass_);
if (this.iterationCount_ === 1) {
this.removeAnimationClass_();
return;
}
this.setupTimer_();
}
this.listenVariantChange_();
}
}
SPZ.defineElement(TAG, SpzCustomPainterButtonAnimation);