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

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" co ntent="width=device-width,user-scalable=no,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
    <meta http-equiv="cache-control" content="max-age=0" />
    <meta http-equiv="cache-control" content="no-cache" />
    <meta http-equiv="expires" content="0" />
    <meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
    <meta http-equiv="pragma" content="no-cache" />
    <title>房间号：<%: ViewData["RoomNumber"] %></title>
    <link type="text/css" rel="stylesheet" href="/Styles/WeiXin/common.css" />
    <link type="text/css" rel="stylesheet" href="/Styles/WeiXin/tip.css" />
    <link type="text/css" rel="stylesheet" href="/Styles/WeiXin/curtain.css" />
    <script type="text/javascript" src="/Scripts/jquery.min.js"></script>
    <script type="text/javascript" src="/Scripts/avalon.mobile.min.js"></script>
    <script type="text/javascript" src="/Scripts/WeiXin/tip.js"></script>
    <script type="text/javascript">

        var vm = avalon.define({
            $id: 'curtain',
            curtainMsg: [],
            gauzeMsg: [],
            groupAddress: '',
            Status: '',
            curtainClick: function (type, Operation, curtain) {
                //				if (type == 'curtain') {

                //					if (Operation == 'Open') {
                //						curtainMsg[index].status = 1;
                //					} else if (Operation == 'Stop') {
                //						curtainMsg[index].status = 3;
                //					} else if (Operation == 'Close') {
                //						curtainMsg[index].status = 2;
                //					}

                //					setCurtain(curtainMsg[index].curtainId, Operation);

                //				} else if (type == 'gauze') {
                //					if (Operation == 'Open') {
                //						gauzeMsg[index].status = 1;
                //					} else if (Operation == 'Stop') {
                //						gauzeMsg[index].status = 3;
                //					} else if (Operation == 'Close') {
                //						gauzeMsg[index].status = 2;
                //					}

                //					setCurtain(curtainMsg[index].curtainId, Operation);
                //				}

                if (Operation == 'Open') {
                    curtain.status = 1;
                } else if (Operation == 'Stop') {
                    curtain.status = 3;
                } else if (Operation == 'Close') {
                    curtain.status = 2;
                }
                setCurtain(curtain.curtainId, Operation);
                hideLoading();
            }
        });


        function setCurtain(curtainId, Operation, callback) {
            $.ajax({
                url: '/WeiXin/Curtain/',
                type: 'POST',
                async: false,
                dataType: 'JSON',
                data: {
                    roomNumber: $('#hfRoomNumber').val(),
                    CurtainId: curtainId,
                    ctrl: Operation
                },

                success: callback || function (r) {

                }
            });
        }

        $(function () {

            $.ajax({
                url: "/WeiXin/LoadCurtain/",
                data: { roomNumber: $('#hfRoomNumber').val(), deviceType: 'Curtain' },
                type: "POST",
                dataType: "JSON",
                success: function (r) {
                    //  hideLoading();
                    if (r.IsSuccess) {
                        vm.curtainMsg = r.Data;
                    } else {
                        showTip(r.Message);
                    }
                }
            });
//            $.ajax({
//                url: "/WeiXin/LoadCurtain/",
//                data: { roomNumber: $('#hfRoomNumber').val(), deviceType: 'Gauze' },
//                type: "POST",
//                dataType: "JSON",
//                success: function (r) {
//                    if (r.IsSuccess) {
//                        vm.gauzeMsg = r.Data;
//                    } else {
//                        showTip(r.Message);
//                    }
//                }
//            });
        });
    </script>
</head>
<body>
    <input id="hfRoomNumber" type="hidden" name="RoomNumber" value='<%: ViewData["RoomNumber"] %>' />
    <div id="curtain-panel" class="clearfix" ms-controller="curtain">
        <div class="curtain-pic" ms-repeat="curtainMsg">
            <div class="divshow">
                <em class="textshow">{{el.Name}}</em>
            </div>
            <a href="javascript:void(0)" ms-class="selected:(el.status==1)" ms-click="curtainClick('curtain','Open',el)">
                <i class="icon icon-curtain-open"></i></a><a href="javascript:void(0)" ms-class="selected:(el.status==3)"
                    ms-click="curtainClick('curtain','Stop',el)"><i class="icon icon-curtain-stop"></i>
                </a><a href="javascript:void(0)" ms-class="selected:(el.status==2)" ms-click="curtainClick('curtain','Close',el)">
                    <i class="icon icon-curtain-close"></i></a>
        </div>
        <%--<div class="gauze-pic" ms-repeat="gauzeMsg">
            <div class="divshow">
                <em class="textshow">{{el.Name}}</em>
            </div>
            <a href="javascript:void(0)" ms-class="selected:(el.status==1)" ms-click="curtainClick('gauze','Open',el)">
                <i class="icon icon-curtain-open"></i></a><a href="javascript:void(0)" ms-class="selected:(el.status==3)"
                    ms-click="curtainClick('gauze','Stop',el)"><i class="icon icon-curtain-stop"></i>
                </a><a href="javascript:void(0)" ms-class="selected:(el.status==2)" ms-click="curtainClick('gauze','Close',el)">
                    <i class="icon icon-curtain-close"></i></a>
        </div>--%>
    </div>
    <%--<div id="curtain-panel" class="clearfix" ms-controller="curtain">
		<dl>
			<dd ms-repeat="curtainMsg" style="margin-left: 0px;">
				<a href="javascript:void(0)" ms-class="selected:(el.CurtainOpen.Status!=0)" ms-click='curtainClick(el.CurtainOpen,el)'>
					<i class="icon icon-curtain-open"></i><em class="text">{{el.CurtainOpen.Name}}</em>
				</a><a href="javascript:void(0)" ms-class="selected:(el.CurtainClose.Status!=0)"
					ms-click='curtainClick(el.CurtainClose,el)'><i class="icon icon-curtain-close"></i>
					<em class="text">{{el.CurtainClose.Name}}</em> </a>
			</dd>
			<dd ms-repeat="gauzeMsg" style="margin-left: 0px;">
				<a href="javascript:void(0)" ms-class="selected:(el.CurtainOpen.Status!=0)" ms-click='curtainClick(el.CurtainOpen,el)'>
					<i class="icon icon-gauze-open"></i><em class="text">{{el.CurtainOpen.Name}}</em>
				</a><a href="javascript:void(0)" ms-class="selected:(el.CurtainClose.Status!=0)"
					ms-click='curtainClick(el.CurtainClose,el)'><i class="icon icon-gauze-close"></i>
					<em class="text">{{el.CurtainClose.Name}}</em> </a>
			</dd>
		</dl>
	</div>--%>
    <% Html.RenderPartial("Footer"); %>
</body>
</html>
