Authored by 梁志锋

Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into feature/cart

@@ -622,6 +622,27 @@ @@ -622,6 +622,27 @@
622 ... //仅头部 622 ... //仅头部
623 } 623 }
624 624
  625 +### 绑定手机号
  626 +
  627 + //绑定页
  628 + {
  629 + countrys: [...], //区域列表
  630 + areaCode: '', //默认区号
  631 + sourceType: 'qq', //用户在登录页选择的第三方登录平台
  632 + openId: '' //第三方登录平台id,用于绑定手机号
  633 + }
  634 +
  635 + //验证码
  636 + {
  637 + areaCode: '',
  638 + phoneNum: ''
  639 + }
  640 +
  641 + //密码页
  642 + {
  643 + ... //仅头部
  644 + }
  645 +
625 ### 找回密码 646 ### 找回密码
626 647
627 //邮箱找回&重置密码 648 //邮箱找回&重置密码
@@ -92,7 +92,7 @@ class BindData @@ -92,7 +92,7 @@ class BindData
92 $param['area'] = $area; 92 $param['area'] = $area;
93 if (!empty($password)) 93 if (!empty($password))
94 { 94 {
95 - $param['passport'] = $password; 95 + $param['password'] = $password;
96 } 96 }
97 97
98 $param['client_secret'] = Sign::getSign($param); 98 $param['client_secret'] = Sign::getSign($param);
  1 +/**
  2 + * 注册
  3 + * @author: xuqi<qi.xu@yoho.cn>
  4 + * @date: 2015/10/8
  5 + */
  6 +var $ = require('jquery');
  7 +
  8 +var $phoneNum = $('#phone-num'),
  9 + $countrySelect = $('#country-select'),
  10 + $areaCode = $('#area-code'),
  11 + $openId = $('#openId'),
  12 + $nickname = $('#nickname'),
  13 + $sourceType = $('#sourceType'),
  14 + $btnNext = $('#btn-next');
  15 +
  16 +var api = require('../api'),
  17 + tip = require('../../plugin/tip'),
  18 + dialog = require('../../me/dialog');
  19 +
  20 +var trim = $.trim;
  21 +var showErrTip = tip.show;
  22 +
  23 +function nextStep(url, mobileNo, areaCode) {
  24 + $.ajax({
  25 + type: 'POST',
  26 + url: '/passport/bind/sendBindMsg',
  27 + data: {
  28 + phoneNum: mobileNo,
  29 + areaCode: areaCode.replace('+', '')
  30 + },
  31 + success: function(res) {
  32 + console.log(res.data);
  33 + location.href = url;
  34 + },
  35 + error: function() {
  36 + tip.show('出错了,请重试!');
  37 + }
  38 + });
  39 +}
  40 +
  41 +api.selectCssHack($('#country-select'));
  42 +
  43 +api.bindClearEvt();
  44 +
  45 +$phoneNum.bind('input', function() {
  46 + if (trim($phoneNum.val()) === '') {
  47 + $btnNext.addClass('disable');
  48 + } else {
  49 + $btnNext.removeClass('disable');
  50 + }
  51 +});
  52 +
  53 +$countrySelect.change(function() {
  54 + $areaCode.text($countrySelect.val());
  55 +});
  56 +
  57 +$btnNext.on('touchstart', function() {
  58 + var pn = trim($phoneNum.val()),
  59 + openId = trim($openId.val()),
  60 + nickname = trim($nickname.val()),
  61 + sourceType = trim($sourceType.val()),
  62 + areaCode = $countrySelect.val();
  63 +
  64 + if ($btnNext.hasClass('disable')) {
  65 + return;
  66 + }
  67 +
  68 + if (api.phoneRegx[areaCode].test(pn)) {
  69 + $.ajax({
  70 + url: '/passport/bind/bindCheck',
  71 + type: 'POST',
  72 + data: {
  73 + areaCode: areaCode.replace('+', ''),
  74 + phoneNum: pn,
  75 + openId: openId,
  76 + sourceType: sourceType,
  77 + nickname: nickname
  78 + },
  79 + success: function(res) {
  80 + console.log(res);
  81 +
  82 + //res : {
  83 + // code: 'xxx',
  84 + // data: {
  85 + // isReg: 0,
  86 + // next: 'xxxx'
  87 + // },
  88 + // message: 'xxxx',
  89 + //}
  90 +
  91 +
  92 + if (res.code === 200) {
  93 + if (res.data.isReg === 1) {
  94 + dialog.showDialog({
  95 + dialogText: '该手机号已注册过有货\n' + pn + ',确定绑定吗?',
  96 + hasFooter: {
  97 + leftBtnText: '更换号码',
  98 + rightBtnText: '继续绑定'
  99 + }
  100 + }, function() {
  101 + nextStep(res.data.next, pn, areaCode);
  102 + });
  103 + } else {
  104 + nextStep(res.data.next, pn, areaCode);
  105 + }
  106 + } else {
  107 + showErrTip(res.message);
  108 + }
  109 + }
  110 + });
  111 + } else {
  112 + showErrTip('手机号格式不正确,请重新输入');
  113 + }
  114 +});
  1 +/**
  2 + * 注册-验证码
  3 + * @author: xuqi<qi.xu@yoho.cn>
  4 + * @date: 2015/10/8
  5 + */
  6 +
  7 +require('../code')(true, true);
  1 +/**
  2 + * 注册-密码
  3 + * @author: xuqi<qi.xu@yoho.cn>
  4 + * @date: 2015/10/8
  5 + */
  6 +var $ = require('jquery');
  7 +
  8 +var $pwd = $('#pwd'),
  9 + $btnSure = $('#btn-sure');
  10 +
  11 +var api = require('../api');
  12 +var tip = require('../../plugin/tip');
  13 +
  14 +var trim = $.trim;
  15 +var showErrTip = tip.show;
  16 +
  17 +var nickname = $('#nickname').val(),
  18 + sourceType = $('#sourceType').val(),
  19 + openId = $('#openId').val(),
  20 + phoneNum = $('#phone-num').val(),
  21 + areaCode = $('#area-code').val().replace('+', '');
  22 +
  23 +function startBind(password) {
  24 + $.ajax({
  25 + url: '/passport/bind/bindMobile',
  26 + type: 'post',
  27 + data: {
  28 + areaCode: areaCode.replace('+', ''),
  29 + phoneNum: phoneNum,
  30 + openId: openId,
  31 + sourceType: sourceType,
  32 + nickname: nickname,
  33 + password: password
  34 + },
  35 + success: function(res) {
  36 + if (res.code === 200) {
  37 + tip.show('登录成功');
  38 + setTimeout(function() {
  39 + location.href = res.data.refer;
  40 + }, 2000);
  41 + } else {
  42 + tip.show(res.message);
  43 + }
  44 + },
  45 + error: function(err) {
  46 + tip.show('登录失败,请重试!');
  47 + }
  48 + });
  49 + }
  50 +
  51 +api.bindEyesEvt({
  52 + status: 'open' //默认眼睛打开
  53 +});
  54 +
  55 +$pwd.bind('input', function() {
  56 + if (trim($pwd.val()) === '') {
  57 + $btnSure.addClass('disable');
  58 + } else {
  59 + $btnSure.removeClass('disable');
  60 + }
  61 +});
  62 +
  63 +$btnSure.on('touchstart', function() {
  64 + var pwd = trim($pwd.val());
  65 +
  66 + if ($btnSure.hasClass('disable')) {
  67 + return;
  68 + }
  69 +
  70 + if (api.pwdValidate(pwd) === false) {
  71 + showErrTip('密码6-20位,请重新输入');
  72 + } else {
  73 + startBind(pwd);
  74 + }
  75 +});
