...
|
...
|
@@ -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++;
|
|
|
}
|
...
|
...
|
|