Authored by 毕凯

Merge branch 'feature/delcode' into 'release/6.5'

del-code



See merge request !1260
1 -require('./back/email-success');  
1 -require('./back/email');  
2 -  
1 -/**  
2 - * Created by TaoHuang on 2016/6/15.  
3 - */  
4 -  
5 -require('./back/mobile');  
1 -/**  
2 - * 找回密码-邮箱找回成功  
3 - * @author: xuqi<qi.xu@yoho.cn>  
4 - * @date: 2015/10/8  
5 - */  
6 -  
7 -let $ = require('yoho-jquery');  
8 -let $resend = $('#resend');  
9 -let tip = require('plugin/tip');  
10 -let showTip = tip.show;  
11 -  
12 -$resend.on('touchstart', function(e) {  
13 - e.preventDefault();  
14 -  
15 - $.ajax({  
16 - url: $resend.data('url'),  
17 - type: 'GET',  
18 - success: function(data) {  
19 - showTip(data.message);  
20 - }  
21 - });  
22 -});  
1 -/**  
2 - * 找回密码-邮箱找回  
3 - * @author: xuqi<qi.xu@yoho.cn>  
4 - * @date: 2015/10/8  
5 - */  
6 -let $ = require('yoho-jquery');  
7 -  
8 -let $email = $('#email'),  
9 - $btnSure = $('#btn-sure');  
10 -  
11 -let api = require('../api');  
12 -let tip = require('plugin/tip');  
13 -  
14 -let trim = $.trim;  
15 -let showErrTip = tip.show;  
16 -  
17 -api.bindClearEvt();  
18 -  
19 -$email.bind('input', function() {  
20 - if (trim($email.val()) === '') {  
21 - $btnSure.addClass('disable');  
22 - } else {  
23 - $btnSure.removeClass('disable');  
24 - }  
25 -});  
26 -  
27 -$btnSure.on('touchstart', function() {  
28 - let email = trim($email.val());  
29 -  
30 - if ($btnSure.hasClass('disable')) {  
31 - return;  
32 - }  
33 -  
34 - if (api.emailRegx.test(email)) {  
35 - $.ajax({  
36 - url: '/passport/back/sendemail',  
37 - type: 'POST',  
38 - data: {  
39 - email: email  
40 - },  
41 - success: function(data) {  
42 - console.log(data);  
43 - if (data.code === 200) {  
44 - location.href = data.data;  
45 - } else {  
46 - showErrTip(data.message);  
47 - }  
48 - }  
49 - });  
50 - } else {  
51 - showErrTip('邮箱格式不正确,请重新输入');  
52 - }  
53 -});  
1 -  
2 -/**  
3 - * 找回密码-手机  
4 - * @author: xuqi<qi.xu@yoho.cn>  
5 - * @date: 2015/10/8  
6 - */  
7 -let $ = require('yoho-jquery');  
8 -  
9 -let $phoneNum = $('#phone-num'),  
10 - $countrySelect = $('#country-select'),  
11 - $areaCode = $('#area-code'),  
12 - $verifyCode = $('#verify-code'),  
13 - $verifyCodeImg = $('#verify-code-img'),  
14 - $btnNext = $('#btn-next');  
15 -  
16 -let api = require('../api');  
17 -let tip = require('plugin/tip');  
18 -  
19 -let trim = $.trim;  
20 -let showErrTip = tip.show;  
21 -  
22 -// 图片验证码  
23 -let Validate = require('plugin/validata');  
24 -  
25 -let validate = new Validate('#js-img-check', {  
26 - useREM: {  
27 - rootFontSize: 40,  
28 - picWidth: 150  
29 - }  
30 -});  
31 -  
32 -validate.init();  
33 -  
34 -api.selectCssHack($('#country-select'));  
35 -  
36 -api.bindClearEvt();  
37 -  
38 -$phoneNum.bind('input', function() {  
39 - if (trim($phoneNum.val()) === '') {  
40 - $btnNext.addClass('disable');  
41 - } else {  
42 - $btnNext.removeClass('disable');  
43 - }  
44 -});  
45 -  
46 -$countrySelect.change(function() {  
47 - $areaCode.text($countrySelect.val());  
48 -});  
49 -  
50 -$verifyCodeImg.on('touchstart', function() {  
51 - let oldSrc = $verifyCodeImg.attr('src').split('=');  
52 -  
53 - $verifyCodeImg.attr('src', oldSrc[0] + '=' + Date.now());  
54 - $verifyCode.val('');  
55 -});  
56 -  
57 -$btnNext.on('touchstart', function() {  
58 - let pn = trim($phoneNum.val()),  
59 - area = trim($countrySelect.val());  
60 -  
61 - if ($btnNext.hasClass('disable')) {  
62 - return;  
63 - }  
64 -  
65 -  
66 - if (area && pn && api.phoneRegx[area].test(pn)) {  
67 - validate.getResults().then((result) => {  
68 - let params = {  
69 - areaCode: area.replace('+', ''),  
70 - phoneNum: pn  
71 - };  
72 -  
73 - $.extend(params, result);  
74 - $.ajax({  
75 - url: '/passport/back/sendcode',  
76 - type: 'POST',  
77 - data: params,  
78 - success: function(data) {  
79 - validate.type === 2 && validate.refresh();  
80 - if (data.code === 200 && data.data) {  
81 - location.href = data.data.href;  
82 - return;  
83 - } else if (data.code === 409) {  
84 - showErrTip(data.message);  
85 - location.href = data.refer;  
86 - } else {  
87 - showErrTip(data.message);  
88 - }  
89 - (data.changeCaptcha && validate.type !== 2) && validate.refresh();  
90 - },  
91 - error: function() {  
92 - showErrTip('出错了,请重试');  
93 - validate.refresh();  
94 - }  
95 - });  
96 - });  
97 - } else if (!area) {  
98 - showErrTip('出错了,请重新刷新页面');  
99 - } else {  
100 - showErrTip('手机号格式不正确,请重新输入');  
101 - }  
102 -});  
1 -require('./login/international');  
1 -require('common');  
2 -require('./login/qr-check');  
3 -require('./login/login');  
4 -  
5 -(function() {  
6 - let channel = window.cookie('_Channel');  
7 - let channelMap = {  
8 - boys: 1,  
9 - girls: 2,  
10 - kids: 3,  
11 - lifestyle: 4  
12 - };  
13 - let param;  
14 -  
15 - channel = channelMap[channel] || 1;  
16 - param = JSON.stringify({C_ID: channel});  
17 -  
18 -  
19 - // when js run  
20 - setTimeout(function() {  
21 - let yas = window._yas;  
22 -  
23 - yas && yas.sendCustomInfo && yas.sendCustomInfo({  
24 - op: 'YB_LOGIN_L',  
25 - param: param  
26 - });  
27 - }, 3000);  
28 -  
29 - $(function() {  
30 - let $smsLogin = $('.sms-login');  
31 -  
32 - // when jump sms-login  
33 - $smsLogin.on('click', function() {  
34 - let yas = window._yas;  
35 -  
36 - yas && yas.sendCustomInfo && yas.sendCustomInfo({  
37 - op: 'YB_MOBILE_QUICK_LOGIN_C',  
38 - param: param  
39 - });  
40 - });  
41 - });  
42 -}());  
1 -/**  
2 - * 国际账号登录  
3 - * @author: xuqi<qi.xu@yoho.cn>  
4 - * @date: 2015/10/8  
5 - */  
6 -let $ = require('yoho-jquery');  
7 -let Validate = require('plugin/validata');  
8 -  
9 -let $phoneNum = $('#phone-num'),  
10 - $countrySelect = $('#country-select'),  
11 - $areaCode = $('#area-code'),  
12 - $pwd = $('#pwd'),  
13 - $loginBtn = $('#btn-login'),  
14 -  
15 - $captcha = $('#js-img-check'),  
16 - useVerify = $captcha.data('userverify'), // 170406 是否使用验证  
17 -  
18 - pnPass = false,  
19 - pwdPass = false;  
20 -  
21 -let api = require('../api');  
22 -let tip = require('plugin/tip');  
23 -  
24 -let trim = $.trim;  
25 -let showErrTip = tip.show;  
26 -  
27 -let validate = {};  
28 -  
29 -if (useVerify) {  
30 - validate = new Validate($captcha, {  
31 - useREM: {  
32 - rootFontSize: 40,  
33 - picWidth: 150  
34 - }  
35 - });  
36 -  
37 - validate.init();  
38 -}  
39 -  
40 -// 登录按钮状态切换  
41 -function switchLoginBtnStatus() {  
42 - let bool = !(pnPass && pwdPass);  
43 -  
44 - $loginBtn.toggleClass('disable', bool);  
45 -}  
46 -  
47 -function resetForm() {  
48 - $pwd.val('').focus();  
49 - $loginBtn.text('登录').addClass('disable');  
50 -}  
51 -  
52 -/**  
53 - * 登录校验  
54 - */  
55 -function loginAuth(params) {  
56 - $.ajax({  
57 - type: 'POST',  
58 - url: '/passport/login/auth',  
59 - data: params,  
60 - success: function(data) {  
61 - let res;  
62 -  
63 - validate && validate.type === 2 && validate.refresh();  
64 - if (data.code === 200) {  
65 - res = data.data;  
66 - showErrTip('登录成功');  
67 -  
68 - // 3秒后强制跳转  
69 - setTimeout(() => {  
70 - location.href = res.href;  
71 - }, 1500);  
72 -  
73 - $loginBtn.text('登录成功');  
74 - showErrTip('登录成功');  
75 - } else {  
76 - if (useVerify && data.captchaShow) {  
77 - ((data.changeCaptcha && validate.type !== 2) && validate.refresh());  
78 - }  
79 -  
80 - showErrTip(data.message);  
81 - resetForm();  
82 - }  
83 - },  
84 - error: function() {  
85 - showErrTip('网络断开连接啦~');  
86 - $loginBtn.text('登录');  
87 -  
88 - validate && validate.refresh();  
89 - }  
90 - });  
91 -}  
92 -  
93 -// Android-UC下显示select的direction:rtl无效的临时解决办法  
94 -api.selectCssHack($countrySelect);  
95 -  
96 -// 显示隐藏密码  
97 -api.bindEyesEvt();  
98 -  
99 -// 清空手机号码  
100 -api.bindClearEvt();  
101 -  
102 -$phoneNum.bind('input', function() {  
103 - if (trim($phoneNum.val()) === '') {  
104 - pnPass = false;  
105 - } else {  
106 - pnPass = true;  
107 - }  
108 -  
109 - switchLoginBtnStatus();  
110 -});  
111 -  
112 -$pwd.bind('input', function() {  
113 - let pwd = trim($pwd.val());  
114 -  
115 - if (pwd === '') {  
116 - pwdPass = false;  
117 - } else {  
118 - pwdPass = true;  
119 - }  
120 -  
121 - switchLoginBtnStatus();  
122 -});  
123 -  
124 -$countrySelect.change(function() {  
125 - $areaCode.text($countrySelect.val());  
126 -});  
127 -  
128 -$loginBtn.on('touchstart', function() {  
129 - let pn = trim($phoneNum.val()),  
130 - areaCode = $countrySelect.val(),  
131 - pwd = trim($pwd.val());  
132 -  
133 - if ($loginBtn.hasClass('disable')) {  
134 - return;  
135 - }  
136 -  
137 - if ((api.phoneRegx[areaCode].test(pn) || areaCode !== '+86') && api.pwdValidate(pwd)) {  
138 - let params = {  
139 - areaCode: areaCode.replace('+', ''),  
140 - account: pn,  
141 - password: pwd  
142 - };  
143 -  
144 - if (useVerify) {  
145 - validate.getResults().then((result) => {  
146 - $loginBtn.text('正在登录...').addClass('disable');  
147 - $.extend(params, result);  
148 - loginAuth(params);  
149 - });  
150 - } else {  
151 - loginAuth(params);  
152 - }  
153 - } else {  
154 - showErrTip('账号或密码有错误,请重新输入');  
155 - $loginBtn.text('登录').addClass('disable');  
156 - }  
157 -});  
158 -  
159 -// 对初始有默认值的情况去初始化登录按钮状态  
160 -$phoneNum.trigger('input');  
161 -$pwd.trigger('input');  
1 -/**  
2 - * 登录  
3 - * @author: xuqi<qi.xu@yoho.cn>  
4 - * @date: 2015/9/30  
5 - */  
6 -let $ = require('yoho-jquery');  
7 -let Validate = require('plugin/validata');  
8 -  
9 -let $account = $('#account'),  
10 - $pwd = $('#pwd'),  
11 - $loginBtn = $('#btn-login'),  
12 -  
13 - $mask = $('#retrive-pwd-mask'),  
14 - $ways = $('#retrive-pwd-ways'),  
15 -  
16 - $captcha = $('#js-img-check'),  
17 -  
18 - accPass = false,  
19 - pwdPass = false;  
20 -  
21 -let api = require('../api');  
22 -let tip = require('plugin/tip');  
23 -let cookie = require('yoho-cookie');  
24 -  
25 -let trim = $.trim;  
26 -let showErrTip = tip.show;  
27 -  
28 -  
29 -let validate = new Validate($captcha, {  
30 - useREM: {  
31 - rootFontSize: 40,  
32 - picWidth: 150  
33 - }  
34 -});  
35 -  
36 -if ($captcha.data('userverify')) {  
37 - validate.init();  
38 -}  
39 -  
40 -// 登录按钮状态切换  
41 -function switchLoginBtnStatus() {  
42 - let bool = true;  
43 -  
44 - bool = !(accPass && pwdPass);  
45 -  
46 - $loginBtn.toggleClass('disable', bool);  
47 -}  
48 -  
49 -function resetForm() {  
50 - // $pwd.val('').focus();  
51 - $loginBtn.text('登录').addClass('disable');  
52 -}  
53 -  
54 -// 显示找回密码面板  
55 -function showRetrivePanel() {  
56 - $mask.show();  
57 - $ways.show();  
58 -}  
59 -  
60 -// 隐藏找回密码面板  
61 -function hideRetrivePanel() {  
62 - $mask.hide();  
63 - $ways.hide();  
64 -}  
65 -  
66 -/**  
67 - * 登录校验  
68 - */  
69 -function loginAuth(params, acc) {  
70 - $.ajax({  
71 - type: 'POST',  
72 - url: '/passport/login/auth',  
73 - data: params,  
74 - success: function(data) {  
75 - let res,  
76 - LOGI_TYPE;  
77 -  
78 - if (acc.indexOf('@') > 0) {  
79 - LOGI_TYPE = 8;  
80 - } else {  
81 - LOGI_TYPE = 5;  
82 - }  
83 -  
84 - if (window._yas && window._yas.sendCustomInfo) {  
85 - window._yas.sendCustomInfo({  
86 - op: 'YB_MY_LOGIN_C',  
87 - param: JSON.stringify({  
88 - C_ID: window._ChannelVary[window.cookie('_Channel')],  
89 - LOGI_TYPE: LOGI_TYPE  
90 - })  
91 - }, true);  
92 - }  
93 - validate && validate.type === 2 && validate.refresh();  
94 - if (data.code === 200) {  
95 - res = data.data;  
96 -  
97 - showErrTip('登录成功');  
98 - location.href = res.href;  
99 - $loginBtn.text('登录成功');  
100 - } else if (data.code === 4189) {  
101 - cookie.set('_loginJumpUrl', $('input[name=username]').val());  
102 - showErrTip('您的账号存在安全隐患需要进行身份验证');  
103 - setTimeout(() => {  
104 - location.href = data.url;  
105 - }, 2500);  
106 - } else if (data.code === 510 || data.code === 50004) {  
107 - location.href = data.url;  
108 - } else {  
109 - $captcha.data('userverify', data.captchaShow);  
110 - if (data.captchaShow) {  
111 - if (validate.atWorking) {  
112 - ((data.changeCaptcha && validate.type !== 2) && validate.refresh());  
113 - } else {  
114 - validate.init();  
115 - }  
116 - }  
117 -  
118 - showErrTip(data.message);  
119 - resetForm();  
120 - }  
121 -  
122 - return data;  
123 - },  
124 - error: function() {  
125 - showErrTip('网络断开连接啦~');  
126 -  
127 - validate && validate.refresh();  
128 - },  
129 - complete: function() {  
130 - $loginBtn.text('登录').removeClass('disable');  
131 - }  
132 - });  
133 -}  
134 -  
135 -// 密码显示与隐藏  
136 -api.bindEyesEvt();  
137 -  
138 -// 清空账号输入框  
139 -api.bindClearEvt();  
140 -  
141 -$account.bind('input', function() {  
142 - if (trim($account.val()) !== '') {  
143 - accPass = true;  
144 - } else {  
145 - accPass = false;  
146 - }  
147 - switchLoginBtnStatus();  
148 -});  
149 -  
150 -$pwd.bind('input', function() {  
151 - if (trim($pwd.val()) === '') {  
152 - pwdPass = false;  
153 - } else {  
154 - pwdPass = true;  
155 - }  
156 - switchLoginBtnStatus();  
157 -});  
158 -  
159 -  
160 -// Login  
161 -$loginBtn.on('touchstart', function() {  
162 - if ($loginBtn.hasClass('disable')) {  
163 - return;  
164 - }  
165 - let acc = trim($account.val()),  
166 - pwd = trim($pwd.val());  
167 -  
168 - // 验证账号(数字或者邮箱)和密码合理性  
169 - if ((/^[0-9]+$/.test(acc) || api.emailRegx.test(acc)) && api.pwdValidate(pwd)) {  
170 - let params = {  
171 - account: acc,  
172 - password: pwd,  
173 - isskip: window.queryString.isskip  
174 - };  
175 -  
176 - if ($captcha.data('userverify')) {  
177 - validate.getResults().then((result) => {  
178 - $loginBtn.text('正在登录...').addClass('disable');  
179 -  
180 - $.extend(params, result);  
181 -  
182 - // auth  
183 - loginAuth(params, acc);  
184 - }, () => {});  
185 - } else {  
186 - loginAuth(params, acc);  
187 - }  
188 - } else {  
189 - showErrTip('账号或密码有错误,请重新输入');  
190 - $loginBtn.text('登录').removeClass('disable');  
191 - }  
192 -});  
193 -  
194 -  
195 -$('#forget-pwd').on('touchstart', function() {  
196 - showRetrivePanel();  
197 -});  
198 -  
199 -$mask.on('touchstart', function() {  
200 - hideRetrivePanel();  
201 -});  
202 -  
203 -$('#cancel-retrive').on('touchstart', function(e) {  
204 - e.preventDefault();  
205 - hideRetrivePanel();  
206 -});  
207 -  
208 -// 对初始有默认值的情况去初始化登录按钮状态  
209 -$account.trigger('input');  
210 -$pwd.trigger('input');  
211 -  
212 -function getTypeName(name) {  
213 - return {  
214 - qq: 1,  
215 - wechat: 4,  
216 - weibo: 2,  
217 - alipay: 3  
218 - }[name];  
219 -}  
220 -  
221 -$('.tp-link a').on('touchstart', function() {  
222 - let logType = getTypeName($(this).prop('className'));  
223 -  
224 - if (window._yas && window._yas.sendCustomInfo) {  
225 - window._yas.sendCustomInfo({  
226 - op: 'YB_MY_LOGIN_C',  
227 - param: JSON.stringify({  
228 - C_ID: window._ChannelVary[window.cookie('_Channel')],  
229 - LOGI_TYPE: logType  
230 - })  
231 - }, true);  
232 - }  
233 -});  
1 -require('./register/password');  
1 -require('./register/register');  
1 -/**  
2 - * 注册-密码  
3 - * @author: xuqi<qi.xu@yoho.cn>  
4 - * @date: 2015/10/8  
5 - */  
6 -let $ = require('yoho-jquery');  
7 -  
8 -let $pwd = $('#pwd'),  
9 - $pwdLint = $('.pwd-lint'),  
10 - $pwdLintTxt = $pwdLint.find('.pwd-lint-txt'),  
11 - $btnSure = $('#btn-sure');  
12 -  
13 -let api = require('../api');  
14 -let tip = require('plugin/tip');  
15 -let validatePWD = require('../password-check');  
16 -  
17 -let trim = $.trim;  
18 -let showErrTip = tip.show;  
19 -let qs;  
20 -  
21 -require('common');  
22 -  
23 -api.bindEyesEvt({  
24 - status: 'open' // 默认眼睛打开  
25 -});  
26 -  
27 -$pwd.bind('input', function() {  
28 - let val = $.trim(this.value);  
29 - let bool = validatePWD(val, function(res) {  
30 - $pwdLint.css({visibility: res.valid ? 'hidden' : 'visible'});  
31 -  
32 - if (!res.valid) {  
33 - $pwdLintTxt.text(res.msg);  
34 - }  
35 - });  
36 -  
37 - $btnSure.toggleClass('disable', !bool);  
38 -});  
39 -  
40 -  
41 -qs = window.queryString;  
42 -  
43 -if (qs.selected && qs.selected === 'N') {  
44 - $('.pitch').removeClass('select').html('&#xe647;');  
45 -}  
46 -  
47 -if (qs.pwd) {  
48 - $pwd.val(qs.pwd);  
49 -  
50 - if (trim($pwd.val()) === '') {  
51 - $btnSure.addClass('disable');  
52 - } else {  
53 - $btnSure.removeClass('disable');  
54 - }  
55 -}  
56 -  
57 -$('.pitch').on('click', function() {  
58 - if ($('.pitch').hasClass('select')) {  
59 - $(this).removeClass('select');  
60 - $(this).html('&#xe647;');  
61 - } else {  
62 - $(this).addClass('select');  
63 - $(this).html('&#xe60a;');  
64 - }  
65 -});  
66 -  
67 -function setPassword() {  
68 - $btnSure.addClass('disable');  
69 - return $.ajax({  
70 - type: 'POST',  
71 - url: '/passport/reg/setpassword',  
72 - data: {  
73 - password: trim($pwd.val()),  
74 - phoneNum: $('#phone-num').val(),  
75 - areaCode: $('#area-code').val(),  
76 - smsCode: $('#sms-code').val(),  
77 - token: $('#token').val(),  
78 - inviteCode: $('#invite-code').val()  
79 - },  
80 - success: function(data) {  
81 - let res = data.data;  
82 -  
83 - if (data.code === 200) {  
84 - showErrTip('注册成功');  
85 -  
86 - window.setCookie('refer', res.session);  
87 - window.setCookie('msgDelivery', res.msgDelivery, {expires: 1, path: '/' });  
88 -  
89 - // 统计代码:用于统计从哪个渠道注册成功的  
90 - if (window._yas && window._yas.sendCustomInfo) {  
91 - window._yas.sendCustomInfo({  
92 - op: 'YB_REGISTER_SUCCESS_L',  
93 - ud: window.getUid(),  
94 - param: JSON.stringify({  
95 - C_ID: window._ChannelVary[window.cookie('_Channel')] || 1,  
96 - UNION_TYPE: window.queryString.union_type || window.cookie('unionTypeYas') || false  
97 - })  
98 - }, true);  
99 - }  
100 -  
101 - setTimeout(function() {  
102 - location.href = res.href;  
103 - }, 1500);  
104 - } else {  
105 - $btnSure.removeClass('disable');  
106 - showErrTip(data.message);  
107 - }  
108 - },  
109 - error: function(data) {  
110 - $btnSure.removeClass('disable');  
111 -  
112 - if (data && data.responseJSON && data.responseJSON.message) {  
113 - showErrTip(data.message);  
114 - }  
115 - }  
116 - });  
117 -}  
118 -  
119 -$btnSure.on('touchstart', function() {  
120 - let pwd = trim($pwd.val());  
121 -  
122 - if ($btnSure.hasClass('disable')) {  
123 - return;  
124 - }  
125 -  
126 - if (!validatePWD(pwd)) {  
127 - showErrTip('密码6-20位,请重新输入');  
128 - } else {  
129 - if ($('.pitch').hasClass('select')) {  
130 - setPassword();  
131 -  
132 - } else {  
133 - $('.prompt').show();  
134 -  
135 - $('.ensure').on('click', function() {  
136 - $('.prompt').hide();  
137 - $('.pitch').addClass('select');  
138 - $('.pitch').html('&#xe60a;');  
139 -  
140 - setPassword();  
141 - });  
142 -  
143 - $('.deny').on('click', function() {  
144 - location.href = '//m.yohobuy.com/passport/agreement' + window.location.search + '&pwd=' + pwd;  
145 - });  
146 - }  
147 - }  
148 -});  
149 -  
150 -$('.agreement-detail').on('click', function() {  
151 - $(this).attr('href', '//m.yohobuy.com/passport/agreement' + window.location.search);  
152 -});  
153 -  
154 -  
155 -// 如果有值, 立刻校验  
156 -if ($pwd.val()) {  
157 - $pwd.triggerHandler('input');  
158 -}  
1 -/**  
2 - * 注册  
3 - * @author: xuqi<qi.xu@yoho.cn>  
4 - * @date: 2015/10/8  
5 - */  
6 -let $ = require('yoho-jquery');  
7 -  
8 -let $phoneNum = $('#phone-num'),  
9 - $countrySelect = $('#country-select'),  
10 - $areaCode = $('#area-code'),  
11 - $btnNext = $('#btn-next');  
12 -  
13 -let api = require('../api');  
14 -let tip = require('plugin/tip');  
15 -  
16 -let trim = $.trim;  
17 -let showErrTip = tip.show;  
18 -  
19 -let requested = false;  
20 -  
21 -require('common');  
22 -  
23 -api.selectCssHack($('#country-select'));  
24 -  
25 -api.bindClearEvt();  
26 -  
27 -  
28 -// 图片验证码  
29 -let Validate = require('plugin/validata');  
30 -  
31 -let validate = new Validate('#js-img-check', {  
32 - useREM: {  
33 - rootFontSize: 40,  
34 - picWidth: 150  
35 - }  
36 -});  
37 -  
38 -validate.init();  
39 -  
40 -/**  
41 - * 必填校验  
42 - */  
43 -function checkEnableNext() {  
44 - let phone = trim($phoneNum.val());  
45 - let area = trim($countrySelect.val());  
46 -  
47 - let ret = true;  
48 -  
49 - $.each([phone, area], function(i, val) {  
50 - if (!val) {  
51 - ret = false;  
52 - return ret;  
53 - }  
54 - });  
55 -  
56 - return ret;  
57 -}  
58 -  
59 -/*  
60 - Event bind  
61 -*/  
62 -$('.reg-page')  
63 - .on('input', '.phone-num', function() {  
64 - $btnNext.toggleClass('disable', !checkEnableNext());  
65 - });  
66 -  
67 -$countrySelect.change(function() {  
68 - $areaCode.text($countrySelect.val());  
69 -});  
70 -  
71 -$btnNext.on('touchstart', function() {  
72 - let pn = trim($phoneNum.val()),  
73 - areaCode = $countrySelect.val();  
74 -  
75 - if ($btnNext.hasClass('disable')) {  
76 - return;  
77 - }  
78 - if (requested) {  
79 - return false;  
80 - }  
81 - if (api.phoneRegx[areaCode].test(pn) || areaCode !== '+86') {  
82 - validate.getResults().then((result) => {  
83 - requested = true;  
84 - let params = {  
85 - areaCode: areaCode.replace('+', ''),  
86 - phoneNum: pn,  
87 - inviteCode: $('#invite-code').val()  
88 - };  
89 -  
90 - $.extend(params, result);  
91 -  
92 - $.ajax({  
93 - url: '/passport/reg/verifymobile',  
94 - type: 'POST',  
95 - data: params,  
96 - success: function(data) {  
97 - validate.type === 2 && validate.refresh();  
98 - if (data.code === 200) {  
99 - location.href = data.data.href;  
100 - } else {  
101 - (data.changeCaptcha && validate.type !== 2) && validate.refresh();  
102 -  
103 - showErrTip(data.message);  
104 - requested = false;  
105 - }  
106 - },  
107 - error: function() {  
108 - showErrTip('出错了,请重试');  
109 - validate.refresh();  
110 - requested = false;  
111 - }  
112 - });  
113 - });  
114 - } else {  
115 - showErrTip('手机号格式不正确,请重新输入');  
116 - }  
117 -});  
118 -  
119 -$(function() {  
120 - if (window.queryString.inviteCode) {  
121 - $.ajax({  
122 - type: 'GET',  
123 - url: '/activity/invite-uesr-info',  
124 - data: {  
125 - inviteCode: window.queryString.inviteCode  
126 - },  
127 - success: function(result) {  
128 -  
129 - $('#invite-code').val(result.data.trendWord ? result.data.trendWord : result.data.inviteCode);  
130 - }  
131 - });  
132 - }  
133 -});  
1 -'use strict';  
2 -  
3 -let tip, api, checkPoint;  
4 -  
5 -let $countrySelect,  
6 - $areaCode,  
7 - $nextBtn,  
8 - $resetBtn,  
9 - $phoneNum,  
10 - $mask = $('#retrive-pwd-mask'),  
11 - $ways = $('#retrive-pwd-ways');  
12 -  
13 -let page;  
14 -  
15 -require('common');  
16 -tip = require('plugin/tip');  
17 -api = require('./api');  
18 -checkPoint = require('./smslogin/check-point');  
19 -  
20 -let cookie = require('yoho-cookie');  
21 -  
22 -// 图片验证码  
23 -let Validate = require('plugin/validata');  
24 -  
25 -let validate = new Validate('#js-img-check', {  
26 - useREM: {  
27 - rootFontSize: 40,  
28 - picWidth: 150  
29 - }  
30 -});  
31 -  
32 -validate.init();  
33 -  
34 -require('./login/qr-check');  
35 -  
36 -  
37 -page = {  
38 - init: function() {  
39 - this.domInit();  
40 - this.bindEvent();  
41 - this.toggleNextBtn();  
42 - },  
43 - domInit: function() {  
44 - $countrySelect = $('#country-select');  
45 - $areaCode = $('#area-code');  
46 - $nextBtn = $('#btn-next');  
47 - $phoneNum = $('#phone-num');  
48 - $resetBtn = $('.clear-input');  
49 - },  
50 - bindEvent: function() {  
51 - let self = this;  
52 -  
53 - $countrySelect.on('change', function() {  
54 - $areaCode.text(this.value);  
55 - });  
56 - $phoneNum.on('input', function() {  
57 - self.toggleNextBtn();  
58 - });  
59 -  
60 - $nextBtn.on('click', function() {  
61 - self.goNext();  
62 - });  
63 -  
64 - $resetBtn.on('click', function() {  
65 - $phoneNum.val('');  
66 - $nextBtn  
67 - .prop('disabled', true)  
68 - .toggleClass('disable', true);  
69 - $resetBtn.hide();  
70 - });  
71 - $('#forget-pwd').on('touchstart', () => {  
72 - this.showRetrivePanel();  
73 - });  
74 -  
75 - $mask.on('touchstart', () => {  
76 - this.hideRetrivePanel();  
77 - });  
78 -  
79 - $('#cancel-retrive').on('touchstart', (e) => {  
80 - e.preventDefault();  
81 - this.hideRetrivePanel();  
82 - });  
83 - },  
84 - showRetrivePanel: () => {  
85 - $mask.show();  
86 - $ways.show();  
87 - },  
88 - hideRetrivePanel: () => {  
89 - $mask.hide();  
90 - $ways.hide();  
91 - },  
92 -  
93 - // 切换$nextBtn disable状态  
94 - toggleNextBtn: function() {  
95 - let bool = Boolean($.trim($phoneNum.val()));  
96 -  
97 - $nextBtn  
98 - .toggleClass('disable', !bool)  
99 - .prop('disabled', !bool);  
100 -  
101 - $resetBtn.toggle(bool);  
102 - },  
103 -  
104 - // 提交按钮  
105 - goNext: function() {  
106 - let areaCode = $countrySelect.val();  
107 - let phone = $.trim($phoneNum.val());  
108 -  
109 - if ($nextBtn.prop('disabled')) {  
110 - return;  
111 - }  
112 -  
113 - if (!api.phoneRegx[areaCode].test(phone)) {  
114 - tip.show('手机号码格式不正确, 请重新输入');  
115 - return;  
116 - }  
117 -  
118 - validate.getResults().then((result) => {  
119 - $nextBtn.prop('disabled', true);  
120 - let params = {  
121 - area: areaCode.replace('+', ''),  
122 - mobile: phone  
123 - };  
124 -  
125 - $.extend(params, result);  
126 - $.post('/passport/sms_login/step1_check', params).done(function(data) {  
127 - validate.type === 2 && validate.refresh();  
128 - if (data.code === 200) {  
129 - checkPoint('YB_MOBILE_NEXT_C'); // 埋点  
130 - // $nextBtn.off();  
131 - location.href = data.redirect;  
132 - } else {  
133 - (data.changeCaptcha && validate.type !== 2) && validate.refresh();  
134 - tip.show(data.message);  
135 - }  
136 - })  
137 - .fail(function() {  
138 - validate.refresh();  
139 - tip.show('出错了, 请重试');  
140 - })  
141 - .always(function() {  
142 - $nextBtn.prop('disabled', false);  
143 - });  
144 - });  
145 - }  
146 -};  
147 -  
148 -$(function() {  
149 - page.init();  
150 -});  
151 -  
152 -// 多次登录失败跳短信认证填充手机号  
153 -$('#phone-num').val(cookie.get('_loginJumpUrl'));  
154 -cookie.remove('_loginJumpUrl');