Authored by xuqi

build back

  1 +/**
  2 + * 找回密码-验证码
  3 + * @author: xuqi<qi.xu@yoho.cn>
  4 + * @date: 2015/10/8
  5 + */
  6 +
  7 +require('../code')(false);
  1 +/**
  2 + * 找回密码-邮箱找回成功
  3 + * @author: xuqi<qi.xu@yoho.cn>
  4 + * @date: 2015/10/8
  5 + */
  6 +
  7 +var $ = require('yoho.zepto');
  8 +
  9 +var $resend = $('#resend');
  10 +
  11 +var api = require('../api'),
  12 + showErrTip = api.showErrTip;
  13 +
  14 +api.initErrTip();
  15 +
  16 +$resend.on('touchstart', function(e) {
  17 + e.preventDefault();
  18 +
  19 + $.ajax({
  20 + url: $resend.data('url'),
  21 + type: 'GET'
  22 + }).then(function(data) {
  23 + if (data.code === 200) {
  24 + showErrTip(data.message);
  25 + } else {
  26 + showErrTip(data.message);
  27 + }
  28 + });
  29 +});
  1 +/**
  2 + * 找回密码-邮箱找回
  3 + * @author: xuqi<qi.xu@yoho.cn>
  4 + * @date: 2015/10/8
  5 + */
  6 +var $ = require('yoho.zepto');
  7 +
  8 +var $email = $('#email'),
  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.bindClearEvt();
  19 +
  20 +$email.bind('input', function() {
  21 + if (trim($email.val()) === '') {
  22 + $btnSure.addClass('disable');
  23 + } else {
  24 + $btnSure.removeClass('disable');
  25 + }
  26 +});
  27 +
  28 +$btnSure.on('touchstart', function() {
  29 + var email = trim($email.val());
  30 +
  31 + if ($btnSure.hasClass('disable')) {
  32 + return;
  33 + }
  34 +
  35 + if (api.emailRegx.test(email)) {
  36 + $.ajax({
  37 + url: '/passport/back/sendemail',
  38 + type: 'POST',
  39 + data: {
  40 + email: email
  41 + }
  42 + }).then(function(data) {
  43 + if (data.code === 200) {
  44 + location.href = data.data;
  45 + } else {
  46 + showErrTip(data.message);
  47 + }
  48 + });
  49 + } else {
  50 + showErrTip('邮箱格式不正确,请重新输入');
  51 + }
  52 +});
  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 + $countrySelector = $('#country-selector'),
  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 +$countrySelector.change(function() {
  31 + $countryCode.text($countrySelector.val());
  32 +});
  33 +
  34 +$btnNext.on('touchstart', function() {
  35 + var pn = trim($phoneNum.val()),
  36 + country = $countrySelector.val();
  37 +
  38 + if ($btnNext.hasClass('disable')) {
  39 + return;
  40 + }
  41 +
  42 + if (api.phoneRegx.test(pn)) {
  43 + $.ajax({
  44 + url: '/passport/back/sendcode',
  45 + type: 'POST',
  46 + data: {
  47 + area: country.split('+')[1],
  48 + mobile: pn
  49 + }
  50 + }).then(function(data) {
  51 + if (data.code === 200) {
  52 + location.href = '/passport/back/code';
  53 + } else {
  54 + showErrTip(data.message);
  55 + }
  56 + });
  57 + } else {
  58 + showErrTip('手机号格式不正确,请重新输入');
  59 + }
  60 +});
  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 + $btnOk = $('#btn-ok');
  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 + $btnOk.addClass('disable');
  23 + } else {
  24 + $btnOk.removeClass('disable');
  25 + }
  26 +});
  27 +
  28 +$btnOk.on('touchstart', function() {
  29 + var pwd = trim($pwd.val());
  30 +
  31 + if ($btnOk.hasClass('disable')) {
  32 + return;
  33 + }
  34 +
  35 + if (api.pwdValidate(pwd)) {
  36 + $.ajax({
  37 + type: 'POST',
  38 + url: '/passport/back/update',
  39 + data: {
  40 + password: pwd
  41 + }
  42 + }).then(function(data) {
  43 + if (data.code === 200) {
  44 + showErrTip('密码修改成功');
  45 +
  46 + //1000ms后跳转页面
  47 + setTimeout(function() {
  48 + location.href = '/';
  49 + }, 1000);
  50 + } else {
  51 + showErrTip(data.message);
  52 + }
  53 + });
  54 + } else {
  55 + showErrTip('密码6-20位,请重新输入');
  56 + }
  57 +});
  1 +.back-email-success-page {
  2 + .tip {
  3 + font-size: 20px;
  4 + color: #fff;
  5 + margin-top: 30px;
  6 + }
  7 +
  8 + .sub-tip, .resend {
  9 + color: #939393;
  10 + font-size: 16px;
  11 + }
  12 +
  13 + .go-email {
  14 + margin: 20px 0 10px;
  15 + }
  16 +
  17 + .resend {
  18 + float: right;
  19 + }
  20 +}
  1 +<div class="back-email-success-page passport-page yoho-page">
  2 + {{> passport/header}}
  3 + <div class="content">
  4 + <p class="tip">验证邮件已发送至你的邮箱</p>
  5 + <p class="sub-tip">请在24小时内通过邮件内的链接设置新密码</p>
  6 + <a class="go-email btn" href="<?php echo $this->name;?>">去邮箱看看</a>
  7 + <a id="resend" class="resend" data-url={{resendUrl}}>重新发送邮件</a>
  8 + </div>
  9 +</div>
  1 +<div class="back-email-page passport-page yoho-page">
  2 + {{> passport/header}}
  3 + <div class="content">
  4 + <div class="input-container row has-clear">
  5 + <input id="email" class="input email" type="text" placeholder="请输入邮箱" autocomplete="off">
  6 + </div>
  7 + <span id="btn-sure" class="btn btn-sure disble row">确定</span>
  8 + </div>
  9 +</div>
  1 +<div class="back-code-page passport-page yoho-page">
  2 + {{> passport/code}}
  3 +</div>
  1 +<div class="back-mobile-page passport-page yoho-page">
  2 + {{> passport/header}}
  3 + <div class="content">
  4 + {{> passport/country_list}}
  5 + <div class="input-container phone-container row has-clear">
  6 + <span id="country-code" class="country-code">{{countryCode}}</span>
  7 + <input id="phone-num" class="input phone-num" type="text" placeholder="手机号">
  8 + </div>
  9 + <span id="btn-next" class="btn btn-next disble row">下一步</span>
  10 + </div>
  11 +</div>
  1 +<div class="back-new-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-ok" class="btn btn-ok disable">完成</span>
  8 + </div>
  9 +</div>