<%@ 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>BLW API</title>
	<style type="text/css">
		body {
			font-size: 10pt;	
		}
	</style>
    <script type="text/javascript" src="/Scripts/jquery.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $('#a1').click(function () {
                var code = $('#txtCode').val();
                var creatDate = $('#txtCreatDate').val();
                var roomNumber = $('#txtRoomNumber').val();
                for (var i = 0; i < 30; i++) {
                    $.ajax({
                        url: '/api/GetRCUStatus/',
                        type: 'POST',
                        dataType: 'JSON',
                        data: { jsonData: "{code: '" + code + "', creatDate: '" + creatDate + "', roomNumber: '" + roomNumber + "'}" },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            alert('访问失败。');
                        },
                        success: function (r) {
                            if (r.IsSuccess) {
                                //alert(JSON.stringify(r.Result));
                                $("#result").html(JSON.stringify(r.Result));
                            } else {
                                //alert(r.Result);
                                $("#result").html(i.toString());
                            }
                        }
                    });
                }
            });
            $('#a6').click(function () {
                var code = $('#txtCode').val();
                var creatDate = $('#txtCreatDate').val();
                var roomNumber = $('#txtRoomNumber').val();
                $.ajax({
                    url: '/api/GetRoomServiceList/',
                    type: 'POST',
                    dataType: 'JSON',
                    data: { jsonData: "{code: '" + code + "', creatDate: '" + creatDate + "', roomNumber: '" + roomNumber + "'}" },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        alert('访问失败。');
                    },
                    success: function (r) {
                        if (r.IsSuccess) {
                            alert(JSON.stringify(r.Result));
                        } else {
                            alert(r.Result);
                        }
                    }
                });
            });
            $('#a7').click(function () {
                var code = $('#txtCode').val();
                var creatDate = $('#txtCreatDate').val();
                var roomNumber = $('#txtRoomNumber').val();
                $.ajax({
                    url: '/api/GetRoomSceneList/',
                    type: 'POST',
                    dataType: 'JSON',
                    data: { jsonData: "{code: '" + code + "', creatDate: '" + creatDate + "', roomNumber: '" + roomNumber + "'}" },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        alert('访问失败。');
                    },
                    success: function (r) {
                        if (r.IsSuccess) {
                            alert(JSON.stringify(r.Result));
                        } else {
                            alert(r.Result);
                        }
                    }
                });
            });
            $('#a2').click(function () {
                var code = $('#txtCode').val();
                var creatDate = $('#txtCreatDate').val();
                var roomNumber = $('#txtRoomNumber').val();
                $.ajax({
                    url: '/api/GetRoomLightList/',
                    type: 'POST',
                    dataType: 'JSON',
                    data: { jsonData: "{code: '" + code + "', creatDate: '" + creatDate + "', roomNumber: '" + roomNumber + "'}" },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        alert('访问失败。');
                    },
                    success: function (r) {
                        if (r.IsSuccess) {
                            alert(JSON.stringify(r.Result));
                        } else {
                            alert(r.Result);
                        }
                    }
                });
            });
            $('#a3').click(function () {
                var code = $('#txtCode').val();
                var creatDate = $('#txtCreatDate').val();
                var roomNumber = $('#txtRoomNumber').val();
                var modalAddress = $('#txtModalAddress').val();
                var status = $('#txtStatus').val();
                var brightness = $('#txtBrightness').val();
                $.ajax({
                    url: '/api/SetRCULight/',
                    type: 'POST',
                    dataType: 'JSON',
                    data: { jsonData: "{code: '" + code + "', creatDate: '" + creatDate + "', roomNumber: '" + roomNumber +
                    "',modalAddress:'" + modalAddress + "',status:" + status + ", brightness:" + brightness + "}"
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        alert('访问失败。');
                    },
                    success: function (r) {
                        if (r.IsSuccess) {
                            alert(r.Result);
                        } else {
                            alert(r.Result);
                        }
                    }
                });
            });
            $('#a4').click(function () {
                var code = $('#txtCode').val();
                var creatDate = $('#txtCreatDate').val();
                var roomNumber = $('#txtRoomNumber').val();
                $.ajax({
                    url: '/api/GetRoomAirList/',
                    type: 'POST',
                    dataType: 'JSON',
                    data: { jsonData: "{code: '" + code + "', creatDate: '" + creatDate + "', roomNumber: '" + roomNumber + "'}" },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        alert('访问失败。');
                    },
                    success: function (r) {
                        if (r.IsSuccess) {
                            alert(JSON.stringify(r.Result));
                        } else {
                            alert(r.Result);
                        }
                    }
                });
            });
            $('#a5').click(function () {
                var code = $('#txtCode').val();
                var creatDate = $('#txtCreatDate').val();
                var roomNumber = $('#txtRoomNumber').val();
                var modalAddress = $('#txtModalAddress1').val();
                var onOff = $('#txtOnOff').val();
                var temperature = $('#txtTemperature').val();
                var fanSpeed = $('#txtFanSpeed').val();
                var mode = $('#txtMode').val();
                var valve = $('#txtValve').val();
                $.ajax({
                    url: '/api/SetRCUAir/',
                    type: 'POST',
                    dataType: 'JSON',
                    data: { jsonData: "{code: '" + code + "', creatDate: '" + creatDate + "', roomNumber: '" + roomNumber +
                    "',modalAddress:'" + modalAddress + "',onOff:" + onOff + ", temperature:" + temperature +
                    ", fanSpeed:" + fanSpeed + ", mode:" + mode + ", valve:" + valve + "}"
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        alert('访问失败。');
                    },
                    success: function (r) {
                        if (r.IsSuccess) {
                            alert(r.Result);
                        } else {
                            alert(r.Result);
                        }
                    }
                });
            });
            $('#a8').click(function () {
                var code = $('#txtCode').val();
                var creatDate = $('#txtCreatDate').val();
                var roomNumber = $('#txtRoomNumber').val();
                var sceneID = $('#txtSceneID').val();
                $.ajax({
                    url: '/api/SetRCUScene/',
                    type: 'POST',
                    dataType: 'JSON',
                    data: { jsonData: "{code: '" + code + "', creatDate: '" + creatDate + "', roomNumber: '" + roomNumber + "',sceneID:" + sceneID + "}"
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        alert('访问失败。');
                    },
                    success: function (r) {
                        if (r.IsSuccess) {
                            alert(r.Result);
                        } else {
                            alert(r.Result);
                        }
                    }
                });
            });
            $('#a9').click(function () {
                var code = $('#txtCode').val();
                var creatDate = $('#txtCreatDate').val();
                var roomNumber = $('#txtRoomNumber').val();
                var modalAddress = $('#txtModalAddress2').val();
                var status = $('#txtStatus2').val();
                $.ajax({
                    url: '/api/SetRCUService/',
                    type: 'POST',
                    dataType: 'JSON',
                    data: { jsonData: "{code: '" + code + "', creatDate: '" + creatDate + "', roomNumber: '" + roomNumber +
                    "',modalAddress:'" + modalAddress + "',status:" + status + "}"
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        alert('访问失败。');
                    },
                    success: function (r) {
                        if (r.IsSuccess) {
                            alert(r.Result);
                        } else {
                            alert(r.Result);
                        }
                    }
                });
            });
            $('#a10').click(function () {
                var code = $('#txtCode').val();
                var creatDate = $('#txtCreatDate').val();
                var roomNumber = $('#txtRoomNumber').val();
                $.ajax({
                    url: '/api/GetHotelInfo/',
                    type: 'POST',
                    dataType: 'JSON',
                    data: { jsonData: "{code: '" + code + "', creatDate: '" + creatDate + "', roomNumber: '" + roomNumber + "'}" },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        alert('访问失败。');
                    },
                    success: function (r) {
                        if (r.IsSuccess) {
                            $("#result").html(JSON.stringify(r.Result));
                        } else {
                            alert(r.Result);
                        }
                    }
                });
            });
            $('#a11').click(function () {
                var code = $('#txtCode').val();
                var creatDate = $('#txtCreatDate').val();
                var roomNumber = $('#txtRoomNumber').val();
                $.ajax({
                    url: '/api/GetRoomTypeAndModalsList/',
                    type: 'POST',
                    dataType: 'JSON',
                    data: { jsonData: "{code: '" + code + "', creatDate: '" + creatDate + "', roomNumber: '" + roomNumber + "'}" },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        alert('访问失败。');
                    },
                    success: function (r) {
                        if (r.IsSuccess) {
                            $("#result").html(JSON.stringify(r.Result));
                        } else {
                            alert(r.Result);
                        }
                    }
                });
            });
            $('#a12').click(function () {
                var phone = $('#txtPhone').val();
                $.ajax({
                    url: '/api/GetHotelInfoForWX/',
                    type: 'POST',
                    dataType: 'JSON',
                    data: { jsonData: "{phone: '" + phone + "'}" },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        alert('访问失败。');
                    },
                    success: function (r) {
                        if (r.IsSuccess) {
                            $("#result").html(JSON.stringify(r.Result));
                        } else {
                            alert(r.Result);
                        }
                    }
                });
            });
            $('#a13').click(function () {
                var code = $('#txtCode').val();
                var creatDate = $('#txtCreatDate').val();
                $.ajax({
                    url: '/api/GetOperationLog/',
                    type: 'POST',
                    dataType: 'JSON',
                    data: { jsonData: "{code: '" + code + "', creatDate: '" + creatDate + "'}" },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        alert('访问失败。');
                    },
                    success: function (r) {
                        if (r.IsSuccess) {
                            $("#result").html(JSON.stringify(r.Result));
                        } else {
                            alert(r.Result);
                        }
                    }
                });
            });
        });
    </script>
