$(function(){
//=======================================
// step1 start
//=======================================
$(document).on("click", ".login-step1 .login-step1-btn-main", function(){
//Login_Email 應該要用Login_Cellhone_Number之類的比較正確 由於怕功能異常造成混亂故保持id跟name一致性所以沒換 如果後端確認 換掉沒問題可以直接換掉
let Country_ID = $("#Country_ID").val(); //+886會變成886
let Login_Email = $("#Login_Email").val();
let SubmitCheck = $("#SubmitCheck").val();
if(Login_Email)
{
//傳送ajax請求 需要驗證驗證碼 錯誤時跟原本一樣跳窗警告
$.ajax({
url:"/member/ajax/ajax_new_login-p.php",
type:"POST",
data:{Country_ID:Country_ID,Login_Email:Login_Email,SubmitCheck:SubmitCheck},
dataType:"json",
success:function(d){
if(d.status == 'ok')
{
/*
step1為驗證手機 step2為有此帳號輸入密碼 step3為無帳號輸入手機驗證碼註冊和設定密碼
此處回傳只有2或3 若有需要能回傳1(要解除下方註解) 回傳1會重新整理
*/
if(d.msg)
{
alert(d.msg);
}
if(d.step == 2)
{
$(".login-step2-title").html(
_jsLang.您的手機號碼 +
`
+${Country_ID} ${Login_Email}
`
)
$(".login-wrapper").removeClass("login-step1").addClass("login-step2");
}
else if(d.step == 3 || d.step == 5)
{
$(".login-step3-title").html(
_jsLang.您的手機號碼 +
`
+${Country_ID} ${Login_Email}
`
)
$(".login-wrapper").removeClass("login-step1").addClass("login-step3");
if(d.step == 5)
{
$("#Step3_Passwrod_Title").html(_jsLang.密碼);
$(".login-step3-btn-main").html(_jsLang.登入);
$("#Send_Password_For_Step3").show();
}
if(d.step == 3)
{
$("#Step3_Passwrod_Title").html(_jsLang.設定您的登入密碼);
}
}
else if(d.step == 4)
{
$(".login-step4-title").html(
_jsLang.您的手機號碼 +
`
+${Country_ID} ${Login_Email}
`
)
$(".login-wrapper").removeClass("login-step1").addClass("login-step4");
}
else if(d.step == 1)
{
location.reload();
}
}
else
{
alert(d.msg);
}
}
});
}
else
{
$("#Login_Email").next(".forms_show").text($("#Login_Email").attr("nullstr"));
}
})
//=======================================
// step1 end
//=======================================
//=======================================
// step2 start
//=======================================
//普通登入
$(document).on("click", ".login-step2-btn-main", function(){
let Country_ID = $("#Country_ID").val() //+886會變成886
let Login_Email = $("#Login_Email").val()
let SubmitCheck = $("#SubmitCheck").val() //圖形驗證碼 第一步有驗證的話這裡可能不需要 測試時為了保持登入功能才留著的
let Login_Password = $("#Login_Password").val()
let data = {
"Country_ID": Country_ID,
"Login_Email": Login_Email,
"SubmitCheck": SubmitCheck,
"Login_Password": Login_Password
}
$.ajax({
url: "/member/member_login-p.php",
type: "POST",
data: data,
dataType:"json",
}).done(function(ret){
if(ret.msg){
alert(ret.msg);
};
if(ret.fun)eval(ret.fun);
})
})
$(document).on("click", ".login-step2-forgetpwd-link", function(){
var _this = $(this);
if($("#Country_ID").val() == ''){
alert(_jsLang.請選擇國別);
return false;
};
if($("#Login_Email").val() == ''){
alert(_jsLang.請輸入行動電話);
return false;
};
if(_this.attr('count') !='0'){
return false;
}
$.ajax({
url:"/member/ajax/ajax_send_password-p.php",
type:"POST",
data:{Country: $("#Country_ID").val(), Cellphone: $("#Login_Email").val()},
dataType:"json",
success:function(d)
{
$("#Country").attr('disabled', true);
$("#Cellphone").attr('readonly', true);
alert(d.msg);
_this.attr('count','600');
timeout_pwd(_this);
}
});
});
//=======================================
// step2 end
//=======================================
//=======================================
// step3 start
//=======================================
//普通註冊
//改不少 目前資料格式照原本member_add手機註冊時的
$(document).on("click", ".login-step3-btn-main", function(){
let Country_ID = $("#Country_ID").val() //+886會變成886
let Cellphone = $("#Login_Email").val() //手機註冊 但id都是共用step1時輸入的
let Code = $("#Code").val() //簡訊驗證碼
let Login_Password = $("#Register_Password").val() // 原本登入註冊不同頁 現在同一頁所以id不同 後端確定沒問題可以改掉
let SubmitCheck = $("#SubmitCheck").val() //圖形驗證碼 第一步有驗證的話這裡應該不需要
let Account_Type = 1 //不知道這是什麼
let agree = 1 //同意條款 因為對面沒給設計稿所以我也不知道有沒有
let step = $(".login-step3-cellphone").attr('step');
if(step == 5)
{
let data = {
"Country_ID": Country_ID,
"Login_Email": Cellphone,
"Code" : Code,
"SubmitCheck": SubmitCheck,
"Login_Password": Login_Password
}
$.ajax({
url: "/member/member_login-p.php",
type: "POST",
data: data,
dataType:"json",
}).done(function(ret){
if(ret.msg){
alert(ret.msg);
};
if(ret.fun)eval(ret.fun);
})
}
else
{
let data = {
"Country_ID": Country_ID,
"Cellphone": Cellphone,
"Code" : Code,
"Login_Password": Login_Password,
"SubmitCheck": SubmitCheck,
}
$.ajax({
url: "/member/member_add-p.php",
type: "POST",
data: data,
dataType:"json"
}).done(function(ret){
if(ret.msg){
alert(ret.msg);
};
if(ret.fun)eval(ret.fun);
})
}
})
//=======================================
// step4 start
//=======================================
//社群榜定
$(document).on("click", ".login-step4-btn-main", function(){
let Country_ID = $("#Country_ID").val() //+886會變成886
let Login_Email = $("#Login_Email").val()
let SubmitCheck = $("#SubmitCheck").val() //圖形驗證碼 第一步有驗證的話這裡可能不需要 測試時為了保持登入功能才留著的
let Code = $("#Code_For_Login").val() //簡訊驗證碼
let data = {
"Country_ID": Country_ID,
"Login_Email": Login_Email,
"Code" : Code,
"SubmitCheck": SubmitCheck,
}
$.ajax({
url: "/member/member_login-p.php",
type: "POST",
data: data,
dataType:"json",
}).done(function(ret){
if(ret.msg){
alert(ret.msg);
};
if(ret.fun)eval(ret.fun);
})
})
//=======================================
// step4 end
//=======================================
//發送簡訊驗證碼
$(".send_sms_bt").click(function()
{
var _this = $(this);
if($("#Country_ID").val() == ''){
alert(_jsLang.請選擇國別);
return false;
};
if($("#Login_Email").val() == ''){
alert(_jsLang.請輸入行動電話);
return false;
};
if(_this.attr('count') !='0'){
return false;
}
var step = $(".login-step3-cellphone").attr('step');
$.post('/member/ajax/ajax_send_sms_code-p.php', {Country: $("#Country_ID").val(), Cellphone: $("#Login_Email").val(),step:step}, function(h){
if(h == 'OK'){
$("#Country").attr('disabled', true);
$("#Cellphone").attr('readonly', true);
alert(_jsLang.簡訊已經發送至您的手機了);
// _this.hide();
_this.attr('count','600');
timeout(_this);
}
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.手機格式錯誤);
}
}, 'html');
});
//=======================================
// step3 end
//=======================================
//顯示密碼
var pwdShow = false
$(document).on("click", ".login-viewpwd", function(){
if(pwdShow){
$(this).html(_jsLang.顯示)
$(this).siblings(".login-input").prop("type","password")
pwdShow = false
}else{
$(this).html(_jsLang.隱藏)
$(this).siblings(".login-input").prop("type","text")
pwdShow = true
}
})
})
function timeout(_this){
var sec = _this.attr('count');
var t
sec = sec - 1 ;
var count_min = 0;
var count_sec = 0;
count_min = Math.floor(sec/60);
count_sec = (Array(2).join('0')+(sec%60)).slice(-2);
if( sec != '0'){
_this.text(_jsLang.重新發送簡訊+' ('+count_min+':'+count_sec+')');
_this.attr('count',sec);
t = setTimeout(function(){
timeout(_this);
},1000);
}else{
_this.text(_jsLang.發送簡訊認證碼);
_this.attr('count','0');
clearTimeout(t);
}
}
function timeout_pwd(_this){
var sec = _this.attr('count');
var t
sec = sec - 1 ;
var count_min = 0;
var count_sec = 0;
count_min = Math.floor(sec/60);
count_sec = (Array(2).join('0')+(sec%60)).slice(-2);
if( sec != '0'){
_this.text(_jsLang.重新發送簡訊+' ('+count_min+':'+count_sec+')');
_this.attr('count',sec);
t = setTimeout(function(){
timeout_pwd(_this);
},1000);
}else{
_this.text(_jsLang.忘記密碼);
_this.attr('count','0');
clearTimeout(t);
}
}