...
|
...
|
@@ -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(); |
...
|
...
|
|