$(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(_jsLang.網路連線過慢網頁請重新整理); }, 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.請勿重覆發送簡訊請等候10分鐘); } 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(_jsLang.網路連線過慢網頁請重新整理); }, 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 if(tel_code == '60'){ var ret = check_tools.checkMyCell($("#Cellphone")); }else{ var ret = check_tools.checkNumNull($("#Cellphone")); } if(ret == 'NULL'){ $(".forms_show[for='"+$("#Cellphone").attr('id')+"']").data("error-str",$("#Cellphone").attr('nullstr')).text(_jsLang.請輸入此欄位); return false; } else if(ret == 'ERROR'){ $(".forms_show[for='"+$("#Cellphone").attr('id')+"']").data("error-str",$("#Cellphone").attr('errorstr')).text(_jsLang.資料格式錯誤); 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(_jsLang.網路連線過慢網頁請重新整理); }, success:function(html){ $("#member-registered-box").html(html); } }); }); });