作者 xiaohu thinkpad
@@ -5,7 +5,8 @@ @@ -5,7 +5,8 @@
5 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 5 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
6 <meta content="yes" name="apple-mobile-web-app-capable"> 6 <meta content="yes" name="apple-mobile-web-app-capable">
7 <meta content="yes" name="apple-touch-fullscreen"> 7 <meta content="yes" name="apple-touch-fullscreen">
8 - <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,maximum-scale=1, minimum-scale=1, user-scalable=no"> 8 + <meta name="viewport"
  9 + content="width=device-width, initial-scale=1,maximum-scale=1,maximum-scale=1, minimum-scale=1, user-scalable=no">
9 <title>登录</title> 10 <title>登录</title>
10 <link rel="stylesheet" href="/static/css/common.css"> 11 <link rel="stylesheet" href="/static/css/common.css">
11 <link rel="stylesheet" href="/static/css/style.css"> 12 <link rel="stylesheet" href="/static/css/style.css">
@@ -27,7 +28,7 @@ @@ -27,7 +28,7 @@
27 <i>抱歉,此手机号没有权限登录</i> 28 <i>抱歉,此手机号没有权限登录</i>
28 </div> 29 </div>
29 <div class="btn_login"> 30 <div class="btn_login">
30 - <img src="/static/image/btn_login.png" /> 31 + <img src="/static/image/btn_login.png"/>
31 </div> 32 </div>
32 </div> 33 </div>
33 34
@@ -36,43 +37,43 @@ @@ -36,43 +37,43 @@
36 <script type="text/javascript" src="/static/js/layer/layer.js"></script> 37 <script type="text/javascript" src="/static/js/layer/layer.js"></script>
37 <script type="text/javascript" src="/static/js/common.js"></script> 38 <script type="text/javascript" src="/static/js/common.js"></script>
38 <script> 39 <script>
39 - $(function () { 40 + $(function () {
40 //获取短信验证码 41 //获取短信验证码
41 var times = 1; 42 var times = 1;
42 - var validCode=true;  
43 - $(".get_code").click (function () {  
44 - if(validCode){  
45 - var user_phone=$(".login_phone").val(); 43 + var validCode = true;
  44 + $(".get_code").click(function () {
  45 + if (validCode) {
  46 + var user_phone = $(".login_phone").val();
46 console.log(user_phone); 47 console.log(user_phone);
47 - if(!user_phone){ 48 + if (!user_phone) {
48 layer.msg("手机号码格式不正确") 49 layer.msg("手机号码格式不正确")
49 - }else{  
50 - if(times ==1){ 50 + } else {
  51 + if (times == 1) {
51 times++; 52 times++;
52 $.ajax({ 53 $.ajax({
53 - type:"post",  
54 - url:"{:url('portal/tool/get_sms_code')}",  
55 - data:{  
56 - mobile:user_phone 54 + type: "post",
  55 + url: "{:url('portal/tool/get_sms_code')}",
  56 + data: {
  57 + mobile: user_phone
57 }, 58 },
58 - success:function(){  
59 - var time=60;  
60 - var code=$(".get_code"); 59 + success: function () {
  60 + var time = 60;
  61 + var code = $(".get_code");
61 if (validCode) { 62 if (validCode) {
62 code.html("60秒"); 63 code.html("60秒");
63 - validCode=false; 64 + validCode = false;
64 code.addClass("msgs1"); 65 code.addClass("msgs1");
65 - var t=setInterval(function () {  
66 - if (time>=0) { 66 + var t = setInterval(function () {
  67 + if (time >= 0) {
67 time--; 68 time--;
68 - code.html(time+"秒");  
69 - validCode=false;  
70 - } else{  
71 - validCode =true; 69 + code.html(time + "秒");
  70 + validCode = false;
  71 + } else {
  72 + validCode = true;
72 code.html("重新获取"); 73 code.html("重新获取");
73 clearInterval(t); 74 clearInterval(t);
74 } 75 }
75 - },1000) 76 + }, 1000)
76 } 77 }
77 } 78 }
78 }) 79 })
@@ -81,29 +82,27 @@ @@ -81,29 +82,27 @@
81 } 82 }
82 }); 83 });
83 84
84 - $('.btn_login').click(function(){  
85 - var user_phone=$(".login_phone").val();  
86 - var user_code=$('.login_code').val();  
87 - if(!user_code){ 85 + $('.btn_login').click(function () {
  86 + var user_phone = $(".login_phone").val();
  87 + var user_code = $('.login_code').val();
  88 + if (!user_code) {
88 layer.msg("验证码不能为空") 89 layer.msg("验证码不能为空")
89 - }else{ 90 + } else {
90 $.ajax({ 91 $.ajax({
91 - type:"post",  
92 - url:"{:url('user/login/do_login')}",  
93 - data:{  
94 - mobile:user_phone,  
95 - sms_code:user_code 92 + type: "post",
  93 + url: "{:url('user/login/do_login')}",
  94 + data: {
  95 + mobile: user_phone,
  96 + sms_code: user_code
96 }, 97 },
97 - success:function(res){  
98 - if(res.code==0){  
99 - $('.login_tab i').text(res.msg);  
100 - $('.login_tab').show();  
101 - }else {  
102 - window.location.href="{:url('user/profile/percenter')}" 98 + success: function (res) {
  99 + if (res.code == 0) {
  100 + layer.msg(res.msg);
  101 + } else {
  102 + window.location.href = "{:url('user/profile/percenter')}"
103 } 103 }
104 - console.log(res);  
105 }, 104 },
106 - error:function(){ 105 + error: function () {
107 106
108 } 107 }
109 }) 108 })