<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<!DOCTYPE html>
<html lang="zh-CN">
<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=no"/>
    <meta http-equiv="X-UA-Compatible" content="ie=edge"/>
    <title><%: Html.Language("WXControlRoom")%></title>
    <link rel="stylesheet" href="/Styles/WeiXin2/normalize.css"/>
    <link rel="stylesheet" href="/Styles/WeiXin2/style.css"/>
    <script type="text/javascript" src="/Scripts/WeiXin/common.js"></script>
    <script type="text/javascript" src="/Scripts/WeiXin/tip.js"></script>
    <script type="text/javascript" src="/Scripts/jquery.min.js"></script>
    <% switch ((int)Session["isCN"]){case 1: %>
    <script type="text/javascript" src="/Scripts/en-US.js"></script>
    <% break; case 2: %>
    <script type="text/javascript" src="/Scripts/zh-TW.js"></script>
    <% break;default: %>
    <script type="text/javascript" src="/Scripts/zh-CN.js"></script>
    <% break; } %>
    <script type="text/javascript">
        $(function () {
            $('#txtRoomNumber').val($('#hidRoomNumber').val());
            $('#login').click(function () {
                var roomNumber = $('#txtRoomNumber').val().trim();
                if (roomNumber === '') {
                    $('#msg').html(lang.PleaseEnterRoomNumber);
                    return;
                }
                var identity = $('#txtIdentity').val().trim();
                if (identity === '') {
                    $('#msg').html(lang.PleaseEnterValidateCode);
                    return;
                }
                $.ajax({
                    url: '/WX/Login/',
                    type: 'POST',
                    dataType: 'JSON',
                    data: { code: $('#hidHotelCode').val(), roomNumber: roomNumber, identity: identity },
                    success: function (r) {
                        if (r.IsSuccess) {
                            $('#msg').html('');
                            window.location.href = r.Target;
                        } else {
                            $('#msg').html(r.Message);
                        }
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        $('#msg').html(lang.LoginFailed);
                    }
                });

            });
        });
    </script>
</head>
<body class="login">
	<input id="hidRoomNumber" type="hidden" value='<%=ViewData["RoomNumber"] %>' />
	<input id="hidHotelCode" type="hidden" value='<%=ViewData["HotelCode"] %>' />
    <div><img alt="" src='<%=ViewData["Logo"] %>' /></div>
    <h1><%: Html.Language("WXControlRoom")%></h1>
    <div class="block" style="height:10px;">&nbsp;</div>
    <div class="block" style="height:20px; font-size:26px;"><%=ViewData["HotelName"]%></div>
    <div class="block" style="color:red" id="msg"></div>
    <div class="block">
        <label for="txtRoomNumber"><%: Html.Language("RoomNumber")%></label>
        <input type="text" id="txtRoomNumber" name="user" maxlength="6" />
    </div>
    <div class="block">
        <label for="txtIdentity"><%: Html.Language("VerificationCode")%></label>
        <input type="text" id="txtIdentity" name="pwd" maxlength="6" value="" />
    </div>
    <div class="block">
        <button id="login" type="button"><%: Html.Language("Login")%></button>
    </div>
</body>
