Authored by biao

update

/**
* 注册
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/10/8
*/
var $ = require('jquery');
var $phoneNum = $('#phone-num'),
$countrySelect = $('#country-select'),
$areaCode = $('#area-code'),
$openId = $('#openId'),
$sourceType = $('#sourceType'),
$btnNext = $('#btn-next');
var api = require('../api'),
tip = require('../../plugin/tip'),
dialog = require('../../me/dialog');
var trim = $.trim;
var showErrTip = tip.show;
api.selectCssHack($('#country-select'));
api.bindClearEvt();
$phoneNum.bind('input', function() {
if (trim($phoneNum.val()) === '') {
$btnNext.addClass('disable');
} else {
$btnNext.removeClass('disable');
}
});
$countrySelect.change(function() {
$areaCode.text($countrySelect.val());
});
$btnNext.on('touchstart', function() {
var pn = trim($phoneNum.val()),
openId = trim($openId.val()),
sourceType = trim($sourceType.val()),
areaCode = $countrySelect.val();
if ($btnNext.hasClass('disable')) {
return;
}
if (api.phoneRegx[areaCode].test(pn)) {
$.ajax({
url: '/passport/bind/bindCheck',
type: 'POST',
data: {
areaCode: areaCode.replace('+', ''),
mobile: pn,
openId: openId,
sourceType: sourceType
},
success: function(res) {
console.log(res);
//res : {
// code: 'xxx',
// data: {
// isReg: 0,
// next: 'xxxx'
// },
// message: 'xxxx',
//}
if (res.code === 200) {
if (res.data.isReg === 1) {
dialog.showDialog({
dialogText: '该手机号已注册过有货\n' + pn +',确定绑定吗?',
hasFooter: {
leftBtnText: '更换号码',
rightBtnText: '继续绑定'
}
}, function() {
location.href = res.data.next;
});
} else {
location.href = res.data.next;
}
} else {
showErrTip(res.message);
}
}
});
} else {
showErrTip('手机号格式不正确,请重新输入');
}
});
... ...
/**
* 注册-验证码
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/10/8
*/
require('../code')(true, true);
... ...
/**
* 注册-密码
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/10/8
*/
var $ = require('jquery');
var $pwd = $('#pwd'),
$btnSure = $('#btn-sure');
var api = require('../api');
var tip = require('../../plugin/tip');
var trim = $.trim;
var showErrTip = tip.show;
api.bindEyesEvt({
status: 'open' //默认眼睛打开
});
$pwd.bind('input', function() {
if (trim($pwd.val()) === '') {
$btnSure.addClass('disable');
} else {
$btnSure.removeClass('disable');
}
});
$btnSure.on('touchstart', function() {
var pwd = trim($pwd.val());
if ($btnSure.hasClass('disable')) {
return;
}
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);
}
}
});
}
});
\ No newline at end of file
... ...
... ... @@ -5,7 +5,7 @@
*/
var $ = require('jquery');
module.exports = function(useInRegister) {
module.exports = function(useInRegister, useForBind) {
var $captcha = $('#captcha'),
$btnNext = $('#btn-next'),
$captchaTip = $('#captcha-tip'),
... ... @@ -52,7 +52,7 @@ module.exports = function(useInRegister) {
$.ajax({
type: 'POST',
url: '/passport/' + urlMid + '/sendcode',
url: useForBind ? '/passport/bind/sendBindMsg' : '/passport/' + urlMid + '/sendcode',
data: {
phoneNum: phoneNum,
areaCode: areaCode
... ... @@ -77,7 +77,7 @@ module.exports = function(useInRegister) {
$.ajax({
type: 'POST',
url: '/passport/' + urlMid + '/verifycode',
url: useForBind ? '/passport/bind/sendBindMsg' : '/passport/' + urlMid + '/verifycode',
data: {
phoneNum: phoneNum,
areaCode: areaCode,
... ...
{{> layout/header}}
<div class="bind-code-page passport-page yoho-page">
<div class="reg-code-page passport-page yoho-page">
{{> passport/code}}
</div>
{{> layout/footer}}
... ...