<extend name="Public/manage" />
<block name="head">
    <link href="__CSS__/iconfont.css" rel="stylesheet">
    <link href="__CSS__/pagination.css" rel="stylesheet">
    <link href="__CSS__/datetimepicker.css" rel="stylesheet">
    <link href="__CSS__/dropdown.css" rel="stylesheet">
    <link href="__CSS__/icon.css" rel="stylesheet">
    <link href="__CSS__/user_zxy.css" rel="stylesheet">
    <script src="__JS__/jquery.min.js"></script>
    <script src="__JS__/common.js"></script>
    <script src="__JS__/bootstrap.min.js"></script>
    <script src="__JS__/bootstrap-datetimepicker.min.js"></script>
    <script src="__JS__/bootstrap-datetimepicker.zh-CN.js"></script>
    <script src="__JS__/bootstrap-select.min.js"></script>
    <script src="__JS__/VMenu.js"></script>
    <script src="__JS__/zh-cn.js"></script>
    <script src="__JS__/echarts-all.js"></script>
    <script src="__JS__/chart.js"></script>
    <script src="__JS__/jquery.tablesorter.js"></script>
    <script src="__JS__/string.js"></script>
    <script src="__JS__/pagination.js"></script>
    <script src="__JS__/datacommon.js"></script>
    <script src="__JS__/retain.js"></script>
	<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
	 <script type="text/javascript" src="__STATIC__/layer/layer.js"></script>
</block>

<block name="location">
<a class="z_nav curt_nav" href="##">消息中心</a>
</block>

<block name="body" >
        <div class="matter_right_content">
            <div class="title">
				<i class="usebase_icon"></i> 
				<span>消息中心</span>
			</div>
                <div class="matter clearfix">
                    <div class="matter_content ">
                        <div class="table_container message_table">
                            <div class="table_responsive">
                                <table class="table table_striped table_hover table_control control">
                                    <thead>
                                        <tr>
                                            <th width="2%"></th>
                                            <th width="20%" style="text-align:left;padding-left:12px;">标题</th>
                                            <th width="50%" style="text-align:left;padding-left:12px;">内容</th>
                                            <th width="15%" style="text-align:left;padding-left:12px;">时间</th>
                                            <th>状态</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    <volist name="data" id="vo">
                                    <tr msg_tr="1" style="cursor:pointer;">
                                        <td style="text-align:left;">
											<label class="checked">
												<input class="ids mcheck" type="checkbox" value="{$vo.id}" name="ids">
												<i class="check_icon"></i>
											</label>
										<!-- <input class="mcheck" value="{$vo.id}" type="checkbox"> -->
										</td>
                                        <td style="text-align:left;">{$vo.title}</td>
                                        <td style="text-align:left;">
                                            <span data-original-title="{$vo.content}" data-placement="bottom" data-toggle="tooltip">{$vo.content}</span>
                                            <span show_all="1" class="hide">{$vo.content}
                                        </span>
                                        </td>
                                        <td style="text-align:left;">{:time_format($vo['create_time'])}</td>
                                        <td>
                                            <eq name="vo.status" value="2">
                                            未读
																						<else />
																						已读
                                            </eq>
                                        </td>
                                    </tr>
                                    </volist>
                                    </tbody>
                                </table>
                                <div style="padding-top:10px;">&nbsp;&nbsp;
								<label class="checked zwm_labwid" for="selectAll">
									<input id="selectAll" value="all" type="checkbox">
									<i class="check_icon ver_alignsub"></i>
									<span class="news_labspan">全选</span>
								</label>
									
                                    <!-- <label for="selectAll">全选</label> -->
                                    <a class="btn btn_primary user_btn" href="#read"><span class="iconfont icon-eye"></span> 已读</a>&nbsp;&nbsp;&nbsp;&nbsp;
                                    <a class="btn btn_primary user_btn" href="#del">删除</a></div>
                            </div>
                        </div>
                        
                    </div>
                </div>
            </div>
        </div>
        <script>
			$.VMenu.show('#menu');
			$.VMenu.open('m6');
            $(document).ready(function(){

                //标记已读
                $(".read_btn").click(function () {
                    var id = $(this).attr("data-msgid");
                    changeStatus(id,1);
                    $(this).remove();
                });


                function changeStatus(ids,status){
                    $.ajax({
                        type : "post",
                        url : "{:U('message/set_status')}",
                        data : {ids:ids,status:status},
                        async : false,
                        success : function(result){
                            if(result.status == 1){
                                layer.msg("操作成功");
                                setTimeout(function(){
                                    location.reload();
                                },1500);
                                
                                return true;
                            }else{
                                layer.msg(result.info);
                                return false;
                            }
                        }
                    });
                }

                $("a[href='#detail']").click(function(event){
                    var msgId = $(this).data('msgid');
                    var param = {};
                    param['msgId'] = msgId;
//                    $.Mask.show(lan_on_loading);
//                    $.Mask.hidden();
                    $.ajax({
                        type:'GET',
                        url:'/Ajax/Member/Msg',
                        data:param,
                        dataType:'json',
                        success:function(data) {
                            if (data['code'] == 0) {
                                $('#msg_title_' + msgId).remove();
                                $('#msg_read_btn_' + msgId).remove();
                            }
                            $.Mask.hidden();
                        }
                    });
                });

                $('#selectAll').click(function(event){
                    var sAChecked = $("#selectAll").prop("checked");
                    $(":checkbox").prop("checked",sAChecked);
                });

                $("a[href='#read']").click(function(event){

                    var msgIds = [];
                    var inputs = document.getElementsByTagName("input");
                    for(var i = 0; i < inputs.length; i++) {
                        if(inputs[i].getAttribute("type") == "checkbox" && inputs[i].checked == true && inputs[i].value != "all") {
                            msgIds.push(inputs[i].value);
                        }
                    }
                    changeStatus(msgIds,1);
                    //location.reload();
                });

                $("a[href='#del']").click(function(event){
                    var msgIds = [];
                    var inputs = document.getElementsByTagName("input");
                    for(var i = 0; i < inputs.length; i++) {
                        if(inputs[i].getAttribute("type") == "checkbox" && inputs[i].checked == true && inputs[i].value != "all") {
                            msgIds.push(inputs[i].value);
                        }
                    }
                    changeStatus(msgIds,0);
                    
                });
                $("tr[msg_tr='1']").click(function(){
                    var $this_tr_td = $(this).children("td:eq(2)");
                    $this_tr_td.children("span:first").hide();
                    $this_tr_td.children("span:last").removeClass("hide");
                });
            });
        </script>
</block>