@@ -5,10 +5,14 @@ @@ -5,10 +5,14 @@
5 */ 5 */
6 var $ = require('jquery'); 6 var $ = require('jquery');
7 7
8 -module.exports = function(useInRegister) { 8 +module.exports = function(useInRegister, useForBind) {
9 var $captcha = $('#captcha'), 9 var $captcha = $('#captcha'),
10 $btnNext = $('#btn-next'), 10 $btnNext = $('#btn-next'),
11 $captchaTip = $('#captcha-tip'), 11 $captchaTip = $('#captcha-tip'),
  12 + isReg = parseInt($('#isReg').val()),
  13 + nickname = $('#nickname').val(),
  14 + sourceType = $('#sourceType').val(),
  15 + openId = $('#openId').val(),
12 phoneNum = $('#phone-num').val(), 16 phoneNum = $('#phone-num').val(),
13 areaCode = $('#area-code').val().replace('+', ''); 17 areaCode = $('#area-code').val().replace('+', '');
14 18
@@ -20,6 +24,34 @@ module.exports = function(useInRegister) { @@ -20,6 +24,34 @@ module.exports = function(useInRegister) {
20 24
21 var urlMid = useInRegister ? 'reg' : 'back'; 25 var urlMid = useInRegister ? 'reg' : 'back';
22 26
  27 + function startBind() {
  28 + $.ajax({
  29 + url: '/passport/bind/bindMobile',
  30 + type: 'post',
  31 + data: {
  32 + areaCode: areaCode.replace('+', ''),
  33 + phoneNum: phoneNum,
  34 + openId: openId,
  35 + sourceType: sourceType,
  36 + nickname: nickname,
  37 + password: ''
  38 + },
  39 + success: function(res) {
  40 + if (res.code === 200) {
  41 + tip.show('登录成功');
  42 + setTimeout(function() {
  43 + location.href = res.data.refer;
  44 + }, 2000);
  45 + } else {
  46 + tip.show(res.message);
  47 + }
  48 + },
  49 + error: function(err) {
  50 + tip.show('登录失败,请重试!');
  51 + }
  52 + });
  53 + }
  54 +
23 function countDown() { 55 function countDown() {
24 var count = 59, 56 var count = 59,
25 itime; 57 itime;
@@ -52,7 +84,7 @@ module.exports = function(useInRegister) { @@ -52,7 +84,7 @@ module.exports = function(useInRegister) {
52 84
53 $.ajax({ 85 $.ajax({
54 type: 'POST', 86 type: 'POST',
55 - url: '/passport/' + urlMid + '/sendcode', 87 + url: useForBind ? '/passport/bind/sendBindMsg' : '/passport/' + urlMid + '/sendcode',
56 data: { 88 data: {
57 phoneNum: phoneNum, 89 phoneNum: phoneNum,
58 areaCode: areaCode 90 areaCode: areaCode
@@ -77,7 +109,7 @@ module.exports = function(useInRegister) { @@ -77,7 +109,7 @@ module.exports = function(useInRegister) {
77 109
78 $.ajax({ 110 $.ajax({
79 type: 'POST', 111 type: 'POST',
80 - url: '/passport/' + urlMid + '/verifycode', 112 + url: useForBind ? '/passport/bind/checkBindMsg' : '/passport/' + urlMid + '/verifycode',
81 data: { 113 data: {
82 phoneNum: phoneNum, 114 phoneNum: phoneNum,
83 areaCode: areaCode, 115 areaCode: areaCode,
@@ -86,12 +118,23 @@ module.exports = function(useInRegister) { @@ -86,12 +118,23 @@ module.exports = function(useInRegister) {
86 }, 118 },
87 success: function(data) { 119 success: function(data) {
88 if (data.code === 200) { 120 if (data.code === 200) {
  121 + if (useForBind) {
  122 + if (isReg) {
  123 + startBind();
  124 + } else {
  125 + location.href = '/passport/bind/password?phoneNum=' +
  126 + phoneNum + '&areaCode=' + areaCode + '&openId=' +
  127 + openId + '&sourceType=' + sourceType + '&nickname=' + nickname;
  128 + }
  129 + } else {
89 location.href = data.data; 130 location.href = data.data;
  131 + }
90 } else { 132 } else {
91 133
92 //验证码不正确,显示提示 134 //验证码不正确,显示提示
93 showErrTip(data.message); 135 showErrTip(data.message);
94 } 136 }
  137 +
95 } 138 }
96 }); 139 });
97 }); 140 });
@@ -3,3 +3,15 @@ @@ -3,3 +3,15 @@
3 color: #fff; 3 color: #fff;
4 font-size: 15px; 4 font-size: 15px;
5 } 5 }
  6 +
  7 + #yohood {
  8 + background-image: image-url('yohood.png');
  9 + background-size: 40%;
  10 + background-repeat: no-repeat;
  11 + background-color: transparent;
  12 + background-position-x: 10%;
  13 + background-position-y: 40%;
  14 + border: none;
  15 + border-bottom: 4px solid #fff;
  16 +
  17 + }
  1 +{{> layout/header}}
  2 +<div class="reg-code-page passport-page yoho-page">
  3 + <input type="hidden" id="isReg" value="{{isReg}}">
  4 + <input type="hidden" id="openId" value="{{openId}}">
  5 + <input type="hidden" id="sourceType" value="{{sourceType}}">
  6 + <input type="hidden" id="nickname" value="{{nickname}}">
  7 + {{> passport/code}}
  8 +</div>
  9 +{{> layout/footer}}
1 {{> layout/header}} 1 {{> layout/header}}
2 <div class="bind-page passport-page yoho-page"> 2 <div class="bind-page passport-page yoho-page">
  3 + <input type="hidden" id="openId" value="{{openId}}">
  4 + <input type="hidden" id="sourceType" value="{{sourceType}}">
  5 + <input type="hidden" id="nickname" value="{{nickname}}">
3 {{> passport/header}} 6 {{> passport/header}}
4 <div class="content"> 7 <div class="content">
5 {{> passport/country_list}} 8 {{> passport/country_list}}
@@ -8,7 +11,7 @@ @@ -8,7 +11,7 @@
8 <input id="phone-num" class="input phone-num" type="text" placeholder="手机号"> 11 <input id="phone-num" class="input phone-num" type="text" placeholder="手机号">
9 </div> 12 </div>
10 <span id="btn-next" class="btn btn-next disable row">下一步</span> 13 <span id="btn-next" class="btn btn-next disable row">下一步</span>
11 - <p class="bind-tip">YOHO!Family账号可登录Yoho!Buy有货、YOHO!Boys、YOHO!Girls及SHOW</p> 14 + <p class="bind-tip">绑定手机号码后,可选择{{platform}}和手机号登录此帐号</p>
12 </div> 15 </div>
13 </div> 16 </div>
14 {{> layout/footer}} 17 {{> layout/footer}}
  1 +{{> layout/header}}
  2 +<div class="bind-password-page passport-page yoho-page">
  3 + <input type="hidden" id="openId" value="{{openId}}">
  4 + <input type="hidden" id="sourceType" value="{{sourceType}}">
  5 + <input type="hidden" id="nickname" value="{{nickname}}">
  6 + {{> passport/header}}
  7 + <div class="content">
  8 + <div class="input-container row has-eye">
  9 + <input id="pwd" class="input pwd" type="text" placeholder="请输入密码" autocomplete="off" maxlength="20">
  10 + </div>
  11 + <span id="btn-sure" class="btn btn-sure disable row">确定</span>
  12 + </div>
  13 + <input id="phone-num" type="hidden" value={{phoneNum}}>
  14 + <input id="area-code" type="hidden" value={{areaCode}}>
  15 + <input id="token" type="hidden" value={{token}}>
  16 +</div>
  17 +{{> layout/footer}}
@@ -52,6 +52,22 @@ @@ -52,6 +52,22 @@
52 seajs.use('js/passport/register/password'); 52 seajs.use('js/passport/register/password');
53 </script> 53 </script>
54 {{/if}} 54 {{/if}}
  55 +{{!-- 绑定手机号 --}}
  56 +{{#if bindIndex}}
  57 +<script>
  58 + seajs.use('js/passport/bind/bind');
  59 +</script>
  60 +{{/if}}
  61 +{{#if bindCode}}
  62 +<script>
  63 + seajs.use('js/passport/bind/code');
  64 +</script>
  65 +{{/if}}
  66 +{{#if bindPwd}}
  67 +<script>
  68 + seajs.use('js/passport/bind/password');
  69 +</script>
  70 +{{/if}}
55 {{!-- 登陆 --}} 71 {{!-- 登陆 --}}
56 {{#if loginIndex}} 72 {{#if loginIndex}}
57 <script> 73 <script>