Authored by htoooth

Merge branch 'feature/passport' into feature/back

  1 +/**
  2 +* 注册控制器
  3 +*/
  4 +'use strict';
  5 +const passportHelper = require('../models/passport-helper');
  6 +const regService = require('../models/reg-service');
  7 +const config = require('../../../config/common');
  8 +
  9 +let helpers = global.yoho.helpers;
  10 +
  11 +let index = (req, res, next) => {
  12 + // 设置注册有效时间30分钟, 防机器刷
  13 + req.session._REG_EXPIRE = Date.now() + 1800000;
  14 +
  15 + let refer = req.query.refer;
  16 +
  17 + refer && res.cookie('refer', encodeURI(refer), {
  18 + domain: 'yohobuy.com'
  19 + });
  20 +
  21 + regService.getRegData().then((result) => {
  22 + res.render('reg/index', {
  23 + title: '新用户注册',
  24 + passport: {
  25 + region: passportHelper.getCountry(),
  26 + location: '+86',
  27 + captchaUrl: helpers.urlFormat('/passport/images', {t: Date.now()}),
  28 + itemUrl: helpers.urlFormat('/help/', {category_id: 9}),
  29 + referUrl: refer,
  30 + loginUrl: helpers.urlFormat('/signin.html', {refer: refer}),
  31 + coverHref: result.url,
  32 + coverImg: result.img,
  33 + regBtnText: '立即注册'
  34 + }
  35 + });
  36 + }).catch(next);
  37 +};
  38 +
  39 +let success = (req, res, next) => {
  40 + let goUrl = req.query.next || config.siteUrl;
  41 + let goShoppingUrl = req.query.goShoppingUrl || config.siteUrl;
  42 +
  43 + regService.getRegData().then((result) => {
  44 + res.render('reg/success', {
  45 + title: '注册成功',
  46 + passport: {
  47 + goUrl: goUrl,
  48 + goShoppong: goShoppingUrl,
  49 + coverHref: result.url,
  50 + coverImg: result.img
  51 + }
  52 + });
  53 + }).catch(next);
  54 +};
  55 +
  56 +module.exports = {
  57 + index,
  58 + success
  59 +};
  1 +/**
  2 + * 注册 model
  3 + */
  4 +'use strict';
  5 +const passportHelper = require('./passport-helper');
  6 +
  7 +const REGISTER_LEFT_BANNER_CODE = 'c479ec90120cae7f96e52922b4917064'; // 注册左边的banner
  8 +
  9 +let getRegData = () => {
  10 + return passportHelper.getLeftBannerAsync(REGISTER_LEFT_BANNER_CODE);
  11 +};
  12 +
  13 +module.exports = {
  14 + getRegData
  15 +};
@@ -12,6 +12,7 @@ const login = require(cRoot + '/login'); @@ -12,6 +12,7 @@ const login = require(cRoot + '/login');
12 12
13 const captcha = require(cRoot + '/captcha'); 13 const captcha = require(cRoot + '/captcha');
14 const back = require(cRoot + '/back'); 14 const back = require(cRoot + '/back');
  15 +const reg = require(cRoot + '/reg');
