<%@ Page Language="C#" AutoEventWireup="true" debug="true" Inherits="WinLibClass.Form.UserInfo.UserMessage.UI_List" CodePage="65001" GameType="1" PageFileFlag="UserMessage" PageFileTitle="会员留言-会员中心" DataBindingType="1" PageFlagId="1"  %>

<%@ Register TagPrefix="Site" TagName="Menu" Src="~/WUC/Common/Site_Menu.ascx" %>
<%@ Register TagPrefix="Site" TagName="UserPicNote" Src="~/WUC/Common/Site_UserPicNote.ascx" %>
<%@ Register TagPrefix="Site" TagName="Game1" Src="~/WUC/Common/Site_Game1.ascx" %>

<%@ Register TagPrefix="Site" TagName="Side_UserPicNote" Src="~/WUC/Common/Site_Side_UserPicNote.ascx" %>
<%@ Register TagPrefix="Site" TagName="Side_Future" Src="~/WUC/Common/Site_Side_Future.ascx" %>
<%@ Register TagPrefix="Site" TagName="Side_Main" Src="~/WUC/Common/Site_Side_Menu.ascx" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<Site:Menu id="menu_headtitle" runat="server" Flag="HeadTitle" CurrentPageTitle = "会员中心 - 会员留言" />
<Site:Menu id="menu_headjs" runat="server" Flag="HeadJs"  />

<link href="/css/common.css" type="text/css" rel="stylesheet" />
<link href="/css/common_3.css" type="text/css" rel="stylesheet" />
<link href="/css/article.css" type="text/css" rel="stylesheet" />

</head>
<script>
<!--
/*第一种形式 第二种形式 更换显示样式*/
function setTab(name,cursel,n){
    for(i=1;i<=n;i++){
    var menu=document.getElementById(name+i);
    //var con=document.getElementById("con_"+name+"_"+i);
    menu.className=i==cursel?"hover":"";
    con.style.display=i==cursel?"block":"none";
    }
}
//-->
</script>
<body>

<Site:Menu id="menu_topmenu" runat="server" Flag="TopMenu"  CurrentPageFlag="User" />

<div class="clear"></div>
<!--start 内容-->
<div class="ArtContent PageWidth">
	<!-- 左侧菜单 -->
<Site:Side_Main id="Side_Main_art1" runat="server" PageFlagId="100"  CurrentPageFlag="User" DataBindingType="1" />
	<!-- 左侧菜单结束 -->
	<!-- 右侧正文或列表 -->
<!--start 主体内容-->
<script type="text/javascript" language="javascript">


function SetTab(mids,focus,blur,cids,curid)
{
	var mid = jQuery(mids);
	var cid = jQuery(cids);
	var curObj = jQuery(curid);
	
	mid.removeClass(focus).addClass(blur);
	curObj.removeClass(blur).addClass(focus);
	cid.addClass("hide");
	jQuery(cids + '[flag="' + curObj.attr("id") + '"]' ).removeClass("hide");

}

jQuery(function(){

	//保存
	$("#btnSubmit").click(function(){if(CheckAll())UpdateInfo();});	

	$("a[id^='trtd_']").click(function(){

		$(this).parent().parent().css("");
		SetActiveForAddress($(this).parent().parent(),1);
	});
	
});



function SetActiveForAddress(o,flag)
{
	if(!flag)flag = 0;
	var x = 1;
	//菜单处理
	if(flag==0) x = o.attr("value");
	else SetCurrentItemToEidt(o);//EDIT
	
	if(x==1)
	{
		if($("#AddId").val()==""||$("#AddId").val()==0 ) x=2;
	}
	SetActive(o.attr("id").substr("tr_".length));

	jQuery("#medit").click();
	

	if(x==2){$("#aspnetForm")[0].reset();$("#AddId").val("0");x=1;};
	$("div[id^='div_AddressItem_']").hide();
	$("#div_AddressItem_"+x).show();
}

function SetCurrentItemToEidt(obj)
{
	var id = obj.attr("id").substr("tr_".length);
	FillItemInput(id,"FromUserId");
	FillItemInput(id,"ToUserId");
	FillItemInput(id,"InfoType");
	FillItemInput(id,"FloorNo");
	FillItemInput(id,"IsReaded");
	FillItemInput(id,"IsChecked");
	FillItemInput(id,"ID");
	FillItemInput(id,"strContent");
	FillItemInput(id,"strTitle");

}

