Authored by 姜敏

个人设置界面校验修复

... ... @@ -40,18 +40,18 @@
<a class="blue operation" href="{{stepUrl}}/bindMobile">绑定</a>
{{/if}}
</div>
<div class="form-group">
<!-- <div class="form-group">
<label class="label-name">邮箱:</label>
{{#if info.verify_email}}
<input class="input no-edit" value="{{info.mobile}}">
<!--<a class="blue operation" href="{{stepUrl}}/modifyEmail">修改</a>-->
&lt;!&ndash;<a class="blue operation" href="{{stepUrl}}/modifyEmail">修改</a>&ndash;&gt;
<a class="blue operation">修改</a>
{{else}}
<input class="input" type="text" placeholder="请绑定邮箱" disabled>
<!--<a class="blue operation" href="{{stepUrl}}/bindEmail">绑定</a>-->
&lt;!&ndash;<a class="blue operation" href="{{stepUrl}}/bindEmail">绑定</a>&ndash;&gt;
<a class="blue operation">绑定</a>
{{/if}}
</div>
</div>-->
<div class="form-group">
<label class="label-name">出生日期:</label>
<input id="birthday" class="input" type="text" value="{{info.birthday}}">
... ... @@ -60,6 +60,7 @@
<div class="form-group-address">
<label class="label-name">居住地址:</label>
<div id="address"></div>
<span class="blue error-tips">{{> icon/error-round}}请选择</span>
</div>
<div class="form-group">
<label class="label-name">详细地址:</label>
... ...
... ... @@ -9,14 +9,10 @@ var _dialog = dialog.Dialog;
var _alert = dialog.Alert;
var Bll = {
setIcon: function() {
setIcon: function () {
var html = [];
html.push('<form id="upload_form" method="post" action="" onsubmit="return checkForm()">');
html.push('<input type="hidden" id="x1" name="x1" />');
html.push('<input type="hidden" id="y1" name="y1" />');
html.push(' <input type="hidden" id="x2" name="x2" />');
html.push(' <input type="hidden" id="y2" name="y2" />');
html.push('<div class="post-picture inline-block">');
html.push('<div class="choose-avatar"></div>');
html.push('<div class="post-file"><input id="avatar" name="avatar" type="file" value="点击上传"></div>');
... ... @@ -31,13 +27,20 @@ var Bll = {
return html.join('');
},
validate: function(info) {
var reg = new RegExp(/^[1-2][0-9][0-9][0-9]-[0-1]{0,1}[0-9]-[0-3]{0,1}[0-9]$/);
validate: function (info) {
var regBirth = new RegExp(/^[1-2][0-9][0-9][0-9]-[0-1]{0,1}[0-9]-[0-3]{0,1}[0-9]$/);
var regName = new RegExp(/^[\u4e00-\u9fa5_-a-zA-Z0-9]+$/);
var birthdayForm = $('#birthday');
var nickForm = $('#nick_name');
var addressForm = $('.form-group-address');
var flag = true;
!reg.test(info.birthday) ? birthdayForm.next().show() : birthdayForm.next().hide();
if (!reg.test(info.birthday)) {
!regBirth.test(info.birthday) ? birthdayForm.next().show() : birthdayForm.next().hide();
!regName.test(info.nick_name) ? nickForm.next().show() : nickForm.next().hide();
typeof (info.area_code) === 'undefined' ?
addressForm.css('margin-bottom', '20px').find('.error-tips').show() :
addressForm.css('margin-bottom', '70px').find('.error-tips').hide();
if (!regBirth.test(info.birthday) || !regName.test(info.nick_name) || typeof (info.area_code) === 'undefined') {
flag = false;
}
return flag;
... ... @@ -52,14 +55,14 @@ require('../me/setting/step3');
// 编辑头像移入移出切换效果
$('.user-icon').hover(function() {
$('.user-icon').hover(function () {
$(this).find('.show-ico ').addClass('hide').end().find('.edit-ico').removeClass('hide');
}, function() {
}, function () {
$(this).find('.show-ico').removeClass('hide').end().find('.edit-ico').addClass('hide');
});
// 编辑头像打开弹框
$(document).on('click', '.edit-ico', function() {
$(document).on('click', '.edit-ico', function () {
var tip = new _dialog({
className: 'settled-success',
title: '自定义头像',
... ... @@ -69,7 +72,7 @@ $(document).on('click', '.edit-ico', function() {
id: 'apply',
btnClass: ['apply'],
name: '保存',
cb: function() {
cb: function () {
tip.close();
}
},
... ... @@ -77,7 +80,7 @@ $(document).on('click', '.edit-ico', function() {
id: 'cancel',
btnClass: ['cancel'],
name: '取消',
cb: function() {
cb: function () {
tip.close();
}
}
... ... @@ -86,7 +89,7 @@ $(document).on('click', '.edit-ico', function() {
});
$(document).on('change', '#avatar', function() {
$(document).on('change', '#avatar', function () {
/* var oFile = $("#avatar")[0].files[0];
var oImage = document.getElementById('post-picture');
var oReader = new FileReader();
... ... @@ -99,16 +102,20 @@ $(document).on('change', '#avatar', function() {
});
$(function() {
$(function () {
var address = cascadingAddress({el: '#address'});
var areaCode = $('#area_code').val();
if (areaCode) {
address.setAddress(areaCode);
}
address.setAddress($('#area_code').val());
// 设置性别
$('.input-radio').check({
type: 'radio',
group: 'genders',
onChange: function(ele, checked, value) {
onChange: function (ele, checked, value) {
var gender = $('#gender').val();
checked ? $('#gender').val(value) : $('#gender').val(gender);
... ... @@ -118,7 +125,7 @@ $(function() {
/**
* 保存修改
*/
$(document).on('click', '#save-settings', function() {
$(document).on('click', '#save-settings', function () {
var area = address.getAreaIds();
var body = {
... ... @@ -136,17 +143,16 @@ $(function() {
zip_code: $('#zip_code').val() || '210000'
};
// console.log(body);
if (Bll.validate(body)) {
$.ajax({
type: 'POST',
url: '/me/setting/editUserInfo',
dataType: 'json',
data: body,
success: function(data) {
success: function (data) {
var len = 0;
data.forEach(function(x) {
data.forEach(function (x) {
if (x.code === 200) {
len++;
}
... ...
... ... @@ -16,7 +16,7 @@ var type = types[types.length - 1];
var second = 60;
var $sms = $('#send-code');// 发送短信验证码按钮
// 发送短信后倒计时显示
var disableSMSBtn = function() {
var disableSMSBtn = function () {
second -= 1;
if (second < 0) {
second = 60;
... ... @@ -31,7 +31,7 @@ var disableSMSBtn = function() {
};
// 发送手机验证码
$sms.click(function() {
$sms.click(function () {
var mobile = $('#real-mobile').val();
var area = $('#country-code').text();
... ... @@ -47,7 +47,7 @@ $sms.click(function() {
mobile: mobile,
area: area
},
success: function(data) {
success: function (data) {
if (data.code !== 200) {
new _alert(data.message).show();
$sms.removeClass('disable');
... ... @@ -58,7 +58,7 @@ $sms.click(function() {
});
});
$('#mobile-step1').click(function() {
$('#mobile-step1').click(function () {
var code = $('#msg-code').val().trim();
var mobile = $('#real-mobile').val();
var area = '+86';
... ... @@ -71,7 +71,7 @@ $('#mobile-step1').click(function() {
mobile: mobile,
area: area
},
success: function(data) {
success: function (data) {
if (data.code === 200) {
location.href = '/me/setting/step2/' + type + '?checkCode=' + $('#checkCode').val();
} else {
... ... @@ -88,7 +88,7 @@ $('#mobile-step1').click(function() {
* 密码校验
*/
// 换图形验证码
$('.change-captcha').click(function() {
$('.change-captcha').click(function () {
var time = new Date();
var $captchaImg = $('.captcha-img');
var captchaImgSrc = $captchaImg.attr('src').split('?')[0];
... ... @@ -97,15 +97,14 @@ $('.change-captcha').click(function() {
});
// 校验图片验证码
$imgCaptchaInput.blur(function() {
$imgCaptchaInput.blur(function () {
$.ajax({
type: 'POST',
url: '/passport/images/check',
data: {
verifyCode: $imgCaptchaInput.val()
},
success: function(data) {
console.log(data);
success: function (data) {
if (data.code === 200) {
$imgCaptchaInput.parent().find('.tips-success').addClass('ok').show();
$imgCaptchaInput.parent().find('.tips-error').removeClass('notok').hide();
... ... @@ -118,7 +117,7 @@ $imgCaptchaInput.blur(function() {
});
// 第一步提交
$('#pwd-step1').click(function() {
$('#pwd-step1').click(function () {
var password = $('#verifyPwd').val();
if ($('.notok').length === 0) {
... ... @@ -128,7 +127,7 @@ $('#pwd-step1').click(function() {
data: {
password: password
},
success: function(data) {
success: function (data) {
if (data.code === 200) {
location.href = '/me/setting/step2/' + type + '?checkCode=' + $('#checkCode').val();
} else {
... ... @@ -144,7 +143,7 @@ $('#pwd-step1').click(function() {
* 邮箱验证
*/
$('#email-step1').click(function() {
$('#email-step1').click(function () {
if ($('.notok').length === 0) {
$.ajax({
type: 'POST',
... ... @@ -152,7 +151,7 @@ $('#email-step1').click(function() {
data: {
email: $('#real-email').val()
},
success: function(data) {
success: function (data) {
// todo 发送邮件
if (data.code === 200) {
$('.operate1').hide();
... ...
... ... @@ -12,7 +12,7 @@ var $imgCaptchaInput = $('#captcha');
var second = 60;
var $sms = $('#send-code2');// 发送短信验证码按钮
// 发送短信后倒计时显示
var disableSMSBtn = function() {
var disableSMSBtn = function () {
second -= 1;
if (second < 0) {
second = 60;
... ... @@ -27,7 +27,7 @@ var disableSMSBtn = function() {
};
// 校验手机号码格式
var validatePhoneNumLocal = function(phoneNum) {
var validatePhoneNumLocal = function (phoneNum) {
var length = phoneNum.length;
if (length === 0) {
... ... @@ -44,12 +44,12 @@ var validatePhoneNumLocal = function(phoneNum) {
/**
* 绑定手机号码
*/
$('#region').on('change', function() {
$('#region').on('change', function () {
$('#country-code').text($(this).val());
});
// 校验手机号码
$('#real-mobile').blur(function() {
$('#real-mobile').blur(function () {
var mobile = $(this).val();
var area = $('#country-code').text();
var self = $('#real-mobile').parent();
... ... @@ -63,7 +63,7 @@ $('#real-mobile').blur(function() {
mobile: mobile,
area: area
},
success: function(data) {
success: function (data) {
if (data.code === 200) {
self.find('.tips-success').addClass('ok').show();
self.find('.tips-error').removeClass('notok').hide();
... ... @@ -79,7 +79,7 @@ $('#real-mobile').blur(function() {
// 发送手机验证码
$sms.click(function() {
$sms.click(function () {
var mobile = $('#real-mobile').val();
var area = $('#country-code').text();
... ... @@ -95,7 +95,7 @@ $sms.click(function() {
mobile: mobile,
area: area
},
success: function(data) {
success: function (data) {
if (data.code !== 200) {
new _alert(data.message).show();
$sms.removeClass('disable');
... ... @@ -106,7 +106,7 @@ $sms.click(function() {
});
});
$('#mobile-step2').click(function() {
$('#mobile-step2').click(function () {
var code = $('#msg-code').val();
var mobile = $('#real-mobile').val();
var self = $('#msg-code').parent();
... ... @@ -120,7 +120,7 @@ $('#mobile-step2').click(function() {
mobile: mobile,
area: area
},
success: function(data) {
success: function (data) {
if (data.code === 200) {
self.find('.tips-success').addClass('ok').show();
self.find('.tips-error').removeClass('notok').hide();
... ... @@ -139,7 +139,7 @@ $('#mobile-step2').click(function() {
* 修改密码
*/
// 输入确认密码
$('#checkPwd').blur(function() {
$('#checkPwd').blur(function () {
var newPwd = $('#newPwd').val().trim();
var checkPwd = $(this).val().trim();
var self = $(this).parent();
... ... @@ -154,15 +154,14 @@ $('#checkPwd').blur(function() {
});
// 校验图片验证码
$imgCaptchaInput.blur(function() {
$imgCaptchaInput.blur(function () {
$.ajax({
type: 'POST',
url: '/passport/images/check',
data: {
verifyCode: $imgCaptchaInput.val()
},
success: function(data) {
console.log(data);
success: function (data) {
if (data.code === 200) {
$imgCaptchaInput.parent().find('.tips-success').addClass('ok').show();
$imgCaptchaInput.parent().find('.tips-error').removeClass('notok').hide();
... ... @@ -175,7 +174,7 @@ $imgCaptchaInput.blur(function() {
});
// 提交修改密码
$('#step2-pwd').click(function() {
$('#step2-pwd').click(function () {
var password = $('#newPwd').val();
if ($('.notok').length === 0) {
... ... @@ -185,7 +184,7 @@ $('#step2-pwd').click(function() {
data: {
password: password
},
success: function(data) {
success: function (data) {
if (data.code === 200) {
location.href = '/me/setting/step3/' + type + '?checkCode=' + $('#checkCode').val();
} else {
... ...