</head>

<body>
    <div>
        code:&nbsp;<input id="txtCode" type="text" value="1001" style="width:80px;" />&nbsp;
        creatDate:&nbsp;<input id="txtCreatDate" type="text" value="2016-09-05" style="width:80px;" />&nbsp;
        roomNumber:&nbsp;<input id="txtRoomNumber" type="text" value="001201" style="width:80px;" /><br />
    </div>
	<div>
        <a id="a1" href="javascript:void(0)">1.获取RCU状态</a><br /><br />
        <a id="a6" href="javascript:void(0)">2.获取服务列表</a><br />
	    回路地址:&nbsp;<input id="txtModalAddress2" type="text" value="004000002" style="width:80px;" />&nbsp;
        开关(1开，2关):&nbsp;<input id="txtStatus2" type="text" value="1" style="width:80px;" /><br />
        <a id="a9" href="javascript:void(0)">3.设置服务</a><br /><br />
        <a id="a2" href="javascript:void(0)">4.获取灯光列表</a><br />
        回路地址:&nbsp;<input id="txtModalAddress" type="text" value="001000002" style="width:80px;" />&nbsp;
        开关(1开，2关):&nbsp;<input id="txtStatus" type="text" value="1" style="width:80px;" />&nbsp;
        亮度(0~100):&nbsp;<input id="txtBrightness" type="text" value="100" style="width:80px;" /><br />
        <a id="a3" href="javascript:void(0)">5.设置灯光</a><br /><br />
        <a id="a7" href="javascript:void(0)">6.获取场景列表</a><br />
        场景ID:&nbsp;<input id="txtSceneID" type="text" value="1" style="width:80px;" /><br />
        <a id="a8" href="javascript:void(0)">7.设置场景</a><br /><br />
        <a id="a4" href="javascript:void(0)">8.获取空调列表</a><br />
        回路地址:&nbsp;<input id="txtModalAddress1" type="text" value="007001000" style="width:80px;" />&nbsp;
        开关(1开，2关):&nbsp;<input id="txtOnOff" type="text" value="1" style="width:30px;" />&nbsp;
        温度(16~32):&nbsp;<input id="txtTemperature" type="text" value="26" style="width:30px;" />&nbsp;
        风速(1低速，2中速，3高速):&nbsp;<input id="txtFanSpeed" type="text" value="1" style="width:30px;" /><br />
        模式(1制冷，2制热，3送风):&nbsp;<input id="txtMode" type="text" value="1" style="width:30px;" />&nbsp;
        阀门(1开，2关):&nbsp;<input id="txtValve" type="text" value="2" style="width:30px;" /><br />
        <a id="a5" href="javascript:void(0)">9.设置空调</a><br /><br />
        <a id="a10" href="javascript:void(0)">10.获取酒店信息</a><br /><br />
        <a id="a11" href="javascript:void(0)">11.获取房型及其回路列表</a><br /><br />
        手机号:&nbsp;<input id="txtPhone" type="text" value="" style="width:80px;" /><br />
        <a id="a12" href="javascript:void(0)">12.获取酒店信息（微信使用）</a><br /><br />
        <a id="a13" href="javascript:void(0)">13.获取操作日志</a><br />
    </div>
    <div id="result"></div>
</body>
</html>