function profile()
{
if ($_POST) {
if (empty($_POST['nickname'])) {
return Swoole\JS::js_back('昵称不能为空!');
}
if (!empty($_FILES['avatar']['name'])) {
global $php;
$php->upload->thumb_width = 90;
$php->upload->thumb_height = 120;
$php->upload->thumb_qulitity = 90;
$php->upload->base_dir = "/static/uploads/avatar";
$upfile = $php->upload->save('avatar');
if ($upfile === false) {
return Swoole\JS::js_back('上传失败!');
}
$set['avatar'] = $_SESSION['user']['avatar'] = $upfile['thumb'];
}
$set['nickname'] = trim($_POST['nickname']);
$set['intro'] = trim($_POST['intro']);
$set['company'] = $_POST['company'];
$set['blog'] = $_POST['blog'];
$set['mobile'] = $_POST['mobile'];
$set['sex'] = (int) $_POST['sex'];
$set['education'] = (int) $_POST['education'];
$set['skill'] = implode(',', $_POST['skill']);
$set['php_level'] = (int) $_POST['php_level'];
$u = model('UserInfo');
$u->set($this->uid, $set);
$_SESSION['user']['realname'] = $set['realname'];
$_SESSION['user']['mobile'] = $set['mobile'];
return Swoole\JS::js_back('修改成功!');
} else {
require WEBPATH . '/dict/forms.php';
$_u = model('UserInfo');
$u = $_u->get($this->uid)->get();
$_skill = model('UserSkill')->getMap(array());
$_forms['sex'] = Swoole\Form::radio('sex', $forms['sex'], $u['sex']);
$_forms['education'] = Swoole\Form::select('education', $forms['education'], $u['education']);
$_forms['skill'] = Swoole\Form::checkbox('skill', $_skill, $u['skill']);
$_forms['level'] = Swoole\Form::radio('php_level', $forms['level'], $u['php_level']);
$this->swoole->tpl->assign('user', $u);
$this->swoole->tpl->assign('forms', $_forms);
$this->swoole->tpl->display();
//$this->view->showTrace();
}
}