Authored by biao

update for bind mobile. code review by LZF

... ... @@ -9,6 +9,7 @@ var $phoneNum = $('#phone-num'),
$countrySelect = $('#country-select'),
$areaCode = $('#area-code'),
$openId = $('#openId'),
$nickname = $('#nickname'),
$sourceType = $('#sourceType'),
$btnNext = $('#btn-next');
... ... @@ -25,10 +26,16 @@ function nextStep(url, mobileNo, areaCode) {
url: '/passport/bind/sendBindMsg',
data: {
phoneNum: mobileNo,
areaCode: areaCode
areaCode: areaCode.replace('+', '')
},
success: function(res) {
console.log(res.data);
location.href = url;
},
error: function() {
tip.show('出错了,请重试!');
}
});
location.href = url;
}
api.selectCssHack($('#country-select'));
... ... @@ -50,6 +57,7 @@ $countrySelect.change(function() {
$btnNext.on('touchstart', function() {
var pn = trim($phoneNum.val()),
openId = trim($openId.val()),
nickname = trim($nickname.val()),
sourceType = trim($sourceType.val()),
areaCode = $countrySelect.val();
... ... @@ -63,9 +71,10 @@ $btnNext.on('touchstart', function() {
type: 'POST',
data: {
areaCode: areaCode.replace('+', ''),
mobile: pn,
phoneNum: pn,
openId: openId,
sourceType: sourceType
sourceType: sourceType,
nickname: nickname
},
success: function(res) {
console.log(res);
... ...
... ... @@ -14,6 +14,40 @@ var tip = require('../../plugin/tip');
var trim = $.trim;
var showErrTip = tip.show;
var nickname = $('#nickname').val(),
sourceType = $('#sourceType').val(),
openId = $('#openId').val(),
phoneNum = $('#phone-num').val(),
areaCode = $('#area-code').val().replace('+', '');
function startBind(password) {
$.ajax({
url: '/passport/bind/bindMobile',
type: 'post',
data: {
areaCode: areaCode.replace('+', ''),
phoneNum: phoneNum,
openId: openId,
sourceType: sourceType,
nickname: nickname,
password: password
},
success: function(res) {
if (res.code === 200) {
tip.show('登录成功');
setTimeout(function() {
location.href = res.data.refer;
}, 2000);
} else {
tip.show(res.message);
}
},
error: function(err) {
tip.show('登录失败,请重试!');
}
});
}
api.bindEyesEvt({
status: 'open' //默认眼睛打开
});
... ... @@ -36,35 +70,6 @@ $btnSure.on('touchstart', function() {
if (api.pwdValidate(pwd) === false) {
showErrTip('密码6-20位,请重新输入');
} else {
$.ajax({
type: 'POST',
url: '/passport/reg/setpassword',
data: {
password: pwd,
phoneNum: $('#phone-num').val(),
areaCode: $('#area-code').val(),
token: $('#token').val()
},
success: function(data) {
var res;
if (data.code === 200) {
res = data.data;
showErrTip('注册成功');
$.ajax({
url: res.session,
dataType: 'jsonp'
});
//1000ms后跳转页面
setTimeout(function() {
location.href = res.href;
}, 1000);
} else {
showErrTip(data.message);
}
}
});
startBind(pwd);
}
});
\ No newline at end of file
});
... ...
... ... @@ -9,6 +9,10 @@ module.exports = function(useInRegister, useForBind) {
var $captcha = $('#captcha'),
$btnNext = $('#btn-next'),
$captchaTip = $('#captcha-tip'),
isReg = parseInt($('#isReg').val()),
nickname = $('#nickname').val(),
sourceType = $('#sourceType').val(),
openId = $('#openId').val(),
phoneNum = $('#phone-num').val(),
areaCode = $('#area-code').val().replace('+', '');
... ... @@ -20,6 +24,34 @@ module.exports = function(useInRegister, useForBind) {
var urlMid = useInRegister ? 'reg' : 'back';
function startBind() {
$.ajax({
url: '/passport/bind/bindMobile',
type: 'post',
data: {
areaCode: areaCode.replace('+', ''),
phoneNum: phoneNum,
openId: openId,
sourceType: sourceType,
nickname: nickname,
password: ''
},
success: function(res) {
if (res.code === 200) {
tip.show('登录成功');
setTimeout(function() {
location.href = res.data.refer;
}, 2000);
} else {
tip.show(res.message);
}
},
error: function(err) {
tip.show('登录失败,请重试!');
}
});
}
function countDown() {
var count = 59,
itime;
... ... @@ -77,7 +109,7 @@ module.exports = function(useInRegister, useForBind) {
$.ajax({
type: 'POST',
url: useForBind ? '/passport/bind/sendBindMsg' : '/passport/' + urlMid + '/verifycode',
url: useForBind ? '/passport/bind/checkBindMsg' : '/passport/' + urlMid + '/verifycode',
data: {
phoneNum: phoneNum,
areaCode: areaCode,
... ... @@ -85,13 +117,22 @@ module.exports = function(useInRegister, useForBind) {
token: $('#token').val()
},
success: function(data) {
if (data.code === 200) {
location.href = data.data;
} else {
if (data.code === 200) {
if (useForBind) {
if (isReg) {
startBind();
} else {
location.href = '/passport/bind/password?phoneNum=' + phoneNum + '&areaCode=' + areaCode + '&openId=' + openId + '&sourceType=' + sourceType + '&nickname=' + nickname;
}
} else {
location.href = data.data;
}
} else {
//验证码不正确,显示提示
showErrTip(data.message);
}
//验证码不正确,显示提示
showErrTip(data.message);
}
}
});
});
... ...
{{> layout/header}}
<div class="reg-code-page passport-page yoho-page">
<input type="hidden" id="isReg" value="{{isReg}}">
<input type="hidden" id="openId" value="{{openId}}">
<input type="hidden" id="sourceType" value="{{sourceType}}">
<input type="hidden" id="nickname" value="{{nickname}}">
{{> passport/code}}
</div>
{{> layout/footer}}
... ...
... ... @@ -2,6 +2,7 @@
<div class="bind-page passport-page yoho-page">
<input type="hidden" id="openId" value="{{openId}}">
<input type="hidden" id="sourceType" value="{{sourceType}}">
<input type="hidden" id="nickname" value="{{nickname}}">
{{> passport/header}}
<div class="content">
{{> passport/country_list}}
... ...
{{> layout/header}}
<div class="bind-password-page passport-page yoho-page">
<input type="hidden" id="openId" value="{{openId}}">
<input type="hidden" id="sourceType" value="{{sourceType}}">
<input type="hidden" id="nickname" value="{{nickname}}">
{{> passport/header}}
<div class="content">
<div class="input-container row has-eye">
... ...