Authored by xuqi

build register

  1 +/**
  2 + * 注册-验证码
  3 + * @author: xuqi<qi.xu@yoho.cn>
  4 + * @date: 2015/10/8
  5 + */
  6 +
  7 +require('../code')(true);
  1 +/**
  2 + * 注册-密码
  3 + * @author: xuqi<qi.xu@yoho.cn>
  4 + * @date: 2015/10/8
  5 + */
  6 +var $ = require('yoho.zepto');
  7 +
  8 +var $pwd = $('#pwd'),
  9 + $btnSure = $('#btn-sure');
  10 +
  11 +var api = require('../api');
  12 +
  13 +var trim = $.trim;
  14 +var showErrTip = api.showErrTip;
  15 +
  16 +api.initErrTip();
  17 +
  18 +api.bindEyesEvt();
  19 +
  20 +$pwd.bind('input', function() {
  21 + if (trim($pwd.val()) === '') {
  22 + $btnSure.addClass('disable');
  23 + } else {
  24 + $btnSure.removeClass('disable');
  25 + }
  26 +});
  27 +
  28 +$btnSure.on('touchstart', function() {
  29 + var pwd = trim($pwd.val());
  30 +
  31 + if ($btnSure.hasClass('disable')) {
  32 + return;
  33 + }
  34 +
  35 + if (api.pwdValidate(pwd) === false) {
  36 + showErrTip('密码6-20位,请重新输入');
  37 + } else {
  38 + $.ajax({
  39 + type: 'POST',
  40 + url: '/passport/register/regmobile',
  41 + data: {
  42 + password: pwd
  43 + }
  44 + }).then(function(data) {
  45 + if (data.code === 200) {
  46 + showErrTip('注册成功');
  47 +
  48 + //1000ms后跳转页面
  49 + setTimeout(function() {
  50 + location.href = data.data;
  51 + }, 1000);
  52 + } else {
  53 + if (data.code === 401 || data.code === 404 || data.code === 505) {
  54 + showErrTip(data.message);
  55 + } else {
  56 + showErrTip(data.message);
  57 + setTimeout(function() {
  58 + location.href = data.data;
  59 + }, 1000);
  60 + }
  61 + }
  62 + });
  63 + }
  64 +});
  1 +/**
  2 + * 注册
  3 + * @author: xuqi<qi.xu@yoho.cn>
  4 + * @date: 2015/10/8
  5 + */
  6 +var $ = require('yoho.zepto');
  7 +
  8 +var $phoneNum = $('#phone-num'),
  9 + $countrySelect = $('#country-select'),
  10 + $countryCode = $('#country-code'),
  11 + $btnNext = $('#btn-next');
  12 +
  13 +var api = require('../api');
  14 +
  15 +var trim = $.trim;
  16 +var showErrTip = api.showErrTip;
  17 +
  18 +api.initErrTip();
  19 +
  20 +api.bindClearEvt();
  21 +
  22 +$phoneNum.bind('input', function() {
  23 + if (trim($phoneNum.val()) === '') {
  24 + $btnNext.addClass('disable');
  25 + } else {
  26 + $btnNext.removeClass('disable');
  27 + }
  28 +});
  29 +
  30 +$countrySelect.change(function() {
  31 + $countryCode.text($countrySelect.val());
  32 +});
  33 +
  34 +$btnNext.on('touchstart', function() {
  35 + var pn = trim($phoneNum.val()),
  36 + country = $countrySelect.val();
  37 +
  38 + if ($btnNext.hasClass('disable')) {
  39 + return;
  40 + }
  41 +
  42 + if (api.phoneRegx[country].test(pn)) {
  43 + $.ajax({
  44 + url: '/passport/register/sendphone',
  45 + type: 'POST',
  46 + data: {
  47 + area: country.split('+')[1],
  48 + profile: pn
  49 + }
  50 + }).then(function(data) {
  51 + if (data.code === 200) {
  52 + location.href = '/passport/register/code';
  53 + } else {
  54 + showErrTip(data.message);
  55 + }
  56 + });
  57 + } else {
  58 + showErrTip('手机号格式不正确,请重新输入');
  59 + }
  60 +});
  1 +.reg-page .register-tip {
  2 + color: #fff;
  3 + font-size: 15px;
  4 +}
  5 +
  6 +.reg-code-page {
  7 + .captcha-tip {
  8 + position: absolute;
  9 + width: 148px;
  10 + text-align: center;
  11 + right: 15px;
  12 + top: 8px;
  13 + color: #36a74c;
  14 + padding: 5px 0;
  15 + border: 1px solid #36a74c;
  16 + border-radius: 20px;
  17 + font-size: 16px;
  18 +
  19 + &.disable {
  20 + color: #8f8f8f;
  21 + border-color: #8f8f8f;
  22 +
  23 + }
  24 + }
  25 +
  26 + .input-container {
  27 + padding-right: 190px;
  28 + }
  29 +
  30 + .text-container {
  31 + color: #fff;
  32 + font-size: 16px;
  33 + margin-bottom: 20px;
  34 + }
  35 +
  36 + .phone {
  37 + color: #4ecae8;
  38 + }
  39 +
  40 + .clear {
  41 + right: 170px;
  42 + }
  43 +}
  1 +<div class="reg-code-page passport-page yoho-page">
  2 + {{> passport/code}}
  3 +</div>
  1 +<div class="reg-page passport-page yoho-page">
  2 + {{> passport/header}}
  3 + <div class="content">
  4 + <div class="select-container row">
  5 + <span class="select-title">国家和地区</span>
  6 + <select id="country-select" class="country-select select in-android-uc">
  7 + {{# countrys}}
  8 + <option value={{val}} {{#if selected}}selected{{/if}}>{{name}}</option>
  9 + {{/ countrys}}
  10 + </select>
  11 + <div class="arrow-right"></div>
  12 + </div>
  13 + <div class="input-container phone-container row has-clear">
  14 + <span id="country-code" class="country-code">{{countryCode}}</span>
  15 + <input id="phone-num" class="input phone-num" type="text" placeholder="手机号" value={{phoneNum}}>
  16 + </div>
  17 + <span id="btn-next" class="btn btn-next disable row">下一步</span>
  18 + <p class="register-tip">YOHO!Family账号可登录YOHO!有货、YOHO!Boys、YOHO!Girls及SHOW</p>
  19 + </div>
  20 +</div>
  1 +<div class="reg-password-page passport-page yoho-page">
  2 + {{> passport/header}}
  3 + <div class="content">
  4 + <div class="input-container row has-eye">
  5 + <input id="pwd" class="input pwd" type="text" placeholder="请输入密码" autocomplete="off" maxlength="20">
  6 + </div>
  7 + <span id="btn-sure" class="btn btn-sure disable row">确定</span>
  8 + </div>
  9 +</div>