Authored by htoooth

add account

... ... @@ -313,7 +313,6 @@ exports.sendMobileMsg = (req, res, next) => {
}
let uid = req.user.uid;
// 真实数据输出
req.ctx(accountModel).sendMobileMsg(req, uid).then(result => {
res.json(result);
}).catch(next);
... ... @@ -323,13 +322,52 @@ exports.sendMobileMsg = (req, res, next) => {
* 修改验证手机号
*/
exports.modifyMobile = (req, res, next) => {
if (!req.user.uid) {
res.redirect(helpers.urlFormat('/signin.html'));
}
let uid = req.user.uid;
let area = req.body.area || '86';
let mobile = req.body.mobile;
let code = req.body.code;
if (!code || !mobile) {
return res.json({
code: 400,
message: '填写错误'
});
}
// 真实数据输出
req.ctx(accountModel).modifyMobile(req, uid).then(result => {
req.ctx(accountModel).newBindMobile(area, mobile, code, uid).then(result => {
res.json(result);
}).catch(next);
};
exports.newSendMsg = (req, res, next) => {
let mobile = req.body.mobile;
let area = req.body.area || '86';
if (!area || !mobile) {
return res.json({
code: 400,
message: '填写错误'
});
}
req.ctx(accountModel).newSendMsg(area, mobile).then(result => {
return res.json(result);
}).catch(next);
};
exports.newBindCheck = (req, res, next) => {
let mobile = req.body.mobile;
let area = req.body.area || '86';
let code = req.body.code;
if (!area || !mobile || !code) {
return res.json({
code: 400,
message: '填写错误'
});
}
req.ctx(accountModel).newBindCheck(area, mobile, code).then(result => {
return res.json(result);
}).catch(next);
};
... ...
/**
* Created by TaoHuang on 2016/10/26.
*/
'use strict';
exports.if_cond = function(left, operator, right, options) {
switch (operator) {
case '==':
return (left == right) ? options.fn(this) : options.inverse(this); // eslint-disable-line
case '!=':
return (left != right) ? options.fn(this) : options.inverse(this); // eslint-disable-line
case '===':
return (left === right) ? options.fn(this) : options.inverse(this);
case '<':
return (left < right) ? options.fn(this) : options.inverse(this);
case '<=':
return (left <= right) ? options.fn(this) : options.inverse(this);
case '>':
return (left > right) ? options.fn(this) : options.inverse(this);
case '>=':
return (left >= right) ? options.fn(this) : options.inverse(this);
case '&&':
return (left && right) ? options.fn(this) : options.inverse(this);
case '||':
return (left || right) ? options.fn(this) : options.inverse(this);
default:
return options.inverse(this);
}
};
... ...
... ... @@ -28,7 +28,7 @@ app.use(global.yoho.hbs({
layoutsDir: doraemon,
partialsDir: [path.join(__dirname, 'views/partial')],
views: path.join(__dirname, 'views/action'),
helpers: global.yoho.helpers,
helpers: Object.assign(require('./helper'), global.yoho.helpers),
cb: hbsEvent.cb
}));
... ...
... ... @@ -104,7 +104,7 @@ module.exports = class extends global.yoho.BaseModel {
}
/**
* 修改验证手机号
* 修改手机号
* @param type $uid
* @param type $area
* @param type $newMobile
... ... @@ -113,7 +113,7 @@ module.exports = class extends global.yoho.BaseModel {
modifyVerifyMobile(uid, area, newMobile) {
let data = {
method: 'web.passport.changeVerifyMobile',
method: 'web.passport.changeMobileForce',
uid: uid,
area: area,
newMobile: newMobile
... ... @@ -122,9 +122,9 @@ module.exports = class extends global.yoho.BaseModel {
return this.get({
data: data
});
}
/**
* 修改邮箱前校验
* @param type $uid
... ... @@ -230,5 +230,38 @@ module.exports = class extends global.yoho.BaseModel {
}
newSendMsg(area, mobile) {
return this.get({
data: {
method: 'app.bind.sendChangeBindMobileCodeOnly',
mobile: mobile,
area: area,
}
});
}
newBindCheck(area, mobile, code) {
return this.get({
data: {
method: 'app.bind.changeMobileCheck',
mobile: mobile,
area: area,
code: code
}
});
}
newBindMobile(area, mobile, code, uid) {
return this.get({
data: {
method: 'app.bind.changeMobileForce',
mobile: mobile,
area: area,
code: code,
uid: uid
}
});
}
};
... ...
... ... @@ -199,9 +199,9 @@ module.exports = class extends global.yoho.BaseModel {
formData = [
{
inputTxt: ischeckMobile ? '输入新的手机号码' : '请输入手机号码',
key: 'mobilevalue',
key: ischeckMobile ? 'mobilevalue2' : 'mobilevalue',
type: 'text',
name: 'mobile'
name: ischeckMobile ? 'mobile2' : 'mobile'
}
];
break;
... ... @@ -327,11 +327,11 @@ module.exports = class extends global.yoho.BaseModel {
url: helpers.urlFormat('/home/account/userpwd'),
isValid: true
// }, {
// icon: 'warning',
// type: '邮箱验证',
// tip: '验证后,可用于找回登录密码。',
// url: helpers.urlFormat('/home/account/email')
// }, {
// icon: 'warning',
// type: '邮箱验证',
// tip: '验证后,可用于找回登录密码。',
// url: helpers.urlFormat('/home/account/email')
}, {
icon: 'warning',
type: '手机验证',
... ... @@ -593,14 +593,16 @@ module.exports = class extends global.yoho.BaseModel {
data.formInfo = {
ischeckEmail: verifyInfo.checkEmailFlag,
formData: verifyInfo.formData,
mobileCode: verifyInfo.checkMobileFlag
mobileCode: verifyInfo.checkMobileFlag,
step: 1
};
} else if (step === 2) {
data.progress[1].iscur = true;
data.returnInfo = false;
data.formInfo = {
formData: verifyInfo.formData,
mobileCode: true
mobileCode: true,
step: 2
};
} else if (step === 3) {
data.progress[2].iscur = true;
... ... @@ -996,56 +998,45 @@ module.exports = class extends global.yoho.BaseModel {
/**
* 修改验证手机号
*/
modifyMobile(req, uid) {
async modifyMobile(req, uid) {
let that = this;
return co(function* () {
let mobile = req.body.mobile || '',
code = req.body.code || '',
_code = req.body.checkCode,
resqData = {code: 400};
let mobile = req.body.mobile || '',
code = req.body.code || '',
_code = req.body.checkCode,
resqData = {code: 400};
let accountDataModel = new AccountApi(that.ctx);
let accountDataModel = new AccountApi(that.ctx);
// 校验验证码前置数据校验
// 校验checkCode,有效时间10分钟(checkCode在调改接口前获取,考虑网络延时,服务器间的时间差,设置10分钟)
if (!_code || !that.checkCode(_code, uid, 600000)) {
return Object.assign(resqData, {
message: '数据验证错误'
});
}
// 校验验证码前置数据校验
// 校验checkCode,有效时间10分钟(checkCode在调改接口前获取,考虑网络延时,服务器间的时间差,设置10分钟)
if (!_code || !that.checkCode(_code, uid, 600000)) {
return Object.assign(resqData, {
message: '数据验证错误'
});
}
if (mobile === '') {
resqData = {
code: 400,
message: '手机号为空',
data: ''
};
return resqData;
}
if (code === '') {
resqData = {
code: 400,
message: '验证码为空',
data: ''
};
return resqData;
}
let mobileInfo = that.handleMobile(mobile);
if (mobile === '') {
resqData = {
code: 400,
message: '手机号为空',
data: ''
};
return resqData;
}
if (code === '') {
resqData = {
code: 400,
message: '验证码为空',
data: ''
};
return resqData;
}
let mobileInfo = that.handleMobile(mobile);
let checkFlag = yield accountDataModel.checkVerifyMobile(uid, mobileInfo.mobile, mobileInfo.area);
resqData = await accountDataModel.modifyVerifyMobile(uid, mobileInfo.area, mobileInfo.mobile);
if (checkFlag.code === 200) {
resqData = yield accountDataModel.modifyVerifyMobile(uid, mobileInfo.area, mobileInfo.mobile);
} else {
resqData = {
code: checkFlag.data,
message: checkFlag.message,
data: ''
};
}
return resqData;
})();
return resqData;
}
/**
... ... @@ -1097,6 +1088,18 @@ module.exports = class extends global.yoho.BaseModel {
})();
}
async newSendMsg(area, mobile) {
return new AccountApi(this.ctx).newSendMsg(area, mobile);
}
async newBindCheck(area, mobile, code) {
return new AccountApi(this.ctx).newBindCheck(area, mobile, code);
}
async newBindMobile(area, mobile, code, uid) {
return new AccountApi(this.ctx).newBindMobile(area, mobile, code, uid);
}
};
... ...
... ... @@ -249,7 +249,10 @@ router.post('/account/checkmobilemsg', AccountController.checkMobileMsg);
router.post('/account/sendmobilemsg', captcha.requiredAPI, AccountController.sendMobileMsg);
// 手机号验证第二步
router.post('/account/modifymobile', AccountController.modifyMobile);
router.post('/account/mobilesendmsg', AccountController.newSendMsg);
router.post('/account/mobilecheck', AccountController.newBindCheck);
// 地址管理
... ...
... ... @@ -41,18 +41,32 @@
</li>
{{/each}}
{{#if mobileCode}}
<li class="user-form-li captcha-li {{#unless @root.captcha.value}}hide{{/unless}}">
<div class="safe-form-l">图形验证码:</div>
<div class="captcha-safe-form-r"></div>
</li>
<li class="user-form-li">
<div class="safe-form-l">手机验证码:</div>
<div class="safe-form-r">
<input name="code" id="inputcode" class="input-code" type="text" value="">
<a href="javascript:void(0);" class="button-icon button-sliver" id="send-mobile-code"><span><i id="sendButton">发送验证码</i></span></a>
<div class="check-info"></div>
</div>
</li>
{{log step}}
{{#if_cond step '===' 2}}
<!-- 这部分是手机验证第二部,需要不同的验证码 -->
<li class="user-form-li">
<div class="safe-form-l">手机验证码:</div>
<div class="safe-form-r">
<input name="smscode" id="inputcode2" class="input-code" type="text" value="">
<a href="javascript:void(0);" class="button-icon button-sliver" id="send-mobile-code2"><span><i id="sendButton">发送验证码</i></span></a>
<div class="check-info"></div>
</div>
</li>
{{^}}
<li class="user-form-li captcha-li {{#unless @root.captcha.value}}hide{{/unless}}">
<div class="safe-form-l">图形验证码:</div>
<div class="captcha-safe-form-r"></div>
</li>
<li class="user-form-li">
<div class="safe-form-l">手机验证码:</div>
<div class="safe-form-r">
<input name="code" id="inputcode" class="input-code" type="text" value="">
<a href="javascript:void(0);" class="button-icon button-sliver" id="send-mobile-code"><span><i id="sendButton">发送验证码</i></span></a>
<div class="check-info"></div>
</div>
</li>
{{/if_cond}}
{{/if}}
{{#if ischeckEmail}}
... ...
... ... @@ -11,7 +11,6 @@ const helpers = global.yoho.helpers;
const passportHelper = require('../models/passport-helper');
const BindService = require('../models/bind-service');
const LoginService = require('../models/login-service');
const UserService = require('../models/user-service');
// const UserService = require('../models/user-service');
const simpleHeaderModel = require('../../../doraemon/models/simple-header');
... ... @@ -66,75 +65,11 @@ const bind = {
res.render('bind/success', data);
},
_bindCheck: (req, mobile, openId, area, sourceType) => {
return req.ctx(BindService).bindCheck(mobile, openId, sourceType, area).then(result => {
if (!result || !result.code) {
return {code: 400, message: '', data: ''};
} else if (result.code === 200 && result.data.is_register === 0) {
let nextUrl = helpers.urlFormat('/passport/thirdlogin/noregist');
// 绑定流程:code=200 未注册,可绑定
return {code: 200, message: result.message, data: {next: nextUrl}};
} else if (result.code === 200 && result.data.is_register === 1) {
return req.ctx(UserService).getUserInfo(area, mobile).then(user => {
// 绑定流程:code=201 已注册 绑定过其他第三方
return {code: 201, message: result.message, data: {user: user}};
});
} else if (result.code === 200 && result.data.is_register === 3) {
// 关联流程
return req.ctx(UserService).getUserInfo(area, mobile).then(user => {
return {code: 203, message: result.message, data: {user: user}};
});
} else if (result.code === 506 || result.code === 505) {
return req.ctx(UserService).getUserInfo(area, mobile).then(user => {
// 绑定流程:code=506 手机号码注册过,而且该手机号码也已经绑定过该类型第三方
// code=505 手机号码注册过,而且该第三方也已经绑定过手机号
return {code: 205, message: result.message, data: {user: user}};
});
} else {
return {code: result.code, message: result.message, data: result.data ? result.data : ''};
}
});
},
bindCheck: (req, res, next) => {
let mobile = req.body.mobile;
let openId = req.body.openId;
let area = req.body.area || '86';
let sourceType = req.body.sourceType;
if (req.session.type !== 'relateStep1') {
return res.json({code: 400, message: '非法请求'});
}
if (mobile && openId && area && sourceType) {
/**
* 接口绑定返回值:
* code:200,is_register=0 // 绑定流程:未注册,可绑定
* code:200,is_register=1 // 绑定流程:已注册绑定过其他第三方
* code:200:is_register=3 // 关联流程
* code:505 // 手机号码注册过,而且该第三方也已经绑定过手机号
* code:506 // 手机号码注册过,而且该手机号码也已经绑定过该类型第三方
*/
bind._bindCheck(req, mobile, openId, area, sourceType).then(result => {
return res.json(result);
}).catch(next);
} else {
return res.json({code: 400, message: '', data: ''});
}
},
sendBindMsg: (req, res, next) => {
let mobile = req.body.mobile;
let area = req.body.area;
let id = req.session.id;
let captcha = req.body.verifyCode;
if (req.session.type !== 'relateStep1') {
return res.json({code: 400, message: '非法请求'});
}
req.ctx(BindService).sendBindMsg(area, mobile, id, captcha).then(result => {
req.ctx(BindService).sendBindMsg(area, mobile).then(result => {
if (result && result.code) {
return res.json(result);
} else {
... ... @@ -149,7 +84,6 @@ const bind = {
let sourceType = _.trim(req.body.sourceType);
let nickName = _.trim(req.body.nickName);
let code = _.trim(req.body.code);
let password = _.trim(req.body.password) || '';
try {
nickName = decodeURIComponent(nickName);
... ... @@ -157,7 +91,7 @@ const bind = {
nickName = '';
}
req.ctx(BindService).bindMobile(openId, sourceType, mobile, area, password, nickName, code).then(result => {
req.ctx(BindService).bindMobile(openId, sourceType, mobile, area, nickName, code).then(result => {
if (result && result.code) {
if (result.code === 200 && result.data && result.data.uid) {
let refer = helpers.urlFormat('/passport/thirdlogin/bindsuccess', {
... ...
... ... @@ -10,9 +10,9 @@ const _ = require('lodash');
const helpers = global.yoho.helpers;
const passportHelper = require('../models/passport-helper');
const CertService = require('../models/cert-service');
const UserService = require('../models/user-service');
const simpleHeaderModel = require('../../../doraemon/models/simple-header');
const config = global.yoho.config;
const LoginService = require('../models/login-service');
const cert = {
index: (req, res) => {
... ... @@ -49,28 +49,6 @@ const cert = {
title: '登录绑定'
});
},
relate: (req, res, next) => {
let mobile = req.body.mobile;
let area = req.body.area;
let refer = req.body.refer;
req.ctx(UserService).getUserInfo(area, mobile).then(user => {
let data = _.assign(user, {
phoneNum: mobile,
areaCode: area,
refer: refer,
changeHref: helpers.urlFormat('/passport/cert/index', {
refer: refer
}),
simpleHeader: simpleHeaderModel.setSimpleHeaderData(),
module: 'passport',
page: 'cert-relate',
title: '账号关联'
});
res.render('cert/relate', data);
}).catch(next);
},
success: (req, res) => {
let type = _.trim(req.query.type);
let refer = req.query.refer || `${config.siteUrl}`;
... ... @@ -152,56 +130,14 @@ const cert = {
});
}
return res.json({
code: 200
return req.ctx(LoginService).syncUserSession(result.data, req, res).then(() => {
return {code: 200, message: result.message};
});
}).catch(() => {
delete req.session.forceBind;
next();
});
},
relateMobile: (req, res, next) => {
let uid = req.user.uid;
let mobile = _.trim(req.body.mobile);
let area = _.trim(req.body.areaCode) || '86';
let code = _.trim(req.body.code);
let refer = req.body.refer;
let email;
req.ctx(UserService).profile(uid).then(info => {
if (info && info.code === 200) {
email = _.get(info, 'data.email');
} else {
return res.json({
code: 400,
message: '系统错误,请稍后再试!'
});
}
req.ctx(CertService).relateMobile(uid, email, code, mobile, area).then(result => {
if (result && result.code === 200) {
let url = helpers.urlFormat('/passport/cert/success', {
type: 'relate',
refer: refer
});
return {
code: 200,
message: result.message,
data: {
nextUrl: url
}
};
} else {
return {
code: _.get(result, 'code', 400),
message: _.get(result, 'message')
};
}
}).then(result => {
res.json(result);
}).catch(next);
}).catch(next);
}
};
... ...
... ... @@ -5,93 +5,35 @@
* @date 2016/06/21
*/
const PAGE = 'pc';
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
bindCheck(mobile, openId, sourceType, area) {
let params = {
method: 'app.passport.signCheck',
area: area,
mobile: mobile,
open_id: openId,
source_type: sourceType
};
return this.get({data: params});
}
sendBindMsg(area, mobile, id, captcha) {
sendBindMsg(area, mobile) {
let params = {
method: 'app.passport.smsbind',
method: 'app.bind.sendThirdBindMobileCodeOnly',
mobile: mobile,
area: area,
udid: id,
fromPage: PAGE,
degrees: captcha
};
return this.get({data: params});
}
checkBindCode(area, mobile, code) {
return this.get({data: {
method: 'app.register.validRegCode',
mobile: mobile,
area: area,
code: code
}});
}
bindMobile(openId, sourceType, mobile, area, password, nickname, code) {
bindMobile(openId, sourceType, mobile, area, nickname, code) {
let params = {
method: 'app.passport.bind',
method: 'app.bind.bindMobile',
area: area,
mobile: mobile,
open_id: openId,
source_type: sourceType,
area: area,
code
};
if (password) {
params.password = password;
}
if (nickname) {
params.nickname = nickname;
}
return this.get({data: params});
}
relateMobile(openId, sourceType, mobile, area) {
return this.get({data: {
method: 'app.passport.relatedMobile',
mobile: mobile,
openId: openId,
source_type: sourceType,
area: area
}});
}
changeCheck(mobile, area) {
return this.get({data: {
method: 'app.passport.changeCheck',
mobile: mobile,
area: area
}});
}
changeMobile(uid, mobile, area, code) {
return this.get({data: {
method: 'app.passport.changeMobile',
mobile: mobile,
uid: uid,
code: code,
area: area
}});
}
};
... ...
/**
* 注册数据接口
*
* @author JiangFeng<jeff.jiang@yoho.cn>
* @date 2016/06/21
*/
'use strict';
const _ = require('lodash');
const BindApi = require('./bind-api');
const CaptchaImgService = require('./captcha-img-service');
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
this.captchaService = new CaptchaImgService(ctx);
this.bindApi = new BindApi(ctx);
this.bindCheck = this.bindApi.bindCheck.bind(this.bindApi);
this.checkBindCode = this.bindApi.checkBindCode.bind(this.bindApi);
this.bindMobile = this.bindApi.bindMobile.bind(this.bindApi);
this.relateMobile = this.bindApi.relateMobile.bind(this.bindApi);
this.changeCheck = this.bindApi.changeCheck.bind(this.bindApi);
this.changeMobile = this.bindApi.changeCheck.bind(this.bindApi);
}
async sendBindMsg(area, mobile, id, captcha) {
let result = await this.bindApi.sendBindMsg(area, mobile, id, captcha);
let captchaNeed = await this.captchaService.try();
_.set(result, 'data.needCaptcha', captchaNeed);
return result;
this.sendBindMsg = this.bindApi.sendBindMsg.bind(this.bindApi);
}
};
... ...
... ... @@ -42,25 +42,5 @@ module.exports = class extends global.yoho.BaseModel {
return this.get({data: params});
}
relateMobile(uid, email, code, mobile, area) {
return this.get({data: {
method: 'app.passport.relatedMobileAndEmail',
uid: uid,
email: email,
mobile: mobile,
code: code,
area: area
}});
}
checkEmailCertTip(uid) {
let param = {
method: 'app.passport.checkIsBindedOrRelated',
uid: uid
};
return this.get({data: param});
}
};
... ...
'use strict';
const CertApi = require('./cert-api');
const CaptchaImgService = require('./captcha-img-service');
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
this.api = new CertApi(ctx);
this.captchaService = new CaptchaImgService(ctx);
this.sendCertMsg = this.api.sendCertMsg.bind(this.api);
this.certMobile = this.api.certMobile.bind(this.api);
this.relateMobile = this.api.relateMobile.bind(this.api);
this.checkEmailCertTip = this.api.checkEmailCertTip.bind(this.api);
}
async certCheck(mobile, area, smsCode) {
... ...
... ... @@ -64,7 +64,6 @@ router.get('/passport/login/renren/callback', login.renren.callback);
// 第三方登录后绑定手机号
router.get('/passport/thirdlogin/index', bind.indexPage);
router.get('/passport/thirdlogin/bindsuccess', bind.bindSuccess);
router.post('/passport/autouserinfo/bindCheck', bind.bindCheck);
router.post('/passport/autouserinfo/sendBindMsg', bind.sendBindMsg);
router.post('/passport/autouserinfo/bindMobile', bind.bindMobile);
... ...
... ... @@ -12,6 +12,8 @@ var phoneRegx = require('../passport/mail-phone-regx');
var Alert = dialog.Alert;
var bindDialog = require('../passport/cert/dialog');
var $checkUser = $('.check-user'),
$checkInput = $checkUser.find('input').not('input[type=button],input[type=hidden],input[type=reset]'),
canSend = true,
... ... @@ -148,7 +150,7 @@ function checkForm(dom) {
text = val.split('-');
if (text.length === 1) {
regular = val.match('^1[35847]{1}[0-9]{9}');
regular = val.match('^1[0-9]{1}[0-9]{9}');
} else {
regular = regular['+' + text[0]].test(text[1]);
}
... ... @@ -289,6 +291,80 @@ function sendMobileMsg(mobileV) {
});
}
function goLogin() {
window.jumpUrl('/signin.html');
}
function goBind(area, mobile, smsCode) {
return $.post('/home/account/modifymobile', {
area: area,
mobile: mobile,
code: smsCode
}).then(function(result) {
if (result.code !== 200) {
new Alert(result.mesage).show();
return false;
}
window.location.href = '/home/account/mobile?step=3&success=true';
return true;
});
}
function checkBind(area, mobile, smsCode) {
return $.post('/home/account/mobilecheck', {
area: area,
mobile: mobile,
code: smsCode
}).then(function(data) {
var isBind, isRegister;
if (data.code === 200) {
isBind = data.data && data.data.isBind;
isRegister = data.data && data.data.isRegister;
if (isRegister === 'Y') {
if (isBind === 'N') {
bindDialog.showBind(goLogin, function() {
goBind(area, mobile, smsCode);
});
} else {
bindDialog.showBind2(goLogin, function() {
goBind(area, mobile, smsCode);
});
}
} else {
goBind(area, mobile, smsCode);
}
} else {
if (data && data.message) {
new Alert(data.message).show();
}
}
});
}
// 发送手机验证码ajax请求
function sendMobileMsg2(mobileV) {
var $code = $('#inputcode2'),
$ccheckInfo = $code.parent().find('.check-info');
var reqData = {
mobile: mobileV
};
$.post('/home/account/mobilesendmsg', reqData, function(result) {
if (result.code && result.code === 200) {
canSend = false;
sInt = setInterval(function() {
code();
}, 1000);
$ccheckInfo.html('');
} else {
$ccheckInfo.html('<div class="form-error">' + result.message + '</div>');
}
});
}
// 发送手机验证码
function sendcode() {
var $mobile = $('#mobilevalue');
... ... @@ -332,6 +408,40 @@ function sendcode() {
}
}
// 发送手机验证码
function sendcode2() {
var $mobile = $('#mobilevalue2');
var $mcheckInfo,
mobileV,
mobileObj;
if ($mobile.length > 0) {
$mcheckInfo = $mobile.next();
mobileV = $mobile.val();
mobileObj = mobileV.split('-');
if (mobileObj.length === 1) {
mobileObj = mobileV.match('^1[0-9]{1}[0-9]{9}');
} else {
mobileObj = phoneRegx.phoneRegx['+' + mobileObj[0]].test(mobileObj[1]);
}
} else {
mobileV = $('#realAccount').val();
}
if ($mobile.length > 0) {
if (mobileObj === null || !mobileObj) {
$mcheckInfo.html('<div class="form-error">手机号错误!</div>');
$mobile.addClass('input-error');
return false;
}
sendMobileMsg2(mobileV);
}
}
// 验证完成后倒计时跳转
function toHome() {
window.location.href = '/home/account';
... ... @@ -399,7 +509,7 @@ function submitForm() {
verifyCode: captcha.getResults()
},
hrefUrl: '/home/account/sendemailsuccess?email=' + $('#realAccount').val() +
'&type=1&checkType=' + curType
'&type=1&checkType=' + curType
};
ajaxAction(opt);
} else {
... ... @@ -433,20 +543,11 @@ function submitForm() {
checkCode: baseQs.checkCode || ''
},
hrefUrl: '/home/account/sendemailsuccess?email=' + $('#email').val() +
'&type=2&checkType=email'
'&type=2&checkType=email'
};
ajaxAction(opt);
} else {
opt = {
url: '/home/account/modifymobile',
data: {
mobile: $('#mobilevalue').val(),
code: $('#inputcode').val(),
checkCode: baseQs.checkCode || ''
},
hrefUrl: '/home/account/mobile?step=3&success=true'
};
ajaxAction(opt);
checkBind(null, $('#mobilevalue2').val(), $('#inputcode2').val());
}
}
}
... ... @@ -503,6 +604,11 @@ $(function() {
sendcode();
});
// 验证手机号第二步,需要不同的发送手机号的方法
$('#send-mobile-code2').on('click', function() {
sendcode2();
});
if ($('#newPwd').length > 0) {
$('#newPwd').on('input', function() {
var $confirm = $('input[name=confirm_password]'),
... ...
... ... @@ -9,8 +9,6 @@ var phoneRegx = require('../common/mail-phone-regx').phoneRegx;
var nopermissionoption = $('#nopermissionmessage').html(); // 倒计时dom
var sendmessagehtml = $('.validatewrapper').html(); // 发送短信dom
var second = +$('.second').text(); // 倒计时秒数
var dovalidate = false; // 校验验证码标识
var validatecode = false; // 验证码是否通过
var choosedpic = 'https://cdn.yoho.cn/yohobuy/assets/img/passport/choosed.png';// 已选择图片
var $wrapper = $('.bindwrapper'),
... ... @@ -18,10 +16,10 @@ var $wrapper = $('.bindwrapper'),
$nextBtn = $wrapper.find('.yohobindbtn');
var Alert = require('../../common/dialog').Alert;
var dialog = require('../cert/dialog');
require('../../simple-header');
var dialog = require('../cert/dialog');
/**
* 选择协议
... ... @@ -66,45 +64,6 @@ function chooseAreaToogle() {
}
/**
* 验证码校验
* @return {[type]} [description]
*/
function codeValidate() {
var validatenum = '';
$(document).on('keyup', '#validatenum', function() {
validatenum = $(this).val();
if (validatenum.length === 4) {
if (!dovalidate) {
dovalidate = true;
$.ajax({
type: 'POST',
url: '/passport/autouserinfo/checkBindMsg',
data: {
code: validatenum,
mobile: $('#mobile').val(),
area: $('#areacode').val()
}
}).then(function(data) {
dovalidate = false;
if (data.code === 200) {
validatecode = true;
} else {
alert(data.message); // eslint-disable-line
}
});
}
}
});
$('#validatenum').focus(function() {
$(this).removeAttr('placeholder');
}).blur(function() {
$(this).attr('placeholder', '验证码');
});
}
/**
* 选择区域
* @return {[type]} [description]
*/
... ... @@ -195,7 +154,7 @@ function sendMessageValidate() {
$.ajax({
type: 'POST',
url: '/passport/autouserinfo/sendBindMsgCode',
url: '/passport/autouserinfo/sendBindMsg',
data: {
mobile: $('#mobile').val(),
area: $('#areacode').val()
... ... @@ -216,21 +175,16 @@ function sendMessageValidate() {
* 最终提交表单
*/
function actionSubmit() {
var mobile = '';
var area = '';
area = $('#areacode').val();
mobile = $('#mobile').val();
$.ajax({
type: 'POST',
url: '/passport/autouserinfo/bindMobile',
data: {
area: area,
area: $('#areacode').val(),
openId: $('#openId').val(),
sourceType: $('#sourceType').val(),
nickName: $('#nickName').val(),
mobile: mobile,
code: $('#validatenum').val()
mobile: $('#mobile').val(),
code: $('#smscode').val()
}
}).then(function(data) {
if (data.code === 200) {
... ... @@ -245,20 +199,9 @@ function actionSubmit() {
});
}
/**
* 确认去绑定
* @return {[type]} [description]
*/
function goToBindPhone() {
$(document).on('click', '#gotobindphone', function() {
if (validatecode === true) {
$('#inarea').val($('#areacode').val());
$('#inmobile').val($('#mobile').val());
actionSubmit();
} else {
alert('请输入正确验证码'); // eslint-disable-line
}
});
function goLogin() {
window.jumpUrl('/signin.html');
}
/**
... ... @@ -266,12 +209,9 @@ function goToBindPhone() {
* @return {[type]} [description]
*/
function nextStep() {
var openId = '';
var sourceType = '';
var mobile = '';
var areaCode = '';
var username = '';
var headImg = '';
var smsCode = '';
$('#bindfirststep').on('click', function(e) {
var regx;
... ... @@ -289,75 +229,42 @@ function nextStep() {
$phoneTip.removeClass('hide');
return;
}
openId = $('#openId').val() || '29803EC6D4AAC3AAB8ABDB6AE829D579';
sourceType = $('#sourceType').val() || 'qq';
smsCode = $('#smscode').val();
if (!smsCode) {
return;
}
$.ajax({
type: 'post',
url: '/passport/autouserinfo/bindCheckSendMsg',
url: '/passport/cert/check',
data: {
mobile: mobile,
area: areaCode,
openId: openId,
sourceType: sourceType
code: smsCode
},
dataType: 'json',
success: function(data) {
var winHeight = $(window).height();
var isBind;
var isRegister;
if (data.code === 200) {
$('#bindmobileform').attr('action', data.data.next);
$('#bindmobileform').submit();
} else if (data.code === 201) {
// 已注册 未绑定
username = data.data.user.username;
headImg = data.data.user.headImg;
$('#registphone').text(mobile);
$('#username').text(username);
if (headImg === '') {
$('#userphoto').attr('src', 'http://img10.static.yhbimg.com/headimg/2013/11/28/09/' +
'01cae078abe5fe320c88cdf4c220212688.gif?imageView/2/w/100/h/100');
} else {
$('#userphoto').attr('src', headImg);
}
$('#logindirectly2').attr('href', data.data.user.bindLogin);
$('.backdrop').show();
$('#alreayregist .mask').css({
'padding-top': winHeight > 440 ? winHeight / 2 : 217
});
$('#alreayregist').show();
// 201 code send msg
circleTime($('#mobile').val());
} else if (data.code === 203) {
// 已注册 可关联
new Alert('绑定失败,该手机号已注册,请更换或使用该手机号直接登录').show();
} else if (data.code === 205) {
// 未注册 不可关联
username = data.data.user.username;
headImg = data.data.user.headImg;
$('#registphonetwo').text(mobile);
$('#username1').text(username);
if (headImg === '') {
$('#userphoto1').attr('src', 'http://img10.static.yhbimg.com/headimg/2013/11/28/09/' +
'01cae078abe5fe320c88cdf4c220212688.gif?imageView/2/w/100/h/100');
isBind = data.data && data.data.isBind;
isRegister = data.data && data.data.isRegister;
if (isRegister === 'Y') {
if (isBind === 'N') {
dialog.showBind(goLogin, actionSubmit);
} else {
dialog.showBind2(goLogin, actionSubmit);
}
} else {
$('#userphoto1').attr('src', headImg);
actionSubmit();
}
$('#logindirectly').attr('href', data.data.user.bindLogin);
$('.backdrop').show();
$('#bindconfirm .mask').css({
'padding-top': winHeight > 440 ? winHeight / 2 : 217
});
$('#bindconfirm').show();
} else if (data.code === 402) {
$phoneTip.find('em').text('手机格式错误');
$phoneTip.removeClass('hide');
} else {
if (data && data.message) {
alert(data.message); // eslint-disable-line
new Alert(data.message).show();
}
}
}
... ... @@ -380,7 +287,5 @@ function init() {
chooseAreaToogle(); // 选择区域展示或关闭
cancelChooseArea(); // 取消选择区域
nextStep(); // 下一步
goToBindPhone(); // 绑定手机
codeValidate(); // 验证码校验
}
init();
... ...
.bind-info-wrapper {
.iconfont {
font-size: 25px;
}
.title {
font-size: 20px;
margin-top: 50px;
margin-bottom: 10px;
}
.title2 {
font-size: 20px;
margin-bottom: 55px;
}
.question {
font-size: 20px;
margin-bottom: 10px;
}
.subtitle {
font-size: 16px;
color: #999;
margin-top: 24px;
margin-bottom: 43px;
}
.btn-cancel {
border-radius: 3px;
width: 120px;
height: 35px;
line-height: 35px;
color: #999;
border: solid 1px #999;
padding: 0 !important;
}
.btn-ok {
width: 120px;
height: 35px;
color: white;
background: #444;
border-radius: 3px;
line-height: 35px;
border: solid 1px #444;
padding: 0 !important;
margin-left: 38px !important;
}
min-width: 320px !important;
padding-left: 55px;
padding-right: 55px;
padding-bottom: 40px;
}
... ...
... ... @@ -13,3 +13,4 @@
@import "list";
@import "good";
@import "invalid-ie";
@import "_bind-dialog";
... ...
... ... @@ -799,59 +799,3 @@
background: resolve("passport/angle.png");
}
}
.bind-info-wrapper {
.iconfont {
font-size: 25px;
}
.title {
font-size: 20px;
margin-top: 50px;
margin-bottom: 10px;
}
.title2 {
font-size: 20px;
margin-bottom: 55px;
}
.question {
font-size: 20px;
margin-bottom: 10px;
}
.subtitle {
font-size: 16px;
color: #999;
margin-top: 24px;
margin-bottom: 43px;
}
.btn-cancel {
border-radius: 3px;
width: 120px;
height: 35px;
line-height: 35px;
color: #999;
border: solid 1px #999;
padding: 0 !important;
}
.btn-ok {
width: 120px;
height: 35px;
color: white;
background: #444;
border-radius: 3px;
line-height: 35px;
border: solid 1px #444;
padding: 0 !important;
margin-left: 38px !important;
}
min-width: 320px !important;
padding-left: 55px;
padding-right: 55px;
padding-bottom: 40px;
}
... ...