Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into develop
Showing
2 changed files
with
42 additions
and
12 deletions
@@ -73,6 +73,8 @@ $loginBtn.on('touchstart', function() { | @@ -73,6 +73,8 @@ $loginBtn.on('touchstart', function() { | ||
73 | return; | 73 | return; |
74 | } | 74 | } |
75 | 75 | ||
76 | + $loginBtn.text('正在登录...').addClass('disable'); | ||
77 | + | ||
76 | if (api.phoneRegx[areaCode].test(pn) && api.pwdValidate(pwd)) { | 78 | if (api.phoneRegx[areaCode].test(pn) && api.pwdValidate(pwd)) { |
77 | $.ajax({ | 79 | $.ajax({ |
78 | type: 'POST', | 80 | type: 'POST', |
@@ -83,7 +85,8 @@ $loginBtn.on('touchstart', function() { | @@ -83,7 +85,8 @@ $loginBtn.on('touchstart', function() { | ||
83 | password: pwd | 85 | password: pwd |
84 | }, | 86 | }, |
85 | success: function(data) { | 87 | success: function(data) { |
86 | - var res; | 88 | + var res, |
89 | + time; | ||
87 | 90 | ||
88 | if (data.code === 200) { | 91 | if (data.code === 200) { |
89 | res = data.data; | 92 | res = data.data; |
@@ -91,19 +94,32 @@ $loginBtn.on('touchstart', function() { | @@ -91,19 +94,32 @@ $loginBtn.on('touchstart', function() { | ||
91 | 94 | ||
92 | $.ajax({ | 95 | $.ajax({ |
93 | url: res.session, | 96 | url: res.session, |
94 | - dataType: 'jsonp' | ||
95 | - }); | 97 | + dataType: 'jsonp', |
98 | + success: function() { | ||
99 | + clearTimeout(time); | ||
96 | 100 | ||
97 | - //2000ms后跳转页面 | 101 | + //Cookie写入成功后,1s后跳转页面 |
98 | setTimeout(function() { | 102 | setTimeout(function() { |
99 | location.href = res.href; | 103 | location.href = res.href; |
100 | - }, 2000); | 104 | + }, 1000); |
105 | + } | ||
106 | + }); | ||
107 | + | ||
108 | + //3秒后强制跳转 | ||
109 | + time = setTimeout(function() { | ||
110 | + location.href = res.href; | ||
111 | + }, 3000); | ||
112 | + | ||
113 | + showErrTip('登录成功'); | ||
101 | } else { | 114 | } else { |
102 | showErrTip(data.message); | 115 | showErrTip(data.message); |
103 | } | 116 | } |
104 | }, | 117 | }, |
105 | error: function() { | 118 | error: function() { |
106 | showErrTip('网络断开连接啦~'); | 119 | showErrTip('网络断开连接啦~'); |
120 | + }, | ||
121 | + complete: function() { | ||
122 | + $loginBtn.text('登录').removeClass('disable'); | ||
107 | } | 123 | } |
108 | }); | 124 | }); |
109 | } else { | 125 | } else { |
@@ -76,6 +76,8 @@ $loginBtn.on('touchstart', function() { | @@ -76,6 +76,8 @@ $loginBtn.on('touchstart', function() { | ||
76 | return; | 76 | return; |
77 | } | 77 | } |
78 | 78 | ||
79 | + $loginBtn.text('正在登录...').addClass('disable'); | ||
80 | + | ||
79 | //验证账号(数字或者邮箱)和密码合理性 | 81 | //验证账号(数字或者邮箱)和密码合理性 |
80 | if ((/^[0-9]+$/.test(acc) || api.emailRegx.test(acc)) && api.pwdValidate(pwd)) { | 82 | if ((/^[0-9]+$/.test(acc) || api.emailRegx.test(acc)) && api.pwdValidate(pwd)) { |
81 | $.ajax({ | 83 | $.ajax({ |
@@ -86,28 +88,40 @@ $loginBtn.on('touchstart', function() { | @@ -86,28 +88,40 @@ $loginBtn.on('touchstart', function() { | ||
86 | password: pwd | 88 | password: pwd |
87 | }, | 89 | }, |
88 | success: function(data) { | 90 | success: function(data) { |
89 | - var res; | 91 | + var res, |
92 | + time; | ||
90 | 93 | ||
91 | if (data.code === 200) { | 94 | if (data.code === 200) { |
92 | res = data.data; | 95 | res = data.data; |
93 | 96 | ||
94 | - showErrTip('登录成功'); | ||
95 | - | ||
96 | $.ajax({ | 97 | $.ajax({ |
97 | url: res.session, | 98 | url: res.session, |
98 | - dataType: 'jsonp' | ||
99 | - }); | 99 | + dataType: 'jsonp', |
100 | + success: function() { | ||
101 | + clearTimeout(time); | ||
100 | 102 | ||
101 | - //2s后跳转页面 | 103 | + //Cookie写入成功后,1s后跳转页面 |
102 | setTimeout(function() { | 104 | setTimeout(function() { |
103 | location.href = res.href; | 105 | location.href = res.href; |
104 | - }, 2000); | 106 | + }, 1000); |
107 | + } | ||
108 | + }); | ||
109 | + | ||
110 | + //3秒后强制跳转 | ||
111 | + time = setTimeout(function() { | ||
112 | + location.href = res.href; | ||
113 | + }, 3000); | ||
114 | + | ||
115 | + showErrTip('登录成功'); | ||
105 | } else { | 116 | } else { |
106 | showErrTip(data.message); | 117 | showErrTip(data.message); |
107 | } | 118 | } |
108 | }, | 119 | }, |
109 | error: function() { | 120 | error: function() { |
110 | showErrTip('网络断开连接啦~'); | 121 | showErrTip('网络断开连接啦~'); |
122 | + }, | ||
123 | + complete: function() { | ||
124 | + $loginBtn.text('登录').removeClass('disable'); | ||
111 | } | 125 | } |
112 | }); | 126 | }); |
113 | } else { | 127 | } else { |
-
Please register or login to post a comment