//本页特定功能
function FillItemInput(id,field)
{
	jQuery("#"+ field).val(jQuery("#input_Hidden_"+field+"_"+id).val());
}
//本页特定
function ShowTitleAndText(id)
{
	var title = jQuery("#input_Hidden_strTitle_"+id).val();
	var text  = jQuery("#input_Hidden_strContent_"+id).val();
	Common.EditDialg("ShowTitleAndText",title,'<div style="width:500px;height:300px;overflow:scroll">'+text+'</div>');
}


function CheckAll()
{

	var t = true;
	if(t) t = CheckIsEmpty("strTitle",0,"填一下标题吧.",20,"标题有点长哟(20字以内)，删减一下吧.");//
	if(t) t = CheckIsEmpty("strContent",0,"您还没有填写留言内容吧?",200,"留言内容有点长了(200字以内)，删减一下吧.");//
	return t;
}
//Common.ShowTipError
//Common.ShowTipSuccess
function UpdateInfo()
{
	var pass =true;
	if(pass)
	{
				var _url = "/index.aspx?s=/UserInfo/UserMessageUpdate";
				var data = jQuery("#aspnetForm").serialize() ;
				AjaxSubmit(null,_url,data
					,function(msg){
					
						if(msg && msg=="1")
						{
							Common.ShowTipSuccess(false,"恭喜,保存成功.");
							location.replace("/UserInfo/UserMessage.aspx");
						}
						else
						{
							Common.ShowTipError(false,"保存失败,请查询数据格式有效性.");
						}
					}
					,function(msg){Common.ShowTipError(false,"系统故障,操作失败.");}
				);
				//格式验证
				return false;
	}
}

function CheckIsEmpty(id,Min,msgMin,Max,msgMax)
{
	var o = $("#"+id);

	//alert(oimg);
	//是否为空
	if(o.val().trim().length<=Min)
	{
		Common.ShowTipFaceSmile(false,msgMin);
		return false;
	}

	//最大值
	else if(o.val().trim().length>Max)
	{
		Common.ShowTipFaceSmile(false,o.val().trim().length + "<br />" +msgMax);
		return false;
	}
	else
	{
		
		return true;
	}
	return false;
	
}

function CheckPostCode(id,msgMin)
{
	var o = $("#"+id);
	var ospan = $("#"+id+"_label");
	var oimg = o.parent().find("img");

	var type = /\d{6}$/;  

	var code = o.val();
	if(!code.match(type))
	{
		oimg.hide();
		ospan.html(msgMin).show();
		return false;
	}
	else
	{
		ospan.html("").hide();
		oimg.show();
		return true;
	}
	
}

function DeleteUserMsg(id)
{
	if(confirm("您确定删除本条留言吗?"))
	{
	var _url = "/index.aspx?s=/UserInfo/User_Message_Delete&id="+id;
		$.ajax({
		type: "POST",
		url: _url,
		data:"",
		cache: false,
		success: function(msg){
			if(msg==1){
				alert("留言已删除");
				location.replace("/UserInfo/UserMessage.aspx");
			}
			else if(msg==-1) alert("没有该留言.")
			else alert("删除异常.");
			
		}
	});
	}
	else
	{
	
	}
}
</script>



<div class="Grid-Base PageWidth_Right2">

	<div class="help-box padding0 " >
 		<div class="tit2 H60 LH55">
				您的留言
		</div>
		<div class="tab">
			<div id="mlist" class="tab-0 ML20 color1" onclick='SetTab(".tab-0","color1","color2",".H485 .editexp","#mlist");'>
				<div class="tab-0-left"></div>
				<div class="yjcont "><div class="tabtit">您的留言列表</div></div>
                <div class="tab-0-right"></div>
				
			</div>

			<div id="medit" class="tab-0 ML5 color2" onclick='SetTab(".tab-0","color1","color2",".H485 .editexp","#medit");'>
                 <div class="tab-1-left"></div>     			
				 <div class="yjcont"><div class="tabtit">添加新留言</div></div>
				 <div class="tab-1-right"></div>
			</div>

		</div>

	</div>

	<div class="help-box H485" style="border-bottom:0px;" >
 
		<div class="editexp hide" id="div-Edit" flag="medit">
        <form name="aspnetForm" id="aspnetForm" onsubmit="return false;checkAll();">		
			<li><div class="info-name">标题：</div><div class="info-input inputbg W298">
			
				<input type="text" class="inputbox W235" id="strTitle" name="strTitle">
				</div></li>

			<li style="height:100px;"><div class="info-name">内容：</div><div class="info-input textareabg W298">
			<textarea class="textareabox W235 H90" id="strContent" name="strContent" ></textarea>
			
			</div></li>
			<li>
			<input type="hidden" name="FromUserId"  id="FromUserId" value=""/>
				<input type="hidden" name="ToUserId"  id="ToUserId" value=""/>
				<input type="hidden" name="InfoType"  id="InfoType"  value=""/>								
				<input type="hidden" name="FloorNo"  id="FloorNo"  value=""/>
				<input type="hidden" name="IsReaded"  id="IsReaded"  value=""/>
				<input type="hidden" name="IsChecked" id="IsChecked" value=""/>
				<input type="hidden" name="ID" class="ID" id="ID" value=""/>			
			
			<input type="image" src="/images/btnsubmit.gif" id="btnSubmit" > </li>
		</form>	
		</div>
		
		<div class="editexp " id="div-List" flag="mlist">
			<table>
				<tr class="list-th">
					<th CLASS="hide">ID</th>
					<th>标题</th>
					<th>更新时间</th>
					<th>类型</th>
					<th>审核</th>
					<th>操作</th>
				</tr>
