Raw Wood Energy · Artisan Polished · Spiritual Healing Mala | Premium Men's Aura Enhancement Bracelet

Raw Wood Energy · Artisan Polished · Spiritual Healing Mala | Premium Men's Aura Enhancement Bracelet

AuraZen Natural Wood Bead Bracelet Collection | Handcrafted Edition

AuraZen Natural Wood Bead Bracelet Collection | Handcrafted Edition

$19.99
$130.89
people are viewing this right now
Color: Cat's Eye Red Sandalwood
Size:
Please select a Size
Quantity
Estimated Delivery:May-26 - Jun-03
Product was out of stock.
Product is unavailable.
Free worldwide shipping

Enjoy free shipping on every order, delivered to your doorstep no matter where you are in the world.

Free returns

Shop with confidence with our hassle-free returns policy, ensuring you love what you buy.

Sustainably made

Designed with the planet in mind, all our products are committed to sustainable practices.

Secure payments

Your payment information is always protected with our advanced, encrypted checkout security.

Description

Product Description

🌿 Harness the Ancient Power of Nature

Each bead in our collection is handcrafted from sustainably sourced, natural hardwood, preserving the wood's unique grain, color, and inherent aromatic properties. We adhere to a strict no-paint, no-wax philosophy, allowing the wood's natural energy to resonate deeply with your aura, bringing calm, focus, and positive transformation.
The 20mm bead size and classic 12-bead configuration are specifically designed for men, offering a bold, sophisticated look that embodies Eastern Zen aesthetics. Perfect for daily wear, meditation, or as a meaningful gift for the spiritual seeker in your life.

✨ Complete Collection (28 Unique Varieties)

