Authored by 王水玲

Merge branch 'feature/passport' into release/4.8

... ... @@ -195,6 +195,7 @@ const resetPasswordPage = (req, res, next) => {
res.render('back/reset-pwd', Object.assign({
module: 'passport',
page: 'back-reset-pwd',
simpleHeader: simpleHeaderModel.setSimpleHeaderData(),
title: '重置密码'
}, {
resetPwd: Object.assign({
... ... @@ -214,6 +215,7 @@ const verifyCodeByMobilePage = (req, res, next) => {
res.render('back/verification', Object.assign({
module: 'passport',
page: 'back-verify-mobile-code',
simpleHeader: simpleHeaderModel.setSimpleHeaderData(),
title: '手机验证'
}, {
verification: {
... ... @@ -245,6 +247,7 @@ const resetPwdSuccessPage = (req, res, next) => {
res.render('back/reset-success', Object.assign({
module: 'passport',
page: 'back-index',
simpleHeader: simpleHeaderModel.setSimpleHeaderData(),
title: '重置密码成功'
}, {
resetSuccess: {
... ...
... ... @@ -11,7 +11,9 @@ const helpers = global.yoho.helpers;
const PassportHelper = require('../models/passport-helper');
const BindService = require('../models/bind-service');
const AuthHelper = require('../models/auth-helper');
const UserService = require('../models/user-service');
// const UserService = require('../models/user-service');
const simpleHeaderModel = require('../../../doraemon/models/simple-header');
const Sources = {
qq: 'QQ',
... ... @@ -35,6 +37,7 @@ const bind = {
serviceUrl: helpers.urlFormat('/help', {
category_id: 9
}),
simpleHeader: simpleHeaderModel.setSimpleHeaderData(),
module: 'passport',
page: 'bind',
title: '联合登录补全信息'
... ... @@ -54,6 +57,7 @@ const bind = {
area: area,
module: 'passport',
page: 'noregist',
simpleHeader: simpleHeaderModel.setSimpleHeaderData(),
title: '登录绑定'
});
... ... @@ -64,25 +68,28 @@ const bind = {
let openId = req.body.openId;
let area = req.body.area;
UserService.findByMobileAsync(area, mobile).then(user => {
if (user) {
return {
thumb: user.headImg,
userName: user.username,
loginHref: user.bindLogin
};
} else {
return {};
}
}).then(user => {
// UserService.findByMobileAsync(area, mobile).then(user => {
// if (user) {
// return {
// thumb: user.headImg,
// userName: user.username,
// loginHref: user.bindLogin
// };
// } else {
// return {};
// }
// })
PassportHelper.getUserInfo(area, mobile).then(user => {
let data = _.assign(user, {
phoneNum: mobile,
areaCode: area,
openId: openId,
sourceType: sourceType,
changeHref: helpers.urlFormat('/passport/thirdlogin/index', {openId: openId, sourceType: sourceType}),
simpleHeader: simpleHeaderModel.setSimpleHeaderData(),
module: 'passport',
page: 'noregist',
page: 'relate',
title: '账号关联'
});
... ... @@ -101,6 +108,7 @@ const bind = {
relate: isRelate,
module: 'passport',
page: 'bind-success',
simpleHeader: simpleHeaderModel.setSimpleHeaderData(),
title: '绑定手机号'
};
... ... @@ -223,7 +231,7 @@ const bind = {
if (result && result.code) {
if (result.code === 200 && result.data && result.data.uid) {
let refer = helpers.urlFormat('/passport/thirdlogin/bindsuccess', {
sourceType: sourceType + '_bind'
sourceType: sourceType + '_relate'
});
return AuthHelper.syncUserSession(result.data.uid, req, res).then(() => {
... ...
... ... @@ -290,6 +290,7 @@ let success = (req, res, next) => {
regService.getRegData().then((result) => {
res.render('reg/success', {
title: '注册成功',
simpleHeader: simpleHeaderModel.setSimpleHeaderData(),
passport: {
goUrl: goUrl,
goShoppong: goShoppingUrl,
... ...
... ... @@ -57,11 +57,13 @@ router.get('/passport/login/account', login.common.needCaptcha);
router.get('/passport/thirdlogin/index', bind.indexPage);
router.get('/passport/thirdlogin/bindsuccess', bind.bindSuccess);
router.post('/passport/thirdlogin/noregist', bind.noregist);
router.post('/passport/thirdlogin/relate', bind.relate);
router.post('/passport/autouserinfo/bindCheck', bind.bindCheck);
router.post('/passport/autouserinfo/sendBindMsg', bind.sendBindMsg);
router.post('/passport/autouserinfo/checkBindMsg', bind.checkBindMsg);
router.post('/passport/autouserinfo/bindMobile', bind.bindMobile);
router.post('/passport/autouserinfo/relateMobile', bind.relateMobile);
/**
* 注册页面路由
... ...
{{> layout/header}}
<div class="third-relate-page passport-page yoho-page clearfix">
{{# relate}}
<div id="relate-main" class="relate-main">
<div class="user-wrapper">
<div class="user-thumb">
<img src="{{thumb}}">
<img src="{{headImg}}">
</div>
<label>用户名: {{userName}}</label>
<label>用户名: {{username}}</label>
</div>
<div class="remind-info">
<h3>手机号
<span>{{phoneNum}}</span>
已经被以上账户注册,点击
<a href="{{loginHref}}" target="_blank">登录该账号</a>
<a href="{{bindLogin}}" target="_blank">登录该账号</a>
</h3>
<p>您可以使用此号码进行账户关联或更换一个新的手机号码</p>
</div>
... ... @@ -43,6 +41,4 @@
</p>
</div>
<div id="hide-info" data-mobile="{{phoneNum}}" data-area="{{areaCode}}" data-openid="{{openId}}" data-source="{{sourceType}}"></div>
{{/ relate}}
</div>
{{> layout/footer}}
\ No newline at end of file
</div>
\ No newline at end of file
... ...
... ... @@ -22,6 +22,7 @@ var $pwdIntensity = $('.pwd-intensity'),
var pwdRegx = require('../common/mail-phone-regx').pwdValidateRegx;
require('yoho-jquery-placeholder');
require('../../simple-header');
/*
... ... @@ -105,6 +106,7 @@ function pwdKeyupEvt() {
} else {
level = 3;
}
switch (level) {
case 0:
$pwdParent.removeClass('red yellow green');
... ... @@ -124,6 +126,8 @@ function pwdKeyupEvt() {
$pwdParent.addClass('green').removeClass('yellow red');
$pwdIntensity.addClass('color');
break;
default:
break;
}
// 提示框
... ...
... ... @@ -13,6 +13,8 @@ var $sc = $('#send-captcha'),
seconds,
itime;
require('../../simple-header');
$sc.click(function() {
$.post('/passport/back/sendbackmobile', {
mobile: $('#mobile').val(),
... ...
/**
* 绑定成功页面
**/
require('../simple-header');
... ...
... ... @@ -15,6 +15,8 @@ var $pwd,
$pwdTip1,
$pwdIntensity;
require('../../simple-header');
nopermissionoption = $('#nopermissionmessage').html();
sendmessagehtml = $('.validatewrapper').html();
second = +$('.second').text();
... ... @@ -199,6 +201,8 @@ function pwdKeyupEvt() {
$pwdParent.addClass('green').removeClass('yellow red');
$pwdIntensity.addClass('color');
break;
default:
break;
}
if (pwd === '') {
isvalidatepwd = false;
... ...
/**
* 第三方关联
* @author: yyqing<yanqing.yang@yoho.cn>
* @date: 2016/4/11
*/
var $ = require('yoho-jquery');
var $relateMain = $('#relate-main'),
$codeValidate = $('#code-validate'),
$vaWrapper = $codeValidate.find('.validate-wrapper'),
$msgCode = $codeValidate.find('.msg-code'),
$second = $codeValidate.find('.count-down span'),
$errTip = $codeValidate.find('.code-error'),
$hideDom = $('#hide-info');
var relate = {};
var circleTime = {};
require('../../simple-header');
relate = $hideDom.data();
$hideDom.remove();
// 倒计时
circleTime = {
init: function() {
if (this.timer) {
window.clearTimeout(this.timer);
}
this.second = 60;
$vaWrapper.addClass('waiting');
this.changeTime();
},
changeTime: function() {
var that = this;
if (this.second && this.second > 0) {
$second.text(this.second);
this.second--;
this.timer = window.setTimeout(function() {
that.changeTime();
}, 1000);
} else {
this.clearTime();
}
},
clearTime: function() {
if (this.timer) {
window.clearTimeout(this.timer);
}
$vaWrapper.removeClass('waiting');
}
};
function sendVerifyMsg() {
circleTime.init();
$.ajax({
type: 'POST',
url: '/passport/autouserinfo/sendBindMsg',
data: {
mobile: relate.mobile,
area: relate.area
}
}).then(function(jsonData) {
if (jsonData && jsonData.code !== 200) {
circleTime.clearTime();
alert(jsonData.message);
}
});
}
function relateMobile() {
var code = $msgCode.val();
if (!code) {
return;
}
$.ajax({
type: 'POST',
url: '/passport/autouserinfo/relateMobile',
data: {
mobile: relate.mobile,
area: relate.area,
openId: relate.openid,
sourceType: relate.source,
code: code
}
}).then(function(jsonData) {
if (jsonData.code === 200) {
window.location.href = jsonData.data.refer;
} else if (jsonData.code === 402) {
$errTip.removeClass('hide');
} else {
$errTip.addClass('hide');
alert(jsonData.message);
}
});
}
$('#next-step-btn').click(function() {
sendVerifyMsg();
$relateMain.addClass('hide');
$errTip.addClass('hide');
$codeValidate.removeClass('hide');
});
$codeValidate.on('keydown', '.msg-code', function(e) {
if (e.keyCode === 13) {
relateMobile();
return false;
}
});
$codeValidate.on('click', '.get-code', function() {
sendVerifyMsg();
});
$codeValidate.on('click', '.perv-step', function() {
circleTime.clearTime();
$relateMain.removeClass('hide');
$codeValidate.addClass('hide');
$msgCode.val('');
});
$('#relate-btn').click(function() {
relateMobile();
});
... ...
... ... @@ -3,7 +3,7 @@
* @author: wq
* @date: 2016/1/27
*/
var $ = require('yoho.jquery');
var $ = require('yoho-jquery');
var dovalidate = false; // 校验验证码的标识
var isvalidatecode = false; // 是否验证成功的标识
var isvalidatepwd = false; // 密码验证是否通过的标识
... ... @@ -208,6 +208,8 @@ function pwdKeyupEvt() {
$pwdParent.addClass('green').removeClass('yellow red');
$pwdIntensity.addClass('color');
break;
default:
break;
}
if (pwd === '') {
isvalidatepwd = false;
... ...
... ... @@ -17,6 +17,8 @@ var $wrapper = $('.bindwrapper'),
$phoneTip = $wrapper.find('.phone-err-tip'),
$nextBtn = $wrapper.find('.yohobindbtn');
require('../../simple-header');
/**
* 选择协议
* @return {[type]} [description]
... ... @@ -178,12 +180,12 @@ function closeMask() {
* @return {[type]} [description]
*/
function yohoBindBtn() {
$(document).on('click', '#yohobindbtn', function(e) {
$(document).on('click', '#yohobindbtn', function() {
$('.phonenum').val('');
$('#bindconfirm').hide();
$('.backdrop').hide();
});
$(document).on('click', '#yohobindbtn2', function(e) {
$(document).on('click', '#yohobindbtn2', function() {
$('.phonenum').val('');
$('#alreayregist').hide();
$('.backdrop').hide();
... ...
require('./bind/relate');
... ...