/**
  * 用户主页
  */
 public function home()
 {
     $this->checkLogin();
     $model = new UserModel();
     if (IS_POST) {
         $avatar = I('avatar');
         $nickname = I('nickname');
         $password = I('password');
         if (!$model->create()) {
             $this->error($model->getError());
         }
         $data = ['avatar' => $avatar, 'nickname' => $nickname];
         if (!empty($password)) {
             $data['password'] = $password;
         }
         if ($model->where(array('userId' => $this->user['userId']))->save() === false) {
             $this->error('编辑失败');
         }
         $this->success('编辑成功');
     } else {
         $user = $model->find($this->user['userId']);
         $this->assign('user', $user);
         $this->display();
     }
 }