- Home
- Art
- Mirrors
- Wall Mirrors
'); // const $a = $('').attr('href', `${productUrl}?color_id=${color.id}`); // const $img = $('') // .attr('src', color.value_data ? color.value_data.image_url : '') // .attr('title', color.label) // .attr('alt', color.label); // $a.append($img); // $div.append($a); // $swatchDiv.append($div); // } // }); // } else { // // 如果没有颜色,可以添加一些默认的提示或者留空 // } // // 如果超过五个颜色,添加额外的自定义图片 // if (item.option_values.length > 5) { // const $div = $('
'); // const $moreLink = $('').attr('href', `${productUrl}`); // const $moreImg = $('') // .attr('src', '/content/images/more.svg') // .attr('alt', 'more icon'); // $moreLink.append($moreImg); // $div.append($moreLink); // $swatchDiv.append($div); // } // } // } // }); // } // } // }) // .catch(error => { // console.error('Error fetching product colors:', error); // // 从集合中移除当前的 productId,以便在失败后可以重新请求 // requestedProductIds.delete(productId); // }); // } var skuCache = {}; var pendingRequests = {}; function getMainImage(productId, sku) { // Check if the image for this SKU is already cached if (skuCache&&skuCache[sku]) { const imgSrc = skuCache[sku]; const $cardImgDiv = $(`#card-img-${productId}`); $cardImgDiv.attr("src", imgSrc); return; // Return early to avoid making a redundant network request } // Check if a request for this SKU is already pending if (pendingRequests[sku]) { // If a request is pending, just wait for it to complete and use the cached value then pendingRequests[sku].then(imgSrc => { const $cardImgDiv = $(`#card-img-${productId}`); $cardImgDiv.attr("src", imgSrc); }); return; } // If not cached and no pending request, make a new network request pendingRequests[sku] = fetch(`https://websiteapi2.zgallerie.com/website/product/skuImgUrl?sku=${sku}`, { method: "GET" }) .then(response => response.json()) .then(res => { if(res.code==200) { const imgSrc = res.data; // Cache the image URL for the SKU skuCache[sku] = imgSrc; const $cardImgDiv = $(`#card-img-${productId}`); $cardImgDiv.attr("src", imgSrc); return imgSrc; // Return the image source to resolve the pending request promise } else { throw new Error("Failed to load image"); } }) .catch(error => { console.error("Error fetching image:", error); }) .finally(() => { // Clean up the pending request entry once it's fulfilled or rejected delete pendingRequests[sku]; }); // Handle the image once the pending request completes pendingRequests[sku].then(imgSrc => { const $cardImgDiv = $(`#card-img-${productId}`); $cardImgDiv.attr("src", imgSrc); }); } // 页面加载完成后执行的代码 window.onload = function() { }; document.addEventListener('DOMContentLoaded', function () { }); function calculateDiscountPercentage(originalPrice, discountedPrice) { if (originalPrice <= 0 || discountedPrice <= 0) { return "Invalid input. Prices must be greater than zero."; } var discount = originalPrice - discountedPrice; var discountPercentage = discount / originalPrice / 5 * 100 ; return Math.floor(discountPercentage.toFixed(2)) * 5 + "% OFF"; } var requestedSkus = new Set(); // 用于存储已请求的 sku function getBynderImgByNode(sku,productId){ const $cardImgDiv = $(`#card-img-${productId}`); fetch(`https://websiteapi2.zgallerie.com/node/getBynderImagesBySku/${sku}`, { method: "GET" }).then(response => response.json()) .then(res => { if (res && res.length > 0) { res.forEach((item) => { if (item.property_Order && item.property_Order[0] == '1') { $cardImgDiv.attr("src", item.thumbnails.webimage); } if (item.property_Order && item.property_Order[0] == '2') { $cardImgDiv.attr("data-nsrc", item.thumbnails.webimage); } }).catch(error => { console.error('Error fetching bynder images:', error); }); } }) } function getProductListImageBynder(sku, productId) { // 检查 element 是否是一个有效的 DOM 元素 const $cardImgDiv = $(`#card-img-${productId}`); if (requestedSkus.has(sku)) { return; // 已请求过,直接返回 } // 添加 sku 到集合中 requestedSkus.add(sku); fetch(`https://websiteapi2.zgallerie.com/website/product/findBynderImg?skuCode=${sku}`, { method: "GET" }).then(response => response.json()) .then(res => { if (res && res.data && res.data.length > 0) { $cardImgDiv.attr("src",res.data[0].webimage); $cardImgDiv.attr("data-nsrc", res.data[1].webimage); }else { getBynderImgByNode(sku,productId) } }) }
'); // const $a = $('').attr('href', `${productUrl}?color_id=${color.id}`); // const $img = $('') // .attr('src', color.value_data ? color.value_data.image_url : '') // .attr('title', color.label) // .attr('alt', color.label); // $a.append($img); // $div.append($a); // $swatchDiv.append($div); // } // }); // } else { // // 如果没有颜色,可以添加一些默认的提示或者留空 // } // // 如果超过五个颜色,添加额外的自定义图片 // if (item.option_values.length > 5) { // const $div = $('
'); // const $moreLink = $('').attr('href', `${productUrl}`); // const $moreImg = $('') // .attr('src', '/content/images/more.svg') // .attr('alt', 'more icon'); // $moreLink.append($moreImg); // $div.append($moreLink); // $swatchDiv.append($div); // } // } // } // }); // } // } // }) // .catch(error => { // console.error('Error fetching product colors:', error); // // 从集合中移除当前的 productId,以便在失败后可以重新请求 // requestedProductIds.delete(productId); // }); // } var skuCache = {}; var pendingRequests = {}; function getMainImage(productId, sku) { // Check if the image for this SKU is already cached if (skuCache&&skuCache[sku]) { const imgSrc = skuCache[sku]; const $cardImgDiv = $(`#card-img-${productId}`); $cardImgDiv.attr("src", imgSrc); return; // Return early to avoid making a redundant network request } // Check if a request for this SKU is already pending if (pendingRequests[sku]) { // If a request is pending, just wait for it to complete and use the cached value then pendingRequests[sku].then(imgSrc => { const $cardImgDiv = $(`#card-img-${productId}`); $cardImgDiv.attr("src", imgSrc); }); return; } // If not cached and no pending request, make a new network request pendingRequests[sku] = fetch(`https://websiteapi2.zgallerie.com/website/product/skuImgUrl?sku=${sku}`, { method: "GET" }) .then(response => response.json()) .then(res => { if(res.code==200) { const imgSrc = res.data; // Cache the image URL for the SKU skuCache[sku] = imgSrc; const $cardImgDiv = $(`#card-img-${productId}`); $cardImgDiv.attr("src", imgSrc); return imgSrc; // Return the image source to resolve the pending request promise } else { throw new Error("Failed to load image"); } }) .catch(error => { console.error("Error fetching image:", error); }) .finally(() => { // Clean up the pending request entry once it's fulfilled or rejected delete pendingRequests[sku]; }); // Handle the image once the pending request completes pendingRequests[sku].then(imgSrc => { const $cardImgDiv = $(`#card-img-${productId}`); $cardImgDiv.attr("src", imgSrc); }); } // 页面加载完成后执行的代码 window.onload = function() { }; document.addEventListener('DOMContentLoaded', function () { }); function calculateDiscountPercentage(originalPrice, discountedPrice) { if (originalPrice <= 0 || discountedPrice <= 0) { return "Invalid input. Prices must be greater than zero."; } var discount = originalPrice - discountedPrice; var discountPercentage = discount / originalPrice / 5 * 100 ; return Math.floor(discountPercentage.toFixed(2)) * 5 + "% OFF"; } var requestedSkus = new Set(); // 用于存储已请求的 sku function getBynderImgByNode(sku,productId){ const $cardImgDiv = $(`#card-img-${productId}`); fetch(`https://websiteapi2.zgallerie.com/node/getBynderImagesBySku/${sku}`, { method: "GET" }).then(response => response.json()) .then(res => { if (res && res.length > 0) { res.forEach((item) => { if (item.property_Order && item.property_Order[0] == '1') { $cardImgDiv.attr("src", item.thumbnails.webimage); } if (item.property_Order && item.property_Order[0] == '2') { $cardImgDiv.attr("data-nsrc", item.thumbnails.webimage); } }).catch(error => { console.error('Error fetching bynder images:', error); }); } }) } function getProductListImageBynder(sku, productId) { // 检查 element 是否是一个有效的 DOM 元素 const $cardImgDiv = $(`#card-img-${productId}`); if (requestedSkus.has(sku)) { return; // 已请求过,直接返回 } // 添加 sku 到集合中 requestedSkus.add(sku); fetch(`https://websiteapi2.zgallerie.com/website/product/findBynderImg?skuCode=${sku}`, { method: "GET" }).then(response => response.json()) .then(res => { if (res && res.data && res.data.length > 0) { $cardImgDiv.attr("src",res.data[0].webimage); $cardImgDiv.attr("data-nsrc", res.data[1].webimage); }else { getBynderImgByNode(sku,productId) } }) }
'); // const $a = $('').attr('href', `${productUrl}?color_id=${color.id}`); // const $img = $('') // .attr('src', color.value_data ? color.value_data.image_url : '') // .attr('title', color.label) // .attr('alt', color.label); // $a.append($img); // $div.append($a); // $swatchDiv.append($div); // } // }); // } else { // // 如果没有颜色,可以添加一些默认的提示或者留空 // } // // 如果超过五个颜色,添加额外的自定义图片 // if (item.option_values.length > 5) { // const $div = $('
'); // const $moreLink = $('').attr('href', `${productUrl}`); // const $moreImg = $('') // .attr('src', '/content/images/more.svg') // .attr('alt', 'more icon'); // $moreLink.append($moreImg); // $div.append($moreLink); // $swatchDiv.append($div); // } // } // } // }); // } // } // }) // .catch(error => { // console.error('Error fetching product colors:', error); // // 从集合中移除当前的 productId,以便在失败后可以重新请求 // requestedProductIds.delete(productId); // }); // } var skuCache = {}; var pendingRequests = {}; function getMainImage(productId, sku) { // Check if the image for this SKU is already cached if (skuCache&&skuCache[sku]) { const imgSrc = skuCache[sku]; const $cardImgDiv = $(`#card-img-${productId}`); $cardImgDiv.attr("src", imgSrc); return; // Return early to avoid making a redundant network request } // Check if a request for this SKU is already pending if (pendingRequests[sku]) { // If a request is pending, just wait for it to complete and use the cached value then pendingRequests[sku].then(imgSrc => { const $cardImgDiv = $(`#card-img-${productId}`); $cardImgDiv.attr("src", imgSrc); }); return; } // If not cached and no pending request, make a new network request pendingRequests[sku] = fetch(`https://websiteapi2.zgallerie.com/website/product/skuImgUrl?sku=${sku}`, { method: "GET" }) .then(response => response.json()) .then(res => { if(res.code==200) { const imgSrc = res.data; // Cache the image URL for the SKU skuCache[sku] = imgSrc; const $cardImgDiv = $(`#card-img-${productId}`); $cardImgDiv.attr("src", imgSrc); return imgSrc; // Return the image source to resolve the pending request promise } else { throw new Error("Failed to load image"); } }) .catch(error => { console.error("Error fetching image:", error); }) .finally(() => { // Clean up the pending request entry once it's fulfilled or rejected delete pendingRequests[sku]; }); // Handle the image once the pending request completes pendingRequests[sku].then(imgSrc => { const $cardImgDiv = $(`#card-img-${productId}`); $cardImgDiv.attr("src", imgSrc); }); } // 页面加载完成后执行的代码 window.onload = function() { }; document.addEventListener('DOMContentLoaded', function () { }); function calculateDiscountPercentage(originalPrice, discountedPrice) { if (originalPrice <= 0 || discountedPrice <= 0) { return "Invalid input. Prices must be greater than zero."; } var discount = originalPrice - discountedPrice; var discountPercentage = discount / originalPrice / 5 * 100 ; return Math.floor(discountPercentage.toFixed(2)) * 5 + "% OFF"; } var requestedSkus = new Set(); // 用于存储已请求的 sku function getBynderImgByNode(sku,productId){ const $cardImgDiv = $(`#card-img-${productId}`); fetch(`https://websiteapi2.zgallerie.com/node/getBynderImagesBySku/${sku}`, { method: "GET" }).then(response => response.json()) .then(res => { if (res && res.length > 0) { res.forEach((item) => { if (item.property_Order && item.property_Order[0] == '1') { $cardImgDiv.attr("src", item.thumbnails.webimage); } if (item.property_Order && item.property_Order[0] == '2') { $cardImgDiv.attr("data-nsrc", item.thumbnails.webimage); } }).catch(error => { console.error('Error fetching bynder images:', error); }); } }) } function getProductListImageBynder(sku, productId) { // 检查 element 是否是一个有效的 DOM 元素 const $cardImgDiv = $(`#card-img-${productId}`); if (requestedSkus.has(sku)) { return; // 已请求过,直接返回 } // 添加 sku 到集合中 requestedSkus.add(sku); fetch(`https://websiteapi2.zgallerie.com/website/product/findBynderImg?skuCode=${sku}`, { method: "GET" }).then(response => response.json()) .then(res => { if (res && res.data && res.data.length > 0) { $cardImgDiv.attr("src",res.data[0].webimage); $cardImgDiv.attr("data-nsrc", res.data[1].webimage); }else { getBynderImgByNode(sku,productId) } }) }
'); // const $a = $('').attr('href', `${productUrl}?color_id=${color.id}`); // const $img = $('') // .attr('src', color.value_data ? color.value_data.image_url : '') // .attr('title', color.label) // .attr('alt', color.label); // $a.append($img); // $div.append($a); // $swatchDiv.append($div); // } // }); // } else { // // 如果没有颜色,可以添加一些默认的提示或者留空 // } // // 如果超过五个颜色,添加额外的自定义图片 // if (item.option_values.length > 5) { // const $div = $('
'); // const $moreLink = $('').attr('href', `${productUrl}`); // const $moreImg = $('') // .attr('src', '/content/images/more.svg') // .attr('alt', 'more icon'); // $moreLink.append($moreImg); // $div.append($moreLink); // $swatchDiv.append($div); // } // } // } // }); // } // } // }) // .catch(error => { // console.error('Error fetching product colors:', error); // // 从集合中移除当前的 productId,以便在失败后可以重新请求 // requestedProductIds.delete(productId); // }); // } var skuCache = {}; var pendingRequests = {}; function getMainImage(productId, sku) { // Check if the image for this SKU is already cached if (skuCache&&skuCache[sku]) { const imgSrc = skuCache[sku]; const $cardImgDiv = $(`#card-img-${productId}`); $cardImgDiv.attr("src", imgSrc); return; // Return early to avoid making a redundant network request } // Check if a request for this SKU is already pending if (pendingRequests[sku]) { // If a request is pending, just wait for it to complete and use the cached value then pendingRequests[sku].then(imgSrc => { const $cardImgDiv = $(`#card-img-${productId}`); $cardImgDiv.attr("src", imgSrc); }); return; } // If not cached and no pending request, make a new network request pendingRequests[sku] = fetch(`https://websiteapi2.zgallerie.com/website/product/skuImgUrl?sku=${sku}`, { method: "GET" }) .then(response => response.json()) .then(res => { if(res.code==200) { const imgSrc = res.data; // Cache the image URL for the SKU skuCache[sku] = imgSrc; const $cardImgDiv = $(`#card-img-${productId}`); $cardImgDiv.attr("src", imgSrc); return imgSrc; // Return the image source to resolve the pending request promise } else { throw new Error("Failed to load image"); } }) .catch(error => { console.error("Error fetching image:", error); }) .finally(() => { // Clean up the pending request entry once it's fulfilled or rejected delete pendingRequests[sku]; }); // Handle the image once the pending request completes pendingRequests[sku].then(imgSrc => { const $cardImgDiv = $(`#card-img-${productId}`); $cardImgDiv.attr("src", imgSrc); }); } // 页面加载完成后执行的代码 window.onload = function() { }; document.addEventListener('DOMContentLoaded', function () { }); function calculateDiscountPercentage(originalPrice, discountedPrice) { if (originalPrice <= 0 || discountedPrice <= 0) { return "Invalid input. Prices must be greater than zero."; } var discount = originalPrice - discountedPrice; var discountPercentage = discount / originalPrice / 5 * 100 ; return Math.floor(discountPercentage.toFixed(2)) * 5 + "% OFF"; } var requestedSkus = new Set(); // 用于存储已请求的 sku function getBynderImgByNode(sku,productId){ const $cardImgDiv = $(`#card-img-${productId}`); fetch(`https://websiteapi2.zgallerie.com/node/getBynderImagesBySku/${sku}`, { method: "GET" }).then(response => response.json()) .then(res => { if (res && res.length > 0) { res.forEach((item) => { if (item.property_Order && item.property_Order[0] == '1') { $cardImgDiv.attr("src", item.thumbnails.webimage); } if (item.property_Order && item.property_Order[0] == '2') { $cardImgDiv.attr("data-nsrc", item.thumbnails.webimage); } }).catch(error => { console.error('Error fetching bynder images:', error); }); } }) } function getProductListImageBynder(sku, productId) { // 检查 element 是否是一个有效的 DOM 元素 const $cardImgDiv = $(`#card-img-${productId}`); if (requestedSkus.has(sku)) { return; // 已请求过,直接返回 } // 添加 sku 到集合中 requestedSkus.add(sku); fetch(`https://websiteapi2.zgallerie.com/website/product/findBynderImg?skuCode=${sku}`, { method: "GET" }).then(response => response.json()) .then(res => { if (res && res.data && res.data.length > 0) { $cardImgDiv.attr("src",res.data[0].webimage); $cardImgDiv.attr("data-nsrc", res.data[1].webimage); }else { getBynderImgByNode(sku,productId) } }) }
'); // const $a = $('').attr('href', `${productUrl}?color_id=${color.id}`); // const $img = $('') // .attr('src', color.value_data ? color.value_data.image_url : '') // .attr('title', color.label) // .attr('alt', color.label); // $a.append($img); // $div.append($a); // $swatchDiv.append($div); // } // }); // } else { // // 如果没有颜色,可以添加一些默认的提示或者留空 // } // // 如果超过五个颜色,添加额外的自定义图片 // if (item.option_values.length > 5) { // const $div = $('
'); // const $moreLink = $('').attr('href', `${productUrl}`); // const $moreImg = $('') // .attr('src', '/content/images/more.svg') // .attr('alt', 'more icon'); // $moreLink.append($moreImg); // $div.append($moreLink); // $swatchDiv.append($div); // } // } // } // }); // } // } // }) // .catch(error => { // console.error('Error fetching product colors:', error); // // 从集合中移除当前的 productId,以便在失败后可以重新请求 // requestedProductIds.delete(productId); // }); // } var skuCache = {}; var pendingRequests = {}; function getMainImage(productId, sku) { // Check if the image for this SKU is already cached if (skuCache&&skuCache[sku]) { const imgSrc = skuCache[sku]; const $cardImgDiv = $(`#card-img-${productId}`); $cardImgDiv.attr("src", imgSrc); return; // Return early to avoid making a redundant network request } // Check if a request for this SKU is already pending if (pendingRequests[sku]) { // If a request is pending, just wait for it to complete and use the cached value then pendingRequests[sku].then(imgSrc => { const $cardImgDiv = $(`#card-img-${productId}`); $cardImgDiv.attr("src", imgSrc); }); return; } // If not cached and no pending request, make a new network request pendingRequests[sku] = fetch(`https://websiteapi2.zgallerie.com/website/product/skuImgUrl?sku=${sku}`, { method: "GET" }) .then(response => response.json()) .then(res => { if(res.code==200) { const imgSrc = res.data; // Cache the image URL for the SKU skuCache[sku] = imgSrc; const $cardImgDiv = $(`#card-img-${productId}`); $cardImgDiv.attr("src", imgSrc); return imgSrc; // Return the image source to resolve the pending request promise } else { throw new Error("Failed to load image"); } }) .catch(error => { console.error("Error fetching image:", error); }) .finally(() => { // Clean up the pending request entry once it's fulfilled or rejected delete pendingRequests[sku]; }); // Handle the image once the pending request completes pendingRequests[sku].then(imgSrc => { const $cardImgDiv = $(`#card-img-${productId}`); $cardImgDiv.attr("src", imgSrc); }); } // 页面加载完成后执行的代码 window.onload = function() { }; document.addEventListener('DOMContentLoaded', function () { }); function calculateDiscountPercentage(originalPrice, discountedPrice) { if (originalPrice <= 0 || discountedPrice <= 0) { return "Invalid input. Prices must be greater than zero."; } var discount = originalPrice - discountedPrice; var discountPercentage = discount / originalPrice / 5 * 100 ; return Math.floor(discountPercentage.toFixed(2)) * 5 + "% OFF"; } var requestedSkus = new Set(); // 用于存储已请求的 sku function getBynderImgByNode(sku,productId){ const $cardImgDiv = $(`#card-img-${productId}`); fetch(`https://websiteapi2.zgallerie.com/node/getBynderImagesBySku/${sku}`, { method: "GET" }).then(response => response.json()) .then(res => { if (res && res.length > 0) { res.forEach((item) => { if (item.property_Order && item.property_Order[0] == '1') { $cardImgDiv.attr("src", item.thumbnails.webimage); } if (item.property_Order && item.property_Order[0] == '2') { $cardImgDiv.attr("data-nsrc", item.thumbnails.webimage); } }).catch(error => { console.error('Error fetching bynder images:', error); }); } }) } function getProductListImageBynder(sku, productId) { // 检查 element 是否是一个有效的 DOM 元素 const $cardImgDiv = $(`#card-img-${productId}`); if (requestedSkus.has(sku)) { return; // 已请求过,直接返回 } // 添加 sku 到集合中 requestedSkus.add(sku); fetch(`https://websiteapi2.zgallerie.com/website/product/findBynderImg?skuCode=${sku}`, { method: "GET" }).then(response => response.json()) .then(res => { if (res && res.data && res.data.length > 0) { $cardImgDiv.attr("src",res.data[0].webimage); $cardImgDiv.attr("data-nsrc", res.data[1].webimage); }else { getBynderImgByNode(sku,productId) } }) }