<!--{include file="<!--{$oetplpath}-->block_head.tpl"}-->
<div class="layui-fluid oe_fluid">
  <div class="oe_breadcrumb_box clearfix">
    <div class="layui-breadcrumb fl" lay-filter="breadcrumb" style="visibility: visible;">
      <a href="javascript:;">会员管理</a><span lay-separator="">/</span>
      <a href="javascript:;">信件管理</a><span lay-separator="">/</span>
      <a><cite>通信记录</cite></a>
    </div>
    <div class="oe_tool_bar ft">
      <a class="layui-btn layui-btn-sm layui-btn-primary layui-btn-radius" href="javascript:window.history.go(-1);">&lt;&lt;返回上一页</a>
    </div> 
  </div>
  
  <div class="oe_chat_box layui-form">
    <div class="chat">
      <div class="header">
        正在与“<!--{$touser.username}-->”(UID:<!--{$touser.userid}-->)私信中...
      </div>
      
      <div class="box">
        <div class="record">
          <!--{if !empty($msglog)}-->
          <!--{foreach $msglog as $volist}-->
          <!--{if $volist.fromuid == $userid}-->
            <div class="msg_to">
              <div class="avatar"><img src="<!--{$volist.from.headimg}-->" title="<!--{$volist.from.username}-->" /></div>
              <div class="msg"><!--{$volist.content|nl2br2}--></div>
              <div class="free"><!--{if $volist.isfree == '1'}-->【免费】<!--{/if}--></div>
            </div>
          <!--{else}-->
            <div class="msg_form">
              <div class="avatar"><img src="<!--{$volist.from.headimg}-->" title="<!--{$volist.from.username}-->" /></div>
              <div class="msg"><!--{$volist.content|nl2br2}--></div>
              <div class="free"><!--{if $volist.isfree == '1'}-->【免费】<!--{/if}--></div>
            </div>
          <!--{/if}-->
          <div class="time">
            <span><!--{$volist.sendtime|date_format:"%Y-%m-%d %H:%M:%S"}--></span>
          </div>
          <!--{/foreach}-->
          <!--{/if}-->
        </div>
        <!--//record end -->
        
        <div class="send_msg">
          <div class="send_to">
            <div class="form">
              收件人：
              <!--{$touser.username}-->
              <span style="font-size:12px">
              (UID:<!--{$touser.userid}-->)
              <!--{hook mod="var" item="gender" type="text" value=$touser.gender}--> / 
              <!--{$touser.age}-->岁 <!--{hook mod="var" item="marry" type="text" value=$touser.marry}-->
              <!--{$touser.height}-->CM <!--{area type="text" value=$touser.dist1}--> <!--{area type="text" value=$touser.dist2}--> 
              <!--{if isset($config.app.autoai)}-->
              <!--{if $config.app.autoai == '1' && $fromuser.isvest == '1'}-->
              <font color="orange">(机器人)</font>
              <!--{/if}-->
              <!--{/if}-->
              </span>
            </div>
          </div>
          <div class="msg_content">
            <textarea class="layui-textarea" name="content" id="content" placeholder="请输入500个字以内的信件内容..."></textarea>
          </div>
          <div class="btn_box">
            <div class="text">500个字以内</div>
            <input type="checkbox" lay-skin="primary" title="收件人免费看信" name="isfree" value="1"/>
            <button class="layui-btn layui-btn-normal" id="but_submit_post" f="but_submit_post">
              发送
              <span class="oe_btn_loading layui-anim layui-icon layui-anim-rotate layui-anim-loop" style="display:none;">&#xe63d;</span>
            </button>
            
          </div>
        </div>
      </div>
      <!--//to box End -->
      
      
      <div class="person_msg">
        <div class="top">
          <div class="avatar">
            <img src="<!--{$fromuser.headimg}-->" alt="" />
          </div>
          <div class="info">
            <div class="name"><!--{$fromuser.username}--> / <!--{$fromuser.userid}--></div>
            <div class="info_box">
            <!--{hook mod="var" item="gender" type="text" value=$fromuser.gender}--> / 
            <!--{$fromuser.age}-->岁 <!--{hook mod="var" item="marry" type="text" value=$fromuser.marry}-->
            <!--{$fromuser.height}-->CM <!--{area type="text" value=$fromuser.dist1}--> <!--{area type="text" value=$fromuser.dist2}--> 
            
            <!--{if isset($config.app.autoai)}-->
            <!--{if $config.app.autoai == '1' && $fromuser.isvest == '1'}-->
            <font color="orange">(机器人)</font>
            <!--{/if}-->
            <!--{/if}-->
            </div>  
          </div>
        </div>
        <div class="intro" style="display:none;">
          <h3>个人简介：</h3>
          <div class="text"><!--{$fromuser.intro|filterhtml:40}-->...</div>
        </div>
        
        <div class="item">
          <div class="label">通信SID：</div>
          <div class="val"><!--{$siddata.bgsid}--></div>
        </div>
        <div class="item">
          <div class="label">通信解锁：</div>
          <div class="val">
            <!--{if $siddata.freelock == '1'}-->
            <font color="green">已解锁</font>
            <!--{else}-->
            <font color="red">未解锁</font>
            <!--{/if}-->
            &nbsp;&nbsp;&nbsp;&nbsp;
            <!--{if $siddata.freelock == '1'}-->
            <a href="javascript:;" class="layui-btn layui-btn-xs layui-btn-normal" id="but_freesid" f="but_freesid" data-type="lock" data-sid="<!--{$siddata.bgsid}-->">点击加锁</a>
            <!--{else}-->
            <a href="javascript:;" class="layui-btn layui-btn-xs" id="but_freesid" f="but_freesid" data-type="free" data-sid="<!--{$siddata.bgsid}-->">点击解锁</a>
            <!--{/if}-->
          </div>
        </div>
        <div class="tips">解锁后双方通信不受限制<br />解锁不扣除会员费用</div>
        <div class="item">
          <div class="label">解锁时间：</div>
          <div class="val">
          <!--{if $siddata.freelock == '1'}-->
          <!--{if $siddata.freetime > 0}-->
          <!--{$siddata.freetime|date_format:"%Y-%m-%d %H:%M:%S"}-->
          <!--{else}-->
          --
          <!--{/if}-->
          <!--{else}-->
          --
          <!--{/if}-->
          </div>
        </div>
        <div class="item" style="display:none;">
          <div class="label">解锁费用：</div>
          <div class="val">
          <!--{if $siddata.freelock == '1'}-->
          <span><!--{doubleval($siddata.freefee)}--></span> <!--{$config.moneyname}-->
          <!--{else}-->
          --
          <!--{/if}-->
          </div>
        </div>
        
        <div class="item">
          <div class="label">双方发信数量：</div>
          <div class="val"><span><!--{$siddata.sendnums}--></span></div>
        </div>
        <div class="item">
          <div class="label">双方收信数量：</div>
          <div class="val"><span><!--{$siddata.receivenums}--></span></div>
        </div>
      </div>
      <!--//from box End -->
      
    </div>
  </div>
