$(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': 800},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)){
$('#menu-nav').on('click','.item-title',function(){
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');
}
}).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{
$('#menu-nav').on('click','.item-title',function(){
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');
}
}
}).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;i45 || 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);
}
}
function Avivid_AddToCart(Datas){
if(Datas){
var num = Datas.length;
var string = '';
for(i=0;i');
}
//結帳
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.R_Price)_item.find(".bounce-pricebox").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);
}
if(d.Box_Pic){
let picWrapper = _item.find(".bounce-product-left")
picWrapper.empty()
picWrapper.append('')
_item.find(".picbox").html(d.Box_Pic).owlCarousel({
items: 1,
nav: false,
dots: true
})
window.dispatchEvent(new Event('resize'))
}
if(d.Serial_No){
$(".rack_detail").attr('serial', d.Serial_No);
$("#Serial_No").val(d.Serial_No)
}
if(d.sale_tag){
_item.find(".sale-tag-box").removeClass("hide").html(d.sale_tag);
}else{
_item.find(".sale-tag-box").addClass("hide").empty()
}
$("#pdlist-addToCart").trigger("changeSpec")
}
// ==========================================================
// tags toggle
// ==========================================================
;(function($) {
function log(obj) {
console.log(obj)
}
$('body').on('click', '.tags-toggle', function(e) {
$(this).parents('.search-modal').toggleClass('tags-active');
})
})($)
// ==========================================================
// search toggle
// ==========================================================
;(function($) {
function log(obj) {
console.log(obj)
}
function stepCheck(step, target, className) {
if (step) {
$('body').addClass('theme-stock')
target.addClass(className)
let searchTopHeight = $(".search-top").height()
$('.search-modal').find(".item-wrapper").height("calc(80vh - " + (searchTopHeight + 20) + "px)")
} else {
$('body').removeClass('theme-stock')
target.removeClass(className)
}
}
let searchStep = 0
$('body').on('click', '.search-button', function(e) {
searchStep = 1
stepCheck(searchStep, $('.search-modal'), 'in-active')
})
$('body').on('click', '.search-modal .modal-closer', function(e) {
searchStep = 0
stepCheck(searchStep, $('.search-modal'), 'in-active')
})
})($)
// ==========================================================
// 商品圖輪播
// ==========================================================
$(function() {
let _window = $(window)
function productImgCarousel(){
if($("body").hasClass('hidden-store')) {
$(".product-img-carousel").each(function(){
let _this = $(this)
_this.owlCarousel({
items: 1,
nav: false,
dots: true
})
})
} else {
if(_window.width() <= 1024){
$(".product-img-carousel").each(function(){
let _this = $(this)
_this.owlCarousel({
items: 1,
nav: false,
dots: true
})
})
}else{
$(".product-img-carousel").each(function(){
$(this).trigger("destroy.owl.carousel")
})
}
}
}
productImgCarousel()
_window.on("resize", productImgCarousel)
})
// ==========================================================
// modal toggle
// ==========================================================
;(function($) {
//跳窗開關
$("body").on('click', '.open-modal:not(.detail-link)', function (e) {
e.preventDefault();
$(this).parents('.modal-layer').removeClass('in-active')
var sid = $(this).attr('sid'),
special_flag = $(this).attr('special_flag');
let is_rosetta = $(this).attr('is_rosetta') ?? 0;
$.ajax({
url:'/ajax/ajax_get_shopbox.php',
type:"POST",
cache:false,
async:true,
dataType: 'json',
data:{sid:sid,special_flag:special_flag,is_rosetta},
error:function(d){
alert(d.responseText);
},
success:function(d){
let wrapper = $("#pdlist-addToCart")
if (d.dataLayer_Data) {
window.dataLayer = window.dataLayer || [];
var dataLayer_products = [];
dataLayer_products.push({
'no' : d.dataLayer_Data['no'],
'series' : '',
'pos' : d.dataLayer_Data['pos'],
'name' : d.dataLayer_Data['name'],
'price' : '',
'category' : '',
'tags' : d.dataLayer_Data['tags'],
'list' : '',
'quantity' : '',
'brand' : '',
'variant' : '',
'position' : ''
});
dataLayer.push({
'productsPopup' : {
'member_id' : d.dataLayer_Data['member_id'],
'products' : dataLayer_products
}
});
}
wrapper.html(d.Data);
wrapper.find(".picbox").owlCarousel({
items: 1,
nav: false,
dots: true
})
window.dispatchEvent(new Event('resize'))
}
});
var type = $(this).data('target');
switch(type)
{
case "#socialShare":
$("#Share_Box").html($(this).parents('.outer-item').find('.Share_Content').html());
break;
case "#pdlist-addToCart":
$("#Spec_Box").html($(this).parents('.outer-item').find('.Spec_Content').html());
break;
}
if(type !== '#stockCheck') {
$('.modal-layer').removeClass('in-active');
}
$(type).addClass('in-active');
});
$(document).on('click', '.open-modal-simple', function (e) {
e.preventDefault();
console.log("aaa")
var type = $(this).data('target');
$(type).addClass('in-active');
});
$("#pdlist-addToCart").on('click',".box-item",function(){
var _item = $(this).parents("#pdlist-addToCart"),
SID = $(this).attr('sid'),
$this = $(this);
//橘標商品用
var Orange_Flag = $("#Orange_Flag_Box").val();
var data = {SID:SID,Orange_Flag:Orange_Flag,Special_Flag:$("#Popup_Special_Flag").val()};
if(SID){
$.ajax({
url:'/products/ajax/common/ajax_get_prod_item.php',
type:"POST",
cache:false,
async:false,
data:data,
dataType: 'json',
error:function(d){
alert(d.responseText);
},
success:function(d){
Set_Box_Files(_item,$this,d);
}
});
}
});
//數量
$("#pdlist-addToCart").on("click",".fa.fa-plus",function(){
var amount = $(this).prev(".amountBox").val(),
max = $(this).prev(".amountBox").attr("max");
if(amount == '無庫存'){
return false;
}
var amount = parseInt(amount);
if(amount+1 > max){
$(this).prev(".amountBox").val(max);
}else{
$(this).prev(".amountBox").val(amount+1);
}
});
$("#pdlist-addToCart").on("click",".fa.fa-minus",function(){
var amount = $(this).next(".amountBox").val();
if(amount == '無庫存'){
return false;
}
var amount = parseInt(amount);
if(amount-1 <= 1){
$(this).next(".amountBox").val(1);
}else{
$(this).next(".amountBox").val(amount-1);
}
});
//wishList
$("#pdlist-addToCart").on("click",".wishButton",function(){
var _item = $(this).parents("#pdlist-addToCart"),
SID = _item.find('.wishButton').attr('SID');
$.ajax({
url:'/products/ajax/common/ajax_add_wish_list.php',
type:"POST",
cache:false,
async:false,
dataType: 'json',
data:{SID:SID},
error:function(d){
alert(d.responseText);
},
success:function(d){
if(d.Msg=='OK'){
if(d.FBQ)
{
eval(d.FBQ);
}
$(".fa-heart"+SID).addClass('red');
$(".wishButton"+SID).addClass('red').addClass('in-withlist');
if (d.dataLayer_Data) {
window.dataLayer = window.dataLayer || [];
var dataLayer_products = [];
dataLayer_products.push({
'no' : d.dataLayer_Data['no'],
'series' : '',
'pos' : d.dataLayer_Data['pos'],
'name' : d.dataLayer_Data['name'],
'price' : '',
'category' : '',
'tags' : d.dataLayer_Data['tags'],
'list' : '',
'quantity' : '',
'brand' : '',
'variant' : '',
'position' : ''
});
dataLayer.push({
'addWishListProduct' : {
'member_id' : d.dataLayer_Data['member_id'],
'products' : dataLayer_products
}
});
}
alert(_jsLang.新增成功);
}else if(d.Msg == 'NO_MEMBER'){
alert(_jsLang.請先登入會員);
}else{
alert(_jsLang.資料庫忙線中);
}
}
});
});
//加入購物車按鈕
$("#pdlist-addToCart").on("click",".add_to_cart",function(){
var _item = $(this).parents("#pdlist-addToCart"),
SID = $(this).attr('sid') || 0,
num = _item.find(".amountBox").val() || 0;
if(SID == 0){
alert(_jsLang.請選擇尺寸或規格);
}else if(num ==0){
alert(_jsLang.請選擇數量);
}else{
var data = 'SID='+SID+'&num='+num+'&webcacheno='+$('#webcacheno').val();
var act_id = $("#Act_ID").val();
var act_type = $("#Act_Type").val();
if(act_id && act_type){
data += "&Act_ID="+act_id + "&Act_Type="+act_type;
}
$.ajax({
url:'/ajax/ajax_add_to_cart.php',
type:"POST",
cache:false,
async:false,
data:data,
dataType: 'json',
error:function(d){
alert(d.responseText);
},
success:function(d){
if(d.Amount)_item.find(".amountBox").html(d.Amount);
$(".shop-num").html(d.Total);
if(d.Total == "0"){
$(".shop-num").addClass("theme-zero")
}else{
$(".shop-num").removeClass("theme-zero")
}
alert(d.Alert);
if(d.Alert == '加入購物車成功'){
if(d.GA && typeof ga == 'function')
{
var new_ga = d.GA[0];
ga('ec:addProduct',new_ga);
ga('ec:setAction','add');
ga('send','event','購物車','加入購物車');
gtag('event', 'conversion', {'send_to': 'AW-670123971/gFIbCNO99cIBEMOPxb8C'});
gtag('event', 'conversion', {'send_to': 'AW-670123971/gFIbCNO99cIBEMOPxb8C'});
}
if(d.FBQ)
{
eval(d.FBQ);
PDA_AddToCart(d.IDs2);
}
if(d.GA4 && typeof gtag == 'function')
{
for(var key in d.GA4)
{
gtag("event","add_to_cart",{
"items":d.GA4
});
}
}
//GOOGLE DATALAYER
if (d.dataLayer_Data) {
window.dataLayer = window.dataLayer || [];
var dataLayer_products = [];
for(var i = 0; i < d.dataLayer_Data['no'].length; i++){
dataLayer_products.push({
'no' : d.dataLayer_Data['no'][i],
'series' : d.dataLayer_Data['series'][i],
'pos' : d.dataLayer_Data['pos'][i],
'name' : d.dataLayer_Data['name'][i],
'price' : d.dataLayer_Data['price'][i],
'category' : d.dataLayer_Data['category'][i],
'tags' : d.dataLayer_Data['tags'][i],
'list' : '',
'quantity' : d.dataLayer_Data['quantity'][i],
'brand' : d.dataLayer_Data['brand'][i],
'variant' : d.dataLayer_Data['variant'][i],
'position' : d.dataLayer_Data['position'][i]
});
}
dataLayer.push({
'addCartProducts' : {
'member_id' : d.dataLayer_Data['member_id'],
'products' : dataLayer_products
}
});
}
let IsHide = d.IsHide ?? false;
$.ajax({
url:"/ajax/ajax_get_cart.php",
type:"POST",
async:false,
cache:false,
data:{Type:'Prod',ID:SID},
success:function(d){
if(!IsHide){
$(".shopping-cartbox").css('display','none');
$("#Header_Shopcart_Prod").html(d);
$("#Header_Shopcart_Prod").parent(".one-cartbox").animate({'opacity':1,'maxHeight':'999px'}).css('z-index','100');
setTimeout(function(){
$("#Header_Shopcart_Prod").parent(".one-cartbox").animate({'maxHeight':'0px','opacity':0},function(){
$(this).removeAttr('style');
$(".shopping-cartbox").removeAttr('style');
});
},3000);
}
}
})
Rosetta_AddToCart(d.IDs3);
SAYA_AddToCart();
Avivid_AddToCart(d.IDs4);
//有在購物車頁加入商品,重整頁面
pathname = window.location.pathname.split('/');;
act = pathname[1];
if (act == 'shopcart') {
location.reload();
}
}
}
});
}
});
$("#pdlist-addToCart").on("click",".Add_Reservation_List", function(){
var SID = $(this).attr('sid') || 0;
if(SID == 0){
alert(_jsLang.請選擇尺寸或規格);
}else{
$.ajax({
url:'/ajax/ajax_reservation_list.php',
type:"POST",
cache:false,
async:false,
data:{SID:SID,Type:"Add"},
dataType: 'json',
error:function(d){
alert(d.responseText);
},
success:function(d){
alert(d.Alert);
}
});
}
});
//跳窗關閉按鈕
$('.modal-layer').on('click','.modal-closer,.add_to_cart',function(e){
const $parent = $(this).parents('.modal-layer')
$parent.removeClass('in-active');
if($parent.attr('id') === 'productDetail') {
$parent.find('.modal-title, .modal-content').empty()
}
});
//跳窗外側關閉
$('.modal-layer').on('click',function(e){
if (e.target === e.currentTarget && !$(e.target).hasClass("close-disabled")) {
$(this).removeClass('in-active');
}
});
})($)
// ==========================================================
// 開啟加入試衣籃跳窗
// ==========================================================
;(function($) {
let canOpen = true
$(document).on('click', '.FittingBasket', function(e) {
e.preventDefault();
var sid = $(this).attr('sid');
$.ajax({
url:'/ajax/ajax_get_shopbox.php',
type:"POST",
cache:false,
async:true,
dataType: 'json',
data:{sid:sid,fit:'1'},
error:function(d){
alert(d.responseText);
},
success:function(d){
if (d.dataLayer_Data) {
window.dataLayer = window.dataLayer || [];
var dataLayer_products = [];
dataLayer_products.push({
'no' : d.dataLayer_Data['no'],
'series' : '',
'pos' : d.dataLayer_Data['pos'],
'name' : d.dataLayer_Data['name'],
'price' : '',
'category' : '',
'tags' : d.dataLayer_Data['tags'],
'list' : '',
'quantity' : '',
'brand' : '',
'variant' : '',
'position' : ''
});
dataLayer.push({
'productsPopup' : {
'member_id' : d.dataLayer_Data['member_id'],
'products' : dataLayer_products
}
});
}
$('#pdlist-addToCart').html(d.Data)
.addClass('in-active')
.find(".picbox").owlCarousel({
items: 1,
nav: false,
dots: true
})
window.dispatchEvent(new Event('resize'))
}
});
})
})($)
;(function($) {
$('.tabs-wrapper').on('click', '.tabs-button', function(e) {
$(this).parent('.tabs-wrapper').toggleClass('in-click');
})
})($)
// ==========================================================
// 搜尋框篩選關鍵字
// ==========================================================
;(function($) {
let searchCarouselParam = {
nav : true,
dots: false,
autoWidth: true,
responsive:{
0:{
margin:8,
},
768:{
margin:10,
},
}
}
const keywordListBox = $(".keyword-list-box").clone()
function Search_Tag(keywords){
let modal = $(".search-modal")
let showTags = []
if(!!keywords){
//搜尋子標籤
$(".sub-tag-group .sub-tag-item").each(function(){
let subTag = $(this)
let tagGroup = subTag.parent(".sub-tag-group")
let subContent = subTag.text()
if(subContent.toLowerCase().indexOf(keywords) !== -1){
if(!showTags.includes(tagGroup.data("index"))){
showTags.push(tagGroup.data("index"))
}
subTag.removeClass("hide")
}else{
subTag.addClass("hide")
}
})
//篩選出有對應關鍵字的主tag並重新渲染
reGeneTagList(showTags)
}else{
//沒有關鍵字就還原
$(".sub-tag-group .sub-tag-item").removeClass("hide")
reGeneTagList()
}
}
function reGeneTagList(showTags = null){
let listBox = keywordListBox.clone()
if(showTags){
listBox.find("[data-target]").each(function(){
let _this = $(this)
let target = _this.data("target")
if(!showTags.includes(target)){
_this.parents(".keyword-item").remove()
}
})
}
$(".keyword-list-box").empty()
$(".keyword-list-box").html(listBox.html())
$(".keyword-list").owlCarousel(searchCarouselParam).trigger("refresh.owl.carousel")
let firstBtn = $(".keyword-list").find(".owl-item").eq(0).find(".keyword-btn")
firstBtn.addClass("in-active")
$(".sub-tag-group").removeClass("in-active")
$(".sub-tag-group[data-index='" + firstBtn.data("target") + "']").addClass("in-active")
getSearchProduct($(".keyword-btn.in-active").data("id"), $(".sub-tag-group.in-active .sub-tag-item:not(.hide)").eq(0).data("sub-id"))
}
let searchKeyword = $(".keyword-list")
let searchTimeout
if(searchKeyword.find(".keyword-item").length > 0){
searchKeyword.owlCarousel(searchCarouselParam)
}
$(document).on('input', '#Top_Search #keywords', function(e) {
clearTimeout(searchTimeout)
searchTimeout = setTimeout(function(){
const thisKeywords = $("#Top_Search #keywords").val().trim().toLowerCase()
//console.log(thisKeywords)
Search_Tag(thisKeywords)
}, 1000)
})
//切換tag
getSearchProduct($(".keyword-btn.in-active").data("id"))
$(document).on("click", ".search-modal .keyword-btn", function(){
let _this = $(this)
let target = _this.data("target")
$(".search-modal .keyword-btn").removeClass("in-active")
_this.addClass("in-active")
$(".sub-tag-group").removeClass("in-active")
$(".sub-tag-group[data-index='" + target + "']").addClass("in-active")
sub = $(".sub-tag-group[data-index='" + target + "']").find(".sub-tag-item").siblings().not('.hide');
getSearchProduct(_this.data("id"), sub.data("sub-id"))
})
$(document).on("click", ".search-modal .sub-tag-item", function(){
getSearchProduct($(".keyword-btn.in-active").data("id") ,$(this).data("sub-id"))
})
function getSearchProduct(tag="", subTag=""){
$.ajax({
url:"/ajax/ajax_get_search_popup_products.php",
type:"POST",
data:{
tag:tag,
subtag: subTag
},
error:function(d){
alert(d.responseText);
},
success:function(d){
$(".search-modal .item-box").html(d);
}
})
}
})($)
function throttle(func, delay){
let timeoutId
return function(...args){
if(!timeoutId){
timeoutId = setTimeout(function(){
func.apply(this, args)
timeoutId = null
}, delay)
}
}
}
// ==========================================================
// 協助 iOS 系統註冊 :active 事件
// ==========================================================
;(function($) {
document.body.addEventListener('touchstart', function() {})
})($)