<%@ page language="C#" autoeventwireup="true" inherits="UserRate_UserRate, DoodiiShop" enableEventValidation="false" viewStateEncryptionMode="Never" %>

<%@ Register Src="../Controls/BriefnessTop.ascx" TagName="BriefnessTop" TagPrefix="uc3" %>

<%@ Register Src="../Controls/BottomNo51la1.ascx" TagName="BottomNo51la" TagPrefix="uc2" %>

<%@ Register Src="../Controls/NewTop.ascx" TagName="NewTop" TagPrefix="uc1" %>

<!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 runat="server">
    <title>订餐评价</title>
    <link href="/favicon.ico" rel="shortcut icon" type="image/x-icon" />
    <link href="/css/V5/Lib.css" rel="stylesheet" type="text/css" />
    <link href="/css/v5/Public.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="/js/jquery.js"></script>
    <script type="text/javascript" src="/js/func.js"></script>
    <script type="text/javascript" src="/js/Format.js"></script>
    <style type="text/css">
        .mianbaoxie
        {
            font-size:14px;
        }
        .EateryAppraise
        {
            background-image:url(/images/shop/rate/EateryAppraise.jpg);
            background-repeat:no-repeat;
            width:690px;
            margin-top:10px;
            padding-left:260px;
        }
        .DivAppraisetop
        {
            width:464px;
            height:87px;
            background-image:url(/images/shop/rate/Appraisetop.jpg);
        }
        .DivAppraisecenter
        {
            border-left:1px solid #ababab;
            border-right:1px solid #ababab;
            background-color:#fff;
            width:450px;
            padding-top:20px;
            padding-left:12px;
        }
        a.DivInput:link, a.DivInput:hover, a.DivInput:visited
        {
            background-image:url(/images/shop/Order/Input.jpg); 
            width:109px; 
            height:30px; 
            display:block;
            line-height:30px;
            font-size:14px;
            color:#fff;
            text-align:center;
        }
        a.DivInput:hover
        {
            color:#ffff00;
        }
        .DivAppraisebottom
        {
            background-image:url(/images/shop/rate/Appraisebottom.jpg);
            width:464px;
            margin-top:0px;
            height:14px;
        }
        .rate_table{width:435px; margin-top:10px;}
        .rate_table td{height:25px;}
        .rate_table input{background-color:#e8fdff; border:1px solid #84a1bd;}
    </style>
    <link href="/favicon.ico" rel="shortcut icon" type="image/x-icon" />
    <link href="/css/V5/Lib.css" rel="stylesheet" type="text/css" />
    
    <script type="text/javascript">
       
        var orderId = 0;
        var gUserName = "";
        var gEmail ="";
        var gPhone ="";
        var gAddress = "";
        var gId =0;
        var gRestName;
        var gState = 0;
        var gStateName ="";
        $(document).ready(function(){
         $("#tbRemark2").bind("blur",function(){
             var strName = $("#tbRemark2").val();
             if(strName == "")
             {
                $("#tbRemark2").val("字数限制在50个汉字以内");
             }
           });
             $("#tbRemark2").bind("focus",function(){
             var strName = $("#tbRemark2").val();
             if(strName == "字数限制在50个汉字以内")
             {
                $("#tbRemark2").val("");
             }
           });
           
            $("#tbRemark").bind("blur",function(){
             var strName = $("#tbRemark").val();
             if(strName == "")
             {
                $("#tbRemark").val("字数限制在50个汉字以内");
             }
           });
             $("#tbRemark").bind("focus",function(){
             var strName = $("#tbRemark2").val();
             if(strName == "字数限制在50个汉字以内")
             {
                $("#tbRemark").val("");
             }
           });
           
            $("#tbRemark1").bind("blur",function(){
             var strName = $("#tbRemark1").val();
             if(strName == "")
             {
                $("#tbRemark1").val("字数限制在255个汉字以内");
             }
           });
             $("#tbRemark1").bind("focus",function(){
             var strName = $("#tbRemark1").val();
             if(strName == "字数限制在255个汉字以内")
             {
                $("#tbRemark1").val("");
             }
           });
        });
        function GetOrderInfo()
        {
               var ret = UserRate_UserRate.GetOrderInfo(orderId).value;
               if(ret == null)
               {
                    window.alert("此订单不存在!");
                    window.location ="/index.aspx";
               }
              gEmail = ret.UserEmail;
              gAddress = ret.Address;
              gPhone =  ret.Mobile +" "+ret.Phone;
              gUserName = ret.Name;
              gRestName = ret.RestName;
              gState = ret.State;
              document.getElementById("<%=spRestName.ClientID %>").innerHTML = gRestName;
              document.getElementById("hidRestId").value = ret.RestId;
              if(gState != 1)
              {
                  document.getElementById("spTitle").style.display = "";
                  if(gState == 0)
                    gStateName ="待处理";
                  else if(gState == -1)
                    gStateName ="已作废";
                  else if(gState == -2)
                    gStateName ="虚假";
                  document.getElementById("spState").innerHTML =gStateName;
              }
              else
                document.getElementById("spTitle").style.display = "none";
        }
        function GetInfo()
        {
             orderId = document.getElementById("<%=spOrderId.ClientID %>").innerHTML;
            GetOrderInfo();
            ChangeChaPing();
           var divNo = document.getElementById("divNo");
           var ret = UserRate_UserRate.GetUserOrderList(orderId).value;
            if(ret == null)
            {
               divNo.style.display = ""; 
            }
            else
            {   document.getElementById("divOver").style.display = "";
                document.getElementById("spAmount").innerHTML = ret.AmountName;
                if(ret.Amount >=0)
                {
                    document.getElementById("spRemark").innerHTML = "附言："+ret.Remark; 
                }
                else
                {
                    document.getElementById("spRemark").innerHTML = "不满详情："+ret.Remark; 
                }
               
                gId = ret.Id;
                document.getElementById("hidRestId").value = ret.RestId;
                //判断是否在7天以内
                var flag = UserRate_UserRate.CheckOrderInDay(ret.UpdateTime).value;
                //判断是否显示修改评价按钮:不显示情况评价为好评,评价已作废,评价的提交时间在7天以外
                if(ret.Amount == 1 || (!flag) || ret.IsDelete !=0)
                {
                    document.getElementById("spUpdate").style.display = "none";
                }
                else
                {
                    document.getElementById("spUpdate").style.display = "";                    
                }
                if(ret.Amount == 1)
                {
                    document.getElementById("imgAmount").src ="/images/shop/rate/laugh.jpg";
                }
                else
                {
                     document.getElementById("imgAmount").src ="/images/shop/rate/commonly.jpg";
                }
            } 
        }
        function ShowDiv()
        {
           document.getElementById("divUpdate").style.display = "";     
           document.getElementById("divOver").style.display = "none";
        }
        function ChangeChaPing()
        {
           if(document.getElementById("raBad").checked)
           {
                document.getElementById("divNotCha").style.display = "none";
                document.getElementById("divCha").style.display = "";
                 //GetOrderInfo();
                document.getElementById("tbUserName").value = gUserName;
                document.getElementById("tbEmail").value = gEmail;
                document.getElementById("tbAddress").value = gAddress;
                document.getElementById("tbPhone").value = gPhone;
           }
           else
           {
                 document.getElementById("divCha").style.display = "none";
                 document.getElementById("divNotCha").style.display = "";
           }
        }
        
       
        function Add()
        {
          if(gState !=1)
            {
                window.alert("只有交易成功后才可进行评价，目前此订单的状态："+ gStateName +"！");
                return;
            }
            var item = document.getElementsByName("raPing");
            var amount =-2;
            for(var i = 0;i<item.length;i++)
            {
                if(item[i].checked)
                {
                    amount = item[i].value;
                    break;
                }
            }
            if(amount == -2)
            {
                window.alert("请您选择一个评价后,再提交操作!");
                return
            }
            var remark = document.getElementById("tbRemark").value;
            var restId = document.getElementById("hidRestId").value;
           var email = document.getElementById("tbEmail").value;
           if($.trim(email) !="")
           {
                if(!checkEmail(email))
                {
                    window.alert("电子邮箱格式错误,请重新输入!");document.getElementById("tbEmail").focus;
                    return;
                }
           }
            if(amount == -1)
            {
                remark = document.getElementById("tbRemark1").value;
                if($.trim(remark)=="" || $.trim(remark)=="字数限制在255个汉字以内")
                {
                    window.alert("请您填写好不满详情,以便我们以后为您更好的服务!");
                    return;
                }
              if(  $.trim(remark).replace(/[^\x00-\xff]/g,"xx").length>510)
                {
                    window.alert("不满详情字数不能超过255个字!");
                     document.getElementById("tbRemark1").focus();
                    return;
                }
            }
            else
            {
                  if($.trim(remark)=="字数限制在50个汉字以内")
                {
                    remark="";
                }
              if(  $.trim(remark).replace(/[^\x00-\xff]/g,"xx").length>100)
                {
                    window.alert("附言字数不能超过50个字!");
                    document.getElementById("tbRemark1").focus;
                    return;
                }
            }
            
            var ret = UserRate_UserRate.AddOrUpdate(0,orderId,amount,email,remark).value;
            if(ret == -3)
            {
                window.alert("此订单号不是您的订单号!");
               window.location ="/index.aspx";
            }else if(ret== -2)
            {
                window.alert("用户评级失败!");
                return;
            }
            else if(ret == -1)
            {
                window.alert("此订单号已经添加了评价!");
                window.location ="/index.aspx";
            }
            else if(ret == -4)
            {
                 window.alert("请您选择一个评价后,再提交操作!");
                return
            }
            else
            {
                window.alert("您的评价已经提交成功!");
                window.location.reload();
            }
        }
        function Update()
        {
             if(gState !=1)
            {
                window.alert("您的订单还未交易成功，请在此订单交易成功后再对餐馆评价！");
                return;
            }
  
            if(document.getElementById("raGood1").checked)
            {
               var amount = 1;
               var remark = document.getElementById("tbRemark2").value;
               if($.trim(remark)=="字数限制在50个汉字以内")
                {
                    remark = "";
                }
              if( $.trim(remark).replace(/[^\x00-\xff]/g,"xx").length>100)
                {
                   window.alert("附言字数不能超过50个字!"); document.getElementById("tbRemark2").focus();
                    return;
                }
               var ret = UserRate_UserRate.AddOrUpdate(gId,orderId,amount,"",remark).value;
               if(ret == 1)
               {
                    window.alert("您的评价已经修改成功!");
                   window.location.reload();
               }
             
            }
            else
            {
                window.alert("请先选择好评,然后提交！");
                return;
            }
            
        }
        function closeDiv()
        {
            document.getElementById("divUpdate").style.display="none";
        }
        function tbOnclick(evt)
        {
            
            var hid = document.getElementById("hidClear");
            if(evt.id == "tbRemark" && hid.value.indexOf("1") < 0  )
            {
                evt.value ="";
                hid.value = hid.value+"1";
                return;
            }
            if(evt.id == "tbRemark1" && hid.value.indexOf("2")<0)
            {
                 evt.value ="";
                hid.value = hid.value+"2";
                return;
            }
             if(evt.id == "tbRemark2" && hid.value.indexOf("3")<0)
            {
                evt.value ="";
                hid.value = hid.value+"3";
                return;
            } 
        }
  </script>
</head>
<body onload="GetInfo()">
    <form id="form1" runat="server" >
        &nbsp;<uc3:BriefnessTop ID="BriefnessTop1" runat="server" />
    <%--为餐馆评价开始--%>
    <div class="Band">
        <div class="BandContain">
            <div class="mianbaoxie" style="font-size:12px">
                <span class="f_00">您现在的位置是：</span><a href="/index.aspx" target="_blank">首页</a>&nbsp;&gt;&nbsp;订餐评价
            </div>
            <div class="EateryAppraise">
                <div class="DivAppraisetop">
                </div>
                <div class="DivAppraisecenter" id="divNo" style="display:none">
                <div style="color:#999;padding-left:15px; margin-bottom:5px;">
                <span id="spTitle" style="display:none">只有交易成功后才可进行评价，目前此订单的状态：<span id="spState" style="color:#000;"></span>！</span><br/>
                 <span> 订餐成功，客户未表态，系统自动评价。</span><br/>
                 </div>
               <div style="font-size:14px;color:#000; padding-left:15px;">订单号：<span class="f_01" id="spOrderId" runat="server"></span>&nbsp;&nbsp;&nbsp;&nbsp;餐馆名称：<span class="f_import" id="spRestName" runat="server">南瓜的一天</span></div>
                   <div style="font-size:14px;height:28px; border:1px solid #bdbcbd; width:435px; margin-top:15px;" >
                        <table style="width:435px;">
                            <tr>
                                <td><input style="border:0px" type="radio" name="raPing" value="1" id="raGood"  onclick="ChangeChaPing()" /></td>
                                <td><img src="/images/shop/rate/laugh.jpg" alt="" /></td>
                                <td class="f_import">好评（加1分）</td>
                                <td><input style="border:0px"  type="radio" value="0" name="raPing" id="raMiddle" onclick="ChangeChaPing()" /></td>
                                <td><img src="/images/shop/rate/commonly.jpg" alt="" /></td>
                                <td class="f_import">中评（不加分）</td>
                                <td><input style="border:0px" type="radio" value="-1" name="raPing" id="raBad" onclick="ChangeChaPing()" /></td>
                                <td><img src="/images/shop/rate/commonly.jpg" alt="" /></td>
                                <td class="f_import">差评（减1分）</td>
                            </tr>
                        </table>
                   </div>
                <div id="divNotCha">
                 <div style="font-size:14px; color:#000; margin-top:15px;">
                        <table>
                        <tr>
                            <td style="font-size:14px; color:#000; vertical-align:top;">&nbsp;附言：</td>
                            <td><textarea cols="60" id="tbRemark" rows="3"  onclick="tbOnclick(this)" title="字数限制在50个汉字以内" style="width:350px; height:57px; background-color:#e8fdff; border:1px solid #84a1bd;">字数限制在50个汉字以内</textarea></td>
                        </tr>
                   </table>
                   </div>
                   <div style="margin-top:20px; margin-left:160px;"><a class="DivInput" style="" href="javascript:void(0)" onclick="Add()">提&nbsp;&nbsp;&nbsp;交</a></div>
                </div>
                
                <%--为餐馆评价结束--%>
                <%--提交差评开始--%>
               <div id="divCha" style="display:none">
                   <div style="color:#ff0000; margin-top:7px;">您正在给<span id="_RName" runat="server">南瓜的一天</span>提交差评，这将会对该餐馆的服务等级评定造成重大影响！</div>
                   <table class="rate_table">
                   <tr>
                        <td class="f_00">联&nbsp;&nbsp;系&nbsp;&nbsp;人：</td><td><input style="width:82px;" readonly="readonly" id="tbUserName" type="text" /><span style="margin-left:40px;"   class="f_00">联络电话：</span><input type="text"  id="tbPhone" readonly="readonly"/></td>
                   </tr>
                   <tr>
                        <td class="f_00">送餐地址：</td><td><input style="width:300px;" type="text" readonly="readonly" id="tbAddress"  /></td>
                   </tr>
                   <tr>
                        <td class="f_00">电子邮箱：</td><td><input style="width:300px;" type="text"  id="tbEmail" /></td>
                   </tr>
                   <tr>
                        <td  class="f_00" style="vertical-align:top;">不满详情：</td>
                        <td><textarea id="tbRemark1" cols="60" rows="3" onclick="tbOnclick(this)"  title="字数限制在255个汉字以内" style="width:350px; height:57px; background-color:#e8fdff; border:1px solid #84a1bd;">字数限制在255个汉字以内</textarea></td>
                   </tr>
                   </table>
                   <div style="margin-top:20px; margin-left:160px;"><a class="DivInput"  href="javascript:void(0)" onclick="Add()">提&nbsp;&nbsp;&nbsp;交</a></div>
                </div>
                </div>
                <%--</div>--%>
                <%--提交差评结束--%>
                <%--已为餐馆评价开始--%>
                   <div class="DivAppraisecenter" id="divOver" style="display:none">
                   <div style="font-size:14px; padding-left:15px;">您已经给该餐馆评价过了。</div>
                   <div style="height:28px; border:1px solid #bdbcbd; width:435px; margin-top:15px;">
                        <table style="width:435px;">
                            <tr>
                             <td style=" color:#000; font-size:14px; width:70px;">评价结果：</td>
                             <td style="width:30px;"><img src="/images/shop/rate/laugh.jpg" alt="" id="imgAmount" /></td>
                             <td class="f_import" style="font-size:14px;"><span id="spAmount">好评（加1分）</span></td>
                            </tr>
                        </table>
                   </div>
                   <div style="font-size:14px; color:#000; margin-top:15px;">
                        &nbsp;<span id="spRemark"></span>
                   </div>
                   <div style="margin-top:20px; margin-left:160px;" id="spUpdate"><a class="DivInput" style="" href="javascript:void(0)"  onclick="ShowDiv()">修改评价</a></div>
                   </div>
                  <%-- 已为餐馆评价结束--%>
                  <%--修改评价开始--%>
                  <div class="DivAppraisecenter" style="display:none" id="divUpdate">
                  <div style="font-size:14px; padding-left:15px;">对于7日内的差评或中评，您有一次机会更改为好评！</div>
                   <div style="font-size:14px;height:28px; border:1px solid #bdbcbd; width:435px; margin-top:15px;">
                        <table style="width:435px;">
                            <tr>
                                <td style="width:8px;"><input style="border:0px" name="rdoRateResult" type="radio" id="raGood1" value="1" /></td>
                                <td style="width:30px;"><img src="/images/shop/rate/laugh.jpg" alt="" /></td>
                                <td class="f_import" style="font-size:14px;">好评（加1分）</td>
                            </tr>
                        </table>
                   </div>
                 <div>
                   <div style="font-size:14px; color:#000; margin-top:15px;">
                        <table>
                        <tr>
                            <td style="font-size:14px; color:#000; vertical-align:top;">&nbsp;附言：</td>
                            <td><textarea cols="60" rows="3" id="tbRemark2"  title="字数限制在50个汉字以内" style="width:350px; height:57px; background-color:#e8fdff; border:1px solid #84a1bd;">字数限制在50个汉字以内</textarea></td>
                        </tr>
                   </table>
                   </div>
                   <div style="margin-top:20px; margin-left:160px;"><a class="DivInput" style="" href="javascript:void(0)" onclick="Update()">提&nbsp;&nbsp;&nbsp;交</a></div>
                </div>
            </div>
            <%--修改评价结束--%>
              <input type="hidden" id="hidRestId" value="0" />
            <input type="hidden" id="hidUserName" value="" />
            <input type="hidden" id="hidPhone" value="" />
            <input type="hidden" id="hidAddress" value="" />
            <input type="hidden" id="hidEmail" value="" />
            <div class="DivAppraisebottom"></div>
            </div>
        </div>
        
    </div>
    <uc2:BottomNo51la ID="BottomNo51la1" runat="server" />
    </form>
    <input type="hidden" id="hidClear" value="0" />
</body>
</html>