</div>
<script src="<!--{$urlpath}-->tpl/static/js/amrplay.js"></script>
<script type="text/javascript">
$(function(){
    
    //发送信件...
    $(document).on("click", "[f='but_submit_post']", function(){
        $obj_id = $(this).attr("data-id");
        if (!$("#"+$obj_id).hasClass("forbid_submit")) {
            
            $content = $("#content").val();
            $isfree = $("input[name='isfree']:checked").val();
            if (typeof($isfree) == "undefined") {
                $isfree = 0;
            }
            
            if ($content.length == 0) {
                layer.msg("请输入500字以内的信件内容");
                return false;
            }
            
            $("#"+$obj_id).addClass("forbid_submit");
            if ($("#"+$obj_id).find("span").length > 0) {
                $("#"+$obj_id).find("span").show();
            }
            $.ajax({
                type: "POST",
                url: "<!--{$oefile}-->&c=message",
                cache: false,
                data: {
                    a:"savewrite", fromuid:"<!--{$fromuser.userid}-->", touid:"<!--{$touser.userid}-->", sid:"<!--{$siddata.bgsid}-->",
                    content:$content, isfree:$isfree, r:get_rndnum(8) 
                },
                dataType: "json",
                success: function(data) {
                    $json = eval(data);
                    $response = $json.response;
                    $result = $json.result;
                    if ($response == '1') {
                        $("#content").val("");
                        layer.msg("发送成功");
                        setTimeout(function(){
                            window.location.reload();
                        }, 500);
                    }
                    else {
                        if ($result.length == 0) {
                            $result = "发送失败";
                        }
                        layer.msg($result);
                    }
                    $("#"+$obj_id).removeClass("forbid_submit");
                    if ($("#"+$obj_id).find("span").length > 0) {
                        $("#"+$obj_id).find("span").hide();
                    }
                },
                error: function() {
                    layer.msg("系统繁忙，请稍后再试");
                    $("#"+$obj_id).removeClass("forbid_submit");
                    if ($("#"+$obj_id).find("span").length > 0) {
                        $("#"+$obj_id).find("span").hide();
                    }
                }
            });

        }
    });
    
    //点击加解锁...
    $(document).on("click", "[f='but_freesid']", function(){
        $_type = $(this).attr("data-type");
        $_sid = $(this).attr("data-sid");
        
        if ($_type == "lock") {
            $_url = _OECPFILE+"&c=msglink&a=locksid";
        }
        else {
            $_url = _OECPFILE+"&c=msglink&a=freesid";
        }
        $_url += $_url+"&sid="+$_sid;
        
        layer.confirm("确定要执行改操作吗？", {
                btn: ["确定","取消"] //按钮
            }, 
            function(){
                layer.closeAll();
                oelove_do_ajax($_url, function(){
                    layer.msg("操作成功", {icon:1});
                    setTimeout(function(){
                        window.location.reload();
                    }, 600);
                });
            }, 
            function(){
                layer.closeAll();
            }
        ); 
        
    });
    
});
</script>
</body>
</html>