/**
  * 登录
  */
 public function login()
 {
     try {
         if (IS_POST) {
             $username = I('username');
             $password = I('password');
             $model = new AdminModel();
             $model->login($username, $password);
             $this->success('登录成功', U('/admin'));
         } else {
             C('LAYOUT_NAME', 'single');
             $this->assign('pageTitle', '登录');
             $this->display();
         }
     } catch (Exception $e) {
         $this->error($e->getMessage());
     }
 }
 public function updatePassword()
 {
     $admin = $this->Admin->getById(session('admin.id'));
     if (IS_POST) {
         if (md5(I('post.old_password')) !== $admin['password']) {
             //                echo error('原密码错误');die;
             $this->error('原密码错误', '', 1);
         }
         if (empty(I('post.password'))) {
             $this->error('密码不能为空');
         }
         if (I('post.password') !== I('post.re_password')) {
             $this->error('两次密码不一致');
         }
         $this->Admin->save(array('id' => session('admin.id'), 'password' => md5(I('post.password'))));
         $this->success('修改密码成功', U('Admin/Admin/logout'));
         exit;
     }
     $this->assign('admin', $admin);
     $this->display('updatePassword');
 }
 public function delete($id)
 {
     $this->Admin->remove($id);
     $this->redirect('all');
     exit;
 }