// ==========================================================
// 蓋版廣告功能
// ==========================================================
;(function($) {
if($('.index-popup-wrapper').length) {
$('body').addClass('overflow-hidden')
}
})($)
// ==========================================================
// 天邊廣告功能
// ==========================================================
;(function($) {
if($('.top-featurebox').length) {
const wrapper = $('.top-featurebox')
const key = "topFeatureLastShown"
const today = new Date().toISOString().split("T")[0]
const lastShown = localStorage.getItem(key)
if(lastShown === today){
wrapper.addClass('in-hidden')
//$("body").removeClass("overflow-hidden")
}else{
wrapper.removeClass('in-hidden')
//$("body").addClass("overflow-hidden")
localStorage.setItem(key, today)
}
$(document).on('click', '.top-featurebox', function(e) {
console.log($(e.target))
if($(e.target).closest(".top-featurebox-background").length || $(e.target).closest(".top-featurebox-button").length){
if(wrapper.hasClass('in-hidden')){
//$("body").addClass("overflow-hidden")
wrapper.removeClass("in-hidden")
}else{
//$("body").removeClass("overflow-hidden")
wrapper.addClass("in-hidden")
}
}
})
}
})($)
// ==========================================================
// 跳窗顯示
// ==========================================================
// ;(function($) {
// const wrapper = $('.index-popup-wrapper')
// if(wrapper.length) {
//
// wrapper.on('click', '.index-popup-closer', function(e) {
// $.ajax({
// type:"POST",
// url:Project_Country+'ajax/ajax_hide_index_popup.php',
// })
// })
// }
// })($)
// ==========================================================
// 紅眼廣告功能
// ==========================================================
;(function($) {
const slideTarget = $('#slideshow')
if(slideTarget.length && slideTarget.children().length > 1) {
slideTarget.owlCarousel({
items: 1,
dots: true,
margin: 10,
loop: true,
autoplay: true,
autoplayTimeout: 8000,
autoplaySpeed: 1000,
animateOut: 'fadeOut',
animateIn: 'fadeIn',
nav: true,
navText: ['', ''],
responsive: {
0: {
autoplayHoverPause: false,
},
1200: {
autoplayHoverPause: true,
},
},
})
}
})($)
// ==========================================================
// 一個廣告功能
// ==========================================================
;(function($) {
const slideTarget = $('.featurebox-01 .featurebox-wrapper')
slideTarget.each(function(){
let _this = $(this)
if(_this.length && _this.children().length > 1) {
_this.owlCarousel({
items: 1,
dots: true,
margin: 10,
loop: true,
autoplay: true,
autoplayTimeout: 8000,
autoplaySpeed: 1000,
animateOut: 'fadeOut',
animateIn: 'fadeIn',
nav: true,
navText: ['', ''],
})
}
})
})($)
// ==========================================================
// 三個廣告功能
// ==========================================================
;(function($) {
const block = $(".featurebox-03")
block.each(function(){
const _this = $(this)
$(window).on("resize", function(){
updateSwiper(_this)
})
})
function initSwiper(parent){
const swiper = new Swiper(parent.find('.swiper')[0] , {
loop:false,
centeredSlides: false,
touchReleaseOnEdges: true,
passiveListeners: true,
navigation: {
nextEl: parent.find('.swiper-button-next')[0],
prevEl: parent.find('.swiper-button-prev')[0],
},
pagination: {
el: parent.find('.swiper-pagination')[0],
clickable: true
},
slidesPerView: 1,
spaceBetween: 12,
})
}
function updateSwiper(parent){
let swiperTarget = parent.find(".swiper")
let groupSize = null
if($(window).width() < 576){
groupSize = 1
}else {
groupSize = 0
}
if(swiperTarget[0]?.swiper && (swiperTarget.data("group-size") !== groupSize)){
swiperTarget[0].swiper.destroy(true, true)
}
let toolbar = parent.find(".swiper-toolbar")
if($(window).width() < 576){
if(swiperTarget.data("group-size") !== groupSize){
initSwiper(parent)
checkToolbar(parent, toolbar, 1)
}
}else {
toolbar.addClass("hide")
}
swiperTarget.data("group-size", groupSize)
}
})($)
// ==========================================================
// 四個廣告功能
// ==========================================================
;(function($) {
const block = $(".featurebox-04")
block.each(function(){
const _this = $(this)
$(window).on("resize", function(){
updateSwiper(_this)
})
})
function initSwiper(parent){
const swiper = new Swiper(parent.find('.swiper')[0] , {
loop:false,
centeredSlides: false,
touchReleaseOnEdges: true,
passiveListeners: true,
navigation: {
nextEl: parent.find('.swiper-button-next')[0],
prevEl: parent.find('.swiper-button-prev')[0],
},
pagination: {
el: parent.find('.swiper-pagination')[0],
clickable: true
},
slidesPerView: 1,
spaceBetween: 12,
})
}
function updateSwiper(parent){
let swiperTarget = parent.find(".swiper")
let groupSize = null
if($(window).width() < 576){
groupSize = 1
}else {
groupSize = 0
}
if(swiperTarget[0]?.swiper && (swiperTarget.data("group-size") !== groupSize)){
swiperTarget[0].swiper.destroy(true, true)
}
let toolbar = parent.find(".swiper-toolbar")
if($(window).width() < 576){
if(swiperTarget.data("group-size") !== groupSize){
initSwiper(parent)
checkToolbar(parent, toolbar, 1)
}
}else {
toolbar.addClass("hide")
}
swiperTarget.data("group-size", groupSize)
}
})($)
// ==========================================================
// 推薦主題商品
// ==========================================================
;(function($) {
const block = $(".index-recommend")
if(block.length) {
block.on('click', '.tag-button', function(e) {
const switchTarget = $(this).data('target')
$(this).parent('.tag-item').addClass('in-active')
.siblings('.tag-item').removeClass('in-active')
$('.content-item[data-id='+ switchTarget + ']').addClass('in-active')
.siblings('.content-item').removeClass('in-active')
$('.banner-item[data-id='+ switchTarget + ']').addClass('in-active')
.siblings('.banner-item').removeClass('in-active')
})
}
})($)
// ==========================================================
// blog function
// ==========================================================
;(function($) {
const block = $(".index-blogs")
block.each(function(){
const _this = $(this)
$(window).on("resize", function(){
initSwiper(_this)
})
})
function initSwiper(parent){
const swiper = new Swiper(parent.find('.swiper')[0] , {
loop:false,
centeredSlides: false,
touchReleaseOnEdges: true,
passiveListeners: true,
navigation: {
nextEl: parent.find('.swiper-button-next')[0],
prevEl: parent.find('.swiper-button-prev')[0],
},
pagination: {
el: parent.find('.swiper-pagination')[0],
clickable: true
},
breakpoints: {
0: {
slidesPerView: 1,
spaceBetween: 12
},
576: {
slidesPerView: 2,
spaceBetween: 12
},
768: {
slidesPerView: 3,
spaceBetween: 16
},
1200: {
slidesPerView: 3,
spaceBetween: 20
}
},
on: {
init: function(){
updateToolbar(parent)
},
resize: function(){
updateToolbar(parent)
}
}
})
}
function updateToolbar(parent){
let toolbar = parent.find(".swiper-toolbar")
if($(window).width() < 576){
checkToolbar(parent, toolbar, 1)
}else if($(window).width() < 768){
checkToolbar(parent, toolbar, 2)
}else{
checkToolbar(parent, toolbar, 3)
}
}
})($)
// ==========================================================
// event function
// ==========================================================
;(function($) {
const block = $(".index-event")
block.each(function(){
const _this = $(this)
$(window).on("resize", function(){
initSwiper(_this)
})
})
function initSwiper(parent){
const swiper = new Swiper(parent.find('.swiper')[0] , {
loop:false,
centeredSlides: false,
touchReleaseOnEdges: true,
passiveListeners: true,
navigation: {
nextEl: parent.find('.swiper-button-next')[0],
prevEl: parent.find('.swiper-button-prev')[0],
},
pagination: {
el: parent.find('.swiper-pagination')[0],
clickable: true
},
breakpoints: {
0: {
slidesPerView: (parent.hasClass("theme-long"))?2:2,
spaceBetween: 12
},
675: {
slidesPerView: (parent.hasClass("theme-long"))?2:3,
spaceBetween: 12
},
768: {
slidesPerView: (parent.hasClass("theme-long"))?2:4,
spaceBetween: 16
},
1200: {
slidesPerView: (parent.hasClass("theme-long"))?2:4,
spaceBetween: 20
}
},
on: {
init: function(){
updateToolbar(parent)
},
resize: function(){
updateToolbar(parent)
}
}
})
}
function updateToolbar(parent){
let toolbar = parent.find(".swiper-toolbar")
if(parent.hasClass("theme-long")){
checkToolbar(parent, toolbar, 2)
}else{
if($(window).width() < 675){
checkToolbar(parent, toolbar, 2)
}else if($(window).width() < 768){
checkToolbar(parent, toolbar, 3)
}else{
checkToolbar(parent, toolbar, 4)
}
}
}
})($)
// ==========================================================
// 型錄廣告 function
// ==========================================================
;(function($) {
const block = $(".index-lookbook")
block.each(function(){
const _this = $(this)
initSwiper(_this)
})
function initSwiper(parent){
const swiper = new Swiper(parent.find('.swiper')[0] , {
loop:false,
centeredSlides: false,
touchReleaseOnEdges: true,
passiveListeners: true,
navigation: {
nextEl: parent.find('.swiper-button-next')[0],
prevEl: parent.find('.swiper-button-prev')[0],
},
spaceBetween: 20,
pagination: {
el: parent.find('.swiper-pagination')[0],
clickable: true
},
on: {
init: function(){
checkToolbar(parent, parent.find(".swiper-toolbar"), 1)
},
}
})
}
})($)
// ==========================================================
// 商品櫥窗快速購物區塊
// ==========================================================
// ;(function($) {
// if($('.showcase').length) {
// let showcaseStep = true
// $('body').on('mouseenter', '.showcase .HoverShopcart', function(e) {
// e.preventDefault()
// const appendTarget = $(this).parents('.item')
// if(showcaseStep) {
// showcaseStep = false
// jQuery.ajax({
// url: Project_Country+'ajax/ajax_showcase_shopbox.php',
// type: 'POST',
// dataType: 'HTML',
// cache: false,
// async: true,
// data: {
// sid: $(this).attr('sid'),
// },
// })
// .done(function(res) {
// appendTarget.append(res)
// })
// .fail(function(x, y, z) {
// console.log(x);
// })
// .always(function() {
// showcaseStep = true
// });
// }
// }).on('mouseleave', '.showcase .item', function(e) {
// e.preventDefault()
// $(this).find('.hover-cart').remove()
// })
// }
// })($)
// ==========================================================
// 影音購物輪播
// ==========================================================
;(function($) {
const block = $(".video-area")
block.each(function(){
const _this = $(this)
initSwiper(_this)
})
function initSwiper(parent){
const swiper = new Swiper(parent.find('.swiper')[0] , {
loop:false,
slidesPerView: 1,
centeredSlides: false,
touchReleaseOnEdges: true,
passiveListeners: true,
spaceBetween: 0,
navigation: {
nextEl: parent.find('.swiper-button-next')[0],
prevEl: parent.find('.swiper-button-prev')[0],
},
pagination: {
el: parent.find('.swiper-pagination')[0],
clickable: true
},
on: {
init: function(){
checkToolbar(parent, parent.find(".swiper-toolbar"), 1)
},
}
})
}
})($)
// ==========================================================
// 抵用券輪播
// ==========================================================
;(function($) {
const block = $(".index-coupon")
block.each(function(){
const _this = $(this)
initSwiper(_this)
})
function initSwiper(parent){
const swiper = new Swiper(parent.find('.swiper')[0] , {
loop:false,
centeredSlides: false,
touchReleaseOnEdges: true,
passiveListeners: true,
navigation: {
nextEl: parent.find('.swiper-button-next')[0],
prevEl: parent.find('.swiper-button-prev')[0],
},
pagination: {
el: parent.find('.swiper-pagination')[0],
clickable: true
},
breakpoints: {
0: {
slidesPerView: 'auto',
spaceBetween: 12
},
675: {
slidesPerView: 2,
spaceBetween: 12
},
768: {
slidesPerView: 3,
spaceBetween: 16
},
1200: {
slidesPerView: 3,
spaceBetween: 20
}
},
on: {
init: function(){
updateToolbar(parent)
},
resize: function(){
updateToolbar(parent)
}
}
})
}
function updateToolbar(parent){
let toolbar = parent.find(".swiper-toolbar")
if($(window).width() < 675){
checkToolbar(parent, toolbar, 1)
}else if($(window).width() >= 675 && $(window).width() < 768) {
checkToolbar(parent, toolbar, 2)
}else {
checkToolbar(parent, toolbar, 3)
}
}
})($)
// ==========================================================
// 主題圖標輪播
// ==========================================================
;(function($) {
const block = $(".index-theme-list")
block.each(function(){
const _this = $(this)
$(window).on("resize", function(){
updateSwiper(_this)
})
})
function initSwiper(parent){
const swiper = new Swiper(parent.find('.swiper')[0] , {
loop:false,
slidesPerView: 1,
centeredSlides: false,
touchReleaseOnEdges: true,
passiveListeners: true,
spaceBetween: 0,
navigation: {
nextEl: parent.find('.swiper-button-next')[0],
prevEl: parent.find('.swiper-button-prev')[0],
},
breakpoints: {
0: {
slidesPerView: 3,
spaceBetween: 24
},
576: {
slidesPerView: 3,
spaceBetween: 40
},
768: {
slidesPerView: 4,
spaceBetween: 45
},
1200: {
slidesPerView: 5,
spaceBetween: 50
},
1600: {
slidesPerView: 6,
spaceBetween: 70
}
},
// pagination: {
// el: parent.find('.swiper-pagination')[0],
// clickable: true
// },
})
}
function updateSwiper(parent){
checkToolbar(parent, parent.find('.swiper-toolbar'), 1)
initSwiper(parent)
}
})($)
// ==========================================================
// 商品櫥窗、加入購物車彈窗
// ==========================================================
;(function($) {
//商品內容
var file_Obj = new prod_file({
type :'1',
itemBox:'product-detail',
});
file_Obj.init();
})($)
// ==========================================================
// 今日限定區塊腳本
// ==========================================================
var debugA = ""
;(function($) {
const todaySale = $('.today-sale')
if(todaySale.length) {
// 倒數計時器
todaySale.find('.timerbox').each(function(i, ele) {
const target = $(ele)
function outputFunc(input) {
target.html(input)
}
CountDown(target, outputFunc)
});
//輪播
todaySale.each(function(){
const _this = $(this)
$(window).on("resize", function(){
updateSwiper(_this)
})
})
function initSwiper(parent){
swiper = new Swiper(parent.find('.swiper')[0], {
loop:false,
centeredSlides: false,
touchReleaseOnEdges: true,
passiveListeners: true,
spaceBetween: 20,
breakpoints: {
0: {
slidesPerView: 1,
spaceBetween: 12
},
576: {
slidesPerView: 1,
spaceBetween: 12
},
768: {
slidesPerView: (parent.hasClass("theme-small"))?1:"auto",
spaceBetween: 16
},
1200: {
slidesPerView: "auto",
spaceBetween: 20
}
},
navigation: {
nextEl: parent.find('.swiper-button-next')[0],
prevEl: parent.find('.swiper-button-prev')[0],
},
pagination: {
el: parent.find('.swiper-pagination')[0],
clickable: true
},
})
}
function updateSwiper(parent){
const viewWidth = window.innerWidth
let groupSize = 1
let toolbarNum = 1
let swiperTarget = parent.find(".swiper")
let wrapper = swiperTarget.find(".swiper-wrapper")
if(parent.hasClass("theme-small")){
if(viewWidth > 1199){
toolbarNum = Math.floor( wrapper[0].clientWidth / wrapper.find(".item").eq(0).width())
}else if(viewWidth > 767){
groupSize = 4
}else if(viewWidth > 674){
groupSize = 3
}else{
groupSize = 4
}
}else if(parent.hasClass("theme-large")){
if(viewWidth > 767){
toolbarNum = Math.floor( wrapper[0].clientWidth / wrapper.find(".item").eq(0).width())
}else if(viewWidth > 674){
groupSize = 3
}else{
groupSize = 2
}
}
if(swiperTarget[0]?.swiper && (swiperTarget.data("group-size") !== groupSize)){
swiperTarget[0].swiper.destroy(true, true)
}
if(swiperTarget.data("group-size") !== groupSize){
groupItems(parent.find('.swiper-wrapper'), groupSize)
checkToolbar(parent, parent.find('.swiper-toolbar'), toolbarNum)
initSwiper(parent)
}
swiperTarget.data("group-size", groupSize)
}
}
})($)
// ==========================================================
// 熱銷商品輪播
// ==========================================================
;(function($) {
const block = $(".oneline-fiveitem-02")
block.each(function(){
const _this = $(this)
$(window).on("resize", function(){
updateSwiper(_this)
})
})
function initSwiper(parent){
swiper = new Swiper(parent.find('.swiper')[0], {
loop:false,
centeredSlides: false,
slidesPerView: 1,
touchReleaseOnEdges: true,
passiveListeners: true,
navigation: {
nextEl: parent.find('.swiper-button-next')[0],
prevEl: parent.find('.swiper-button-prev')[0],
},
breakpoints: {
0: {
spaceBetween: 12
},
768: {
spaceBetween: 16
},
1200: {
spaceBetween: 20
},
},
pagination: {
el: parent.find('.swiper-pagination')[0],
clickable: true
},
})
}
function updateSwiper(parent){
const viewWidth = window.innerWidth
let groupSize
let swiperTarget = parent.find(".swiper")
if(viewWidth > 674){
groupSize = 6
}else {
groupSize = 4
}
if(swiperTarget[0]?.swiper && (swiperTarget.data("group-size") !== groupSize)){
swiperTarget[0].swiper.destroy(true, true)
}
if(swiperTarget.data("group-size") !== groupSize){
groupItems(parent.find('.swiper-wrapper'), groupSize)
checkToolbar(parent, parent.find('.swiper-toolbar'), 1)
initSwiper(parent)
}
swiperTarget.data("group-size", groupSize)
}
})($)
// ==========================================================
// 新品上市輪播
// 獨家販售輪播
// ==========================================================
;(function($) {
const block = $(".oneline-fiveitem-01, .new-arrivals")
block.each(function(){
const _this = $(this)
$(window).on("resize", function(){
updateSwiper(_this)
})
})
function initSwiper(parent){
swiper = new Swiper(parent.find('.swiper')[0], {
loop:false,
centeredSlides: false,
slidesPerView: 1,
touchReleaseOnEdges: true,
passiveListeners: true,
navigation: {
nextEl: parent.find('.swiper-button-next')[0],
prevEl: parent.find('.swiper-button-prev')[0],
},
breakpoints: {
0: {
spaceBetween: 12
},
768: {
spaceBetween: 16
},
1200: {
spaceBetween: 20
},
},
pagination: {
el: parent.find('.swiper-pagination')[0],
clickable: true
},
})
}
function updateSwiper(parent){
const viewWidth = window.innerWidth
let groupSize
let swiperTarget = parent.find(".swiper")
if(viewWidth > 674){
groupSize = 8
}else {
groupSize = 4
}
if(swiperTarget[0]?.swiper && (swiperTarget.data("group-size") !== groupSize)){
swiperTarget[0].swiper.destroy(true, true)
}
if(swiperTarget.data("group-size") !== groupSize){
groupItems(parent.find('.swiper-wrapper'), groupSize)
checkToolbar(parent, parent.find('.swiper-toolbar'), 1)
initSwiper(parent)
}
swiperTarget.data("group-size", groupSize)
}
})($)
// ==========================================================
// 櫥窗12輪播
// ==========================================================
;(function($) {
const block = $(".showcase-carousel-block")
block.each(function(){
const _this = $(this)
$(window).on("resize", function(){
initSwiper(_this)
})
})
function initSwiper(parent){
const swiper = new Swiper(parent.find('.swiper')[0] , {
loop:false,
centeredSlides: false,
touchReleaseOnEdges: true,
passiveListeners: true,
navigation: {
nextEl: parent.find('.swiper-button-next')[0],
prevEl: parent.find('.swiper-button-prev')[0],
},
pagination: {
el: parent.find('.swiper-pagination')[0],
clickable: true
},
breakpoints: {
0: {
slidesPerView: 2,
spaceBetween: 12
},
576: {
slidesPerView: 3,
spaceBetween: 12
},
768: {
slidesPerView: 4,
spaceBetween: 16
},
992: {
slidesPerView: 5,
spaceBetween: 20
}
},
on: {
init: function(){
updateToolbar(parent)
},
resize: function(){
updateToolbar(parent)
}
}
})
}
function updateToolbar(parent){
let toolbar = parent.find(".swiper-toolbar")
if($(window).width() < 576){
checkToolbar(parent, toolbar, 2)
}else if($(window).width() >= 576 && $(window).width() < 768) {
checkToolbar(parent, toolbar, 3)
}else if($(window).width() >= 768 && $(window).width() < 992) {
checkToolbar(parent, toolbar, 4)
}else {
checkToolbar(parent, toolbar, 5)
}
}
})($)
// ==========================================================
// 好評分享輪播
// ==========================================================
;(function($) {
const block = $(".index-review-google")
block.each(function(){
const _this = $(this)
initSwiper(_this)
})
function initSwiper(parent){
const swiper = new Swiper(parent.find('.swiper')[0] , {
loop:false,
centeredSlides: false,
touchReleaseOnEdges: true,
passiveListeners: true,
navigation: {
nextEl: parent.find('.swiper-button-next')[0],
prevEl: parent.find('.swiper-button-prev')[0],
},
pagination: {
el: parent.find('.swiper-pagination')[0],
clickable: true
},
breakpoints: {
0: {
slidesPerView: 1,
spaceBetween: 12
},
576: {
slidesPerView: 2,
spaceBetween: 16
},
768: {
slidesPerView: 3,
spaceBetween: 16
},
1200: {
slidesPerView: 3,
spaceBetween: 20
}
},
on: {
init: function(){
updateToolbar(parent)
},
resize: function(){
updateToolbar(parent)
}
}
})
}
function updateToolbar(parent){
let toolbar = parent.find(".swiper-toolbar")
if($(window).width() < 576){
checkToolbar(parent, toolbar, 1)
}else if($(window).width() < 768) {
checkToolbar(parent, toolbar, 2)
}else {
checkToolbar(parent, toolbar, 3)
}
}
})($)
// ==========================================================
// 倒數
// ==========================================================
;(function($) {
let blocks = $(".index-countdown .countdown-box")
function setTime(box, time){
let day = String(Math.floor(time / 86400)).padStart(2, '0')
let hour = String(Math.floor((time % 86400) / 3600)).padStart(2, '0')
let minute = String(Math.floor((time % 3600) / 60)).padStart(2, '0')
let second = String(Math.floor(time % 60)).padStart(2, '0')
box.find(".slot-day").text(day)
box.find(".slot-hour").text(hour)
box.find(".slot-minute").text(minute)
box.find(".slot-second").text(second)
}
function startCountdown(box){
if(!box.data("endTime")){
const totalSeconds = parseInt(box.data("time"), 10)
const endTime = Date.now() + totalSeconds * 1000
box.data("endTime", endTime)
}
let interval = setInterval(function(){
const diff = Math.ceil((box.data("endTime") - Date.now()) / 1000)
const time = Math.max(0, diff)
if(time <= 0){
clearInterval(interval)
box.parents(".index-countdown ").remove()
return
}
setTime(box, time)
}, 1000)
}
if(blocks.length > 0){
blocks.each(function(){
startCountdown($(this))
})
}
})($)
// ==========================================================
// trigger function
// ==========================================================
;(function($) {
$(window).triggerAll('scroll resize')
})($)