var language = 0; var time = 60; var time2 = 60; var ifSend = true; var ifSend2 = true; var way = 0; var mobile1 = ""; var mobile2 = ""; var pin1 = ""; var pin2 = ""; var loginTo = sessionStorage.getItem("miaomuLoginTo"); sessionStorage.removeItem("miaomuLoginTo"); $(function () { var session = sessionStorage.getItem("MiaoMuAction"); if(session=="forget"){ sessionStorage.removeItem("MiaoMuAction"); setTimeout(function(){ forget1(); }, 100); } $(".Send a").click(function () { checkMobile1(); }); $("#change2").click(function () { if(way == 0){ $(".Send").show(); if(language==0){ $(this).html("输入密ç 登录"); $("#password").attr("placeholder", "请输入验è¯ç "); }else if(language==1){ $(this).html("輸入密碼登入"); $("#password").attr("placeholder", "請輸入驗è‰ç¢¼"); }else { $(this).html("By password"); $("#password").attr("placeholder", "Input PIN"); } $(".login")[0].reset(); $("#password").css("background-image","url(../images/验è¯.png)"); $("#password").attr("maxlength","6"); $("#password").attr("type","text"); way = 1; }else{ $(".Send").hide(); if(language==0){ $(this).html("手机çŸä¿¡ç™»å½•"); $("#password").attr("placeholder", "请输入密ç "); }else if(language==1){ $(this).html("手機çŸä¿¡ç™»å…¥"); $("#password").attr("placeholder", "請輸入密碼"); }else { $(this).html("By SMS"); $("#password").attr("placeholder", "Input password"); } $("#password").val(""); $("#password").css("background-image","url(../images/密ç .jpg)"); $("#password").attr("maxlength","16"); $("#password").attr("type","password"); way = 0; } }); $("#change3").click(function () { if(language==0){ forget1(); }else if(language==1){ forget2(); }else { forget3(); } }); $(".other-img img").click(function () { if (language == 0) { layer.msg('抱æ‰ï¼æ£åœ¨å¼€å‘ä¸ï¼Œæ•¬è¯·æœŸå¾…ï¼', { icon: 4 }); } else if (language == 1) { layer.msg('抱æ‰ï¼æ£åœ¨é–‹ç™¼ä¸ï¼Œæ•¬è«‹æœŸå¾…ï¼', { icon: 4 }); } else { layer.msg('Sorry! Developing now, coming soon!', { icon: 4 }); } }); $("#changeA").click(function () { if(way==0){ $("#password").attr("placeholder", "请输入密ç "); $("#change2").html("手机çŸä¿¡ç™»å½•"); }else{ $("#password").attr("placeholder", "请输入验è¯ç "); $("#change2").html("输入密ç 登录"); } $(".Send a").html("å‘é€éªŒè¯ç "); $("#change1").html("è´¦å·ç™»å½•"); $("#login").attr("value", "ç™» 录"); $("#change3").html("忘记密ç "); $("#change4").html("ç«‹å³æ³¨å†Œ"); $("#change5").html("å…¶ä»–æ–¹å¼ç™»å½•"); $("#change6").html("常è§é—®é¢˜"); $("#change7").html("éšç§æ”¿ç–"); $("#change6").css("width", "100px"); $("#change7").css("width", "100px"); $(".m3-2").css("width", "28%"); language = 0; }); $("#changeB").click(function () { if(way==0){ $("#password").attr("placeholder", "請輸入密碼"); $("#change2").html("手機çŸä¿¡ç™»å…¥"); }else{ $("#password").attr("placeholder", "請輸入驗è‰ç¢¼"); $("#change2").html("輸入密碼登入"); } $(".Send a").html("發é€é©—è‰ç¢¼"); $("#change1").html("賬號登入"); $("#login").attr("value", "ç™» å…¥"); $("#change3").html("忘記密碼"); $("#change4").html("ç«‹å³è¨»å†Š"); $("#change5").html("å…¶ä»–æ–¹å¼ç™»å…¥"); $("#change6").html("常見å•題"); $("#change7").html("éš±ç§æ”¿ç–"); $("#change6").css("width", "100px"); $("#change7").css("width", "100px"); $(".m3-2").css("width", "28%"); language = 1; }); $("#changeC").click(function () { if(way==0){ $("#password").attr("placeholder", "Input password"); $("#change2").html("By SMS"); }else{ $("#password").attr("placeholder", "Input PIN"); $("#change2").html("By password"); } $(".Send a").html("Send PIN"); $("#change1").html("Login"); $("#login").attr("value", "Login"); $("#change3").html("Forget PWD"); $("#change4").html("Register"); $("#change5").html("Other way"); $("#change6").html("Common problem"); $("#change7").html("Privacy policy"); $("#change6").css("width", "9%"); $("#change7").css("width", "8%"); $(".m3-2").css("width", "34%"); language = 2; }); $("#login").click(function () { if(way==1){ loginBySMS(); }else{ loginTest(); } }); }); function loginTest() { var username = $("#username").val(); var password = $("#password").val(); if (username == null || username == "" || password == null || password == "") { if (language == 0) { layer.msg('æ‰‹æœºå·æˆ–密ç ä¸èƒ½ä¸ºç©ºï¼', { icon: 2 }); } else if (language == 1) { layer.msg('手機號或密碼ä¸èƒ½ç‚ºç©ºï¼', { icon: 2 }); } else { layer.msg('Mobile or password cannot be empty', { icon: 2 }); } } else { var data = { "phone": username, "passWord": password ,"platform":'Web',"equipment":getBrowser()}; $.ajax({ url:url+"/user/loginUser", data: data, type: "post", dateType: "json", success: function (response, status, xhr) { if (response.length == 1) { if (language == 0) { layer.msg('登录æˆåŠŸï¼Œå³å°†è·³è½¬', { icon: 1 }); } else if (language == 1) { layer.msg('登入æˆåŠŸï¼Œå³å°‡è·³è½‰', { icon: 1 }); } else { layer.msg('Login succeeded, about to jump', { icon: 1 }); } localStorage.setItem("miaomu_pc_user_id", response[0].id); localStorage.setItem("miaomu_pc_login_time",new Date().getTime()); /*var userInfo = loadUserInfo(response[0].id);*/ getLast(response[0].id); setLast(response[0].id); setTimeout(function () { if(loginTo){ window.location.href = loginTo; }else{ window.location.href = "../manage/"; } }, 2000); } else { if (language == 0) { layer.msg('æ‰‹æœºå·æˆ–密ç 错误ï¼', { icon: 2 }); } else if (language == 1) { layer.msg('手機號或密碼錯誤ï¼', { icon: 2 }); } else { layer.msg('Wrong mobile or password', { icon: 2 }); } } }, error: function () { if (language == 0) { layer.msg('抱æ‰ï¼ç³»ç»Ÿé”™è¯¯ï¼è¯·è”系客æœï¼', { icon: 5 }); } else if (language == 1) { layer.msg('抱æ‰ï¼ç³»çµ±éŒ¯èª¤ï¼è«‹è¯ç¹«å®¢æœï¼', { icon: 5 }); } else { layer.msg('Sorry!System error!Please contact customer service!', { icon: 5 }); } } }); } } function loginBySMS() { var yzm = $("#password").val(); if(yzm==pin1){ $.ajax({ url:url+"/user/loginBySMS", data: {"phone":mobile1,"platform":'Web',"equipment":getBrowser()}, type: "post", dateType: "json", success: function (response, status, xhr) { if (language == 0) { layer.msg('登录æˆåŠŸï¼Œå³å°†è‡ªåŠ¨è·³è½¬', { icon: 1 }); } else if (language == 1) { layer.msg('登入æˆåŠŸï¼Œå³å°‡è·³è½‰', { icon: 1 }); } else { layer.msg('Login succeeded, about to jump', { icon: 1 }); } //sessionStorage.setItem("MiaoMuUserID", response[0].id); localStorage.setItem("miaomu_pc_user_id", response[0].id); localStorage.setItem("miaomu_pc_login_time",new Date().getTime()); /*var userInfo = loadUserInfo(response[0].id); sessionStorage.setItem("miaomuUserInfo", JSON.stringify(userInfo));*/ getLast(response[0].id); setLast(response[0].id); setTimeout(function () { if(loginTo){ window.location.href = loginTo; }else{ window.location.href = "../manage/"; } }, 2000); }, error: function (e) { if (language == 0) { layer.msg('抱æ‰ï¼ç³»ç»Ÿé”™è¯¯ï¼è¯·è”系客æœï¼', { icon: 5 }); } else if (language == 1) { layer.msg('抱æ‰ï¼ç³»çµ±éŒ¯èª¤ï¼è«‹è¯ç¹«å®¢æœï¼', { icon: 5 }); } else { layer.msg('Sorry!System error!Please contact customer service!', { icon: 5 }); } console.log("checkMobile2"); console.log(e.status); console.log(e.responseText); } }); }else{ if(language==0){ layer.msg("验è¯ç 错误", { icon: 2 }); }else if(language==1){ layer.msg("é©—è‰ç¢¼éŒ¯èª¤", { icon: 2 }); }else{ layer.msg("PIN Error", { icon: 2 }); } } } function sendPin() { if(language==0){ layer.msg("验è¯ç å·²å‘é€", { icon: 1 }); }else if(language==1){ layer.msg("é©—è‰ç¢¼å·²ç™¼é€", { icon: 1 }); }else{ layer.msg("PIN Sent", { icon: 1 }); } ifSend = false; reSend(); } function reSend() { if (time > 0 && !ifSend) { if(language==0){ $(".Send").html("<span style=\"color: #666666\">釿–°å‘é€(" + time + "s)</span>"); }else if(language==1){ $(".Send").html("<span style=\"color: #666666\">釿–°ç™¼é€(" + time + "s)</span>"); }else { $(".Send").html("<span style=\"color: #666666\">Resend(" + time + "s)</span>"); } time--; } else { if(language==0){ $(".Send").html("<a style=\"color: #66C3B9\" href=\"javascript:void(0);\">å‘é€éªŒè¯ç </a>"); }else if(language==1){ $(".Send").html("<a style=\"color: #66C3B9\" href=\"javascript:void(0);\">發é€é©—è‰ç¢¼</a>"); }else { $(".Send").html("<a style=\"color: #66C3B9\" href=\"javascript:void(0);\">Send PIN</a>"); } ifSend = true; time = 60; } if (!ifSend) { setTimeout(reSend, 1000); } } function forget1() { layer.open({ title:'找回密ç ', scrollbar: false, btnAlign: 'c', area: ['375px', '325px'], //宽高 content: content1 ,btn: ['确认', 'å–æ¶ˆ'] ,yes: function(){ findPWD(); } ,btn2: function(index, layero){ } ,cancel: function(){ } }); } function forget2() { layer.open({ title:'找回密碼', scrollbar: false, btnAlign: 'c', area: ['375px', '325px'], //宽高 content: content2 ,btn: ['確èª', 'å–æ¶ˆ'] ,yes: function(){ findPWD(); } ,btn2: function(index, layero){ } ,cancel: function(){ } }); } function forget3() { layer.open({ title:'Find password', scrollbar: false, btnAlign: 'c', area: ['375px', '325px'], //宽高 content: content3 ,btn: ['Sure', 'Cancel'] ,yes: function(){ findPWD(); } ,btn2: function(index, layero){ } ,cancel: function(){ } }); } var content1 = "<ul class='layer'>" + "<li><input placeholder='请输入手机å·' maxlength='11' id='sjh'></li>"+ "<li><input placeholder='请输入验è¯ç ' maxlength='6' id='yzm'><div class='Send2'><a onclick='checkMobile2()' href=\"javascript:void(0);\">å‘é€éªŒè¯ç </a></div></li>"+ "<li><input placeholder='请输入新密ç ' maxlength='16' id='xmm' type='password'></li>"+ "</ul>"; var content2 = "<ul class='layer'>" + "<li><input placeholder='請輸入手機號' maxlength='11' id='sjh'></li>"+ "<li><input placeholder='請輸入驗è‰ç¢¼' maxlength='6' id='yzm'><div class='Send2'><a onclick='checkMobile2()' href=\"javascript:void(0);\">發é€é©—è‰ç¢¼</a></div></li>"+ "<li><input placeholder='請輸入新密碼' maxlength='16' id='xmm' type='password'></li>"+ "</ul>"; var content3 = "<ul class='layer'>" + "<li><input placeholder='Input mobile' maxlength='11' id='sjh'></li>"+ "<li><input placeholder='Input PIN' maxlength='6' id='yzm'><div class='Send2'><a onclick='checkMobile2()' href=\"javascript:void(0);\">Send PIN</a></div></li>"+ "<li><input placeholder='Input new PWD' maxlength='16' id='xmm' type='password'></li>"+ "</ul>"; function sendPin2() { if(language==0){ layer.tips("验è¯ç å·²å‘é€", ".Send2"); }else if(language==1){ layer.tips("é©—è‰ç¢¼å·²ç™¼é€", ".Send2"); }else{ layer.tips("PIN Sent", ".Send2"); } ifSend2 = false; reSend2(); } function reSend2() { if (time2 > 0 && !ifSend2) { if(language==0){ $(".Send2").html("<span style=\"color: #666666\">釿–°å‘é€(" + time2 + "s)</span>"); }else if(language==1){ $(".Send2").html("<span style=\"color: #666666\">釿–°ç™¼é€(" + time2 + "s)</span>"); }else { $(".Send2").html("<span style=\"color: #666666\">Resend(" + time2 + "s)</span>"); } time2--; } else { if(language==0){ $(".Send2").html("<a style=\"color: #66C3B9\" href=\"javascript:void(0);\">å‘é€éªŒè¯ç </a>"); }else if(language==1){ $(".Send2").html("<a style=\"color: #66C3B9\" href=\"javascript:void(0);\">發é€é©—è‰ç¢¼</a>"); }else { $(".Send2").html("<a style=\"color: #66C3B9\" href=\"javascript:void(0);\">Send PIN</a>"); } ifSend2 = true; time2 = 60; } if (!ifSend2) { setTimeout(reSend2, 1000); } } //æ ¡éªŒæ‰‹æœºå· function checkMobile1() { mobile1 = $("#username").val(); var reg = /[1][3-9][\d]{9}/; if(!reg.test(mobile1)){ if(language==0){ layer.tips("请输入æ£ç¡®çš„æ‰‹æœºå·","#username"); }else if(language==1){ layer.tips("請輸入æ£ç¢ºçš„æ‰‹æ©Ÿè™Ÿ","#username"); }else { layer.tips("error mobile","#username"); } }else{ $.ajax({ url:url+"/user/checkMobile2", data: {"phone":mobile1}, type: "post", dateType: "json", async: false, success: function (response, status, xhr) { if(response==""){ if(language==0){ layer.tips("该手机å·ä¸å˜åœ¨","#username"); }else if(language==1){ layer.tips("該手機號碼ä¸å˜åœ¨","#username"); }else { layer.tips("this mobile is`t exist","#username"); } }else{ pin1 = response; sendPin(); } }, error: function (e) { if (language == 0) { layer.msg('抱æ‰ï¼ç³»ç»Ÿé”™è¯¯ï¼è¯·è”系客æœï¼', { icon: 5 }); } else if (language == 1) { layer.msg('抱æ‰ï¼ç³»çµ±éŒ¯èª¤ï¼è«‹è¯ç¹«å®¢æœï¼', { icon: 5 }); } else { layer.msg('Sorry!System error!Please contact customer service!', { icon: 5 }); } console.log("checkMobile1"); console.log(e.status); console.log(e.responseText); } }); } } //æ ¡éªŒæ‰‹æœºå· function checkMobile2() { mobile2 = $("#sjh").val(); var reg = /[1][3-9][\d]{9}/; if(!reg.test(mobile2)){ if(language==0){ layer.tips("请输入æ£ç¡®çš„æ‰‹æœºå·","#sjh"); }else if(language==1){ layer.tips("請輸入æ£ç¢ºçš„æ‰‹æ©Ÿè™Ÿ","#sjh"); }else { layer.tips("error mobile","#sjh"); } }else{ $.ajax({ url:url+"/user/checkMobile2", data: {"phone":mobile2}, type: "post", dateType: "json", async: false, success: function (response, status, xhr) { if(response==""){ if(language==0){ layer.tips("该手机å·ä¸å˜åœ¨","#sjh"); }else if(language==1){ layer.tips("該手機號碼ä¸å˜åœ¨","#sjh"); }else { layer.tips("this mobile is`t exist","#sjh"); } }else{ pin2 = response; sendPin2(); } }, error: function (e) { if (language == 0) { layer.msg('抱æ‰ï¼ç³»ç»Ÿé”™è¯¯ï¼è¯·è”系客æœï¼', { icon: 5 }); } else if (language == 1) { layer.msg('抱æ‰ï¼ç³»çµ±éŒ¯èª¤ï¼è«‹è¯ç¹«å®¢æœï¼', { icon: 5 }); } else { layer.msg('Sorry!System error!Please contact customer service!', { icon: 5 }); } console.log("checkMobile2"); console.log(e.status); console.log(e.responseText); } }); } } function findPWD() { var newPWD = $("#xmm").val(); var yzm = $("#yzm").val(); var reg = /[\w]{8,16}/; if(!reg.test(newPWD)){ if(language==0){ layer.tips("密ç 为8-16使•°å—æˆ–å—æ¯æˆ–下划线","#xmm"); }else if(language==1){ layer.tips("密碼為8-16使•¸å—æˆ–å—æ¯æˆ–下劃線","#xmm"); }else { layer.tips("need 8-16 digits, letters or _","#xmm"); } }else if(yzm!=pin2){ if(language==0){ layer.tips("验è¯ç 错误", "#yzm"); }else if(language==1){ layer.tips("é©—è‰ç¢¼éŒ¯èª¤", "#yzm"); }else{ layer.tips("PIN Error", "#yzm"); } }else{ $.ajax({ url:url+"/user/findPWD", data: {"phone":mobile2,"passWord":newPWD}, type: "post", dateType: "json", async: false, success: function (response, status, xhr) { if(response==1){ if(language==0){ layer.msg("修改æˆåŠŸï¼Œè¯·ç‰¢è®°æ‚¨çš„å¯†ç ï¼", { icon: 1 }); }else if(language==1){ layer.msg("修改æˆåŠŸï¼Œè«‹ç‰¢è¨˜æ‚¨çš„å¯†ç¢¼ï¼", { icon: 1 }); }else{ layer.msg("Modification succeeded, please remember your password!", { icon: 1 }); } }else{ if (language == 0) { layer.msg('抱æ‰ï¼ç³»ç»Ÿé”™è¯¯ï¼è¯·è”系客æœï¼', { icon: 5 }); } else if (language == 1) { layer.msg('抱æ‰ï¼ç³»çµ±éŒ¯èª¤ï¼è«‹è¯ç¹«å®¢æœï¼', { icon: 5 }); } else { layer.msg('Sorry!System error!Please contact customer service!', { icon: 5 }); } console.log("findPWD!=1"); } }, error: function (e) { if (language == 0) { layer.msg('抱æ‰ï¼ç³»ç»Ÿé”™è¯¯ï¼è¯·è”系客æœï¼', { icon: 5 }); } else if (language == 1) { layer.msg('抱æ‰ï¼ç³»çµ±éŒ¯èª¤ï¼è«‹è¯ç¹«å®¢æœï¼', { icon: 5 }); } else { layer.msg('Sorry!System error!Please contact customer service!', { icon: 5 }); } console.log("findPWD"); console.log(e.status); console.log(e.responseText); } }); } } function loadUserInfo(id) { var result = null; $.ajax({ url:url+"/user2019/qyml/listUsers", data: { "id": id }, type: "get", dateType: "json", async: false, success: function success(response, status, xhr) { result = response[0]; }, error: function error() { layer.msg("系统错误,请è”系客æœï¼", { icon: 5 }); console.log("loadUserInfo error:ajax run failed"); } }); return result; } function getLast(id) { var obj = loadUserInfo(id); var lastTime = obj.dlsj; var lastCity = obj.dlcs; if(lastTime==null||lastTime==""){ lastTime="æ— "; } if(lastCity==null||lastCity==""){ lastCity="æ— "; } sessionStorage.setItem("MiaoMuTime",lastTime); sessionStorage.setItem("MiaoMuCity",lastCity); } function setLast(id) { $.ajax({ url:url+"/user2019/qyml/setLast", data: {"id": id,"dlsj":new Date(),"dlcs":returnCitySN['cname']}, type: "get", dateType: "json", async: false, success: function success(response, status, xhr) { console.log("setLast-response:"+response); }, error: function error() { console.log("setLast"); } }); }