<?php
namespace app\index\controller;
use think\Controller;
use think\Db;
use app\index\model\Admin;
class Login extends Controller
{
    public function index()
    {
		 if(request()->isget()){
            $this->check(input('code'));
        	$admin=new Admin();
        	$num=$admin->login(input('get.'));
        	if($num==1){
        		$this->error('用户不存在！');
        	}
        	if($num==2){
        		$this->redirect('/index.php/index/tree.html');
	      	}
        	if($num==3){
        		$this->error('密码错误！');
        	}
                if($num==4){
        		$this->redirect('/index.php/admin/bdz/lst.html');
	      	}
                if($num==5){
        		$this->redirect('/index.php/admin/admin/lst.html');
	      	}
        	return;
        } 
//   public function index()
//    {
//		 if(request()->isPost()){
//            $this->check(input('code'));
//        	$admin=new Admin();
//        	$num=$admin->login(input('post.'));
//        	if($num==1){
//        		$this->error('用户不存在！');
//        	}
//        	if($num==2){
//        		$this->success('success!',url('/index/tree'));
//        	}
//        	if($num==3){
//        		$this->error('密码错误！');
//        	}
//        	return;
//        }   
		
		
		$mc = Db::table('sys_rg')->where('unique', 1)->find();
		$key='92A60665B64D4CD39FD764763886B4C7';
		$cacweb = Sha1($mc['mc'].'xinyi'.$key);
		//echo ($cacweb);
		if($cacweb != $mc['ac2']){
			Db::table('sys_rg')->where('unique', 1)->update(['ck2' => 0]);
		}else{
			Db::table('sys_rg')->where('unique', 1)->update(['ck2' => 1]);
		}
		if($mc['ck1']==1&& $mc['ck2']==1&&$mc['ck3']==1&&$mc['ck4']==1&&$mc['ck5']==1&&$mc['ck6']==1&&$mc['ck7']==1&&$mc['ck8']==1&&$mc['ck9']==1){
			//echo ($cacweb);
			return view();
		}else{
			
			die('没有获取绑定码，请联系相关人员');
		}       
    }
    // 验证码检测
    public function check($code='')
    {
//        if (!captcha_check($code)) {
//            $this->error('验证码错误');
//        } else {
//            return true;
//        }
        return true;
    }

}