15 16
16 const router = express.Router(); // eslint-disable-line 17 const router = express.Router(); // eslint-disable-line
17 18
@@ -19,6 +20,13 @@ router.get('/autosign/wechat', login.wechat.beforeLogin, login.wechat.login); // @@ -19,6 +20,13 @@ router.get('/autosign/wechat', login.wechat.beforeLogin, login.wechat.login); //
19 router.get('/login/wechat/callback', login.wechat.callback); 20 router.get('/login/wechat/callback', login.wechat.callback);
20 21
21 /** 22 /**
  23 + * 注册页面路由
  24 + */
  25 +router.get('/reg/index', reg.index);
  26 +
  27 +router.get('/reg/success', reg.success);
  28 +
  29 +/**
22 * 找回密码首页信息 30 * 找回密码首页信息
23 */ 31 */
24 // 找回密码首页 32 // 找回密码首页
  1 +<div class="passport-page yoho-page clearfix">
  2 + {{# passport}}
  3 + {{> reg/cover}}
  4 + <div class="content">
  5 + {{> reg/register}}
  6 + </div>
  7 + {{/ passport}}
  8 +</div>
  1 +<div class="passport-page yoho-page clearfix">
  2 + {{# passport}}
  3 + {{> reg/cover}}
  4 + <div class="content">
  5 + <div class="register-page">
  6 + <div class="success-box">
  7 + <div class="success-text">
  8 + <span>恭喜!</span>账号注册成功,&nbsp;<span id="count-down">5</span>&nbsp;&nbsp;秒后将跳转至首页
  9 + </div>
  10 + <a class="success-btn" href="{{goShoppong}}" data-url="{{goUrl}}">随便逛逛</a>
  11 + </div>
  12 + </div>
  13 + </div>
  14 + {{/ passport}}
  15 +</div>
  1 +{{> layout/header}}
  2 +<div class="passport-page yoho-page clearfix">
  3 + {{# passport}}
  4 + {{> passport/cover}}
  5 + <div class="content">
  6 + {{> passport/register}}
  7 + </div>
  8 + {{/ passport}}
  9 +
  10 + <div class="page-tip clearfix">为了给您更好的购物体验, 建议您创建YOHO!Family账号</div>
  11 +
  12 +</div>
  13 +{{> layout/footer}}
  1 +<div class="passport-cover">
  2 + <div class="cover-content">
  3 + {{#if coverHref}}
  4 + <a href="{{coverHref}}" target="_bank">
  5 + <img class="cover-img" src="{{coverImg}}">
  6 + </a>
  7 + {{^}}
  8 + <img class="cover-img" src="{{coverImg}}">
  9 + {{/if}}
  10 + </div>
  11 +</div>
  1 +<div class="register-page">
  2 + <ul>
  3 + <li class="clearfix">
  4 + <select id="region" class="region" name="region">
  5 + {{#each region}}
  6 + <option {{#if selected}}selected="selected"{{/if}} value="{{areaCode}}">{{name}}</option>
  7 + {{/each}}
  8 + </select>
  9 + </li>
  10 + <li class="clearfix" data-index="0">
  11 + <span id="country-code" class="country-code">{{location}}</span>
  12 + <input value="" id="phone-num" class="input va phone-num" type="text" name="phoneNum" placeholder="请输入手机号码" autocomplete="off">
  13 + </li>
  14 + <li class="w330 clearfix" data-index="1">
  15 + <input id="captcha" class="input va captcha" type="text" name="captcha" placeholder="图形验证码" autocomplete="off" maxlength="4">
  16 + <img id="captcha-img" class="captcha-img" src="{{captchaUrl}}" alt="">
  17 + <a class="link change-captcha">换一张</a>
  18 + </li>
  19 + <li class="clearfix" data-index="2">
  20 + <input id="msg-captcha" class="input va msg-captcha" type="text" name="msgCaptcha" placeholder="短信验证码" autocomplete="off" maxlength="4">
  21 + <input id="send-captcha" class="btn send-captcha disable" type="button" value="获取短信验证码">
  22 + <span id="msg-tip" class="hide msg-tip">短信验证码已发送至您的手机,请查收</span>
  23 + </li>
  24 + <li class="clearfix" data-index="3">
  25 + <input id="pwd" class="input va pwd" name="pwd" placeholder="设置密码" autocomplete="off" maxlength="20" type="password">
  26 + <div class="pwd-intensity-container">
  27 + <span class="pwd-intensity low"></span>
  28 + <span class="pwd-intensity mid"></span>
  29 + <span class="pwd-intensity high"></span>
  30 + </div>
  31 + <div id="pwd-tips" class="hide pwd-tips">
  32 + <div class="default" id="pwd-tip1"><i></i>密码只支持6-20位字符</div>
  33 + <div class="default" id="pwd-tip2"><i></i>由字母、 数字组合,不能包含特殊符号</div>
  34 + </div>
  35 + </li>
  36 +
  37 + <li class="items-container clearfix">
  38 + <input id="agree-terms" class="agree-terms" type="checkbox" checked="">
  39 + <span>
  40 + 我已阅读并同意遵守
  41 + <a class="link go-yoho-items" href="{{itemUrl}}" target="_blank">YOHO!BUY 有货服务条款</a>
  42 + </span>
  43 + </li>
  44 + <li class="clearfix">
  45 + <input name="refer" id="refer" type="hidden" value="{{referUrl}}">
  46 + <input id="register-btn" class="btn register-btn disable" type="submit" value="{{regBtnText}}" disabled="">
  47 + </li>
  48 + {{# loginUrl}}
  49 + <li class="quick-login-container">
  50 + 我已注册YOHO!BUY 有货账号
  51 + <a class="link go-login" href="{{.}}">快速登录</a>
  52 + </li>
  53 + {{/loginUrl}}
  54 +
  55 + {{# skipUrl}}
  56 + <li class="skip-user-info">
  57 + <a href="{{.}}">跳过此步</a>
  58 + </li>
  59 + {{/skipUrl}}
  60 +
  61 + </ul>
  62 + <div id="err-tip" class="err-tip hide">
  63 + <span></span>
  64 + <b></b>
  65 + </div>
  66 + <input name="" type="hidden" id="open-id" value="{{openId}}"/>
  67 + <input name="" type="hidden" id="source-type" value="{{sourceType}}"/>
  68 +</div>
@@ -15,7 +15,7 @@ module.exports = { @@ -15,7 +15,7 @@ module.exports = {
15 siteUrl: 'http://www.yohobuy.com', 15 siteUrl: 'http://www.yohobuy.com',
16 domains: { 16 domains: {
17 api: 'http://devapi.yoho.cn:58078/', // devapi.yoho.cn:58078 testapi.yoho.cn:28078 devapi.yoho.cn:58078 17 api: 'http://devapi.yoho.cn:58078/', // devapi.yoho.cn:58078 testapi.yoho.cn:28078 devapi.yoho.cn:58078
18 - service: 'http://devservice.yoho.cn:28077/', // testservice.yoho.cn:28077 devservice.yoho.cn:58077 18 + service: 'http://devservice.yoho.cn:58077/', // testservice.yoho.cn:28077 devservice.yoho.cn:58077
19 search: 'http://192.168.102.216:8080/yohosearch/' 19 search: 'http://192.168.102.216:8080/yohosearch/'
20 }, 20 },
21 useOneapm: false, 21 useOneapm: false,
@@ -77,12 +77,11 @@ if (isProduction) { @@ -77,12 +77,11 @@ if (isProduction) {
77 } else if (isTest) { 77 } else if (isTest) {
78 Object.assign(module.exports, { 78 Object.assign(module.exports, {
79 appName: 'www.yohobuy.com for test', 79 appName: 'www.yohobuy.com for test',
80 -  
81 - // domains: {  
82 - // api: 'http://testapi.yoho.cn:28078/',  
83 - // service: 'http://testservice.yoho.cn:28077/',  
84 - // search: 'http://192.168.102.216:8080/yohosearch/'  
85 - // }, 80 + domains: {
  81 + api: 'http://testapi.yoho.cn:28078/',
  82 + service: 'http://testservice.yoho.cn:28077/',
  83 + search: 'http://192.168.102.216:8080/yohosearch/'
  84 + },
86 useOneapm: true, 85 useOneapm: true,
87 useCache: true, 86 useCache: true,
88 memcache: { 87 memcache: {
@@ -93,6 +93,7 @@ @@ -93,6 +93,7 @@
93 "yoho-handlebars": "^4.0.5", 93 "yoho-handlebars": "^4.0.5",
94 "yoho-jquery": "^1.12.4", 94 "yoho-jquery": "^1.12.4",
95 "yoho-jquery-lazyload": "^1.9.7", 95 "yoho-jquery-lazyload": "^1.9.7",
  96 + "yoho-jquery-placeholder": "0.0.3",
96 "yoho-slider": "0.0.2" 97 "yoho-slider": "0.0.2"
97 } 98 }
98 } 99 }
1 -/**  
2 - * 找回密码  
3 - * @author: xuqi<qi.xu@yoho.cn>  
4 - * @date: 2015/12/14  
5 - */  
6 -  
7 -var $ = require('yoho-jquery'),  
8 - regx = require('./mail-phone-regx'),  
9 - emailReg = regx.emailRegx,  
10 - phoneRegx = regx.phoneRegx;  
11 -  
12 -var emailAc = require('./ac-email'); //邮箱自动完成  
13 -  
14 -var $cr = $('#country-code-hide'),  
15 - $phoneNum = $('#phone-num'),  
16 - $ca = $('#captcha'),  
17 - $ccList = $('#country-code-list'),  
18 - $cc = $('#country-code'),  
19 - $btn = $('#find-btn'),  
20 - $accErr = $('#account-err'),  
21 - $caErr = $('#captcha-err'),  
22 - caCount = 4, //验证码位数  
23 - hasPh = false,  
24 - hasCa = false;  
25 -  
26 -  
27 -require('yoho-jquery-placeholder');  
28 -  
29 -function imgcode() {  
30 - var time = new Date(),  
31 - $captchaImg = $('#captcha-img'),  
32 - captchaImgSrc = $captchaImg.attr('src').split('?')[0];  
33 -  
34 - $('#captcha-img').attr('src', captchaImgSrc + '?t=' + time.getTime());  
35 -}  
36 -  
37 -function enableBtn() {  
38 - if (hasPh && hasCa) {  
39 - $btn.removeClass('disable').prop('disabled', false);  
40 - } else {  
41 - $btn.addClass('disable').prop('disabled', true);  
42 - }  
43 -}  
44 -  
45 -function authcode() {  
46 - if (!hasPh || !hasCa) {  
47 - enableBtn();  
48 - return;  
49 - }  
50 -  
51 - $.ajax({  
52 - type: 'POST',  
53 - url: '/passport/back/authcode',  
54 - data: {  
55 - verifyCode: $.trim($ca.val()),  
56 - phoneNum: $phoneNum.val(),  
57 - area: $cr.val()  
58 - }  
59 -  
60 - }).then(function(data) {  
61 - if (data.code === 200) {  
62 - hasCa = true;  
63 - } else if (data.code === 402) {  
64 - hasPh = false;  
65 - hasCa = true;  
66 - $accErr.removeClass('hide').find('em').text('该账号不存在');  
67 - $phoneNum.addClass('error');  
68 - } else if (data.code === 400) {  
69 - hasCa = false;  
70 - imgcode();  
71 - }  
72 - enableBtn();  
73 - });  
74 -}  
75 -  
76 -function vaPn(v) {  
77 - var pass = true,  
78 - errTxt = '';  
79 -  
80 - v = $.trim(v);  
81 - if (v !== '') {  
82 - if (/^[0-9]+$/.test(v)) {  
83 - if (phoneRegx[$cr.val()].test(v)) {  
84 - pass = true;  
85 - } else {  
86 - errTxt = '手机号码格式不正确, 请重新输入';  
87 - pass = false;  
88 - }  
89 - } else {  
90 - if (emailReg.test(v)) {  
91 - pass = true;  
92 - } else {  
93 - errTxt = '邮箱格式不正确, 请重新输入';  
94 - pass = false;  
95 - }  
96 - }  
97 - } else {  
98 - errTxt = '账户名不能为空';  
99 - pass = false;  
100 - }  
101 - hasPh = pass;  
102 - authcode();  
103 -  
104 - return {  
105 - pass: pass,  
106 - errTxt: errTxt  
107 - };  
108 -}  
109 -  
110 -function vaCa() {  
111 - var v = $.trim($ca.val());  
112 -  
113 - if (v === '' || v.length < caCount) {  
114 - hasCa = false;  
115 - enableBtn();  
116 - return;  
117 - }  
118 -  
119 - hasCa = true;  
120 -  
121 - authcode();  
122 -}  
123 -  
124 -emailAc($phoneNum, function() {  
125 - var pnVa = vaPn($phoneNum.val());  
126 -  
127 - if (pnVa.pass) {  
128 - $accErr.addClass('hide');  
129 - $phoneNum.removeClass('error');  
130 - } else {  
131 - $accErr.removeClass('hide').find('em').text(pnVa.errTxt);  
132 - $phoneNum.addClass('error');  
133 - }  
134 - }  
135 -);  
136 -  
137 -$ca.attr('maxlength', caCount);  
138 -  
139 -//IE8 placeholder  
140 -$('input').placeholder();  
141 -  
142 -$('#change-captcha, #captcha-img').on('click', function() {  
143 - imgcode();  
144 -});  
145 -  
146 -$cc.on('click', function(e) {  
147 - e.stopPropagation();  
148 - if ($ccList.css('style') === 'block') {  
149 - $ccList.slideUp('fast');  
150 - } else {  
151 - $ccList.slideDown('fast');  
152 - }  
153 -});  
154 -  
155 -$ccList.delegate('li', 'click', function(e) {  
156 - var $cur = $(this),  
157 - code = $cur.data('cc'),  
158 - pnVa;  
159 -  
160 - e.stopPropagation();  
161 - $cr.val(code);  
162 - $cc.find('em').html($cur.text());  
163 -  
164 - //切换后验证手机号码  
165 - if ($.trim($phoneNum.val()) !== '') {  
166 - pnVa = vaPn($phoneNum.val());  
167 - enableBtn();  
168 - if (hasPh) {  
169 - $accErr.addClass('hide');  
170 - $phoneNum.removeClass('error');  
171 - } else {  
172 - $accErr.removeClass('hide').text(pnVa.errTxt);  
173 - $phoneNum.addClass('error');  
174 - }  
175 - }  
176 - $ccList.slideUp('fast');  
177 -});  
178 -  
179 -$(document).click(function() {  
180 - if ($ccList.css('display') === 'block') {  
181 - $ccList.slideUp();  
182 - }  
183 -});  
184 -  
185 -$phoneNum.keyup(function() {  
186 - vaPn($.trim($(this).val()));  
187 -}).focus(function() {  
188 - $(this).removeClass('error');  
189 -  
190 - //focus隐藏错误提示  
191 - $accErr.addClass('hide');  
192 -});  
193 -  
194 -//验证码在鼠标移开后验证, keyup时不再验证  
195 -$ca.blur(function() {  
196 - var errTxt = $.trim($ca.val()) === '' ? '验证码不能为空' : '验证码不正确';  
197 -  
198 - if (hasCa) {  
199 - $caErr.addClass('hide');  
200 - $ca.removeClass('error');  
201 - } else {  
202 - $caErr.removeClass('hide').find('em').text(errTxt);  
203 - $ca.addClass('error');  
204 -  
205 - //验证码错误则刷新验证码  
206 - if ($ca.val() < caCount) {  
207 -  
208 - //防止重复刷新验证码  
209 - imgcode();  
210 - }  
211 - }  
212 -}).focus(function() {  
213 - $(this).removeClass('error');  
214 -  
215 - //focus隐藏错误提示  
216 - $caErr.addClass('hide');  
217 -}).keyup(function() {  
218 - vaCa();  
219 -});  
220 -  
221 -$('#find-btn').click(function(e) {  
222 -  
223 - if (/^[0-9]+$/.test($.trim($phoneNum.val()))) {  
224 - $('#find-form').attr('action', '/passport/back/mobile');  
225 - }  
226 - if ($(this).hasClass('disable')) {  
227 - return;  
228 - }  
229 - if (!hasCa || !hasPh) {  
230 - e.preventDefault();  
231 - return true;  
232 - }  
233 -}); 1 +/**
  2 + * 找回密码
  3 + * @author: xuqi<qi.xu@yoho.cn>
  4 + * @date: 2015/12/14
  5 + */
  6 +
  7 +var $ = require('yoho-jquery'),
  8 + regx = require('../common/mail-phone-regx'),
  9 + emailReg = regx.emailRegx,
  10 + phoneRegx = regx.phoneRegx;
  11 +
  12 +var emailAc = require('./ac-email'); // 邮箱自动完成
  13 +
  14 +var $cr = $('#country-code-hide'),
  15 + $phoneNum = $('#phone-num'),
  16 + $ca = $('#captcha'),
  17 + $ccList = $('#country-code-list'),
  18 + $cc = $('#country-code'),
  19 + $btn = $('#find-btn'),
  20 + $accErr = $('#account-err'),
  21 + $caErr = $('#captcha-err'),
  22 + caCount = 4, // 验证码位数
  23 + hasPh = false,
  24 + hasCa = false;
  25 +
  26 +
  27 +require('yoho-jquery-placeholder');
  28 +
  29 +function imgcode() {
  30 + var time = new Date(),
  31 + $captchaImg = $('#captcha-img'),
  32 + captchaImgSrc = $captchaImg.attr('src').split('?')[0];
  33 +
  34 + $('#captcha-img').attr('src', captchaImgSrc + '?t=' + time.getTime());
  35 +}
  36 +
  37 +function enableBtn() {
  38 + if (hasPh && hasCa) {
  39 + $btn.removeClass('disable').prop('disabled', false);
  40 + } else {
  41 + $btn.addClass('disable').prop('disabled', true);
  42 + }
  43 +}
  44 +
  45 +function authcode() {
  46 + if (!hasPh || !hasCa) {
  47 + enableBtn();
  48 + return;
  49 + }
  50 +
  51 + $.ajax({
  52 + type: 'POST',
  53 + url: '/passport/back/authcode',
  54 + data: {
  55 + verifyCode: $.trim($ca.val()),
  56 + phoneNum: $phoneNum.val(),
  57 + area: $cr.val()
  58 + }
  59 +
  60 + }).then(function(data) {
  61 + if (data.code === 200) {
  62 + hasCa = true;
  63 + } else if (data.code === 402) {
  64 + hasPh = false;
  65 + hasCa = true;
  66 + $accErr.removeClass('hide').find('em').text('该账号不存在');
  67 + $phoneNum.addClass('error');
  68 + } else if (data.code === 400) {
  69 + hasCa = false;
  70 + imgcode();
  71 + }
  72 + enableBtn();
  73 + });
  74 +}
  75 +
  76 +function vaPn(v) {
  77 + var pass = true,
  78 + errTxt = '';
  79 +
  80 + v = $.trim(v);
  81 + if (v !== '') {
  82 + if (/^[0-9]+$/.test(v)) {
  83 + if (phoneRegx[$cr.val()].test(v)) {
  84 + pass = true;
  85 + } else {
  86 + errTxt = '手机号码格式不正确, 请重新输入';
  87 + pass = false;
  88 + }
  89 + } else {
  90 + if (emailReg.test(v)) {
  91 + pass = true;
  92 + } else {
  93 + errTxt = '邮箱格式不正确, 请重新输入';
  94 + pass = false;
  95 + }
  96 + }
  97 + } else {
  98 + errTxt = '账户名不能为空';
  99 + pass = false;
  100 + }
  101 + hasPh = pass;
  102 + authcode();
  103 +
  104 + return {
  105 + pass: pass,
  106 + errTxt: errTxt
  107 + };
  108 +}
  109 +
  110 +function vaCa() {
  111 + var v = $.trim($ca.val());
  112 +
  113 + if (v === '' || v.length < caCount) {
  114 + hasCa = false;
  115 + enableBtn();
  116 + return;
  117 + }
  118 +
  119 + hasCa = true;
  120 +
  121 + authcode();
  122 +}
  123 +
  124 +emailAc($phoneNum, function() {
  125 + var pnVa = vaPn($phoneNum.val());
  126 +
  127 + if (pnVa.pass) {
  128 + $accErr.addClass('hide');
  129 + $phoneNum.removeClass('error');
  130 + } else {
  131 + $accErr.removeClass('hide').find('em').text(pnVa.errTxt);
  132 + $phoneNum.addClass('error');
  133 + }
  134 +}
  135 +);
  136 +
  137 +$ca.attr('maxlength', caCount);
  138 +
  139 +// IE8 placeholder
  140 +$('input').placeholder();
  141 +
  142 +$('#change-captcha, #captcha-img').on('click', function() {
  143 + imgcode();
  144 +});
  145 +
  146 +$cc.on('click', function(e) {
  147 + e.stopPropagation();
  148 + if ($ccList.css('style') === 'block') {
  149 + $ccList.slideUp('fast');
  150 + } else {
  151 + $ccList.slideDown('fast');
  152 + }
  153 +});
  154 +
  155 +$ccList.delegate('li', 'click', function(e) {
  156 + var $cur = $(this),
  157 + code = $cur.data('cc'),
  158 + pnVa;
  159 +
  160 + e.stopPropagation();
  161 + $cr.val(code);
  162 + $cc.find('em').html($cur.text());
  163 +
  164 + // 切换后验证手机号码
  165 + if ($.trim($phoneNum.val()) !== '') {
  166 + pnVa = vaPn($phoneNum.val());
  167 + enableBtn();
  168 + if (hasPh) {
  169 + $accErr.addClass('hide');
  170 + $phoneNum.removeClass('error');
  171 + } else {
  172 + $accErr.removeClass('hide').text(pnVa.errTxt);
  173 + $phoneNum.addClass('error');
  174 + }
  175 + }
  176 + $ccList.slideUp('fast');
  177 +});
  178 +
  179 +$(document).click(function() {
  180 + if ($ccList.css('display') === 'block') {
  181 + $ccList.slideUp();
  182 + }
  183 +});
  184 +
  185 +$phoneNum.keyup(function() {
  186 + vaPn($.trim($(this).val()));
  187 +}).focus(function() {
  188 + $(this).removeClass('error');
  189 +
  190 + // focus隐藏错误提示
  191 + $accErr.addClass('hide');
  192 +});
  193 +
  194 +// 验证码在鼠标移开后验证, keyup时不再验证
  195 +$ca.blur(function() {
  196 + var errTxt = $.trim($ca.val()) === '' ? '验证码不能为空' : '验证码不正确';
  197 +
  198 + if (hasCa) {
  199 + $caErr.addClass('hide');
  200 + $ca.removeClass('error');
  201 + } else {
  202 + $caErr.removeClass('hide').find('em').text(errTxt);
  203 + $ca.addClass('error');
  204 +
  205 + // 验证码错误则刷新验证码
  206 + if ($ca.val() < caCount) {
  207 +
  208 + // 防止重复刷新验证码
  209 + imgcode();
  210 + }
  211 + }
  212 +}).focus(function() {
  213 + $(this).removeClass('error');
  214 +
  215 + // focus隐藏错误提示
  216 + $caErr.addClass('hide');
  217 +}).keyup(function() {
  218 + vaCa();
  219 +});
  220 +
  221 +$('#find-btn').click(function(e) {
  222 +
  223 + if (/^[0-9]+$/.test($.trim($phoneNum.val()))) {
  224 + $('#find-form').attr('action', '/passport/back/mobile');
  225 + }
  226 + if ($(this).hasClass('disable')) {
  227 + return;
  228 + }
  229 + if (!hasCa || !hasPh) {
  230 + e.preventDefault();
  231 + return true;
  232 + }
  233 +});
@@ -19,7 +19,7 @@ var $pwdIntensity = $('.pwd-intensity'), @@ -19,7 +19,7 @@ var $pwdIntensity = $('.pwd-intensity'),
19 $pwdParent = $pwdIntensity.closest('.pwd-intensity-container'), 19 $pwdParent = $pwdIntensity.closest('.pwd-intensity-container'),
20 $pwdTip1 = $('#pwd-tip1'); 20 $pwdTip1 = $('#pwd-tip1');
21 21
22 -var pwdRegx = require('./mail-phone-regx').pwdValidateRegx; 22 +var pwdRegx = require('../common/mail-phone-regx').pwdValidateRegx;
23 23
24 require('yoho-jquery-placeholder'); 24 require('yoho-jquery-placeholder');
25 25
@@ -95,7 +95,7 @@ function pwdKeyupEvt() { @@ -95,7 +95,7 @@ function pwdKeyupEvt() {
95 pwdStrength = computeComplex(pwd), 95 pwdStrength = computeComplex(pwd),
96 level = 0; 96 level = 0;
97 97
98 - //TODO:自定义密码强度规则,需要修正 98 + // TODO:自定义密码强度规则,需要修正
99 if (pwdStrength === 0) { 99 if (pwdStrength === 0) {
100 level = 0; 100 level = 0;
101 } else if (pwdStrength <= 10) { 101 } else if (pwdStrength <= 10) {
@@ -126,7 +126,7 @@ function pwdKeyupEvt() { @@ -126,7 +126,7 @@ function pwdKeyupEvt() {
126 break; 126 break;
127 } 127 }
128 128
129 - //提示框 129 + // 提示框
130 if (pwd === '') { 130 if (pwd === '') {
131 $pwdTip1.removeClass('red yes no').addClass('default'); 131 $pwdTip1.removeClass('red yes no').addClass('default');
132 } else if (pwd.length < 6 || pwd.length > 20) { 132 } else if (pwd.length < 6 || pwd.length > 20) {
@@ -142,7 +142,7 @@ function pwdKeyupEvt() { @@ -142,7 +142,7 @@ function pwdKeyupEvt() {
142 } 142 }
143 } 143 }
144 144
145 -//IE8 placeholder 145 +// IE8 placeholder
146 $('input').placeholder(); 146 $('input').placeholder();
147 147
148 $('.va').keyup(function() { 148 $('.va').keyup(function() {
@@ -208,7 +208,7 @@ $('.va').keyup(function() { @@ -208,7 +208,7 @@ $('.va').keyup(function() {
208 }).focus(function() { 208 }).focus(function() {
209 $(this).removeClass('error'); 209 $(this).removeClass('error');
210 210
211 - //focus后错误提示隐藏 211 + // focus后错误提示隐藏
212 if ($(this).hasClass('pwd')) { 212 if ($(this).hasClass('pwd')) {
213 $pwdErr.addClass('hide'); 213 $pwdErr.addClass('hide');
214 } else { 214 } else {
@@ -226,7 +226,7 @@ $pwd.focus(function() { @@ -226,7 +226,7 @@ $pwd.focus(function() {
226 $('#pwd, #repwd').keydown(function(e) { 226 $('#pwd, #repwd').keydown(function(e) {
227 var code = e.keyCode || e.which; 227 var code = e.keyCode || e.which;
228 228
229 - //空格输入过滤 229 + // 空格输入过滤
230 if (code === 32) { 230 if (code === 32) {
231 e.preventDefault(); 231 e.preventDefault();
232 return; 232 return;
  1 +var reg = require('./reg/reg');
  2 +
  3 +reg.init();
  1 +/*
  2 + * @description 注册页js
  3 + * @time 2015/12/14
  4 + */
  5 +
  6 +var $ = require('yoho-jquery'),
  7 + regValidate = require('../common/mail-phone-regx'),
  8 + computeComplex = require('../common/pwd-strength');
  9 +
  10 +var $registerPage = $('.register-page'),
  11 + $pwdTips = $('#pwd-tips'),
  12 + $pwdTip1 = $pwdTips.find('#pwd-tip1'),
  13 + $errTip = $('#err-tip'),
  14 + $registerBtn = $('#register-btn'),
  15 + $countDown = $('#count-down'),
  16 + $successBtn = $('.success-btn'),
  17 + countDown = 5,
  18 + clearT;
  19 +
  20 +var $sendCaptcha = $('#send-captcha'),
  21 + caCount = 4,
  22 + validateResult = [];
  23 +
  24 +var $pn = $('#phone-num'),
  25 + $mc = $('#msg-captcha'),
  26 + $pwd = $('#pwd'),
  27 + $repwd = $('#repwd'),
  28 + $ca = $('#captcha'),
  29 + timeResidue = 0;
  30 +
  31 +// 密码强度验证
  32 +var $pwdIntensity = $('.pwd-intensity'),
  33 + $pwdParent = $pwdIntensity.closest('.pwd-intensity-container');
  34 +
  35 +// signup验证
  36 +var $region = $('#country-code'),
  37 + $regionSelect = $('#region');
  38 +
  39 +var isPwd = false,
  40 + pwdVal;
  41 +
  42 +var pwdReg = regValidate.pwdValidateRegx;
  43 +
  44 +var $curErrContainer;
  45 +
  46 +var oldPhone = ''; // 如果手机号改变时刷新验证码
  47 +
  48 +require('yoho-jquery-placeholder');
  49 +
  50 +setTimeout(function() {
  51 + $pn.val('');
  52 + $mc.val('');
  53 + $pwd.val('');
  54 + $repwd.val('');
  55 + $ca.val('');
  56 +}, 0);
  57 +
  58 +// 验证码位数
  59 +$ca.attr('maxlength', caCount);
  60 +
  61 +// 密码规则提示
  62 +$pwd.focus(function() {
  63 + $pwdTips.removeClass('hide');
  64 + isPwd = true;
  65 + pwdVal = $(this).val();
  66 +}).blur(function() {
  67 + $pwdTips.addClass('hide');
  68 + isPwd = false;
  69 +});
  70 +
  71 +
  72 +// IE8 placeholder
  73 +$('[placeholder]').placeholder();
  74 +
  75 +// 存储校验信息
  76 +validateResult = [
  77 + {
  78 + id: 'phone-num',
  79 + message: '', // 错误信息
  80 + status: false // 当前的状态
  81 + },
  82 + {
  83 + id: 'captcha',
  84 + message: '',
  85 + status: false
  86 + },
  87 + {
  88 + id: 'msg-captcha',
  89 + message: '',
  90 + status: false
  91 + },
  92 + {
  93 + id: 'pwd',
  94 + message: '',
  95 + status: false
  96 + },
  97 + {
  98 + id: 'repwd',
  99 + message: '',
  100 + status: false
  101 + }
  102 +];
  103 +
  104 +// 刷新图形验证码
  105 +function refreshPic() {
  106 + var time = new Date(),
  107 + $captchaImg = $('.captcha-img'),
  108 + captchaImgSrc = $captchaImg.attr('src').split('?')[0];
  109 +
  110 + $captchaImg.attr('src', captchaImgSrc + '?t=' + time.getTime());
  111 +}
  112 +
  113 +// 手机号ajax校验
  114 +function phoneAjaxFn(page, callback) {
  115 + var url,
  116 + data;
  117 +
  118 + if (page === 'reg') {
  119 + url = '/passport/register/checkmobile';
  120 + data = {
  121 + mobile: $pn.val(),
  122 + area: $region.text().split('+')[1]
  123 + };
  124 + } else if (page === 'third') {
  125 + url = '/passport/autouserinfo/bindCheck';
  126 + data = {
  127 + mobile: $pn.val(),
  128 + area: $region.text().split('+')[1],
  129 + openId: $('#open-id').val(),
  130 + sourceType: $('#source-type').val()
  131 + };
  132 + }
  133 +
  134 + validateResult[0].message = 'err';
  135 + validateResult[0].status = false;
  136 +
  137 + $.ajax({
  138 + url: url,
  139 + type: 'POST',
  140 + data: data
  141 + }).then(function(res) {
  142 + if (!res) {
  143 + return;
  144 + }
  145 +
  146 + switch (res.code) {
  147 + case 200:
  148 +
  149 + if ($pn.val() !== oldPhone && oldPhone !== '') {
  150 +
  151 + // 如果手机号发生改变则刷新验证码并且更新状态
  152 + refreshPic();
  153 + $sendCaptcha.addClass('disable').attr('disabled', 'disabled');
  154 + validateResult[1].message = '图形验证码错误';
  155 + validateResult[1].status = false;
  156 + }
  157 +
  158 + oldPhone = $pn.val();
  159 +
  160 + validateResult[0].message = '';
  161 + validateResult[0].status = true;
  162 + break;
  163 + case 400:
  164 + refreshPic();
  165 + validateResult[0].message = res.message;
  166 + validateResult[0].status = false;
  167 + break;
  168 + default:
  169 + break;
  170 + }
  171 +
  172 + callback();
  173 + });
  174 +}
  175 +
  176 +// 图形验证码ajax校验
  177 +function picCaptchaAjaxFn(page, callback) {
  178 + var url;
  179 +
  180 + if (page === 'reg') {
  181 + url = '/passport/register/piccaptcha';
  182 + } else if (page === 'third') {
  183 + url = '/passport/autouserinfo/checkPicCode';
  184 + }
  185 + $.ajax({
  186 + type: 'POST',
  187 + url: url,
  188 + data: {
  189 + verifyCode: $ca.val()
  190 +
  191 + // mobile: $pn.val(),
  192 + // area: $region.text().split('+')[1]
  193 + }
  194 + }).then(function(data) {
  195 + if (!data) {
  196 + return;
  197 + }
  198 +
  199 + switch (data.code) {
  200 + case 200:
  201 + validateResult[1].message = '';
  202 + validateResult[1].status = true;
  203 + break;
  204 + case 400:
  205 + refreshPic();
  206 + validateResult[1].message = '图形验证码错误';
  207 + validateResult[1].status = false;
  208 + break;
  209 + default:
  210 + break;
  211 + }
  212 + callback();
  213 + });
  214 +}
  215 +
  216 +// 短信验证码ajax校验
  217 +function msgCaptchaAjaxFn(page, callback) {
  218 + var url;
  219 +
  220 + if (page === 'reg') {
  221 + url = '/passport/register/msgcaptcha';
  222 + } else if (page === 'third') {
  223 + url = '/passport/autouserinfo/checkBindMsg';
  224 + }
  225 + $.ajax({
  226 + type: 'POST',
  227 + url: url,
  228 + data: {
  229 + code: $mc.val(),
  230 + mobile: $pn.val(),
  231 + area: $region.text().split('+')[1]
  232 + }
  233 + }).then(function(data) {
  234 + if (!data) {
  235 + return;
  236 + }
  237 +
  238 + switch (data.code) {
  239 + case 200:
  240 + validateResult[2].message = '';
  241 + validateResult[2].status = true;
  242 + break;
  243 + case 400:
  244 + validateResult[2].message = '短信验证码错误';
  245 + validateResult[2].status = false;
  246 + break;
  247 + default:
  248 + break;
  249 + }
  250 +
  251 + callback();
  252 + });
  253 +}
  254 +
  255 +// 验证
  256 +function validateRule(page, $element, callback) {
  257 +
  258 + var val = $.trim($element.val()),
  259 + regionCode;
  260 +
  261 +
  262 +
  263 + // 根据需求http://redmine.yoho.cn/issues/3117改成上边的正则
  264 + // 对应的错误提示语也改了,感觉要不了多久就会改回来
  265 + // pwdReg = /^([a-zA-Z0-9\-\+_!@\#$%\^&\*\(\)\:\;\.=\[\]\\\',\?]){6,20}$/gi;
  266 +
  267 + // 手机号校验
  268 + if ($element.hasClass('phone-num')) {
  269 +
  270 + regionCode = $region.text();
  271 +
  272 +
  273 + if (val === '') {
  274 + validateResult[0].message = '请输入手机号码';
  275 + validateResult[0].status = false;
  276 + return callback();
  277 +
  278 + } else {
  279 + if (!/^[0-9]+$/.test(val) ||
  280 + (regionCode === '+86' && !regValidate.phoneRegx[regionCode].test(val))) {
  281 + validateResult[0].message = '手机号码格式不正确,请重新输入';
  282 + validateResult[0].status = false;
  283 + return callback();
  284 + } else {
  285 + phoneAjaxFn(page, callback);
  286 + }
  287 + }
  288 +
  289 + // 图形验证码校验
  290 + } else if ($element.hasClass('captcha')) {
  291 + if (val === '') {
  292 + validateResult[1].message = '请输入图形验证码';
  293 + validateResult[1].status = false;
  294 + return callback();
  295 +
  296 + } else if (val.length <= 3) {
  297 + validateResult[1].message = '图形验证码为4位';
  298 + validateResult[1].status = false;
  299 + return callback();
  300 +
  301 + } else {
  302 +
  303 + // 并且手机号正确
  304 + if (validateResult[0].status) {
  305 + picCaptchaAjaxFn(page, callback);
  306 + } else {
  307 + validateResult[1].message = '图形验证码错误';
  308 + validateResult[1].status = false;
  309 + return callback();
  310 + }
  311 +
  312 + }
  313 +
  314 + // 短信验证码校验
  315 + } else if ($element.hasClass('msg-captcha')) {
  316 +
  317 + if (val === '') {
  318 + validateResult[2].message = '请输入短信验证码';
  319 + validateResult[2].status = false;
  320 + return callback();
  321 +
  322 + } else if (val.length <= 3) {
  323 + validateResult[2].message = '短信验证码错误';
  324 + validateResult[2].status = false;
  325 + return callback();
  326 +
  327 + } else {
  328 +
  329 + // 并且图形验证码正确
  330 + if (validateResult[1].status) {
  331 + msgCaptchaAjaxFn(page, callback);
  332 + } else {
  333 + validateResult[2].message = '短信验证码错误';
  334 + validateResult[2].status = false;
  335 + return callback();
  336 + }
  337 + }
  338 +
  339 + // 密码校验
  340 + } else if ($element.hasClass('pwd')) {
  341 + if (val === '') {
  342 + validateResult[3].message = '请输入密码';
  343 + validateResult[3].status = false;
  344 +
  345 + } else if (val.length < 6 || val.length > 20) {
  346 + validateResult[3].message = '密码只支持6-20位字符';
  347 + validateResult[3].status = false;
  348 +
  349 + } else if (!pwdReg.test($element.val())) {
  350 + validateResult[3].message = '密码须字母和数字组合';
  351 + validateResult[3].status = false;
  352 +
  353 + } else {
  354 + validateResult[3].message = '';
  355 + validateResult[3].status = true;
  356 + }
  357 + return callback();
  358 +
  359 + // 二次密码校验
  360 + } else if ($element.hasClass('repwd')) {
  361 + if (val === '') {
  362 + validateResult[4].message = '请输入密码确认';
  363 + validateResult[4].status = false;
  364 +
  365 + } else if ($pwd.val() !== val) {
  366 + validateResult[4].message = '与密码不一致,请重新输入';
  367 + validateResult[4].status = false;
  368 +
  369 + } else {
  370 + validateResult[4].message = '';
  371 + validateResult[4].status = true;
  372 +
  373 + }
  374 +
  375 + return callback();
  376 + }
  377 +}
  378 +
  379 +function posErrTip() {
  380 + var tipPos = $curErrContainer.offset();
  381 +
  382 + return $errTip.css({
  383 + top: tipPos.top - 40,
  384 + left: tipPos.left
  385 + });
  386 +}
  387 +
  388 +// 显示提示信息
  389 +function showErrTip() {
  390 +
  391 + var show = false,
  392 + i,
  393 + validateResultLen = validateResult.length;
  394 +
  395 + for (i = 0; i < validateResultLen; i++) {
  396 + if (!show) {
  397 +
  398 + // 不可以通过status判断
  399 + if (!!validateResult[i].message && validateResult[i].message !== 'err') {
  400 +
  401 + // 显示错误提示
  402 + $errTip.find('span').text(validateResult[i].message);
  403 + $curErrContainer = $('#' + validateResult[i].id);
  404 + posErrTip().removeClass('hide');
  405 +
  406 + show = true; // 停止判断
  407 + } else {
  408 + $errTip.addClass('hide');
  409 + }
  410 + }
  411 + }
  412 +}
  413 +
  414 +// 显示红色边框
  415 +function showBorder() {
  416 +
  417 + var $errInput,
  418 + i,
  419 + validateResultLen = validateResult.length;
  420 +
  421 + for (i = 0; i < validateResultLen; i++) {
  422 + if (validateResult[i].message) {
  423 +
  424 + // 显示红色边框
  425 + $errInput = $('#' + validateResult[i].id);
  426 + $errInput.addClass('error');
  427 +
  428 + } else {
  429 +
  430 + // 去掉红色边框
  431 + $errInput = $('#' + validateResult[i].id);
  432 + $errInput.removeClass('error');
  433 + }
  434 + }
  435 +}
  436 +
  437 +// 密码强度验证
  438 +function pwdFn($obj) {
  439 + var pwd = $obj.val(),
  440 + pwdStrength = computeComplex(pwd),
  441 + level = 0;
  442 +
  443 + if (pwdStrength === 0) {
  444 + level = 0;
  445 + } else if (pwdStrength <= 10) {
  446 + level = 1;
  447 + } else if (pwdStrength <= 20) {
  448 + level = 2;
  449 + } else {
  450 + level = 3;
  451 + }
  452 +
  453 + switch (level) {
  454 + case 0:
  455 + $pwdParent.removeClass('red yellow green');
  456 + $pwdIntensity.removeClass('color');
  457 + break;
  458 + case 1:
  459 + $pwdParent.addClass('red').removeClass('yellow green');
  460 + $pwdIntensity.filter('.low').addClass('color');
  461 + $pwdIntensity.filter('.mid,.high').removeClass('color');
  462 + break;
  463 + case 2:
  464 + $pwdParent.addClass('yellow').removeClass('red green');
  465 + $pwdIntensity.filter('.low,.mid').addClass('color');
  466 + $pwdIntensity.filter('.high').removeClass('color');
  467 + break;
  468 + case 3:
  469 + $pwdParent.addClass('green').removeClass('yellow red');
  470 + $pwdIntensity.addClass('color');
  471 + break;
  472 + default:
  473 + break;
  474 + }
  475 +
  476 + // 提示框
  477 + if (pwd === '') {
  478 + $pwdTip1.removeClass('red yes no').addClass('default');
  479 + } else if (pwd.length < 6 || pwd.length > 20) {
  480 + $pwdTip1.removeClass('default yes').addClass('no red');
  481 + } else {
  482 + $pwdTip1.removeClass('default no red').addClass('yes');
  483 + }
  484 +}
  485 +
  486 +// 重新定位错误提示
  487 +$(window).resize(function() {
  488 + if ($errTip.hasClass('hide')) {
  489 + return;
  490 + }
  491 +
  492 + posErrTip();
  493 +});
  494 +
  495 +// 失去焦点时开始校验
  496 +// Tips: 不可以在获得焦点的时候验证,获得焦点和失去焦点的间隔太小,如果中间存在ajax校验的话会出现问题
  497 +// ( ▼-▼ )注册页和信息完善页面接口不同
  498 +exports.init = function(page) {
  499 +
  500 + $('#agree-terms').click(function() {
  501 +
  502 + var $this = $(this),
  503 + i,
  504 + passI = 0;
  505 +
  506 + if ($this.attr('notchecked')) {
  507 +
  508 + $this.removeAttr('notchecked');
  509 +
  510 + // 勾选
  511 + for (i = 0; i < validateResult.length; i++) {
  512 + if (validateResult[i].status) {
  513 + passI++;
  514 + }
  515 + }
  516 + if (passI === 4) {
  517 + $registerBtn.removeClass('disable').removeAttr('disabled');
  518 + }
  519 + } else {
  520 +
  521 + // 取消勾选
  522 + $registerBtn.addClass('disable').attr('disabled', 'disabled');
  523 + $this.attr('notchecked', 'notchecked');
  524 + }
  525 + });
  526 +
  527 + // 按回车键提交
  528 + $registerPage.on('keydown', function(e) {
  529 + var key = e.which;
  530 +
  531 + if (key === 13) {
  532 + $registerBtn.click();
  533 + }
  534 + });
  535 +
  536 + $registerPage.find('.va').keyup(function() {
  537 +
  538 + var j,
  539 + statusLen = 0,
  540 + vLen = validateResult.length,
  541 + $that = $(this);
  542 +
  543 + validateRule(page, $(this), function() {
  544 + showErrTip(); // 显示错误提示
  545 + showBorder(); // 显示红色边框
  546 +
  547 + // 如果validateResult中有4个status为true表示验证通过
  548 + for (j = 0; j < vLen; j++) {
  549 +
  550 + if (validateResult[j].status) {
  551 +
  552 + statusLen++;
  553 + }
  554 +
  555 + }
  556 +
  557 + if (statusLen === 4 && !$('#agree-terms').attr('notchecked')) {
  558 + $registerBtn.removeClass('disable').removeAttr('disabled');
  559 + } else {
  560 + $registerBtn.addClass('disable').attr('disabled', 'disabled');
  561 + }
  562 +
  563 + // 图形验证通过时,发送短信按钮可点击
  564 + if (validateResult[1].status && timeResidue <= 0) {
  565 + $sendCaptcha.removeClass('disable').removeAttr('disabled');
  566 + } else {
  567 + $sendCaptcha.addClass('disable').attr('disabled', 'disabled');
  568 + }
  569 +
  570 + // 图形验证通过时,发送短信按钮可点击 end
  571 +
  572 + });
  573 +
  574 + // 如果是密码则校验强度
  575 + if (($that).hasClass('pwd')) {
  576 + pwdFn($that);
  577 + }
  578 +
  579 + }).blur(function() {
  580 +
  581 + /* validateRule($(this), function() {
  582 + showErrTip();
  583 + showBorder(); // 显示红色边框
  584 + });*/
  585 + });
  586 +
  587 + $regionSelect.change(function() {
  588 +
  589 + $region.text($('#region').val());
  590 +
  591 + validateRule(page, $pn, showErrTip); // 验证
  592 + });
  593 +
  594 + // 点击发送验证码
  595 + $sendCaptcha.click(function() {
  596 + var t,
  597 + url;
  598 +
  599 + if ($(this).hasClass('disable')) {
  600 + return;
  601 + }
  602 +
  603 + timeResidue = 60;
  604 +
  605 + $('#msg-tip').removeClass('hide');
  606 +
  607 + $sendCaptcha.addClass('disable').attr('disabled', 'disabled');
  608 + $sendCaptcha.val('60秒可重新发送');
  609 +
  610 + t = setInterval(function() {
  611 + if (timeResidue <= 0) {
  612 + $sendCaptcha.removeClass('disable').removeAttr('disabled').val('获取短信验证码');
  613 + clearInterval(t);
  614 + return;
  615 + }
  616 + $sendCaptcha.val(timeResidue-- + '秒可重新发送');
  617 + }, 1000);
  618 +
  619 + if (page === 'reg') {
  620 + url = '/passport/register/sendBindMsg';
  621 + } else if (page === 'third') {
  622 + url = '/passport/autouserinfo/sendBindMsg';
  623 + }
  624 +
  625 + // todo ajax 发送验证码
  626 + $.ajax({
  627 + type: 'POST',
  628 + url: url,
  629 + data: {
  630 + area: $region.text().split('+')[1],
  631 + mobile: $pn.val(),
  632 + verifyCode: $ca.val()
  633 + }
  634 + });
  635 + });
  636 +
  637 + // 防止粘贴密码
  638 + if ($('.success-box').length <= 0) {
  639 + $pwd[0].onpaste = function() {
  640 + return false;
  641 + };
  642 + }
  643 +
  644 + // ajax表单提交
  645 + $registerBtn.click(function() {
  646 + var url;
  647 +
  648 + if (page === 'reg') {
  649 + url = '/passport/register/mobileregister';
  650 + } else if (page === 'third') {
  651 + url = '/passport/autouserinfo/bindMobile';
  652 + }
  653 +
  654 + if ($(this).hasClass('disable')) {
  655 + return;
  656 + } else {
  657 +
  658 + // ajax提交
  659 + $.ajax({
  660 + type: 'POST',
  661 + url: url,
  662 + data: {
  663 + area: $region.text().split('+')[1],
  664 + mobile: $pn.val(),
  665 + verifyCode: $ca.val(),
  666 + code: $mc.val(),
  667 + password: $pwd.val()
  668 + }
  669 + }).then(function(data) {
  670 +
  671 + var time = 0,
  672 + t,
  673 + refer;
  674 +
  675 + if (data.code === 200) {
  676 +
  677 + refer = data.data.href;
  678 +
  679 + t = setTimeout(function() {
  680 + time++;
  681 + }, 1000);
  682 +
  683 + $.ajax({
  684 + type: 'GET',
  685 + url: data.data.session
  686 + }).then(function(res) {
  687 +
  688 + if (res.code === 200 && t < 3) {
  689 + clearInterval(t);
  690 + location.href = refer;
  691 + }
  692 + });
  693 +
  694 + if (t >= 3) {
  695 + clearInterval(t);
  696 + location.href = refer;
  697 + }
  698 + } else {
  699 +
  700 + // todo
  701 + console.log('网络超时~');
  702 + }
  703 +
  704 + });
  705 + }
  706 + });
  707 +
  708 + $('.change-captcha').click(function() {
  709 + refreshPic();
  710 + });
  711 +
  712 + // 注册成功页面5秒后跳转
  713 + if ($('.success-box').length > 0) {
  714 + clearT = setInterval(function() {
  715 +
  716 + if (countDown === 0) {
  717 +
  718 + window.location.href = $successBtn.attr('data-url');
  719 +
  720 + clearInterval(clearT);
  721 + }
  722 + $countDown.text(countDown--);
  723 + }, 1000);
  724 + }
  725 +};
@@ -15,6 +15,7 @@ @@ -15,6 +15,7 @@
15 float: right; 15 float: right;
16 cursor: pointer; 16 cursor: pointer;
17 color: #b9b9b9; 17 color: #b9b9b9;
  18 +
18 .iconfont { 19 .iconfont {
19 font-size: 14px; 20 font-size: 14px;
20 vertical-align: middle; 21 vertical-align: middle;
@@ -28,8 +29,9 @@ @@ -28,8 +29,9 @@
28 font-size: 22px; 29 font-size: 22px;
29 line-height: 40px; 30 line-height: 40px;
30 color: #000; 31 color: #000;
31 - font-weight: normal; 32 + font-weight: normal;
32 } 33 }
  34 +
33 .title2 { 35 .title2 {
34 margin: 0 0 5px; 36 margin: 0 0 5px;
35 font-size: 22px; 37 font-size: 22px;
@@ -90,6 +92,7 @@ @@ -90,6 +92,7 @@
90 outline: none; 92 outline: none;
91 cursor: pointer; 93 cursor: pointer;
92 } 94 }
  95 +
93 .change-captcha { 96 .change-captcha {
94 color: #ff1901; 97 color: #ff1901;
95 font-size: 12px; 98 font-size: 12px;
@@ -140,7 +143,7 @@ @@ -140,7 +143,7 @@
140 } 143 }
141 } 144 }
142 145
143 -.verification-page .content{ 146 +.verification-page .content {
144 li { 147 li {
145 position: relative; 148 position: relative;
146 margin-bottom: 43px; 149 margin-bottom: 43px;
@@ -165,7 +168,8 @@ @@ -165,7 +168,8 @@
165 margin: 0 10px; 168 margin: 0 10px;
166 } 169 }
167 170
168 - .country-code, .phone-num { 171 + .country-code,
  172 + .phone-num {
169 color: #000; 173 color: #000;
170 font-size: 16px; 174 font-size: 16px;
171 } 175 }
@@ -192,7 +196,7 @@ @@ -192,7 +196,7 @@
192 color: #a5a4a4; 196 color: #a5a4a4;
193 197
194 .iconfont { 198 .iconfont {
195 - color: #0F9ACD; 199 + color: #0f9acd;
196 font-size: 14px; 200 font-size: 14px;
197 margin: 0 8px 0 0; 201 margin: 0 8px 0 0;
198 vertical-align: 12%; 202 vertical-align: 12%;
@@ -235,4 +239,4 @@ @@ -235,4 +239,4 @@
235 text-align: center; 239 text-align: center;
236 background-color: #ff1901; 240 background-color: #ff1901;
237 } 241 }
238 -}  
  242 +}
@@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
18 border: 1px solid #dbdbdb; 18 border: 1px solid #dbdbdb;
19 text-indent: 10px; 19 text-indent: 10px;
20 color: #9a9a9a; 20 color: #9a9a9a;
21 - color: rgba(0,0,0,.5); 21 + color: rgba(0, 0, 0, .5);
22 } 22 }
23 23
24 .error { 24 .error {
@@ -52,6 +52,7 @@ @@ -52,6 +52,7 @@
52 .pwd-intensity { 52 .pwd-intensity {
53 color: #ee0011; 53 color: #ee0011;
54 } 54 }
  55 +
55 .color { 56 .color {
56 background: #ee0011; 57 background: #ee0011;
57 color: #fff; 58 color: #fff;
@@ -62,6 +63,7 @@ @@ -62,6 +63,7 @@
62 .pwd-intensity { 63 .pwd-intensity {
63 color: #f6da1e; 64 color: #f6da1e;
64 } 65 }
  66 +
65 .color { 67 .color {
66 background: #f6da1e; 68 background: #f6da1e;
67 color: #fff; 69 color: #fff;
@@ -72,11 +74,13 @@ @@ -72,11 +74,13 @@
72 .pwd-intensity { 74 .pwd-intensity {
73 color: #3ee392; 75 color: #3ee392;
74 } 76 }
  77 +
75 .color { 78 .color {
76 background: #3ee392; 79 background: #3ee392;
77 color: #fff; 80 color: #fff;
78 } 81 }
79 } 82 }
  83 +
80 .pwd-intensity { 84 .pwd-intensity {
81 height: 15px; 85 height: 15px;
82 font-size: 12px; 86 font-size: 12px;
@@ -164,7 +168,6 @@ @@ -164,7 +168,6 @@
164 height: 14px; 168 height: 14px;
165 width: 14px; 169 width: 14px;
166 background: url(/passport/tip/error.png) no-repeat; 170 background: url(/passport/tip/error.png) no-repeat;
167 -  
168 margin-right: 5px; 171 margin-right: 5px;
169 } 172 }
170 173
@@ -209,7 +212,6 @@ @@ -209,7 +212,6 @@
209 margin-top: 50px; 212 margin-top: 50px;
210 } 213 }
211 } 214 }
212 -  
213 @import "login"; 215 @import "login";
214 @import "register"; 216 @import "register";
215 @import "back"; 217 @import "back";
@@ -30,7 +30,6 @@ @@ -30,7 +30,6 @@
30 top: 20px; 30 top: 20px;
31 right: 0; 31 right: 0;
32 z-index: 1; 32 z-index: 1;
33 -  
34 border-radius: 5px; 33 border-radius: 5px;
35 34
36 li { 35 li {
@@ -49,7 +48,7 @@ @@ -49,7 +48,7 @@
49 } 48 }
50 49
51 /* 验证码 */ 50 /* 验证码 */
52 - .captcha{ 51 + .captcha {
53 width: 160px; 52 width: 160px;
54 float: left; 53 float: left;
55 } 54 }
@@ -11,7 +11,8 @@ @@ -11,7 +11,8 @@
11 width: 330px; 11 width: 330px;
12 } 12 }
13 13
14 - input, select { 14 + input,
  15 + select {
15 outline: none; 16 outline: none;
16 } 17 }
17 18
@@ -38,7 +39,8 @@ @@ -38,7 +39,8 @@
38 right: 0; 39 right: 0;
39 } 40 }
40 41
41 - &.captcha, &.msg-captcha{ 42 + &.captcha,
  43 + &.msg-captcha {
42 width: 160px; 44 width: 160px;
43 float: left; 45 float: left;
44 } 46 }
@@ -114,6 +116,7 @@ @@ -114,6 +116,7 @@
114 margin-top: 4px; 116 margin-top: 4px;
115 float: left; 117 float: left;
116 } 118 }
  119 +
117 .change-captcha { 120 .change-captcha {
118 margin-left: 10px; 121 margin-left: 10px;
119 cursor: pointer; 122 cursor: pointer;
@@ -188,6 +191,7 @@ @@ -188,6 +191,7 @@
188 &.skip-user-info { 191 &.skip-user-info {
189 font-size: 18px; 192 font-size: 18px;
190 text-align: center; 193 text-align: center;
  194 +
191 a { 195 a {
192 color: #ff1901; 196 color: #ff1901;
193 text-decoration: underline; 197 text-decoration: underline;
@@ -210,6 +214,7 @@ @@ -210,6 +214,7 @@
210 background: url(/passport/tip/succ-info.png) no-repeat; 214 background: url(/passport/tip/succ-info.png) no-repeat;
211 } 215 }
212 } 216 }
  217 +
213 .err-tip { 218 .err-tip {
214 z-index: 1000; 219 z-index: 1000;
215 position: absolute; 220 position: absolute;
@@ -228,7 +233,6 @@ @@ -228,7 +233,6 @@
228 background: url(/passport/tip/angle.png) no-repeat; 233 background: url(/passport/tip/angle.png) no-repeat;
229 width: 17px; 234 width: 17px;
230 height: 9px; 235 height: 9px;
231 -  
232 } 236 }
233 } 237 }
234 238
@@ -259,9 +263,9 @@ @@ -259,9 +263,9 @@
259 top: 6px; 263 top: 6px;
260 } 264 }
261 265
262 - #count-down { 266 + #count-down {
263 color: #ff1901; 267 color: #ff1901;
264 - } 268 + }
265 } 269 }
266 270
267 .success-btn { 271 .success-btn {
@@ -276,4 +280,4 @@ @@ -276,4 +280,4 @@
276 letter-spacing: 2px; 280 letter-spacing: 2px;
277 } 281 }
278 } 282 }
279 -}  
  283 +}
@@ -184,4 +184,4 @@ @@ -184,4 +184,4 @@
184 outline: none; 184 outline: none;
185 margin: 20px 0; 185 margin: 20px 0;
186 } 186 }
187 -}  
  187 +}
@@ -53,4 +53,4 @@ @@ -53,4 +53,4 @@
53 background-image: resolve('passport/edit-info.png'); 53 background-image: resolve('passport/edit-info.png');
54 } 54 }
55 } 55 }
56 -}  
  56 +}