All bracelets feature the same premium construction: 20mm diameter beads, 12 beads per strand, high-elasticity durable cord, and matching wood guru bead with traditional knot.
  1. Cat's Eye Red Sandalwood 
    Features a striking chatoyant (cat's eye) effect that shimmers in light. This rare wood enhances intuition and spiritual insight, helping you see clearly through life's challenges and make wise decisions.
  2. Vietnamese Agarwood 
    The "King of Incense", with a rich, earthy, and deeply calming fragrance. Renowned for purifying negative energy, relieving anxiety, and deepening meditation practice. A sacred wood used in spiritual rituals for millennia.
  3. Burma Padauk
    Warm reddish-brown hue with beautiful flowing grain patterns and a subtle fruity aroma. Symbolizes prosperity and good fortune, attracting abundance and harmonious relationships into your life.
  4. Purpleheart Wood
    Stunning natural violet-purple color that deepens with age and exposure to light. Activates the third eye chakra, enhancing creativity, intuition, and spiritual awareness.
  5. Golden Sandalwood
    Lustrous golden-brown color with fine, silky grain and a gentle, woody scent. Associated with wealth and success, it boosts confidence and personal magnetism, helping you achieve your goals.
  6. Laos Rosewood
    Deep, rich reddish-brown color with dramatic black streaks. A symbol of strength and resilience, it provides grounding energy and protection against negative influences.
  7. Small Leaf Red Sandalwood
    Dense, heavy wood with a deep red color and smooth, polished finish. Nurtures physical health and vitality, promoting longevity and overall well-being. An affordable alternative to premium red sandalwood.
  8. Goldenwood
    Bright, sunny golden-yellow color that radiates warmth and positivity. Attracts joy, optimism, and new opportunities, making it perfect for anyone looking to start a new chapter in life.
  9. Multi-Wood Harmony Bracelet 
    A curated blend of 12 different precious woods in one bracelet. Combines the unique energies of each wood to create a powerful, balanced energy field, promoting overall harmony and success in all areas of life. The perfect beginner's bracelet.
  10. Wenge Wood
    Distinctive black and brown striped grain resembling chicken feathers. A protective wood that wards off negative energy and enhances courage and determination, helping you overcome obstacles.
  11. Ebony Wood
    Deep, jet-black color with a subtle, glossy sheen. Known as the "Black Diamond of Woods", it offers powerful spiritual protection, grounding, and purification of the energy field.
  12. Big Leaf Huanghuali
    Beautiful golden-brown color with intricate, flowing grain patterns. Highly prized in Chinese culture, it symbolizes nobility, wealth, and good fortune.
  13. Zambian Red Sandalwood
    Rich, deep purple-red color with a dense, fine grain. Promotes emotional balance, reduces stress, and enhances spiritual connection. A popular choice for meditation and mindfulness practice.
  14. Imperial Bloodwood
    Unique translucent red color that glows when held up to light. A rare and powerful wood that enhances vitality, strength, and leadership qualities. Associated with royalty and power.
  15. Sinking Wood Phoebe Zhennan
    Ancient wood that has been buried underground for thousands of years. Carries the wisdom of the ages, providing deep grounding, protection, and spiritual transformation. Has a subtle, calming fragrance.
  16. Taihang Arborvitae
    Grows on the rocky cliffs of the Taihang Mountains. Has a distinctive, refreshing medicinal aroma that clears the mind, relieves stress, and purifies the air. Promotes longevity and good health.
  17. Babi Sandalwood
    Creamy light brown color with a sweet, warm sandalwood fragrance. Calms the nervous system, promotes relaxation, and enhances spiritual awareness. Perfect for meditation and yoga.
  18. Golden Phoebe Zhennan
    One of the most precious woods in China, with a stunning golden luster and silky smooth texture. Symbolizes wealth, status, and good fortune. Has a delicate, long-lasting fragrance.
  19. Tiger Skin Sandalwood
    Bold, striped grain pattern resembling a tiger's coat. Enhances courage, strength, and confidence, helping you face challenges head-on and achieve victory.
  20. Green Sandalwood
    Unique natural green color that changes over time and a pleasant, long-lasting fragrance. Associated with healing and purification, it balances the heart chakra and promotes emotional well-being.
  21. Aged Six-Wood
    Distinctive six longitudinal grooves on each bead, symbolizing the six realms of existence in Buddhism. A sacred wood that brings peace, protection, and spiritual enlightenment.
  22. Indonesian Star Red Sandalwood
    Deep red color with sparkling golden "stars" scattered throughout the grain. Enhances prosperity, success, and spiritual growth. A highly sought-after variety of red sandalwood.
  23. Camphor Wood
    Strong, fresh, and aromatic fragrance that repels insects and purifies the air. Clears negative energy, promotes mental clarity, and brings a sense of peace and tranquility to your space.
  24. Rhinoceros Horn Red Sandalwood
    Extremely dense and heavy wood with a deep, rich color and smooth, glass-like finish. Provides powerful grounding energy, enhances focus, and helps you stay centered in chaotic situations.
  25. Zambian Star Red Sandalwood
    Premium grade Zambian red sandalwood with abundant golden star patterns. Combines the healing properties of red sandalwood with the prosperity-enhancing energy of the golden stars.
  26. Dyed Rosewood
    Rich, uniform dark red color achieved through an eco-friendly dyeing process. Offers the same beautiful look and grounding energy as natural rosewood at an accessible price point.
  27. Black Rosewood
    Dark brown to black color with attractive grain patterns. A durable and stable wood that provides protection, grounding, and emotional balance.

🛠️ AuraZen Quality Guarantee

  • Sourced from sustainable, responsibly managed forests
  • Handcrafted by skilled artisans with over 20 years of experience
  • 30-step polishing process for a flawless, mirror-like finish
  • Smooth, burr-free holes for maximum durability
  • High-tensile elastic cord that stretches comfortably and resists breakage
  • Each bracelet is unique due to the natural variations in wood grain and color

💫 Care Instructions

  • Avoid prolonged exposure to water, sweat, and harsh chemicals
  • Remove before showering, swimming, or exercising
  • When not wearing, store in the included velvet pouch to prevent drying and cracking
  • Gently wipe with a soft, dry cloth regularly to maintain the luster and develop a beautiful patina over time
Embrace the healing power of nature with AuraZen. Each bracelet is more than just an accessory—it's a personal talisman that will accompany you on your spiritual journey.
const TAG = "spz-custom-product-automatic"; class SpzCustomProductAutomatic extends SPZ.BaseElement { constructor(element) { super(element); this.variant_id = 'c5ac3fa3-7b7f-4eef-b9ac-cfb9c47dfe4a'; this.isRTL = SPZ.win.document.dir === 'rtl'; this.isAddingToCart_ = false; // 加购中状态 } 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.init(); // 监听事件 this.bindEvent_(); } async init() { this.handleFitTheme(); const data = await this.getDiscountList(); this.renderApiData_(data); } async getDiscountList() { const productId = 'f240992b-cc59-4e73-b579-aaa78c935332'; const variantId = this.variant_id; const productType = 'default'; const reqBody = { product_id: productId, variant_id: variantId, discount_method: "DM_AUTOMATIC", customer: { customer_id: window.C_SETTINGS.customer.customer_id, email: window.C_SETTINGS.customer.customer_email }, product_type: productType } const url = `/api/storefront/promotion/display_setting/text/list`; const data = await this.xhr_.fetchJson(url, { method: "post", body: reqBody }).then(res => { return res; }).catch(err => { this.setContainerDisabled(false); }) return data; } async renderDiscountList() { this.setContainerDisabled(true); const data = await this.getDiscountList(); this.setContainerDisabled(false); // 重新渲染 抖动问题处理 this.renderApiData_(data); } clearDom() { const children = this.element.querySelector('*:not(template)'); children && SPZCore.Dom.removeElement(children); } async renderApiData_(data) { const parentDiv = document.querySelector('.automatic_discount_container'); const newTplDom = await this.getRenderTemplate(data); if (parentDiv) { parentDiv.innerHTML = ''; parentDiv.appendChild(newTplDom); } else { console.log('automatic_discount_container is null'); } } doRender_(data) { const renderData = data || {}; return this.templates_ .findAndRenderTemplate(this.element, renderData) .then((el) => { this.clearDom(); this.element.appendChild(el); }); } async getRenderTemplate(data) { const renderData = data || {}; return this.templates_ .findAndRenderTemplate(this.element, { ...renderData, isRTL: this.isRTL }) .then((el) => { this.clearDom(); return el; }); } setContainerDisabled(isDisable) { const automaticDiscountEl = document.querySelector('.automatic_discount_container_outer'); if(isDisable) { automaticDiscountEl.setAttribute('disabled', ''); } else { automaticDiscountEl.removeAttribute('disabled'); } } // 绑定事件 bindEvent_() { window.addEventListener('click', (e) => { let containerNodes = document.querySelectorAll(".automatic-container .panel"); let bool; Array.from(containerNodes).forEach((node) => { if(node.contains(e.target)){ bool = true; } }) // 是否popover面板点击范围 if (bool) { return; } if(e.target.classList.contains('drowdown-icon') || e.target.parentNode.classList.contains('drowdown-icon')){ return; } const nodes = document.querySelectorAll('.automatic-container'); Array.from(nodes).forEach((node) => { node.classList.remove('open-dropdown'); }) // 兼容主题 this.toggleProductSticky(true); }) // 监听变体变化 document.addEventListener('dj.variantChange', async(event) => { // 重新渲染 const variant = event.detail.selected; if (variant.product_id == 'f240992b-cc59-4e73-b579-aaa78c935332' && variant.id != this.variant_id) { this.variant_id = variant.id; this.renderDiscountList(); } }); } // 兼容主题 handleFitTheme() { // top 属性影响抖动 let productInfoEl = null; if (window.SHOPLAZZA.theme.merchant_theme_name === 'Wind' || window.SHOPLAZZA.theme.merchant_theme_name === 'Flash') { productInfoEl = document.querySelector('.product-info-body .product-sticky-container'); } else if (window.SHOPLAZZA.theme.merchant_theme_name === 'Hero') { productInfoEl = document.querySelector('.product__info-wrapper .properties-content'); } if(productInfoEl){ productInfoEl.classList.add('force-top-auto'); } } // 兼容 wind/flash /hero 主题 (sticky属性影响 popover 层级展示, 会被其他元素覆盖) toggleProductSticky(isSticky) { let productInfoEl = null; if (window.SHOPLAZZA.theme.merchant_theme_name === 'Wind' || window.SHOPLAZZA.theme.merchant_theme_name === 'Flash') { productInfoEl = document.querySelector('.product-info-body .product-sticky-container'); } else if (window.SHOPLAZZA.theme.merchant_theme_name === 'Hero') { productInfoEl = document.querySelector('.product__info-wrapper .properties-content'); } if(productInfoEl){ if(isSticky) { // 还原该主题原有的sticky属性值 productInfoEl.classList.remove('force-position-static'); return; } productInfoEl.classList.toggle('force-position-static'); } } setupAction_() { this.registerAction('handleDropdown', (invocation) => { const discount_id = invocation.args.discount_id; const nodes = document.querySelectorAll('.automatic-container'); Array.from(nodes).forEach((node) => { if(node.getAttribute('id') != `automatic-${discount_id}`) { node.classList.remove('open-dropdown'); } }) const $discount_item = document.querySelector(`#automatic-${discount_id}`); $discount_item && $discount_item.classList.toggle('open-dropdown'); // 兼容主题 this.toggleProductSticky(); }); // 加购事件 this.registerAction('handleAddToCart', (invocation) => { // 阻止事件冒泡 const event = invocation.event; if (event) { event.stopPropagation(); event.preventDefault(); } // 如果正在加购中,直接返回 if (this.isAddingToCart_) { return; } const quantity = invocation.args.quantity || 1; this.addToCart(quantity); }); } // 加购方法 async addToCart(quantity) { // 设置加购中状态 this.isAddingToCart_ = true; const productId = 'f240992b-cc59-4e73-b579-aaa78c935332'; const variantId = this.variant_id; const url = '/api/cart'; const reqBody = { product_id: productId, variant_id: variantId, quantity: quantity }; try { const data = await this.xhr_.fetchJson(url, { method: 'POST', body: reqBody }); // 触发加购成功提示 this.triggerAddToCartToast_(); return data; } catch (error) { error.then(err=>{ this.showToast_(err?.message || err?.errors?.[0] || 'Unknown error'); }) } finally { // 无论成功失败,都重置加购状态 this.isAddingToCart_ = false; } } showToast_(message) { const toastEl = document.querySelector("#apps-match-drawer-add_to_cart_toast"); if (toastEl) { SPZ.whenApiDefined(toastEl).then((apis) => { apis.showToast(message); }); } } // 触发加购成功提示 triggerAddToCartToast_() { // 如果主题有自己的加购提示,则不显示 const themeAddToCartToastEl = document.querySelector('#add-cart-event-proxy'); if (themeAddToCartToastEl) return; // 显示应用的加购成功提示 this.showToast_("Added successfully"); } 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, SpzCustomProductAutomatic);
class SpzCustomDiscountBundle extends SPZ.BaseElement { constructor(element) { super(element); } isLayoutSupported(layout) { return layout == SPZCore.Layout.LOGIC; } mountCallback() {} unmountCallback() {} setupAction_() { this.registerAction('showAddToCartToast', () => { const themeAddToCartToastEl = document.querySelector('#add-cart-event-proxy') if(themeAddToCartToastEl) return const toastEl = document.querySelector('#apps-match-drawer-add_to_cart_toast') SPZ.whenApiDefined(toastEl).then((apis) => { apis.showToast("Added successfully"); }); }); } buildCallback() { this.setupAction_(); }; } SPZ.defineElement('spz-custom-discount-toast', SpzCustomDiscountBundle);
class SpzCustomDiscountFlashsale extends SPZ.BaseElement { constructor(element) { super(element); this.xhr_ = SPZServices.xhrFor(this.win); this.getFlashSaleApi = "\/api\/storefront\/promotion\/flashsale\/display_setting\/product_setting"; this.timer = null; this.variantId = "c5ac3fa3-7b7f-4eef-b9ac-cfb9c47dfe4a"; // 促销活动数据 this.flashsaleData = {} } isLayoutSupported(layout) { return layout == SPZCore.Layout.CONTAINER; } buildCallback() { this.templates_ = SPZServices.templatesForDoc(); this.viewport_ = this.getViewport(); // 挂载bind函数 解决this指向问题 this.render = this.render.bind(this); this.resize = this.resize.bind(this); this.switchVariant = this.switchVariant.bind(this); } mountCallback() { // 获取数据 this.getData(); this.element.onclick = (e) => { const cur = this.win.document.querySelector(".app_discount_flashsale_desc"); const setting = this.flashsaleData.product_setting; const landingUrl = `/promotions/discount-default/${this.flashsaleData.discount_info.id}`; const finalUrl = appDiscountUtils.resolveDiscountHref(setting, landingUrl); if (finalUrl && appDiscountUtils.inProductBody(this.element) && e.target !== cur) { this.win.open(finalUrl, '_blank', 'noopener'); } } // 绑定 this.viewport_.onResize(this.resize); // 监听子款式切换,重新渲染 this.win.document.addEventListener('dj.variantChange', this.switchVariant); } unmountCallback() { // 解绑 this.viewport_.removeResize(this.resize); this.win.document.removeEventListener('dj.variantChange', this.switchVariant); // 清除定时器 if (this.timer) { clearTimeout(this.timer); this.timer = null; } } resize() { if (this.timer) { clearTimeout(this.timer) this.timer = null; } this.timer = setTimeout(() => { this.render(); }, 200) } switchVariant(event) { const variant = event.detail.selected; if (variant.product_id == 'f240992b-cc59-4e73-b579-aaa78c935332' && variant.id != this.variantId) { this.variantId = variant.id; this.getData(); } } getData() { const reqBody = { product_id: "f240992b-cc59-4e73-b579-aaa78c935332", product_type: "default", variant_id: this.variantId } this.flashsaleData = {}; this.win.fetch(this.getFlashSaleApi, { method: "POST", body: JSON.stringify(reqBody), headers: { "Content-Type": "application/json" } }).then(async (response) => { if (response.ok) { this.flashsaleData = await response.json(); this.render(); } else { this.clearDom(); } }).catch(err => { this.clearDom(); }); } clearDom() { const children = this.element.querySelector('*:not(template)'); children && SPZCore.Dom.removeElement(children); } render() { this.templates_ .findAndRenderTemplate(this.element, { isMobile: appDiscountUtils.judgeMobile(), isRTL: appDiscountUtils.judgeRTL(), inProductDetail: appDiscountUtils.inProductBody(this.element), flashsaleData: this.flashsaleData, image_domain: this.win.SHOPLAZZA.image_domain, }) .then((el) => { this.clearDom(); this.element.appendChild(el); }) } } SPZ.defineElement('spz-custom-discount-flashsale', SpzCustomDiscountFlashsale);
/** * 优惠码组件模型类 * 处理优惠码的显示和交互逻辑 */ class SpzCustomDiscountCodeModel extends SPZ.BaseElement { constructor(element) { super(element); // 复制按钮和内容的类名 this.copyBtnClass = "discount_code_btn" this.copyClass = "discount_code_value" } isLayoutSupported(layout) { return layout == SPZCore.Layout.LOGIC; } buildCallback() { // 初始化服务 this.action_ = SPZServices.actionServiceForDoc(this.element); this.templates_ = SPZServices.templatesForDoc(this.element); this.xhr_ = SPZServices.xhrFor(this.win); } /** * 渲染优惠码组件 * @param {Object} data - 渲染数据 */ doRender_(data) { return this.templates_ .findAndRenderTemplate(this.element, Object.assign(this.getDefaultData(), data) ) .then((el) => { this.clearDom(); this.element.appendChild(el); // 绑定复制代码功能 this.copyCode(el, data); }); } /** * 获取渲染模板 * @param {Object} data - 渲染数据 */ getRenderTemplate(data) { const renderData = Object.assign(this.getDefaultData(), data); return this.templates_ .findAndRenderTemplate(this.element, renderData) .then((el) => { this.clearDom(); return el; }); } /** * 清除DOM内容 */ clearDom() { const children = this.element.querySelector('*:not(template)'); children && SPZCore.Dom.removeElement(children); } /** * 获取默认数据 * @returns {Object} 默认数据对象 */ getDefaultData() { return { isMobile: appDiscountUtils.judgeMobile(), isRTL: appDiscountUtils.judgeRTL(), image_domain: this.win.SHOPLAZZA.image_domain, copyBtnClass: this.copyBtnClass, copyClass: this.copyClass } } /** * 复制优惠码功能 * @param {Element} el - 当前元素 */ copyCode(el) { const copyBtnList = el.querySelectorAll(`.${this.copyBtnClass}`); if (copyBtnList.length > 0) { copyBtnList.forEach(item => { item.onclick = async () => { // 确保获取正确的元素和内容 const codeElement = item.querySelector(`.${this.copyClass}`); if (!codeElement) return; // 获取纯文本内容 const textToCopy = codeElement.innerText.trim(); // 尝试使用现代API,如果失败则使用备用方案 try { if (navigator.clipboard && navigator.clipboard.writeText) { await navigator.clipboard.writeText(textToCopy); } else { throw new Error('Clipboard API not available'); } // 显示复制成功提示 this.showCopySuccessToast(textToCopy, el); } catch (err) { console.error('Modern clipboard API failed, trying fallback...', err); // 使用备用复制方案 this.fallbackCopy(textToCopy, el); } const discountId = item.dataset["discountId"]; // 跳转决策: is_redirection + link(可选覆盖) const setting = { is_redirection: item.dataset["redirection"] === "true", link: item.dataset["link"], }; const landingUrl = `/promotions/discount-default/${discountId}`; const finalUrl = appDiscountUtils.resolveDiscountHref(setting, landingUrl); if (finalUrl && appDiscountUtils.inProductBody(this.element)) { this.win.open(finalUrl, '_blank', 'noopener'); } } }) } } /** * 使用 execCommand 的复制方案 * @param {string} codeText - 要复制的文本 * @param {Element} el - 当前元素 */ fallbackCopy(codeText, el) { const textarea = this.win.document.createElement('textarea'); textarea.value = codeText; // 设置样式使文本框不可见 textarea.style.position = 'fixed'; textarea.style.left = '-9999px'; textarea.style.top = '0'; // 添加 readonly 属性防止移动端虚拟键盘弹出 textarea.setAttribute('readonly', 'readonly'); this.win.document.body.appendChild(textarea); textarea.focus(); textarea.select(); try { this.win.document.execCommand('copy'); // 显示复制成功提示 this.showCopySuccessToast(codeText, el); } catch (err) { console.error('Copy failed:', err); } this.win.document.body.removeChild(textarea); } /** * 创建 Toast 元素 * @returns {Element} 创建的 Toast 元素 */ createToastEl_() { const toast = document.createElement('ljs-toast'); toast.setAttribute('layout', 'nodisplay'); toast.setAttribute('hidden', ''); toast.setAttribute('id', 'discount-code-toast'); toast.style.zIndex = '1051'; return toast; } /** * 挂载 Toast 元素到 body * @returns {Element} 挂载的 Toast 元素 */ mountToastToBody_() { const existingToast = this.win.document.getElementById('discount-code-toast'); if (existingToast) { return existingToast; } const toast = this.createToastEl_(); this.win.document.body.appendChild(toast); return toast; } /** * 复制成功的提醒 * @param {string} codeText - 要复制的文本 * @param {Element} el - 当前元素 */ showCopySuccessToast(codeText, el) { const $toast = this.mountToastToBody_(); SPZ.whenApiDefined($toast).then(toast => { toast.showToast("Discount code copied !"); this.codeCopyInSessionStorage(codeText); }); } /** * 复制优惠码成功后要存一份到本地存储中,购物车使用 * @param {string} codeText - 要复制的文本 */ codeCopyInSessionStorage(codeText) { try { sessionStorage.setItem('other-copied-coupon', codeText); } catch (error) { console.error(error) } } } // 注册自定义元素 SPZ.defineElement('spz-custom-discount-code-model', SpzCustomDiscountCodeModel);
/** * Custom discount code component that handles displaying and managing discount codes * @extends {SPZ.BaseElement} */ class SpzCustomDiscountCode extends SPZ.BaseElement { constructor(element) { super(element); // API endpoint for fetching discount codes this.getDiscountCodeApi = "\/api\/storefront\/promotion\/code\/list"; // Debounce timer for resize events this.timer = null; // Current variant ID this.variantId = "c5ac3fa3-7b7f-4eef-b9ac-cfb9c47dfe4a"; // Store discount code data this.discountCodeData = {} } /** * Check if layout is supported * @param {string} layout - Layout type * @return {boolean} */ isLayoutSupported(layout) { return layout == SPZCore.Layout.LOGIC; } /** * Initialize component after build */ buildCallback() { this.templates_ = SPZServices.templatesForDoc(); this.viewport_ = this.getViewport(); // Bind methods to maintain context this.render = this.render.bind(this); this.resize = this.resize.bind(this); this.switchVariant = this.switchVariant.bind(this); } /** * Setup component when mounted */ mountCallback() { this.getData(); // Add event listeners this.viewport_.onResize(this.resize); this.win.document.addEventListener('dj.variantChange', this.switchVariant); } /** * Cleanup when component is unmounted */ unmountCallback() { this.viewport_.removeResize(this.resize); this.win.document.removeEventListener('dj.variantChange', this.switchVariant); // 清除定时器 if (this.timer) { clearTimeout(this.timer); this.timer = null; } } /** * Handle resize events with debouncing */ resize() { if (this.timer) { clearTimeout(this.timer) this.timer = null; } this.timer = setTimeout(() => { if (appDiscountUtils.inProductBody(this.element)) { this.render(); } else { this.renderSkeleton(); } }, 200); } /** * Handle variant changes * @param {Event} event - Variant change event */ switchVariant(event) { const variant = event.detail.selected; if (variant.product_id == 'f240992b-cc59-4e73-b579-aaa78c935332' && variant.id != this.variantId) { this.variantId = variant.id; this.getData(); } } /** * Fetch discount code data from API */ getData() { if (appDiscountUtils.inProductBody(this.element)) { const reqBody = { product_id: "f240992b-cc59-4e73-b579-aaa78c935332", variant_id: this.variantId, product_type: "default", } if (!reqBody.product_id || !reqBody.variant_id) return; this.discountCodeData = {}; this.win.fetch(this.getDiscountCodeApi, { method: "POST", body: JSON.stringify(reqBody), headers: { "Content-Type": "application/json" } }).then(async (response) => { if (response.ok) { let data = await response.json(); if (data.list && data.list.length > 0) { data.list[0].product_setting.template_config = JSON.parse(data.list[0].product_setting.template_config); // Format timestamps to local timezone const zone = this.win.SHOPLAZZA.shop.time_zone; data.list = data.list.map(item => { if(+item.ends_at !== -1) { item.ends_at = appDiscountUtils.convertTimestampToFormat(+item.ends_at, zone); } item.starts_at = appDiscountUtils.convertTimestampToFormat(+item.starts_at, zone); return item; }); } this.discountCodeData = data; this.render(); } else { this.clearDom(); } }).catch(err => { console.error("discount_code", err) this.clearDom(); }); } else { this.renderSkeleton(); } } /** * Clear component DOM except template */ clearDom() { const children = this.element.querySelector('*:not(template)'); children && SPZCore.Dom.removeElement(children); } /** * Render discount codes with formatted dates */ render() { // Render using discount code model SPZ.whenApiDefined(document.querySelector('#spz_custom_discount_code_model')).then(renderApi => { renderApi.doRender_({ discountCodeData: this.discountCodeData }) }).catch(err => { this.clearDom(); }) } renderSkeleton() { // Render template for non-product pages this.templates_ .findAndRenderTemplate(this.element, { isMobile: appDiscountUtils.judgeMobile() }) .then((el) => { this.clearDom(); this.element.appendChild(el); }) .catch(err => { this.clearDom(); }); } } // Register custom element SPZ.defineElement('spz-custom-discount-code', SpzCustomDiscountCode);
No products viewed