<?php
class Admin_LoginController extends Ctrl_Admin{
	public function IndexAction(){
		session_destroy();
		unset($_SESSION);
		$HospitalInfo = $this->HospitalInfo();
		$this->assign('HospitalInfo',$HospitalInfo);
	}
	public function LoginAction(){
        $tAMO = new AdminModel;
        $REQUEST =json_decode(file_get_contents('php://input'),true);
        var_dump($REQUEST);
        var_dump($_POST);;die;
        $pPasswd = empty($REQUEST['password'])?Tool_Fnc::ajaxMsg('密码不能为空'):trim($REQUEST['password']);
        $pName = empty($REQUEST['username'])?Tool_Fnc::ajaxMsg('用户名不能为空'):Tool_Fnc::safe_string($REQUEST['username']);
        $AdminInfo = $tAMO->field("*")->where("admin_username='{$pName}'")->fRow();
       	if (empty($AdminInfo)) {
       		Tool_Fnc::apiMsg('用户名错误',500);
       	}
       	$password = $AdminInfo['admin_password'];
       	$QueryPwd = Tool_Fnc::markmd5($pPasswd,$AdminInfo['admin_token']);
       	if ($password!=$QueryPwd) {
       		Tool_Fnc::apiMsg('密码错误',500);
       	}
        $data['token'] = Tool_Fnc::markmd5($AdminInfo['admin_token'],$AdminInfo['admin_password']);
        Tool_Fnc::apiMsg('登陆成功',20000,$data);
	}
}