$(function(){ $('#agree_check').click(function(){ $('#agree').val(''); if($(this).prop("checked")){ $('#agree').val('1'); } }); }); $(document).ready(function(){ //實作發送認證碼 function sendSMSCode($obj){ var url = $obj.attr('data-url'); var datas = "&Country_ID="+$("#Country_ID").val()+"&Cellphone="+$("#Cellphone").val(); var step = $obj.attr('data-step'); $.post('/member/ajax/ajax_send_sms_code-p.php', {Country_ID: $("#Country_ID").val(), Cellphone: $("#Cellphone").val()}, function(h){ if(h == 'OK'){ $.ajax({ url:url, type:"POST", data: datas, cache:false, error:function(error){ alert('網路連線過慢,網頁請重新整理'); }, success:function(html){ $("#member-registered-box").html(html); if(step == 'step2'){ var date = new Date(); time = 600; //預設10分倒數 setInterval(function(){ if(time == 0){ return false; } time -=1; var str = '', new_min = Math.floor(time/60), new_sec = time%60; if(new_min < 0){ str += '00:'; }else if(new_min < 10){ str += '0'+(new_min) + ':'; }else{ str += (new_min) + ':'; } if(new_sec < 0){ str += '00'; }else if(new_sec < 10){ str += '0'+(new_sec); }else{ str += (new_sec); } $("#member-registered-sms-time").html(str); },1000); } } }); } else if(h == 'RET_REPLY'){ alert(_jsLang.請勿重覆發送簡訊請等侯5分鐘); } else if(h == 'RET_OVER'){ alert(_jsLang.手機簡訊發送已上限); } else if(h == 'RET_CELLPHONE_REPLY'){ alert(_jsLang.此手機已經被認證綁定了); } else if(h == 'RET_ERROR_DATABASE'){ alert(_jsLang.資料庫忙線中); } else if(h == 'WRONG_CELLPHONE_FORMAT'){ alert(_jsLang.手機格式錯誤); } else if(h == 'RET_ERROR_CRM'){ alert(_jsLang.會員中心呼叫異常); } }, 'html'); } //檢查認證碼 function checkSMSCode($obj){ var url = $obj.attr('data-url'); var datas = "&Country_ID="+$("#Country_ID").val()+"&Cellphone="+$("#Cellphone").val()+"&Code="+$("#Code").val(); $.post('/member/ajax/ajax_check_sms_code-p.php', {Code: $("#Code").val(), Cellphone: $("#Cellphone").val()}, function(h){ if(h == 'OK'){ $.ajax({ url:url, type:"POST", data: datas, cache:false, error:function(error){ alert('網路連線過慢,網頁請重ddddd新整理'); }, success:function(html){ $("#member-registered-box").html(html); } }); } else if(h == 'ERROR'){ alert($obj.attr('error1')); } else if(h == 'TIMEOUT'){ alert($obj.attr('error2')); } }, 'html'); } //下一步 $(".sign-page").on('click', '#member-registered-submit', function(){ var tel_code = $("#Country_ID").find("option:selected").attr('tel-code'); if(tel_code == '886'){ var ret = check_tools.checkTaiwanCell($("#Cellphone")); } else{ var ret = check_tools.checkNumNull($("#Cellphone")); } if(ret == 'NULL'){ $(".forms_show[for='"+$("#Cellphone").attr('id')+"']").html($("#Cellphone").attr('nullstr')); return false; } else if(ret == 'ERROR'){ $(".forms_show[for='"+$("#Cellphone").attr('id')+"']").html($("#Cellphone").attr('errorstr')); return false; } if($(this).attr('data-step') == 'step2'){ sendSMSCode($(this)); } else if($(this).attr('data-step') == 'step3'){ checkSMSCode($(this)); } }); //重發驗證碼 $(".sign-page").on('click', '#member-registered-sms-replay', function(){ // if($("#member-registered-sms-time").text() == '00:00'){ sendSMSCode($(this)); //} }); //改Email註冊 $(".sign-page").on('click', '#member-registered-email ', function(){ var url = $(this).attr('data-url'); var datas = "Email_Reg=On&Country_ID="+$("#Country_ID").val()+"&Cellphone="+$("#Cellphone").val(); $.ajax({ url:url, type:"POST", data: datas, cache:false, error:function(error){ alert('網路連線過慢,網aaaaa頁請重新整理'); }, success:function(html){ $("#member-registered-box").html(html); } }); }); //寶寶卡片新增 $(document).on("click", ".bady-add-btn", function(){ let _this = $(this) let index = _this.data('index') $.ajax({ url:"/member/ajax/ajax_baby_card.php", type:"POST", data: { index: index }, cache:false, error:function(error){ alert('網路連線過慢,網頁請重新整理'); }, success:function(res){ _this.data("index",parseInt(_this.data('index')) + 1) //console.log(_this.data('index')) $("#babyCardList").append(res); $("#noBaby").prop("checked", false) } }); }) //寶寶卡片刪除 $(document).on("click", ".card-closer", function(){ let _this = $(this) let card = _this.parents(".baby-card") if(confirm("確認刪除寶貝資料?")){ card.remove(); } }) //孕期狀態切換 $(document).on("change", ".baby-status-radio", function(){ let _this = $(this) let card = _this.parents(".baby-card") if(_this.data("show") == "card-type1"){ card.find(".card-type1").addClass("in-active") card.find(".card-type1 input[data-fun]").each(function(){ $(this).attr("fun", $(this).data("fun")) }) card.find(".card-type2").removeClass("in-active") card.find(".card-type2 input[data-fun]").attr("fun", "") }else{ card.find(".card-type2").addClass("in-active") card.find(".card-type2 input[data-fun]").each(function(){ $(this).attr("fun", $(this).data("fun")) }) card.find(".card-type1").removeClass("in-active") card.find(".card-type1 input[data-fun]").attr("fun", "") } }) //勾選沒有小朋友清空現有卡片 $(document).on("click", ".no-baby-btn", function(e){ e.preventDefault() let checkbox = $("#noBaby") let cardlist = $("#babyCardList") if(!checkbox.prop("checked")){ if(cardlist.find(".baby-card").length > 0){ //有已添加的寶寶資料 if(confirm("將會刪除已添加的寶貝資料,確定要刪除嗎?")){ $("#babyCardList").empty() checkbox.prop("checked", true) } }else{ checkbox.prop("checked", true) } }else{ checkbox.prop("checked", false) } }) });