var keepTopCurrent
function keepTop(){
keepTopCurrent = $(window).scrollTop()
}
function toTop(){
if(keepTopCurrent){
$("html,body").scrollTop(keepTopCurrent)
}
}
// ==========================================================
// 通用型滑動到指定位置
// ==========================================================
;(function($) {
$(document).on('click', '.ScrollToTarget', function(e) {
e.preventDefault()
const scrollTarget = $(this).attr('data-target')
if($(scrollTarget).length) {
const scrollTop = $(scrollTarget).offset().top - $('.header').height()
$('html, body').animate({
scrollTop
}, 750)
}
})
})($)
// ==========================================================
// 商品列表規格購買
// ==========================================================
;(function($) {
let list = $('.items-list') //$('.product-list,.combosBox')
function onceProductClose(){
$(document).off("click.onceProductClose")
$(document).on("click.onceProductClose", function(e){
let target = $(e.target)
if(!target.closest(".product-box.in-open").length){
$(".product-box").removeClass("in-open")
$(document).off("click.onceProductClose")
}
})
}
list.on("mouseenter", '.product-box', function(){
let _this = $(this)
if($(window).width() >= 1200){
$(".product-box").removeClass("in-open")
_this.addClass("in-open")
onceProductClose()
$('body').addClass("in-spec-open")
}
})
list.on("mouseleave", '.product-box', function(){
let _this = $(this)
if($(window).width() >= 1200){
$('body').removeClass("in-spec-open")
}
})
list.on('click', '.product-toggle-btn', function(){
let box = $(this).parents('.product-box')
if(box.hasClass('in-open')){
box.removeClass('in-open')
$(document).off("click.onceProductClose")
$('body').addClass("in-spec-open")
}else{
$(".product-box").removeClass("in-open")
box.addClass('in-open')
onceProductClose()
$('body').removeClass("in-spec-open")
}
})
})($)
// 關閉跳窗特效
function PopupCloseAnimate(jqElement) {
if(jqElement.hasClass("popupBox-constant")){
jqElement.addClass("hide")
}else{
jqElement.remove()
}
$('body').removeClass('overflow-hidden')
}
// 客製化 alert popup
function AlertPop(obj) {
const setting = {
backgroundColor: '',
color: '',
icon: '',
string: '',
}
if(obj) {
Object.assign(setting, obj)
}
let customStyle = ''
customStyle += (setting.backgroundColor)? `background-color: ${setting.backgroundColor};`: ''
customStyle += (setting.color)? `color: ${setting.color};`: ''
const alertStyle = (customStyle)? `style="${customStyle}"`: ''
const customIcon = (setting.icon)? `${setting.icon}`: '';
const alertElement = `
${customIcon}
${setting.string}
`
$('body').addClass('overflow-hidden').append(alertElement)
const alertTarget = $('.alert-wrapper')
setTimeout(function() {
PopupCloseAnimate(alertTarget)
}, 1500)
}
// 主選單開關
;(function($) {
$('body').on('click', '.menu-toggle', function(e) {
e.preventDefault()
$('body').toggleClass('menu-active');
})
})($)
// 滑動定位
// 螢幕滾動
;(function($) {
let lastScrolltop = 0
$(window).on('scroll', function(e) {
let currentScrolltop = $(this).scrollTop()
if(currentScrolltop > 0){
$('.gotop').fadeIn(400)
$("body").addClass('is-sticky');
}else{
$('.gotop').fadeOut(400)
$("body").removeClass('is-sticky');
}
if(currentScrolltop > lastScrolltop){
$("body").removeClass('is-upwards');
}else{
$("body").addClass('is-upwards');
}
lastScrolltop = currentScrolltop
})
})($)
// 點擊滑動動畫
;(function($) {
const slideTarget = $('body, html')
const slideDuration = 750
$('#gotop').on('click', function(e) {
e.preventDefault()
slideTarget.animate({
scrollTop: 0
}, slideDuration);
})
})($)
// 倒數計時
;(function($) {
if($("#CountDown_Box").length) {
let num = parseInt($("#CountDown_Box").attr("second"),10);
const _this = $("#CountDown_Box");
if(num > 0) {
setInterval(function() {
num--;
if(num <= 0) {
$("#CountDown_Box").hide();
}
var day = Math.floor(num/(3600*24)),
hour = Math.floor((num - (day*3600*24) )/3600),
min = Math.floor((num - (day*3600*24) - (hour*3600) )/60 ),
second = num - (day*3600*24) - (hour*3600) - (min*60),
pad = '00';
if(day > 0) {
_this.find(".timer").eq(0).html(day);
_this.find(".timer").eq(1).html(pad.substring(hour.toString().length)+hour);
_this.find(".timer").eq(2).html(pad.substring(min.toString().length)+min);
_this.find(".timer").eq(3).html(pad.substring(second.toString().length)+second);
} else {
_this.find(".Date_Box").remove();
_this.find(".timerbox").html(_this.find(".timerbox").html().replace('天',''));
_this.find(".timer").eq(0).html(pad.substring(hour.toString().length)+hour);
_this.find(".timer").eq(1).html(pad.substring(min.toString().length)+min);
_this.find(".timer").eq(2).html(pad.substring(second.toString().length)+second);
}
},1000);
} else {
_this.remove()
}
}
})($)
// 商品資料頁籤切換
;(function($) {
$('body').on('click', '.tag-box .title-h2', function(e) {
e.preventDefault()
const tagTarget = $(this).attr('for')
$(this).addClass('in-active')
.siblings('.title-h2').removeClass('in-active')
$(this).parents('.tag-box')
.find('.' + tagTarget).addClass('in-active')
.siblings('.itembox').removeClass('in-active')
})
})($)
// ==========================================================
// 通用跳窗功能
// ==========================================================
;(function($) {
$(document).on("click", ".popup-trigger", function(){
let _this = $(this)
let target = _this.data("target")
$(".popupBox-wrapper[data-index=" + target + "]").removeClass("hide")
})
$('body').on('click', '.popupBox-wrapper:not(.close-disabled)', function(e) {
if(e.currentTarget === e.target || $(e.target).hasClass('closer') || $(e.target).parent().hasClass('closer') || $(e.target).hasClass('js-popupBox-closer')) {
e.preventDefault()
if($(e.target).closest(".popupBox-wrapper").hasClass("popupBox-constant")){
$(e.target).closest(".popupBox-wrapper").addClass("hide")
}else{
PopupCloseAnimate($(e.currentTarget))
}
}
})
// 關閉跳窗特效
function PopupCloseAnimate(jqElement) {
if(jqElement.hasClass("popupBox-constant")){
jqElement.addClass("hide")
}else{
jqElement.remove()
}
$('body').removeClass('overflow-hidden')
}
})($)
// ==========================================================
// 快速購物跳窗
// ==========================================================
;(function($) {
let commonShopcartStep = false
$('body').on('click', '.QuickShop', function(e) {
e.preventDefault()
if(!commonShopcartStep) {
commonShopcartStep = true
jQuery.ajax({
url: Project_Country + 'ajax/ajax_popup_shopbox.php',
type: 'POST',
dataType: 'html',
data: {
SID: $(this).attr('sid'),
Serial: $(this).attr('serial'),
Page_Shop_ID:$('#Page_Shop_ID').val(),
Add_Type:$(this).attr('add_type')
},
}).done(function(res) {
if(res.indexOf('window.location.href=') == 0)
{
eval(res);
}
else
{
$('body').addClass('overflow-hidden').append(res)
const slideTarget = $('.quickShop-box .preview-slide')
if(slideTarget.length && slideTarget.children('.slide-item').length > 1) {
slideTarget.addClass('with-dots').owlCarousel({
nav: true,
navText: ['', ''],
dots: true,
margin: 10,
items: 1,
})
}
}
}).fail(function(x, y, z) {
console.log(x)
}).always(function() {
commonShopcartStep = false
})
}
})
})($)
$(function() {
$("#Main_Form").fromsAuth();
//一開始就先更新一次購物車數量
if($("#CartTotal").length && $("#CartTotal").val() !== undefined){
$(".cart-total").text($("#CartTotal").val())
}
$("#Main_Content").on('click','#productlist .button-full,#productlist2 .button-full',function(){
if(!$(this).is('.button-cant')){
var $class = $(this).attr("class"),
type = '1';
if($class == 'button-add')
{
type = '2';
}
$('.popupbg').addClass('is-show');
$('.popupbg').attr("type",type);
$('.popupbg').html($(this).parents(".productBox").find(".Box_Data").html());
}
});
$("#Main_Content").on('click','.informButton',function(){
$("#informID").val($(this).attr("sid"));
$('.emailPopup').css('display','flex');
});
$("#Main_Content").on('click','.emailPopup .close',function(){
$('.emailPopup').css('display','none');
});
$(".Change_Pic").click(function(e){
$(".Checkspan").load(Project_Country+'ajax/ajax_get_check_pic.php',{change:1});
});
$(document).on("click", ".memberbox-header .header-item", function(){
let _this = $(this)
let target = _this.data("target")
$(".memberbox-header .header-item").removeClass("in-active")
_this.addClass("in-active")
$(".login-popup-group").removeClass("in-current")
$(".login-popup-group[data-index='"+target+"']").addClass("in-current")
})
/* 小圖hover效果及切換功能 */
if($(".moreview .picitem ").length > 5){
$(".productView .moreview").owlCarousel({
loop:false,
responsive:{
0:{
items : 3,
},
768:{
items : 5,
}
},
nav : true,
dots: false,
navText: ['', ''],
}).on('mouseleave','.owl-stage-outer', function() {
var box = $(this).parents(".productBox");
box.find(".productView .zoonbox").removeAttr('style');
})
.on('click','.owl-item', function() {
var now = $(this).index(),
box = $(this).parents(".productBox");
box.find(".productView .owl-item").not(this).find('.picitem').removeClass('now');
$(this).find('.picitem').addClass('now');
box.find(".productView .zoonbox").removeClass('now').eq(now).addClass('now');
})
.on('mouseenter','.owl-item', function() {
var now = $(this).index(),
box = $(this).parents(".productBox");
box.find(".productView .zoonbox").css('display','none').eq(now).css('display','flex');
});
}else{
$(".productView .moreview")
.on('mouseleave', function() {
var box = $(this).parents(".productBox");
box.find(".productView .zoonbox").removeAttr('style');
})
.on('click','.picitem', function() {
var now = $(this).index(),
box = $(this).parents(".productBox");
box.find(".productView .picitem").removeClass('now');
$(this).addClass('now');
box.find(".productView .zoonbox").removeClass('now').eq(now).addClass('now');
})
.on('mouseenter','.picitem', function() {
var now = $(this).index(),
box = $(this).parents(".productBox");
box.find(".productView .zoonbox").css('display','none').eq(now).css('display','block');
});
}
$("#Main_Content").on('focusin','.input-text',function(){
$(this).parents(".word-line").find('.text-title').addClass('now');
});
$("#Main_Content").on('focusout','.input-text',function(){
if($(this).val()==''){
$(this).parents(".word-line").find('.text-title').removeClass('now');
}
});
$('.gotop').on('click',function(){
$("html,body").animate({scrollTop: 0},800);
});
});
//刪除購物車
$("#Main_Content").on('click','.product-del',function() {
$.ajax({
url:Project_Country+"quickshop/ajax/ajax_del_cart.php",
type:"POST",
cache:false,
data:{ID:$(this).attr("sid"), Page_Shop_ID:$("#Page_Shop_ID").val()},
dataType:'json',
error:function(d){
alert('網路連線過慢,網頁請重新整理');
},
success:function(d){
if(d.Status == 'RET_SUCCESS')
{
alert(_jsLang.刪除成功);
updatePage();
}
else
{
alert(_jsLang.資料庫忙線中);
}
}
});
setTimeout(function () {
$('.emptyCartPrompt').fadeOut()
}, 5000)
});
//修改數量
$("#Main_Content").on('click','.Prod_Plus',function(){
var Amount = parseInt($(this).prev(".Prod_Amount").val())+1,
Stock = parseInt($(this).prev(".Prod_Amount").attr("max"));
$(this).prop("disabled", true)
if(Amount > 100)
{
$(this).prop("disabled", false)
return false;
}
$(this).prev(".Prod_Amount").val(Amount).change();
});
$("#Main_Content").on('click','.Prod_Minus',function(){
var Amount = parseInt($(this).next(".Prod_Amount").val())-1;
$(this).prop("disabled", true)
if(Amount < 1)
{
$(this).prop("disabled", false)
return false;
}
$(this).next(".Prod_Amount").val(Amount).change();
});
$("#Main_Content").on('change','.Prod_Amount',function(){
var ID = $(this).data("sid"),
Amount = $(this).val(),
Input = $(this),
limit = $(this).attr("max"),
origin = $(this).data("origin");
if(parseInt(Amount) >= parseInt(limit))
{
var msg = _jsLang?.只能再挑選X件商品 || '只能再挑選%s件商品';
$(this).val(origin);
alert(msg.replace("%s", (limit - origin)));
return false;
}
if(Amount > 100)
{
Amount = 100;
}
if(Amount < 1)
{
Amount = 1;
}
$.ajax({
url:Project_Country+"quickshop/ajax/ajax_change_cart.php",
type:"POST",
cache:false,
data:{ID:ID,Amount:Amount,Page_Shop_ID:$("#Page_Shop_ID").val()},
error:function(d){
alert('網路連線過慢,網頁請重新整理');
},
success:function(d){
var d = d.trim();
updatePage();
switch(d){
case "RET_SUCCESS":
break;
case "RET_NO_MEMBER_NO":
alert(_jsLang.欲購買紅利兌換商品請先登入會員並完成會員認證);
break;
case "RET_RBONUS_OUT":
alert(_jsLang.紅利不足);
break;
case "RET_ERROR":
alert(_jsLang.資料庫忙線中);
break;
case "RET_PROD_ERROR":
alert(_jsLang商品已下架);
break;
case "RET_NO_PROD":
alert(_jsLang.請選擇商品);
break;
case "RET_STOCK_ERROR":
alert(_jsLang.商品庫存不足);
break;
case "RET_LIMIT_ERROR":
alert(_jsLang.數量超過限購量);
break;
case "RET_OVER_SIT_MAX":
alert(_jsLang.數量超過定期購限購量);
break;
default:
alert(_jsLang.資料庫忙線中);
break;
};
}
});
});
//活動字串
$("#Main_Content").on('click','#Act_Str_Button',function(){
var str = $("#Act_Str_Input").val();
if(str)
{
updatePage('&Act_Str='+str);
}
});
$("#Main_Content").on('click','#Act_Str_Cancel',function(){
updatePage('&Act_Str=Cancel_Act_Str');
});
//退貨保留款
$("#Main_Content").on('click','#MemberMoney_Use',function(){
var str = $("#MemberMoney_Input").val();
if(str)
{
updatePage('&MemberMoney='+str);
}
});
$("#Main_Content").on('click','#MemberMoney_Cancel',function(){
updatePage('&MemberMoney=MemberMoney_Cancel');
});
$("#Main_Content").on('click','#MemberMoney_Unuse',function(){
updatePage('&MemberMoney=MemberMoney_Cancel');
});
$("#Main_Content").on('click', "#Same_Button", function () {
let sameValue = $("#Same_Button").val() ?? 1;
var $data = '&same=' + sameValue;
updatePage($data);
});
//切換手機國碼
$("#Main_Content").on('change','#Country_Tel_Code',function(){
updatePage('&Country_Tel_Code='+$(this).val());
});
//切換配送國家
$("#Main_Content").on('change','#Buy_Country',function(){
updatePage('&Buy_Country='+$(this).val());
});
//切換配送城市
$("#Main_Content").on('change','#Buy_City_ID',function(){
updatePage('&Buy_City='+$(this).val());
});
//切換配送地區
$("#Main_Content").on('change','#Buy_Area_ID',function(){
updatePage('&Buy_Area='+$(this).val());
});
$("#Main_Content").on('change','#Send_Country',function(){
updatePage('&Country='+$(this).val());
});
//切換配送方式
$("#Main_Content").on('click','input[name="Ship_Type"]',function(){
updatePage('&Ship_Type='+$(this).val());
});
//門市取貨
$("#Main_Content").on("change","#Store_Pick",function(){
updatePage('&CVSStoreID='+$(this).val());
});
//切換付款方式
$("#Main_Content").on('click','input[name="Pay_Type"]',function(){
updatePage('&Pay_Type='+$(this).val());
});
//切換配送城市
$("#Main_Content").on('change','#Send_City',function(){
updatePage('&City='+$(this).val());
});
//切換配送地區
$("#Main_Content").on('change','#Send_Area',function(){
updatePage('&Area='+$(this).val());
});
//選擇門市
$("#Main_Content").on("click","#Choose_Store", function(){
var $type = $(this).attr("type"),
$coll = $(this).attr("coll");
updatePage('&save=1');
setTimeout(function(){
window.location.href = '/shopcart/e_returns/emap-p.php?url='+$("#Page_Shop_Url").val()+'&type='+$type+'&coll='+$coll+'&shop_id='+$("#Page_Shop_ID").val();
},500);
});
//送出訂單
$("#Main_Content").on('click','#Form_Submit',function(){
var gift = $("#Act13_Num").val() - $("#ChooseGift").val();
if($("#CanGift").val() == 1 && (gift > 0 || gift < 0)){
if(gift > 0) {
alert(_jsLang.尚可挑選+gift+_jsLang.件贈品請挑選後再送出購物車);
} else {
alert(_jsLang.贈品+_jsLang.數量超過限購量);
}
}
// else if($("#CanAdd").val() == 1 && $("#ChooseAdd").val() == 0) {
// alert(_jsLang.至少加購一件加購品);
// }
else{
$("#Main_Form").submit();
}
});
//姓名、電話、Email、地址、備註
$("#Main_Content").on('change','#Send_Name,#Send_Cellphone,#Email,#Send_Address,#Send_Memo',function(){
updatePage('&save=1');
});
//自動加入會員、收貨時間
$("#Main_Content").on('click',"#Auto_Add,input[name='Send_Time']",function(){
updatePage('&save=1');
});
//常用收件資料
$("#Main_Content").on('click', ".Send_Book", function () {
var $data = '&send_book=' + $(this).attr("sid");
$("[data-index='AddressControl']").addClass("hide")
updatePage($data);
});
//切換載具類型
$("#Main_Content").on('change',"#CarrierType",function(){
updatePage();
});
//切換發票類型
$("#Main_Content").on('click',"input[name='Invo_Mod']",function(){
updatePage();
});
//同收件地址
$("#Main_Content").on('click','#Invo_Same_Button',function(){
if($(this).prop("checked"))
{
var same = '1';
$("#Invo_Address_Box").hide();
$("#Invo_Address").attr("fun","");
}
else
{
var same = '2';
$("#Invo_Address_Box").show();
$("#Invo_Address").attr("fun","checkNull");
}
updatePage('&Invo_Same='+same+'&save=1');
$("input[name='Invo_Same']").val(same);
});
$("#Main_Content").on('change','#Invo_Same_Email',function(){
if($(this).prop("checked"))
{
$("#Invo_Email").val($("#Buy_Email").val())
}else{
$("#Invo_Email").val("")
}
});
$("#Main_Content").on('click','.title-big',function(){
var num = $(this).parent('section').attr("num");
if(num > '0')
{
$(this).parent('section').toggleClass("open",500);
}
else
{
$(".emptyCartPrompt").css("display","block");
setTimeout(function () {
$('.emptyCartPrompt').fadeOut()
}, 5000)
}
});
$("#Main_Content").on('click','.shopcart-link',function(){
$('section').addClass("open",500);
});
$('body').on('click','.arrow .title-big', function(event) {
// console.log($('.is-nowStep'));
if(!$(this).is('.open')){
$('.arrow').not(this).removeClass('open');
$(this).parent('.arrow').addClass('open');
updatePage('&Step='+$(this).parent('section').attr("id").substr(1,1)+'&save=1');
}
});
// 按下我要結帳後出現底部浮動
$("#Main_Content").on('click', '#step2', function() {
$('.moneyPrompt').css('display', 'block').hide().fadeIn()
});
//切換定期購期數
$("#Main_Content").on('change',"#SIT_Installment",function(){
updatePage();
});
//切換定期購期數
$("#Main_Content").on('change',"#Sit_Frequency, #Sit_Period",function(){
updatePage();
});
//切換發票資料
$("#Main_Content").on('change',"input[name='Invo_Mod2']",function(){
updatePage('&Invo_Mod='+$(this).val());
});
$("#Main_Content").on('change',"input[name='Invo_Type']",function(){
updatePage('&Invo_Type='+$(this).val());
});
//切換發票地址
$("#Main_Content").on('change',"select[name='Invo_Country'],select[name='Invo_City'],select[name='Invo_Area']",function(){
updatePage();
});
//結帳登入 手機驗證碼
function timeout(btn, verifyFlag = true) {
let sec = btn.attr('countdown');
let t
sec = sec - 1;
let count_min = 0;
let count_sec = 0;
count_min = Math.floor(sec / 60);
count_sec = (Array(2).join('0') + (sec % 60)).slice(-2);
if (sec != '0') {
if(!verifyFlag){
btn.text(`剩餘(${count_min}:${count_sec})`)
}else{
btn.text(`送出驗證(${count_min}:${count_sec})`)
}
btn.attr('countdown', sec);
t = setTimeout(function () {
timeout(btn, verifyFlag)
}, 1000);
} else {
clearTimeout(t);
btn.removeClass("js-verify-submit")
if(!verifyFlag){
btn.prop("disabled", false)
btn.removeClass("btn-muted")
btn.addClass("btn-primary")
}
btn.text("重發驗證信");
btn.attr('countdown', '0');
}
}
function smsRemaining(){
let remaining = parseInt($("#SMS_Remaining").val())
let btn = $("#VerifyCode_Button")
let isMember = btn.data("is-member")
//有倒數中的簡訊驗證
if(remaining && remaining > 0){
$(".cellphone-verify-show").removeClass("hide")
if(isMember == 1)
{
btn.attr("countdown", remaining)
btn.addClass("js-verify-submit").html(`送出驗證(${String(Math.floor(remaining / 60)).padStart(2,'0')}:${String(Math.floor(remaining % 60)).padStart(2,'0')})`);
timeout(btn)
}
else
{
btn.prop("disabled", true)
btn.removeClass("btn-primary")
btn.addClass("btn-muted")
btn.attr("countdown", remaining)
btn.html(`${String(Math.floor(remaining / 60)).padStart(2,'0')}:${String(Math.floor(remaining % 60)).padStart(2,'0')}`);
timeout(btn, false)
}
}
}
smsRemaining()
$("#Main_Content").on('click','#VerifyCode_Button',function(e){
var Button = $(this);
var Email = $('#Buy_Email').val();
var Buy_Cellphone = $('#Buy_Cellphone').val();
let cellbox = $('#Buy_Cellphone').parents(".table-content")
var Password = $('#Login_Password').val();
var Country_Tel_Code = $('#Buy_Country_Tel_Code').val();
var Country_ID = $('#Buy_Country_Tel_Code option:selected').data('country-id');
var isMember = Button.data("is-member");
if(!Button.hasClass("js-verify-submit")){
//送出驗證信
// if(Email == ""){alert('請輸入訂購人的E-mail');return false;}
if(Buy_Cellphone == ""){alert('請輸入訂購人的行動電話');return false;}
if(cellbox.find(".forms_show").attr("error") == "true"){
alert('行動電話格式錯誤');
return false;
}
// if(Password == ""){alert('請輸入密碼');return false;}
// if(Country_Tel_Code == ""){alert("請輸入國碼");return false;}
$(".common-loading").removeClass("hide")
$.ajax({
url: Project_Country + "shopcart/ajax/ajax_verifycode.php",
type:"POST",
cache:false,
data:{Email:Email,CellPhone:Buy_Cellphone,Password:Password,Country_Tel_Code:Country_Tel_Code,Country_ID:Country_ID},
success:function(h){
$(".common-loading").addClass("hide")
if(h=="ERROR1"){
alert(Email +' - 此E-Mail已是網站會員,請直接登入。\n若忘記密碼,請按"忘記密碼?"進行索取。');
$(".login-popup").removeClass("hide")
//window.location.href = '/' + $("#Website_Mall_ID").val() + '/member-login';
}
else if(h=="ERROR2"){
alert(Buy_Cellphone +' - 此手機號碼已是網站會員,請直接登入。\n若忘記密碼,請按"忘記密碼?"進行索取。');
$(".login-popup").removeClass("hide")
//window.location.href = '/' + $("#Website_Mall_ID").val() + '/member-login';
}
else if(h=='OK'){
$('#VerifyCode_Tag').hide();
$('#VerifyCode').attr("fun","");
alert('您已是網站會員,請直接登入。');
$(".login-popup").removeClass("hide")
//window.location.href = '/' + $("#Website_Mall_ID").val() + '/member-login';
}
else if(h == 'RET_REPLY'){
alert('請勿重覆發送簡訊, 請等侯10分鐘');
smsRemaining()
}
else if(h == 'RET_OVER'){
alert('手機簡訊發送已上限');
}
else if(h == 'RET_CELLPHONE_REPLY'){
alert('您已經是會員,請登入會員,如忘記登入密碼,可至會員登入處點選「忘記密碼?」');
$(".login-popup").removeClass("hide")
//window.location.href = '/' + $("#Website_Mall_ID").val() + '/member-login';
}
else if(h == 'RET_OK')
{
$(".cellphone-verify-show").removeClass("hide")
if(isMember == 1)
{
Button.attr("countdown", 600)
Button.addClass("js-verify-submit").html('送出驗證(10:00)');
timeout(Button)
alert('認證簡訊已發送,請在有效時間內送出驗證');
}
else
{
Button.prop("disabled", true)
Button.removeClass("btn-primary")
Button.addClass("btn-muted")
Button.attr("countdown", 600)
Button.html('10:00');
timeout(Button, false)
alert('認證簡訊已發送,請在有效時間內結帳');
}
}
else if(h == 'RET_ERROR_CRM'){
alert(_jsLang.會員中心呼叫異常);
}
},
error: function(){
$(".common-loading").addClass("hide")
}
});
}else{
//驗證驗證碼
$.ajax({
url: Project_Country + "shopcart/ajax/ajax_verifycode_verify.php",
type:"POST",
cache:false,
dataType:"JSON",
data:{
cellphone: $('#Buy_Cellphone').val(),
countryId: $('#Buy_Country_Tel_Code option:selected').data('country-id'),
code: $("#SMSCode").val()
},
success: function(res){
if(res.status == "ok"){
updatePage();
}
alert(res.msg);
},
error: function(){
alert('驗證失敗');
}
})
}
});
function updatePage(data) {
//取得一般配送資料
var send = '';
var data = data || '';
//寄送資料
let radios = new Set()
$("#Main_Form").find("input, select, textarea").each(function(){
let form = $("#Main_Form")
let _this = $(this)
let name = _this.attr("name")
let type = _this.attr("type")
if(!name){
return
}
if(type === "radio"){
// if(radios.has(name)){
// return
// }
// radios.add(name)
// let val = form.find(`input[name="${name}"]:checked`).val()
// if(val !== undefined){
// send += `&${name}=${encodeURIComponent(_this.val())}`
// }
}else if(type === 'checkbox'){
if(_this.is(":checked")){
send += `&${name}=${encodeURIComponent(_this.val())}`
}
}else{
send += `&${name}=${encodeURIComponent(_this.val())}`
}
})
// $("#Send_Name,#Send_Cellphone,#Email,#Send_Address,input[name='Send_Time']:checked,#Send_Memo,#Del_Type,#Auto_Add:checked,#SIT_Installment,#Sit_Frequency").each(function(){
// send += '&'+$(this).attr("name")+'='+$(this).val();
// });
// //發票資料
// $("input[name='Invo_Mod']:checked,#CarrierType,#CarrierId1,#CarrierId2,#NPOBAN,#Invo_Title,#Invo_No,#Invo_Address").each(function(){
// send += '&'+$(this).attr("name")+'='+$(this).val();
// });
var $data = 'type=update'+data+send+'&Page_Shop_ID='+$("#Page_Shop_ID").val();
keepTop()
$(".common-loading").removeClass("hide")
$.ajax({
url:Project_Country+"quickshop/ajax/ajax_get_cart.php",
type:"POST",
async: true,
data:$data,
cache:false,
error:function(d,e,f){
$(".common-loading").addClass("hide")
alert('網路連線過慢,網頁請重新整理');
},
success:function(d){
$(".common-loading").addClass("hide")
if(d)
{
$("#Ajax_Box").html(d);
smsRemaining()
//活動字串訊息
if($("#Coupon_Msg").val()){
alert($("#Coupon_Msg").val());
}
$("#Main_Form").fromsAuth();
//加購按鈕
var add = parseInt($("#CanAdd").val());
if(add > 0)
{
$(".Add_Button").removeClass('button-cant btn-muted');
$(".Add_Button").addClass('add_to_cart btn-primary');
$(".Add_Button").html('');
}
else
{
$(".Add_Button").addClass('button-cant btn-muted');
$(".Add_Button").removeClass('add_to_cart btn-primary');
$(".Add_Button").html('');
}
//滿額按鈕
var gift = parseInt($("#CanGift").val());
if(gift > 0)
{
$(".Gift_Button").removeClass('button-cant btn-muted');
$(".Gift_Button").addClass('add_to_cart btn-primary');
$(".Gift_Button").html('');
}
else
{
$(".Gift_Button").addClass('button-cant btn-muted');
$(".Gift_Button").removeClass('add_to_cart btn-primary');
$(".Gift_Button").html('');
}
var amount = parseInt($("#ChooseGift").val());
$("#Gift_Amount").html(amount);
if($("#CartTotal").length && $("#CartTotal").val() !== undefined){
$(".cart-total").text($("#CartTotal").val())
}
toTop()
}
}
})
}
//商品彈窗內商品說明頁簽
;(function($) {
$(document).on('click', '.detail-tag', function(){
let _this = $(this),
target = _this.data('target')
if(!_this.hasClass('in-active')){
$('.detail-tag').removeClass('in-active')
_this.addClass('in-active')
$('.detail-content').removeClass('in-active')
$('.detail-content[data-index=' + target + ']').addClass('in-active')
}
})
})($)
// 密碼顯示切換
;(function($) {
$(document).on('click', '.password-toggle', function(e) {
e.preventDefault()
const target = $(this).parents('.password-group').find('.password')
const targetType = target.attr('type')
$(this).find('.icon').toggleClass('icon-eye').toggleClass('icon-eye-slash')
if(targetType === 'password') {
target.attr('type', 'text')
} else if(targetType === 'text') {
target.attr('type', 'password')
}
})
})($)
// ==========================================================
// 開關上方商品介紹
// ==========================================================
;(function($) {
$(document).on('click', '.detail-title', function(e) {
let _this = $(this)
let box = _this.parents(".detail-wrap")
box.toggleClass("in-open")
})
})($)
// ==========================================================
// 展開活動
// ==========================================================
;(function($) {
$(document).on('click', '.sale-view-more', function(e) {
let _this = $(this)
let box = _this.parents(".detail-collapse-box").find(".sale-list")
box.toggleClass("in-open")
})
})($)
// ==========================================================
// 跳窗內說明切換
// ==========================================================
;(function($) {
$(document).on('click', '.detail-tag', function(e) {
let _this = $(this)
let target = _this.data("target")
$(".detail-wrapper .detail-tag").removeClass("in-active")
_this.addClass("in-active")
$(".detail-wrapper .detail-content").removeClass("in-active")
$(".detail-wrapper .detail-content[data-index='" + target + "']").addClass("in-active")
$(".detail-wrapper .detail-content[data-index='" + target + "']")[0].scrollIntoView({
behavior: 'smooth',
block:'start'
})
})
})($)
// window trigger
;(function($) {
$(window).trigger('resize, scroll')
})($)