<!DOCTYPE html>
<!--[if IE 8 ]><html dir="ltr" lang="zh-TW" class="ie8"><![endif]-->
<!--[if IE 9 ]><html dir="ltr" lang="zh-TW" class="ie9"><![endif]-->
<!--[if (gt IE 9)|!(IE)]><!-->
<html dir="ltr" lang="zh-TW">
<!--<![endif]-->
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
<title>後台登入介面</title>
<meta name="robots" content="noindex, nofollow" />
<link href="css/main.css" rel="stylesheet">
<link href="less/login.less" rel="stylesheet/less">
<script src="/jquery/jquery-1.10.js"></script>
<script src="/js/less.min.js" ></script>
<script>
	if('<?# alertMsg ?>' != ''){
		alert('<?# alertMsg ?>');
		if('<?# goBack ?>' == 'Y') history.back();
	}
	if('<?# locationHref ?>' != '') location.href = '<?# locationHref ?>';
</script>
</head>
<body class="d_flex f_justify_center f_aitems_center">
    <div id="login_box">
    	<h3 class="mb_3 talign_center">後台管理介面</h3>
        <form class="mb_3 bg_white" id="form1" name="form1" method="post" action="login.php">
			<div class="mt_3 mb_5"><label class="mb_1">帳號</label><input type="text" id="login" name="login" placeholder="請輸入您的帳號" /></div>
			<div class="mb_5"><label class="mb_1">密碼</label><input type="password" id="pass" name="pass" placeholder="請輸入您的密碼" /></div>
			<?# checknum_html ?>
			<div class="mb_3 talign_center"><a class="btn btn_primary" href="javascript:void(0);" data-action="submit">登入</a></div>
        </form>
		<?# login_html ?>
    </div>
</body>
</html>
<script>
	function loginsystem(){
        if($('#login').val() == ''){
            alert('請輸入帳號!');
            $('#login').focus();
            return false;
        }
        if($('#pass').val() == ''){
            alert('請輸入密碼!');
            $('#pass').focus();
            return false;
        }
        if($('#checknum').val() == ''){
            alert('請輸入驗證碼!');
            $('#checknum').focus();
            return false;
        }
        $('#form1').submit();
	}
	$(function(){
		$('a[data-action="submit"]').click(function(){
			loginsystem();
		});
		$('#login_box').on('click','#rand-img',function(){
		    this.src="/vdimgck.php?";
		});
    	$("#login_box").on('keypress','#checknum',function(e){
    		code = (e.keyCode ? e.keyCode : e.which);
    		if (code == 13){
    			loginsystem();
    		}
    	});
		$('#getCode').click(function(){
            $.ajax({
                url: 'ajax/login.php',
                async: false,
                type: 'POST',
                data: {'do':'getcode','login':$('#login').val()},
                dataType: "json",
                context: $(this),
                success: function(obj){
					if(obj.html != ''){
						$('#check_box').html(obj.html);
					}else{
						alert(obj.msg);
						if(obj.err != 0) location.href = 'login.php';
					}
                },
                error: function(){
                    alert('系統異常!');
                }
            });
		});
	});
</script>