diff --git a/static/js/passport/back/code.js b/static/js/passport/back/code.js new file mode 100644 index 0000000..a4242b9 --- /dev/null +++ b/static/js/passport/back/code.js @@ -0,0 +1,7 @@ +/** + * 找回密码-验证码 + * @author: xuqi<qi.xu@yoho.cn> + * @date: 2015/10/8 + */ + +require('../code')(false); \ No newline at end of file diff --git a/static/js/passport/back/email-success.js b/static/js/passport/back/email-success.js new file mode 100644 index 0000000..fde80a5 --- /dev/null +++ b/static/js/passport/back/email-success.js @@ -0,0 +1,29 @@ +/** + * 找回密码-邮箱找回成功 + * @author: xuqi<qi.xu@yoho.cn> + * @date: 2015/10/8 + */ + +var $ = require('yoho.zepto'); + +var $resend = $('#resend'); + +var api = require('../api'), + showErrTip = api.showErrTip; + +api.initErrTip(); + +$resend.on('touchstart', function(e) { + e.preventDefault(); + + $.ajax({ + url: $resend.data('url'), + type: 'GET' + }).then(function(data) { + if (data.code === 200) { + showErrTip(data.message); + } else { + showErrTip(data.message); + } + }); +}); \ No newline at end of file diff --git a/static/js/passport/back/email.js b/static/js/passport/back/email.js new file mode 100644 index 0000000..d8fdf3f --- /dev/null +++ b/static/js/passport/back/email.js @@ -0,0 +1,52 @@ +/** + * 找回密码-邮箱找回 + * @author: xuqi<qi.xu@yoho.cn> + * @date: 2015/10/8 + */ +var $ = require('yoho.zepto'); + +var $email = $('#email'), + $btnSure = $('#btn-sure'); + +var api = require('../api'); + +var trim = $.trim; +var showErrTip = api.showErrTip; + +api.initErrTip(); + +api.bindClearEvt(); + +$email.bind('input', function() { + if (trim($email.val()) === '') { + $btnSure.addClass('disable'); + } else { + $btnSure.removeClass('disable'); + } +}); + +$btnSure.on('touchstart', function() { + var email = trim($email.val()); + + if ($btnSure.hasClass('disable')) { + return; + } + + if (api.emailRegx.test(email)) { + $.ajax({ + url: '/passport/back/sendemail', + type: 'POST', + data: { + email: email + } + }).then(function(data) { + if (data.code === 200) { + location.href = data.data; + } else { + showErrTip(data.message); + } + }); + } else { + showErrTip('邮箱格式不正确,请重新输入'); + } +}); \ No newline at end of file diff --git a/static/js/passport/back/mobile.js b/static/js/passport/back/mobile.js new file mode 100644 index 0000000..22758df --- /dev/null +++ b/static/js/passport/back/mobile.js @@ -0,0 +1,60 @@ +/** + * 找回密码-手机 + * @author: xuqi<qi.xu@yoho.cn> + * @date: 2015/10/8 + */ +var $ = require('yoho.zepto'); + +var $phoneNum = $('#phone-num'), + $countrySelector = $('#country-selector'), + $countryCode = $('#country-code'), + $btnNext = $('#btn-next'); + +var api = require('../api'); + +var trim = $.trim; +var showErrTip = api.showErrTip; + +api.initErrTip(); + +api.bindClearEvt(); + +$phoneNum.bind('input', function() { + if (trim($phoneNum.val()) === '') { + $btnNext.addClass('disable'); + } else { + $btnNext.removeClass('disable'); + } +}); + +$countrySelector.change(function() { + $countryCode.text($countrySelector.val()); +}); + +$btnNext.on('touchstart', function() { + var pn = trim($phoneNum.val()), + country = $countrySelector.val(); + + if ($btnNext.hasClass('disable')) { + return; + } + + if (api.phoneRegx.test(pn)) { + $.ajax({ + url: '/passport/back/sendcode', + type: 'POST', + data: { + area: country.split('+')[1], + mobile: pn + } + }).then(function(data) { + if (data.code === 200) { + location.href = '/passport/back/code'; + } else { + showErrTip(data.message); + } + }); + } else { + showErrTip('手机号格式不正确,请重新输入'); + } +}); \ No newline at end of file diff --git a/static/js/passport/back/new-password.js b/static/js/passport/back/new-password.js new file mode 100644 index 0000000..7aab991 --- /dev/null +++ b/static/js/passport/back/new-password.js @@ -0,0 +1,57 @@ +/** + * 密码找回-新密码 + * @author: xuqi<qi.xu@yoho.cn> + * @date: 2015/10/8 + */ +var $ = require('yoho.zepto'); + +var $pwd = $('#pwd'), + $btnOk = $('#btn-ok'); + +var api = require('../api'); + +var trim = $.trim; +var showErrTip = api.showErrTip; + +api.initErrTip(); + +api.bindEyesEvt(); + +$pwd.bind('input', function() { + if (trim($pwd.val()) === '') { + $btnOk.addClass('disable'); + } else { + $btnOk.removeClass('disable'); + } +}); + +$btnOk.on('touchstart', function() { + var pwd = trim($pwd.val()); + + if ($btnOk.hasClass('disable')) { + return; + } + + if (api.pwdValidate(pwd)) { + $.ajax({ + type: 'POST', + url: '/passport/back/update', + data: { + password: pwd + } + }).then(function(data) { + if (data.code === 200) { + showErrTip('密码修改成功'); + + //1000ms后跳转页面 + setTimeout(function() { + location.href = '/'; + }, 1000); + } else { + showErrTip(data.message); + } + }); + } else { + showErrTip('密码6-20位,请重新输入'); + } +}); \ No newline at end of file diff --git a/static/sass/passport/_back.scss b/static/sass/passport/_back.scss new file mode 100644 index 0000000..d024649 --- /dev/null +++ b/static/sass/passport/_back.scss @@ -0,0 +1,20 @@ +.back-email-success-page { + .tip { + font-size: 20px; + color: #fff; + margin-top: 30px; + } + + .sub-tip, .resend { + color: #939393; + font-size: 16px; + } + + .go-email { + margin: 20px 0 10px; + } + + .resend { + float: right; + } +} \ No newline at end of file diff --git a/template/m.yohobuy.com/actions/passport/back/email-success.phtml b/template/m.yohobuy.com/actions/passport/back/email-success.phtml new file mode 100644 index 0000000..7c42efe --- /dev/null +++ b/template/m.yohobuy.com/actions/passport/back/email-success.phtml @@ -0,0 +1,9 @@ +<div class="back-email-success-page passport-page yoho-page"> + {{> passport/header}} + <div class="content"> + <p class="tip">验证邮件已发送至你的邮箱</p> + <p class="sub-tip">请在24小时内通过邮件内的链接设置新密码</p> + <a class="go-email btn" href="<?php echo $this->name;?>">去邮箱看看</a> + <a id="resend" class="resend" data-url={{resendUrl}}>重新发送邮件</a> + </div> +</div> \ No newline at end of file diff --git a/template/m.yohobuy.com/actions/passport/back/email.phtml b/template/m.yohobuy.com/actions/passport/back/email.phtml index e69de29..ce0ef8e 100644 --- a/template/m.yohobuy.com/actions/passport/back/email.phtml +++ b/template/m.yohobuy.com/actions/passport/back/email.phtml @@ -0,0 +1,9 @@ +<div class="back-email-page passport-page yoho-page"> + {{> passport/header}} + <div class="content"> + <div class="input-container row has-clear"> + <input id="email" class="input email" type="text" placeholder="请输入邮箱" autocomplete="off"> + </div> + <span id="btn-sure" class="btn btn-sure disble row">确定</span> + </div> +</div> \ No newline at end of file diff --git a/template/m.yohobuy.com/actions/passport/back/mobile-code.phtml b/template/m.yohobuy.com/actions/passport/back/mobile-code.phtml new file mode 100644 index 0000000..f9631cb --- /dev/null +++ b/template/m.yohobuy.com/actions/passport/back/mobile-code.phtml @@ -0,0 +1,3 @@ +<div class="back-code-page passport-page yoho-page"> + {{> passport/code}} +</div> \ No newline at end of file diff --git a/template/m.yohobuy.com/actions/passport/back/mobile.phtml b/template/m.yohobuy.com/actions/passport/back/mobile.phtml index e69de29..6214435 100644 --- a/template/m.yohobuy.com/actions/passport/back/mobile.phtml +++ b/template/m.yohobuy.com/actions/passport/back/mobile.phtml @@ -0,0 +1,11 @@ +<div class="back-mobile-page passport-page yoho-page"> + {{> passport/header}} + <div class="content"> + {{> passport/country_list}} + <div class="input-container phone-container row has-clear"> + <span id="country-code" class="country-code">{{countryCode}}</span> + <input id="phone-num" class="input phone-num" type="text" placeholder="手机号"> + </div> + <span id="btn-next" class="btn btn-next disble row">下一步</span> + </div> +</div> \ No newline at end of file diff --git a/template/m.yohobuy.com/actions/passport/back/new-password.phtml b/template/m.yohobuy.com/actions/passport/back/new-password.phtml new file mode 100644 index 0000000..5c1c59d --- /dev/null +++ b/template/m.yohobuy.com/actions/passport/back/new-password.phtml @@ -0,0 +1,9 @@ +<div class="back-new-password-page passport-page yoho-page"> + {{> passport/header}} + <div class="content"> + <div class="input-container row has-eye"> + <input id="pwd" class="input pwd" type="text" placeholder="请输入新密码" autocomplete="off" maxlength="20"> + </div> + <span id="btn-ok" class="btn btn-ok disable">完成</span> + </div> +</div> \ No newline at end of file