<asp:Repeater id="rpList" runat="server"> 
<ItemTemplate>					

				<tr class="list-td" id="tr_<%#Eval("id")%>">

                    <td CLASS="hide" value="<%#Eval("id")%>" ><%#Eval("id")%></td>
					<td  value="<%#Eval("NoteTitle")%>" ><%#Eval("NoteTitle")%></td>
                    <td value="<%#Eval("UpdateTime")%>" ><%#Eval("UpdateTime","{0:yyyy-MM-dd HH:mm}")%></td>
					<td value="" ><%#UserMessageTypeName(Eval("FromUserId"),Eval("ToUserId"),Eval("FromUserIdName"),Eval("ToUserIdName"))%>
					
						<textarea id="input_Hidden_strTitle_<%#Eval("id")%>" style="display:none"><%#Eval("NoteTitle")%></textarea>
						<textarea id="input_Hidden_strContent_<%#Eval("id")%>" style="display:none"><%#Eval("NoteText")%></textarea>
						
						
				<input type="hidden" id="input_Hidden_FromUserId_<%#Eval("id")%>" value="<%#Eval("FromUserId")%>"/>
				
				<input type="hidden" id="input_Hidden_ToUserId_<%#Eval("id")%>" value="<%#Eval("ToUserId")%>"/>
				<input type="hidden" id="input_Hidden_InfoType_<%#Eval("id")%>"  value="<%#Eval("InfoType")%>"/>								
				<input type="hidden" id="input_Hidden_FloorNo_<%#Eval("id")%>"  value="<%#Eval("FloorNo")%>"/>
				<input type="hidden" id="input_Hidden_IsReaded_<%#Eval("id")%>"  value="<%#Eval("IsReaded")%>"/>
				<input type="hidden" id="input_Hidden_IsChecked_<%#Eval("id")%>" value="<%#Eval("IsChecked")%>"/>
				<input type="hidden" id="input_Hidden_ID_<%#Eval("id")%>" value="<%#Eval("id")%>"/>							
					
					<input type="hidden" id="input_Hidden_ID_<%#Eval("id")%>" value="<%#Eval("id")%>"/>		
					<input type="hidden" id="input_Hidden_UpdateTime_<%#Eval("id")%>" value="<%#Eval("UpdateTime")%>"/>		
					
					</td>
                        <td >

                            <%#(Eval("IsChecked").ToString()=="1"?"是":"否")%>
							
                        </td>								
							
					<td>
							<a href="#;" onclick='ShowTitleAndText(<%#Eval("id")%>);' >查看</a>
							|							
                            <a href="#;" id="trtd_<%#Eval("id")%>" >编辑<%//#(Eval("FromUserId").ToString()==CurrentUserId.ToString()?"编辑":"")%></a>
							<%#(Eval("FromUserId").ToString()==CurrentUserId.ToString()?"":"<font color='red只读'></font>")%>
							|
							<a href="#;" onclick='DeleteUserMsg(<%#Eval("id")%>);return false;' >删除</a>
					
					</td>				
				
				
				</tr>
		
</ItemTemplate>		
</asp:Repeater>						
				
			</table>
			<div class="Page Pnv">
<%=strPageInfo%>			
			</div>
		</div>
	</div>

</div>
<!--end 主体内容结束-->
	<!-- 右侧正文或列表结束 -->

  <div class="clear"></div>

</div>
<!--end 内容-->
<div class=" clear"></div>
<Site:Menu id="menu_foothelper" runat="server" Flag="FootHelper"  />
<div class=" clear"></div>
<Site:Menu id="menu_links" runat="server" Flag="Links"  />
<div class=" clear"></div>
<Site:Menu id="menu_foot" runat="server" Flag="Foot"   />

</body>
</html>
