...
|
...
|
@@ -9,68 +9,16 @@ |
|
|
* @author: bikai<kai.bi@yoho.cn>
|
|
|
* @date: 2015/11/19
|
|
|
*/
|
|
|
import $ from 'yoho-jquery';
|
|
|
import Page from 'yoho-page';
|
|
|
import tip from 'plugin/tip';
|
|
|
|
|
|
let $ = require('yoho-jquery');
|
|
|
let $userAvatar = $('.user-avatar');
|
|
|
let myImage = new Image(),
|
|
|
avatar;
|
|
|
|
|
|
require('common');
|
|
|
|
|
|
class PersonDetail extends Page {
|
|
|
constructor() {
|
|
|
super();
|
|
|
this.selector = {
|
|
|
$modifyInp: $('.modify'),
|
|
|
$nickName: $('.nick-name'),
|
|
|
$gender: $('.gender'),
|
|
|
$birthday: $('.birthday'),
|
|
|
};
|
|
|
|
|
|
this.init();
|
|
|
}
|
|
|
|
|
|
init() {
|
|
|
this.bindEvents();
|
|
|
|
|
|
// 部分老用户没有头像,显示默认头像
|
|
|
avatar = $userAvatar.data('avatar');
|
|
|
myImage.src = avatar;
|
|
|
myImage.onload = function() {
|
|
|
$userAvatar.css('background-image', 'url(' + avatar + ')');
|
|
|
};
|
|
|
}
|
|
|
|
|
|
bindEvents() {
|
|
|
this.selector.$modifyInp.on('blur', this.modifyInp.bind(this));
|
|
|
}
|
|
|
|
|
|
modifyInp() {
|
|
|
if (!this.selector.$nickName.val()) {
|
|
|
tip.show('请输入昵称');
|
|
|
return false;
|
|
|
}
|
|
|
this.ajax({
|
|
|
url: '/home/mydetails/modify',
|
|
|
data: {
|
|
|
nickName: this.selector.$nickName.val(),
|
|
|
gender: this.selector.$gender.val(),
|
|
|
birthday: this.selector.$birthday.val()
|
|
|
},
|
|
|
}).then(result => {
|
|
|
if (result && result.code === 200) {
|
|
|
location.href = location.href;
|
|
|
} else {
|
|
|
tip.show(result.message);
|
|
|
}
|
|
|
}).catch(error => {
|
|
|
tip.show(error);
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$(() => {
|
|
|
new PersonDetail();
|
|
|
}); |
|
|
// 部分老用户没有头像,显示默认头像
|
|
|
avatar = $userAvatar.data('avatar');
|
|
|
myImage.src = avatar;
|
|
|
myImage.onload = function() {
|
|
|
$userAvatar.css('background-image', 'url(' + avatar + ')');
|
|
|
}; |
...
|
...
|
|