-
Free air shipping over $129
Free air shipping over $129
Shop now
Free air shipping over $129
Shop now
Free air shipping over $129
Shop now
Login
Please enter your e-mail and password:
${data.errors && data.errors[0]}
Email is required
Please enter a valid email.
Password is required.
Password must be between 6-16 characters long.
${
Object.keys((data && data.login_setting) || {})
.map(type => ``)
.join("")
}
${function(){
const settings_product_title = "title";
const product_grid_image_size = "100%";
const settings_product_image_hover_on = true;
let settings_product_save_label = true;
const settings_product_swatches_name = ["color"];
const settings_collection_color_swatches = true;
const variantShowLimit = 4;
const private_id = 'product-tmpl-' + Math.random().toFixed(6).slice(-6)
const product_variants = data.variants || [];
const product_id = data.id;
const images = data.images || [];
const image = data.image || {};
const imageWidth = image.width;
let imageHeight = image.height;
if (product_grid_image_size !== 'natural') {
imageHeight = (imageWidth * parseFloat(product_grid_image_size)) / 100;
}
const price = Number(data.price_min);
let compareAtPrice = Number(data.compare_at_price);
let offRatio = data.off_ratio;
const type = data.type;
const isMock = data.isMock;
let product_image_hover_on = false;
for (let i = 0; i < product_variants.length; i++) {
const item = product_variants[i];
const vcap = Number(item.compare_at_price);
if (item.price == price && vcap > compareAtPrice) {
compareAtPrice = vcap;
offRatio = item.off_ratio;
}
}
let second_image = null;
if (settings_product_image_hover_on) {
for (let i = 1; i < images.length; i++) {
const img = images[i];
if (img.src && img.src.indexOf('video=') === -1) {
second_image = img;
product_image_hover_on = true;
break;
}
}
}
let sold_label_on = false;
let sale_label_on = false;
if (settings_product_save_label == null) {
settings_product_save_label = true;
}
if (!data.available) {
sold_label_on = true;
}
if (settings_product_save_label && compareAtPrice > price && data.available) {
sale_label_on = true;
}
const diffPrice = compareAtPrice - price;
const variantValues = [];
const showVariants = [];
if (data.need_variant_image && settings_collection_color_swatches && settings_product_swatches_name.length > 0) {
for (let i = 0; i < (data.options || []).length; i++) {
const option = data.originData.options[i];
const optionName = option.name && option.name.toLowerCase();
if (settings_product_swatches_name.includes(optionName)) {
for (let j = 0; j < product_variants.length; j++) {
const variant = product_variants[j];
const value = variant.options[i].value;
if (!variantValues.includes(value)) {
variantValues.push(value);
showVariants.push(variant);
}
}
break;
}
}
}
return `
`;
}()}
${function() {
let availableQuantity = data && data.available_quantity;
const lowStock = 5;
if (availableQuantity == undefined) { return ''; }
availableQuantity = Math.max(availableQuantity, 0);
return availableQuantity > lowStock ? `
${("{stock} in stock, ready to be shipped").replace(/\{*stock*\}/, availableQuantity)}
` : `
${("Only {count} left!").replace(/\{*count*\}/, availableQuantity)}
`;
}()}
-
Price
${function() {
const selectedVariant = data.variants.find(v => v.available) || data.variants[0];
return !!selectedVariant ? `
Save
` : `
-
`;
}()}
${function() {
const selectedVariant = data.variants.find(v => v.available) || data.variants[0];
const statusLan = (
(selectedVariant && !selectedVariant.available) ||
(!selectedVariant && !data.available)) ?
"Sold out" :
"Add to cart";
const status = (
(selectedVariant && !selectedVariant.available) ||
(!selectedVariant && !data.available)) ? 'soldout' : 'available';
return `
Product is unavailable.
Product was out of stock.
`;
}()}
${function() {
const MAX_INVENTORY = 999999;
const product0 = Object.prototype.toString.call(data) == '[object Array]' ? data[0] : data;
const inventoryQty = product0.inventory_quantity;
const inventoryPolicy = product0.inventory_policy;
const inventoryTracking = product0.inventory_tracking;
const exactInventoryStatusId = "quick-shop-exact-inventory-render";
const lowStock = 5;
const selectedVariant = product0.variants.find(v => v.available) || data.variants[0];
const selectedVariantAvailableQuantity = selectedVariant && selectedVariant.available_quantity;
let actualInventory = inventoryQty;
if ((inventoryTracking && inventoryPolicy == 'continue') || !inventoryTracking) {
actualInventory = MAX_INVENTORY;
}
return `
Avaliability:
Out of stock
in stock, ready to be shipped
Low stock
`;
}()}
- ${data.eventName == 'mouseout' ? data.selectedOptions[0] : (data.targetOption || data.defaultValue || '')}
${function() {
var thumbSwitchName = '';
return (data.product.options || []).map((option, index) => {
const optionName = option.name || '';
const position = `option${index + 1}`;
var isThumbImage = false;
if (data.product.need_variant_image && thumbSwitchName === '') {
const variantNames = ["color"] || [];
for (let i = 0, len = variantNames.length; i < len; i++) {
const name = variantNames[i];
if (name === optionName) {
isThumbImage = true;
thumbSwitchName = name;
}
}
}
const variantType = "button";
const thumbStyle = "image_with_text";
const mouseEvent = isThumbImage ? ('quick-shop-variant-template-' + optionName + '.rerender(data=event);') : '';
return (variantType == 'dropdown' && !isThumbImage) ? `
${optionName.toLowerCase()}
` : `
${optionName.toLowerCase()}
${option.values.map(value => {
const selected = data.selectedValues[optionName] == value ? 'selected' : '';
let thumbImage = null;
if (isThumbImage) {
const variants = data.product.variants;
for (let i = 0, len = variants.length; i < len; i++) {
const variant = variants[i];
if (variant[position] == value && thumbImage == null) {
thumbImage = variant.image;
break;
}
}
}
return `
${value}
`;
}).join('')}
`;
}).join('')
}()}
${function() {
const images = data.images || [];
const selectedVariant = data.variants.find(v => v.available) || data.variants[0];
const selectedIndex = !!selectedVariant ? images.findIndex(img => img.src === (selectedVariant.image && selectedVariant.image.src)) : 0;
const initialSlide = selectedIndex === -1 ? 0 : selectedIndex;
return `
${images.map((image, index) => `
`).join('')}
${images.map(image => `
`).join('')}
`;
}()}
${data.title}
Price
${function() {
const selectedVariant = data.variants.find(v => v.available) || data.variants[0];
return !!selectedVariant ? `
Save
` : `
-
`;
}()}
${function() {
const selectedVariant = data.variants.find(v => v.available) || data.variants[0];
const statusLan = (
(selectedVariant && !selectedVariant.available) ||
(!selectedVariant && !data.available)) ?
"Sold out" :
"Add to cart";
const status = (
(selectedVariant && !selectedVariant.available) ||
(!selectedVariant && !data.available)) ? 'soldout' : 'available';
return `
Product is unavailable.
Product was out of stock.
`;
}()}
${function() {
const MAX_INVENTORY = 999999;
const product0 = Object.prototype.toString.call(data) == '[object Array]' ? data[0] : data;
const inventoryQty = product0.inventory_quantity;
const inventoryPolicy = product0.inventory_policy;
const inventoryTracking = product0.inventory_tracking;
const exactInventoryStatusId = "quick-view-exact-inventory-render";
const lowStock = 5;
const selectedVariant = product0.variants.find(v => v.available) || data.variants[0];
const selectedVariantAvailableQuantity = selectedVariant && selectedVariant.available_quantity;
let actualInventory = inventoryQty;
if ((inventoryTracking && inventoryPolicy == 'continue') || !inventoryTracking) {
actualInventory = MAX_INVENTORY;
}
return `
Avaliability:
Out of stock
in stock, ready to be shipped
Low stock
`;
}()}
- ${data.eventName == 'mouseout' ? data.selectedOptions[0] : (data.targetOption || data.defaultValue || '')}
${function() {
var thumbSwitchName = '';
return (data.product.options || []).map((option, index) => {
const optionName = option.name || '';
const position = `option${index + 1}`;
var isThumbImage = false;
if (data.product.need_variant_image && thumbSwitchName === '') {
const variantNames = ["color"] || [];
for (let i = 0, len = variantNames.length; i < len; i++) {
const name = variantNames[i];
if (name === optionName) {
isThumbImage = true;
thumbSwitchName = name;
}
}
}
const variantType = "button";
const thumbStyle = "image_with_text";
const mouseEvent = isThumbImage ? ('quick-view-variant-template-' + optionName + '.rerender(data=event);') : '';
return (variantType == 'dropdown' && !isThumbImage) ? `
${optionName.toLowerCase()}
` : `
${optionName.toLowerCase()}
${option.values.map(value => {
const selected = data.selectedValues[optionName] == value ? 'selected' : '';
let thumbImage = null;
if (isThumbImage) {
const variants = data.product.variants;
for (let i = 0, len = variants.length; i < len; i++) {
const variant = variants[i];
if (variant[position] == value && thumbImage == null) {
thumbImage = variant.image;
break;
}
}
}
return `
${value}
`;
}).join('')}
`;
}).join('')
}()}
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);
${function () {
const renderData = data.data;
const position_bottom = renderData.height;
const model_style = renderData.subwindow_style == "model1" ? "model-type-icon" : "model-type-icon-with-text";
const filterSubwindow = renderData.subwindow.filter(item =>
renderData.subwindow_style == "model1" && item.image || (renderData.subwindow_style == "model2" && (item.image || item.title))
);
const initFoldStyle = renderData.hover_display === 'foldable' && 'fold';
const initShowStyle = renderData.hover_mode != 'permanent' && 'app-floating-hidden';
const is_model_style_follow_theme = renderData.template_style == "follow_theme" && renderData.subwindow_style == "model2";
const is_model_style_custom = renderData.template_style == "custom" && renderData.subwindow_style == "model2"
let isShowApp = false;
let isCustomPage = false;
const current_page_url = 'https://www.jewelock.com/account/login';
const current_page_type = 'login';
if(renderData.effective_pages.type === 'specify' && renderData.effective_pages.specify_page.includes('custom') && renderData.effective_pages.custom_page.length > 0) {
renderData.effective_pages.custom_page.forEach(item => {
const custom_url = item?.split('?')[0];
if(current_page_url === decodeURI(custom_url)) {
isCustomPage = true;
return;
}
})
}
if(renderData.effective_pages.type === 'all' || (renderData.effective_pages.type === 'specify' && renderData.effective_pages.specify_page.includes(current_page_type)) || isCustomPage) {
isShowApp = true;
}
if(isShowApp && filterSubwindow.length > 0) {
return `
${function() {
if(renderData.hover_mode === "scroll") {
return `
`
} else if (renderData.hover_mode === "threshold_scroll") {
return `
`
} else {
return ``
}
}()}
${function() {
const [firstIem, ...restItems] = filterSubwindow
const item = firstIem;
return `${firstIem ? `
-
`: ''}
${restItems.length > 0 ? `
-
${restItems.map(item => `
`).join('')
}
`: ''
}`
}()}
`
} else {
return ``
}
}()}