/**
* 願望清單需要登入時的共用處理
*
* 願望清單一律綁定會員(不再以 cookie 記錄),未登入點擊愛心/加入我的最愛時,後端會回
* Msg = 'NO_MEMBER',前端統一提示後導向登入頁。
* 登入頁網址由後端以 LoginUrl 帶入(需經 safe_lib::checkUrl 補上語系/分店前綴),
* 後端同時已記下使用者原本所在的頁面,登入完成後會自動導回。
* 定義在最外層,供 list.js / list_m.js / film.js 及各頁的 inline script 共用。
*/
function wishNeedLogin(loginUrl) {
alert(_jsLang.請先登入會員);
location.href = loginUrl || '/member-login/';
}
/**
* 同步單一商品規格的願望清單狀態
*
* 同一個商品規格可能同時出現在多個位置(列表紅心、商品詳細頁收藏按鈕、快速購物跳窗),
* 統一在這裡一起更新,避免只更新被點的那一顆造成畫面不一致。
*
* 全站的愛心元素有兩種寫法,兩種都要涵蓋,否則會有頁面補不到狀態:
* 1. class 帶 fa-heart{SID} 或 wishButton{SID}(商品列表、商品詳細頁、快速購物跳窗)
* 2. class 只有 love、商品ID放在 sid 屬性(新品上市、iwoman、影音專區等版型)
*
* 按鈕文字只有在元素帶 data-wish-add / data-wish-del 時才更新(本專案語系走 PHP 常數,
* 故文字由後端帶入,不在 JS 寫死中文)。
*
* @param {number|string} SID 商品規格ID
* @param {boolean} isAdd true=已收藏、false=未收藏
*/
function wishSetState(SID, isAdd) {
if (!SID) return;
//同步更新已取得的收藏名單。
//「開啟快取時由AJAX補紅心」的機制會在每次 AJAX 完成後依名單重新套用一次狀態,
//若這裡不更新名單,顧客剛按下的加入/取消就會被舊名單蓋回去。
if (_wishIdMap !== null) {
if (isAdd) {
_wishIdMap[SID] = true;
} else {
delete _wishIdMap[SID];
}
}
var $targets = $(".wishButton" + SID + ",.fa-heart" + SID + ",.love[sid='" + SID + "']");
if (isAdd) {
$targets.addClass('red').addClass('in-withlist');
} else {
$targets.removeClass('red').removeClass('in-withlist');
}
$targets.each(function () {
var $target = $(this),
text = isAdd ? $target.attr('data-wish-del') : $target.attr('data-wish-add');
if (text) {
$target.text(text);
}
});
}
/**
* 開啟網頁快取時,由 AJAX 補上愛心狀態
*
* 網頁快取的檔名不含會員身分,同一份 HTML 會給所有訪客看,因此後端在快取開啟時一律
* 輸出「未收藏」(見 prod_wish::isStateByAjax),頁面載入後再由這裡取回該會員的
* 收藏清單把紅心補回去。
*
* - 是否需要補值由後端以 window._wishStateByAjax 帶入;快取關閉時不會發出任何請求。
* - 清單只取一次,之後存在 _wishIdMap 重複使用,不會因為頁面上有其他 AJAX 就重複查詢。
* - 除了頁面載入,任何 AJAX 完成後也會再套用一次,讓「切換規格」、「載入推薦商品」、
* 「開啟快速購物跳窗」等後來才產生的元素同樣帶到正確狀態。
*/
var _wishIdMap = null, //已收藏的商品規格ID對照表,null 表示尚未取得
_wishLoading = false; //是否正在取得清單,避免同時發出多次請求
function wishHydrate() {
if (!window._wishStateByAjax) return;
if (_wishIdMap !== null) {
wishApplyState();
return;
}
if (_wishLoading) return;
_wishLoading = true;
$.ajax({
url: '/products/ajax/common/ajax_get_wish_list.php',
type: 'POST',
cache: false,
dataType: 'json',
success: function (d) {
if (!d || d.Msg != 'OK') return;
_wishIdMap = {};
var ids = d.IDs || [];
for (var i = 0; i < ids.length; i++) {
_wishIdMap[ids[i]] = true;
}
wishApplyState();
},
// 失敗時不提示:補紅心失敗只是少了「已收藏」的視覺提示,
// 不影響顧客點擊收藏,不需要用錯誤訊息打擾使用者。
complete: function () {
_wishLoading = false;
}
});
}
/**
* 依收藏清單,套用頁面上每一顆愛心的狀態
*
* 以「掃一次畫面上的愛心元素」而非「逐一比對收藏清單」的方式處理:
* 收藏數量多的會員可能有數百筆,但一頁通常只有數十個愛心,掃畫面的成本較低且穩定,
* 同時也能把不該亮的紅心一併關掉(例如快取殘留的狀態)。
*/
function wishApplyState() {
if (_wishIdMap === null) return;
var seen = {};
$("[class*='fa-heart'],[class*='wishButton'],.love[sid]").each(function () {
//兩種寫法都要取得商品規格ID:class 的 fa-heart{ID} / wishButton{ID},或 sid 屬性
var m = /(?:fa-heart|wishButton)(\d+)/.exec(this.className || ''),
SID = m ? m[1] : $(this).attr('sid');
if (!SID || seen[SID]) return;
seen[SID] = true;
wishSetState(SID, !!_wishIdMap[SID]);
});
}
/**
* 判斷這個 AJAX 網址是否會改變願望清單的內容
*
* 這類請求完成後「不可以」再依名單重新套用一次狀態:
* 顧客剛按下的加入/取消已經由各自的處理程式即時更新到畫面上,
* 此時若再拿一份名單來套用,只要那份名單有任何一點時間差(例如讀到的是尚未同步的資料),
* 就會把剛按好的狀態又蓋回去,畫面看起來就像「按了沒反應」。
*
* 正確的狀態由 wishSetState() 在更新畫面的同時一併記進名單,不需要再問後端一次。
*/
function wishIsMutateUrl(url) {
var mutateUrls = [
'ajax_add_wish_list.php', //加入/取消收藏
'ajax_del_wish.php', //購物車收藏頁刪除
'ajax_del_order_next-p.php', //我的最愛刪除
'ajax_cart_next.php', //購物車「下次再買」
'ajax_add_to_cart.php', //從收藏清單加入購物車會一併移出收藏
'ajax_add_to_order_cart-p.php'
];
for (var i = 0; i < mutateUrls.length; i++) {
if (url.indexOf(mutateUrls[i]) >= 0) return true;
}
return false;
}
$(function () {
wishHydrate();
//後續以 AJAX 載入的內容(切換規格、推薦商品、快速購物跳窗等)也要補上狀態。
//ajaxComplete 在各自的 success 之後才觸發,此時新的 HTML 已經放進畫面。
$(document).ajaxComplete(function (e, xhr, settings) {
var url = (settings && settings.url) ? settings.url : '';
//排除取清單本身,避免還沒取到清單前互相觸發造成無限請求
if (url.indexOf('ajax_get_wish_list.php') >= 0) return;
//加入/取消收藏:畫面已由各自的處理程式即時更新,名單也已同步(見 wishSetState),
//這裡不可以再套用一次,否則會把顧客剛按好的狀態蓋掉
if (wishIsMutateUrl(url)) return;
wishHydrate();
});
});
/**
* 商品影片共用處理(商品詳細頁、活動詳細頁共用)
* - 定義在最外層,讓 defer 執行的 products_detail.js / activities_detail.js 與 list.js 都取得到
* - 影片元素會在切換規格時被重新產生,所以一律在使用當下才以 id 取得,不保留參考
*/
var prod_video = {
//目前的影片元素
el: function () {
return document.getElementById("Video");
},
//依影片「實際」狀態切換小圖的播放/暫停 icon
syncIcon: function () {
var video = prod_video.el();
if (!video) { return; }
$(".moreview .video_control")
.toggleClass('fa-pause', !video.paused)
.toggleClass('fa-play', video.paused);
},
//播放;被瀏覽器 autoplay policy 阻擋時靜音重試
play: function () {
var video = prod_video.el();
if (!video) { return; }
var pp = video.play();
if (pp && pp.catch) {
pp.catch(function () {
video.muted = true;
var retry = video.play();
if (retry && retry.catch) { retry.catch(function () { }); }
});
}
},
//依主圖目前有沒有顯示影片決定播放/暫停
//用 :visible 判斷,可同時涵蓋商品詳細頁(zoonbox 的 now class)與活動詳細頁(inline display)兩種切換方式
syncPlayback: function () {
var video = prod_video.el();
if (!video) { return; }
if ($(video).is(':visible')) {
prod_video.play();
} else {
video.pause();
}
},
//切換播放狀態(點小圖或點影片本身都會呼叫);icon 交由 play/pause 事件同步
toggle: function () {
var video = prod_video.el();
if (!video) { return; }
if (video.paused) {
prod_video.play();
} else {
video.pause();
}
},
//以影片畫面當小圖封面:等比放大填滿 canvas 後置中裁切,避免影片與小圖比例不同時變形
drawCover: function () {
var video = prod_video.el(),
canvas = document.getElementById("video_review");
//部分版型的小圖不是 canvas
if (!video || !canvas || !canvas.getContext) { return; }
//readyState < 2 (HAVE_CURRENT_DATA) 代表還沒有可用的畫格,畫出來會是空白
if (!video.videoWidth || video.readyState < 2) { return; }
var scale = Math.max(canvas.width / video.videoWidth, canvas.height / video.videoHeight),
w = video.videoWidth * scale,
h = video.videoHeight * scale;
canvas.getContext('2d').drawImage(video, (canvas.width - w) / 2, (canvas.height - h) / 2, w, h);
},
//小圖封面的 canvas 標籤;活動詳細頁(type 3)的小圖較小,尺寸與各頁 PHP 產出一致
coverTag: function (type) {
return (type == 3)
? ''
: '';
},
//初始化影片:綁狀態事件、畫小圖封面,並依大圖目前顯示的內容決定要不要播放。切換規格重新產生影片後可重複呼叫
init: function () {
var video = prod_video.el();
if (!video) { return; }
//icon 一律跟著影片實際狀態走,不論是自動播放、點擊或瀏覽器自行暫停
//同一個元素重複 addEventListener 同一個函式參考不會重複註冊
video.addEventListener('play', prod_video.syncIcon);
video.addEventListener('pause', prod_video.syncIcon);
//影片預設不播放,只能等預載到有畫格時才畫得出封面。
//各瀏覽器到達 HAVE_CURRENT_DATA 時送出的事件時機不一,多綁幾個;drawCover 本身有 readyState 判斷,重複呼叫無妨
video.addEventListener('loadeddata', prod_video.drawCover);
video.addEventListener('canplay', prod_video.drawCover);
video.addEventListener('seeked', prod_video.drawCover);
prod_video.drawCover();
prod_video.syncIcon();
//預設顯示的是第一張主圖,影片要等切過去才播放
prod_video.syncPlayback();
},
//綁定點擊事件;委派到 document,避免小圖容器被輪播套件搬移或重建時漏綁
bind: function () {
$(document).off('click.prodVideo')
.on('click.prodVideo', '.moreview .video_control', prod_video.toggle) //點小圖
.on('click.prodVideo', '.productView video#Video', prod_video.toggle); //點影片本身
}
};
$(function () {
$(".menu_class_a, .menu_sub_a").mouseover(function () {
var pic = $(this).attr('pic');
var url = $(this).attr('url');
var href = (url) ? url : 'javascript:;';
var h = (pic) ? '' : '';
$(this).parents('.item-subitembox').find('.picbox').html(h);
});
$(".menu_sub_a").mouseout(function () {
var pic = $(this).parents('.nav-item').find('.menu_class_a').attr('pic');
var url = $(this).parents('.nav-item').find('.menu_class_a').attr('url');
var href = (url) ? url : 'javascript:;';
var h = (pic) ? '
' : '';
$(this).parents('.nav-item').find('.item-subitembox').children('.picbox').html(h);
});
$("#Select_This_Country").on("click", "li", function () {
$.post('/ajax/ajax_change_country.php', {
ID: $(this).attr('sid')
}, function (h) {
if (typeof updatePage == "function") {
updatePage();
return false;
}
if (h) {
window.location.reload();
}
}, 'html');
});
$('.lazyimg').lazyload({
effect: 'fadeIn',
});
$("body").on("click", ".rack_detail", function () {
var sid = $(this).attr("store_sid");
var serial_no = $(this).attr("serial");
var flag = $(this).attr("data_id");
var box = $(this);
if (!sid) {
sid = $(this).attr("sid");
}
if (sid && flag != sid) {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (position) {
var pos = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
$.ajax({
url: '/products/ajax/detail/ajax_get_mobile_data.php',
type: 'POST',
async: false,
data: {
lat: position.coords.latitude,
lng: position.coords.longitude,
serial_no: serial_no
},
error: function (d) {
alert(d.responseText);
},
success: function (d) {
box.attr('data_id', sid);
$("#stockCheck").find(".modal-content").html(d);
}
});
}, function () {
$.ajax({
url: '/products/ajax/detail/ajax_get_mobile_data.php',
type: 'POST',
async: false,
data: {
serial_no: serial_no
},
error: function (d) {
alert(d.responseText);
},
success: function (d) {
box.attr('data_id', sid);
$("#stockCheck").find(".modal-content").html(d);
}
});
if (typeof handleLocationError == 'function') {
handleLocationError(true, infoWindow, map.getCenter());
}
});
} else {
console.log('error');
// Browser doesn't support Geolocation
if (typeof handleLocationError == 'function') {
handleLocationError(true, infoWindow, map.getCenter());
}
}
}
});
//門市資料
$("body").on('change', '.stock-drop', function () {
$('.CityList').hide();
$('.Main-City' + $(this).val()).show();
});
var _window = $(window);
var _body = $('body');
var change_1023 = 0;
var nav_item = $('#menu-nav .nav-item');
var scroll_switch = true;
scroll_switch = nav_censor(scroll_switch);
var body_padding = 121;
var body_padding_s = 40;
var userAgent = navigator.userAgent;
/* 回頁首 */
$('.gotop').on('click', function () {
$("html,body").animate({
scrollTop: 0
}, 800);
});
//上方廣告
var button = 0;
$('.top_adbox_button').on('click', function () {
if (_window.width() <= 1023) {
$(".top_adbox").remove();
if (button == 1) button--;
} else {
if (button == 0) {
$(".top_adbox").css('height', 'auto');
$('.top_adbox .fa').removeClass('fa-plus').addClass('fa-times');
$('.top_adbox .inner').stop().animate({
'max-height': '100vh'
}, 1000, function () {
button++;
});
} else {
$('.top_adbox .fa').removeClass('fa-times').addClass('fa-plus');
$('.top_adbox .inner').stop().animate({
'max-height': 0
}, 1000, function () {
button--;
});
}
}
});
var change = 0;
//noisePop();
/* 手機平板 */
if (_window.width() <= 1024 || $(".header-01").hasClass("theme-act")) {
//上方廣告
if ($('.top_adbox').attr('tag-status') == '1') {
$('.top_adbox .fa').removeClass('fa-plus').addClass('fa-times');
$(".top_adbox").show();
};
//天邊會員登入
var member_click_n = 0;
$('.shopbox span.fa-user').on('click', function () {
if (member_click_n == 0) {
member_click_n = 1;
$('.userbox').addClass('open');
} else {
member_click_n = 0;
$('.userbox').removeClass('open');
}
});
var language_click_n = 0;
$('.language_t').on('click', '.wrapper ', function () {
if (language_click_n == 0) {
language_click_n = 1;
$('.language_t').addClass('open');
} else {
language_click_n = 0;
$('.language_t').removeClass('open');
}
});
//天邊會員登入
var language_click_n = 0;
$('#language').on('click', '.wrapper ', function () {
if (language_click_n == 0) {
language_click_n = 1;
$('#language').addClass('open');
} else {
language_click_n = 0;
$('#language').removeClass('open');
}
});
//menu開合
$('#menu-nav .hover').removeClass('hover');
if (/Windows/i.test(userAgent)) {
// console.log(`device1`)
$('#menu-nav').on('click', '.item-title', function (e) {
var n = $(this).parent(".open").length;
$('#menu-nav .nav-item').removeClass('open');
$('#menu-nav .menu-item').removeClass('open-sub');
if (n == 0) {
$(this).parent(".nav-item").addClass('open');
}
menuOpenStyle('#menu-nav a.item-title')
}).on(' click', '.subtitle', function () {
var n = $(this).parent(".open-sub").length;
$('#menu-nav .menu-item').removeClass('open-sub');
if (n == 0) {
$(this).parent(".menu-item").addClass('open-sub');
}
});
} else {
// console.log(`device2`)
$('#menu-nav').on('click', '.item-title', function (e) {
console.log(e.currentTarget)
var n = $(this).parent(".open").length;
var t = $(this).attr("type");
if (t == '') {
$('#menu-nav .nav-item').removeClass('open');
$('#menu-nav .menu-item').removeClass('open-sub');
$(".subitembox").removeClass('open-sub');
if (n == 0) {
$(this).parent(".nav-item").addClass('open');
}
} else {
$('#menu-nav .nav-item').removeClass('open');
$('#menu-nav .menu-item').removeClass('open-sub');
$(".subitembox").removeClass('open-sub');
if (n == 0) {
$(this).parent(".nav-item").find("#subitembox" + t).addClass('open-sub');
$(this).parent(".nav-item").addClass('open');
}
}
menuOpenStyle('#menu-nav a.item-title')
}).on(' click', '.subtitle', function () {
var n = $(this).parent(".open-sub").length;
$('#menu-nav .menu-item').removeClass('open-sub');
if (n == 0) {
$(this).parent(".menu-item").addClass('open-sub');
}
});
}
} else {
//上方廣告
if ($('.top_adbox').attr('tag-status') == '1') {
$(".top_adbox").show();
$(".top_adbox_button").trigger('click');
};
}
/* 手機 */
if (_window.width() <= 480 && change_1023 != 480) {
change_1023 = 480;
body_padding = 50;
/* 平板 */
} else if (_window.width() > 480 && _window.width() <= 1024 && change_1023 != 1024) {
change_1023 = 1023;
body_padding = 75;
body_padding_s = 50;
nav_item.find('.subitem').attr('type', 'checkbox');
/* 電腦 */
} else if (_window.width() > 1023 && change_1023 != 1200) {
change_1023 = 1200;
body_padding = 121;
body_padding_s = 40;
//天邊會員登入hover下拉
$('.shopbox span.fa-user').on('mouseenter', function () {
$('.userbox').addClass('open');
});
//天邊購物車hover下拉
$(document).on('mouseenter', 'body:not(.hidden-store) .shopbox #Shop_Cart_Total', function () {
$("#Header_Shopcart").load('/ajax/ajax_get_cart.php', '');
$('.shopping-cartbox').addClass('open');
});
$('.shopbox').on('mouseleave', function () {
var _this_user = $(this).find('.userbox'),
_this_shop = $(this).find('.shopping-cartbox');
if (_this_user.length == 1) {
$('.userbox').removeClass('open');
} else if (_this_shop.length == 1) {
$('.shopping-cartbox').removeClass('open');
}
});
}
let windowScroll = 0,
isChangeClass = false
_window.on('scroll', throttle(function (event) {
var scrollTop = _window.scrollTop()
if (scrollTop > 0) {
$(".gotop").css("opacity", "1");
$("body").addClass('is-sticky');
} else {
$(".gotop").css("opacity", "0");
$("body").removeClass('is-sticky');
}
//向上滑
if (!isChangeClass) {
if (windowScroll > scrollTop) {
isChangeClass = true
$("body").addClass('is-upwards');
} else {
isChangeClass = true
$("body").removeClass('is-upwards');
}
setTimeout(function () {
isChangeClass = false
}, 150)
}
windowScroll = scrollTop
}, 100));
_window.trigger('scroll')
var time_id;
_window.on('resize', function () {
clearTimeout(time_id);
time_id = setTimeout(nav_censor(scroll_switch), 500);
_window = $(window);
if (_window.width() <= 1023 && change_1023 == 1200) {
//上方廣告
// $('.top_adbox .fa').removeClass('fa-plus').addClass('fa-times');
$('.top_adbox_button').on('click', function () {
$('.top_adbox').remove();
});
$('.shopbox span.fa-user,.shopbox .fa-shopping-cart').off('mouseenter');
//天邊會員登入
var member_click_n = 0;
$('.shopbox span.fa-user').on('click', function () {
if (member_click_n == 0) {
member_click_n = 1;
$('.userbox').addClass('open');
} else {
member_click_n = 0;
$('.userbox,.shopping-cartbox').removeClass('open');
}
});
$('.shopbox').off('mouseleave');
}
if (_window.width() <= 480 && change_1023 != 480) {
change_1023 = 480;
body_padding = 50;
var scrollTop = _window.scrollTop();
} else if (_window.width() > 480 && _window.width() <= 1023 && change_1023 != 1023) {
change_1023 = 1023;
body_padding = 75;
body_padding_s = 50;
var scrollTop = _window.scrollTop();
nav_item.find('.subitem').attr('type', 'checkbox');
} else if (_window.width() > 1023 && change_1023 != 1200) {
change_1023 = 1200;
body_padding = 121;
body_padding_s = 40;
var scrollTop = _window.scrollTop();
nav_item.find('.subitem').attr('type', 'radio');
$('.shopbox span.fa-user').off('click');
//天邊會員登入
$('.shopbox span.fa-user').on('mouseenter', function () {
$('.userbox').addClass('open');
});
//天邊購物車hover下拉
$('.shopbox .fa-shopping-cart').on('mouseenter', function () {
$("#Header_Shopcart").load('/ajax/ajax_get_cart.php', '');
$('.shopping-cartbox').addClass('open');
});
$('.shopbox').on('mouseleave', function () {
$('.userbox,.shopping-cartbox').removeClass('open');
});
//移除menu開合事件
$('#menu-nav').off('click', '.item-title').off('click', '.subtitle');
}
});
function nav_censor(scroll_switch) {
if (scroll_switch) {
for (var i = 1; i < nav_item.length; i++) {
if (nav_item.eq(i).find('h3').height() > 45 || nav_item.eq(i).find('a.item-title').height() > 45) {
nav_item.eq(i).addClass('nav-item-big');
scroll_switch = false;
}
}
}
return scroll_switch;
}
var nav_n = false;
$('.menu-b').on('click', function () {
if (!nav_n) {
nav_n = true;
$('body').addClass('overflow-hidden').addClass('open-nav')
} else {
nav_n = false;
$('body').removeClass('overflow-hidden').removeClass('open-nav')
}
});
$('.navBox').on('click', function (e) {
if (e.target === e.currentTarget) {
nav_n = false;
$('body').removeClass('overflow-hidden').removeClass('open-nav')
}
});
$('.close-menu').on('click', function (e) {
nav_n = false;
$('body').removeClass('overflow-hidden').removeClass('open-nav')
});
$('.footer_menu').on('click', '.menu-item', function () {
$(this).addClass('open');
});
$('.footer_menu').on('click', '.open', function () {
$(this).removeClass('open');
});
$("#Noise_Pop").on("click", ".fa-times", function (e) {
e.preventDefault();
$.ajax({
url: "/ajax/ajax_get_noisePop.php",
type: "POST",
cache: false,
async: false,
data: {
Type: 'Cancel'
},
success: function (d) {
$("#Noise_Pop").remove();
}
});
});
$(".HITS_BT").on("click", function (e) {
e.preventDefault();
if ($.isNumeric($(this).attr('hid')) && $.isNumeric($(this).attr('hdid'))) {
var hid = $(this).attr('hid');
var hdid = $(this).attr('hdid');
var url = $(this).attr('href');
var target = $(this).attr('target');
$.ajax({
url: "/ajax/ajax_add_ad_hits-p.php",
type: "POST",
cache: false,
async: false,
data: {
Hid: hid,
Hdid: hdid
},
success: function (d) {
if (url) {
if (target == '_blank') {
window.open(url);
} else if ((typeof target === 'undefined') || (target == '')) {
window.location = url;
} else {}
}
}
});
} else {
alert(_jsLang.這是錯誤的連結);
}
});
//點擊清空輸入框
$(".CLEAR_INPUT").one("click", function () {
$(this).attr('placeholder', '');
});
//語系選擇
$("#Select_This_Lang").on("click", "li", function () {
$.post('/ajax/ajax_change_language.php', {
Name: $(this).attr('sid')
}, function (h) {
window.location.reload();
}, 'html');
});
//語系選擇
$("#Select_This_Lang3").on("click", "a", function () {
let pageShopId = $("#Page_Shop_ID").val();
$.ajax({
url: "/ajax/ajax_change_language.php",
type: "POST",
cache: false,
async: false,
data: {
Name: $(this).attr('sid'),
PageShopId: pageShopId
},
success: function (d) {
window.location.reload();
}
});
});
if ($(".rosetta-products.theme-carousel").length > 0) {
$(".rosetta-products.theme-carousel").owlCarousel({
nav: true,
responsive: {
0: {
items: 2,
margin: 16,
stagePadding: 30
},
768: {
items: 4,
margin: 16,
},
}
})
}
});
function PDA_AddToCart(Serial_No) {
window.dotq = window.dotq || [];
window.dotq.push({
'projectId': '10000',
'properties': {
'pixelId': '10095723',
'qstrings': {
'et': 'custom',
'ea': 'AddToCart',
'product_id': Serial_No,
}
}
});
window.dotq = window.dotq || [];
window.dotq.push({
'projectId': '10000',
'properties': {
'pixelId': '10146549',
'qstrings': {
'et': 'custom',
'ea': 'AddToCart',
'product_id': Serial_No,
}
}
});
}
function Rosetta_AddToCart(Pos_No) {
if (Pos_No && typeof rosetta == 'function') {
const param = {
type: 'select',
target: Pos_No
};
rosetta('event', param);
console.log('rosetta.event.select');
console.log(param);
console.log(123);
}
}
function Avivid_AddToCart(Datas) {
if (Datas) {
var num = Datas.length;
var string = '';
for (i = 0; i < num; i++) {
string += '[' + Datas[i] + '],';
}
console.log(string.substring(0, string.length - 1));
if (typeof AviviD == 'function') {
setTimeout(function () {
AviviD.analysis(1, [string.substring(0, string.length - 1)]);
}, 5000);
}
}
}
function Avivid_StartCart(Datas) {
if (typeof AviviD == 'function') {
setTimeout(function () {
AviviD.analysis(2, [Datas]);
}, 5000);
}
}
function Avivid_Purchase(Datas) {
if (typeof AviviD == 'function') {
setTimeout(function () {
AviviD.analysis(3, [Datas]);
}, 5000);
}
}
function SAYA_AddToCart() {
var noscript = '';
$("#SAYA_noscript").append(noscript);
var axel = Math.random() + "";
var a = axel * 10000000000000;
$("#SAYA_Div").append('
');
}
//結帳
function SAYA_Purchase() {
var noscript = '';
$("#SAYA_noscript").append(noscript);
var axel = Math.random() + "";
var a = axel * 10000000000000;
$("#SAYA_Div").append('
');
}
//訂單完成
function SAYA_OrderSuccess() {
var noscript = '';
$("#SAYA_noscript").append(noscript);
var axel = Math.random() + "";
var a = axel * 10000000000000;
$("#SAYA_Div").append('
');
}
//訂單完成頁
function SAYA_ShopcartOrder() {
var noscript = '';
$("#SAYA_noscript").append(noscript);
var axel = Math.random() + "";
var a = axel * 10000000000000;
$("#SAYA_Div").append('
');
}
function Set_Box_Files(_item, $this, d) {
if (d.R_Name) _item.find(".box_name").html(d.R_Name);
if (d.Color) _item.find(".colorbox").html(d.Color);
if (d.Color_Name) {
_item.find(".box_color").html('顏色 / ' + d.Color_Name);
}
if (d.Prod_No) {
_item.find(".prodnoBox").html(d.Prod_No);
}
if (d.Size_Name) {
_item.find(".box_size").html('尺寸 / ' + d.Size_Name);
}
if (d.Size_Button) _item.find(".sizebox").html(d.Size_Button);
if (d.Max_Stock) {
//if(d.Max_Stock > 10){d.Max_Stock=10}
_item.find(".amountBox").attr('max', d.Max_Stock);
_item.find(".amountBox").val('1');
}
if (d.Price2) _item.find(".font-delete").html(d.Price2);
if (d.R_Price) _item.find(".font-big").html('NT$' + d.R_Price);
for ($i = 1; $i <= 3; $i++) {
if (d.Button[$i]) _item.find(".Add_Button" + $i).html(d.Button[$i]);
}
if (d.ID) {
_item.find(".stock-icon").attr("sid", d.ID);
_item.find(".wishButton").attr("sid", d.ID);
_item.find(".Add_Reservation_List").attr("sid", d.ID);
}
// 切換規格時同步願望清單按鈕狀態(Love2 已含 wishlist wishButton wishButton{ID},已收藏時帶 red)
if (d.Love2) {
_item.find(".wishButton").attr("class", "button2 " + d.Love2);
}
if (d.Box_Pic) {
let picWrapper = _item.find(".bounce-product-left")
picWrapper.empty()
picWrapper.append('