Authored by htoooth

fix.bind

... ... @@ -30,7 +30,7 @@ const bind = {
let openId = req.query.openId;
let sourceType = req.query.sourceType;
res.render('bind', {
res.render('bind/index', {
thirdLogin: true,
openId: openId,
sourceType: sourceType,
... ... @@ -193,7 +193,7 @@ const bind = {
* code:505 // 手机号码注册过,而且该第三方也已经绑定过手机号
* code:506 // 手机号码注册过,而且该手机号码也已经绑定过该类型第三方
*/
bind._bindCheck(mobile, openId, area, sourceType).then(result => {
bind._bindCheck(req, mobile, openId, area, sourceType).then(result => {
if (result.code === 201) {
req.ctx(BindService).sendBindMsg(area, mobile, id, captcha).then(d => {
if (d && d.code) {
... ...
... ... @@ -7,10 +7,31 @@
'use strict';
const _ = require('lodash');
const BindApi = require('./bind-api');
const CaptchaImgService = require('./captcha-img-service');
module.exports = class extends BindApi {
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;
}
};
... ...
... ... @@ -64,7 +64,7 @@ router.get('/passport/login/renren/callback', login.renren.callback);
// 第三方登录后绑定
router.get('/passport/thirdlogin/index', captcha.required, bind.indexPage);
router.get('/passport/thirdlogin/bindsuccess', bind.bindSuccess);
router.post('/passport/thirdlogin/noregist', bind.noregist);
router.post('/passport/thirdlogin/noregist', captcha.required, bind.noregist);
router.post('/passport/thirdlogin/relate', bind.relate);
router.post('/passport/autouserinfo/bindCheckSendMsg', captcha.requiredAPI, bind.captchaSuccess, bind.bindCheckSendMsg);
... ...
... ... @@ -44,7 +44,7 @@
<div class="yohobindrow" style="height: 100px;">
<div class="name phonetag"></div>
<div id="captcha" style="display: inline-block; position: relative;">
<div id="captcha" class="{{#unless @root.captcha.value}}hide{{/unless}}" style="display: inline-block; position: relative;">
</div>
</div>
</form>
... ... @@ -120,7 +120,7 @@
</div>
<div class="yohobindrow" style="height: 110px;">
<div class="name phonetag"></div>
<div id="captcha2" style="display: inline-block; position: relative;">
<div id="captcha2" class='{{#unless @root.captcha.value}}hide{{/unless}}' style="display: inline-block; position: relative;">
</div>
</div>
<div class="gobindbottomwrapper">
... ...
... ... @@ -10,8 +10,8 @@
</p>
<form action="infoform" method="post">
<div class="validaterow">
<div class="yohobindrow" style="height: 110px;">
<div id="captcha" style="display: inline-block; position: relative;">
<div class="yohobindrow" style="height: 100px;">
<div id="captcha" class="{{#unless @root.captcha.value}}hide{{/unless}}" style="display: inline-block; position: relative;">
</div>
</div>
<div class="name phonetag">短信验证码</div>
... ... @@ -69,3 +69,5 @@
<input type="hidden" value="{{area}}" id="area"/>
</form>
</div>
{{> gee-captcha}}
... ...
... ... @@ -120,7 +120,6 @@ function sendMessageValidate() {
var area = '';
$(document).on('click', '#sendmessage', function() {
captcha.hideTip();
mobile = $('#mobile').val();
area = $('#area').val();
$.ajax({
... ... @@ -135,9 +134,10 @@ function sendMessageValidate() {
if (data.code === 200) {
circleTime();
return true;
} else if (data.code === 405) {
captcha.showTip(data.message);
return true;
}
if (data.data && data.data.needCaptcha){
captcha.show();
}
alert(data.message); // eslint-disable-line
... ...
... ... @@ -19,12 +19,17 @@ var $wrapper = $('.bindwrapper'),
$nextBtn = $wrapper.find('.yohobindbtn');
var captcha = new Captcha('#captcha').init();
var captcha2;
var captcha2 = new Captcha('#captcha2');
var Alert = require('../../common/dialog').Alert;
require('../../simple-header');
function showCaptchaImg() {
captcha.show();
captcha2.show();
}
/**
* 选择协议
* @return {[type]} [description]
... ... @@ -236,7 +241,6 @@ function sendMessageValidate() {
if ($('#sendmessage').attr('disabled') === 'disabled') {
return;
}
captcha2.hideTip();
$.ajax({
type: 'POST',
... ... @@ -247,10 +251,7 @@ function sendMessageValidate() {
verifyCode: captcha2.getResults()
}
}).then(function(data) {
if (data.code === 405) {
// 验证码 error
captcha2.showTip(data.message);
} else if (data.code !== 200) {
if (data.code !== 200) {
alert(data.message); // eslint-disable-line
} else {
circleTime($('#mobile').val());
... ... @@ -324,7 +325,6 @@ function nextStep() {
var regx;
e.preventDefault();
captcha.hideTip();
mobile = $('.phonenum').val();
areaCode = $('#areanum').text();
regx = phoneRegx['+' + areaCode];
... ... @@ -354,11 +354,15 @@ function nextStep() {
success: function(data) {
var winHeight = $(window).height();
if (data.code !== 200 && data.data && data.data.needCaptcha) {
showCaptchaImg();
}
if (data.code === 200) {
$('#bindmobileform').attr('action', data.data.next);
$('#bindmobileform').submit();
} else if (data.code === 201) {
captcha2 = new Captcha('#captcha2').init();
captcha2.init();
// 已注册 未绑定
username = data.data.user.username;
... ... @@ -405,9 +409,6 @@ function nextStep() {
} else if (data.code === 402) {
$phoneTip.find('em').text('手机格式错误');
$phoneTip.removeClass('hide');
} else if (data.code === 405) {
// 验证码 error
captcha.showTip(data.message);
} else {
if (data && data.message) {
alert(data.message); // eslint-disable-line
... ...