<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
    <title>宝来威智能设备授权</title>
    <style type="text/css">
        body
        {
            font-size: 16pt;
        }
    </style>
    <script type="text/javascript" src="/Scripts/jquery.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $('#login').click(function () {
                var account = $("#txtAccount").val().trim();
                if (account === '') {
                    $("#msg").html('请输入用户名');
                    return;
                }
                var password = $("#txtPassword").val().trim();
                if (password === '') {
                    $("#msg").html('请输入密码');
                    return;
                }
                $('#login').attr("disabled", true);
                $.ajax({
                    dataType: 'JSON',
                    type: "POST",
                    url: "/Oauth2/LoginOn/",
                    data: { jsonData: "{account: '" + account + "', password: '" + password + "', client_id: '" + $('#client_id').val() + "', redirect_uri: '" + $('#redirect_uri').val() + "', state: '" + $('#state').val() + "'}" },
                    success: function (r) {
                        $('#login').attr("disabled", false);
                        if (r && r.IsSuccess) {
                            window.location = r.Message;
                        } else {
                            $("#msg").html(r.Message);
                        }
                    }
                });
            });
        });
    </script>
</head>
<body>
	<input id="client_id" type="hidden" value='<%=ViewData["client_id"] %>' />
	<input id="redirect_uri" type="hidden" value='<%=ViewData["redirect_uri"] %>' />
	<input id="state" type="hidden" value='<%=ViewData["state"] %>' />
    <div style="margin:0 auto; text-align:center; margin-top:200px;">
        <table cellpadding="10" style="width:100%;">
            <tr>
                <td>宝来威智能设备授权</td>
            </tr>
            <tr>
                <td>
                    <input id="txtAccount" name="Account" type="text" style="height:30px; font-weight:bold;" placeholder="请输入用户名" />
                </td>
            </tr>
            <tr>
                <td>
                    <input id="txtPassword" name="Password" type="password" style="height:30px; font-weight:bold;" placeholder="请输入密码" />
                </td>
            </tr>
            <tr>
                <td>
                    <a id="login" href="javascript:void(0)">登 录</a>
                </td>
            </tr>
            <tr>
                <td id="msg"></td>
            </tr>
        </table>
    </div>
</body>
</html>
