<!--{include file="<!--{$oetplpath}-->block_head.tpl"}-->

<!--{if $a == "run"}-->
<div class="layui-fluid oe_fluid">
  <form class="layui-form" id="mysearch" action="<!--{$oefile}-->&c=<!--{$c}-->" method="post">
  <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>
  <!--//top end -->
  
  <div class="oe_searchbar layui-form">
    <div class="more_search_open"></div>
    <div class="layui-form-item">
      <div class="layui-inline">
        <div class="layui-form-label">发件人UID：</div>
        <div class="layui-input-inline input-150">
          <input type="text" name="sfromuid" id="sfromuid" class="layui-input" value="<!--{if $sfromuid > 0}--><!--{$sfromuid}--><!--{/if}-->" />
        </div>
      </div>
      <div class="layui-inline">
        <div class="layui-form-label">收件人UID：</div>
        <div class="layui-input-inline input-150">
          <input type="text" name="stouid" id="stouid" class="layui-input" value="<!--{if $stouid > 0}--><!--{$stouid}--><!--{/if}-->" />
        </div>
      </div>
      <div class="layui-inline">
        <div class="layui-form-label">内容：</div>
        <div class="layui-input-inline input-150">
          <input type="text" name="scont" id="scont" class="layui-input" value="<!--{$scont}-->" />
        </div>
      </div>
      
      <div class="layui-inline">
        <button class="layui-btn layui-btn-sm search" id="but_submit_search2" lay-submit lay-filter="searchform2">
          <i class="layui-icon layui-icon-search"></i>
          搜索
          <span class="oe_btn_loading layui-anim layui-icon layui-anim-rotate layui-anim-loop" style="display:none;">&#xe63d;</span>
        </button>
      </div>
      
      <div class="layui-form-item">
        <div class="layui-form-label">状&#12288;态：</div>
        <div class="label_box">
          <input type="hidden" name="sflag" id="sflag" value="<!--{$sflag}-->" />
          <span f="but_search_cat" data-val="0" data-input="sflag"<!--{if $sflag == '0'}--> class="current"<!--{/if}-->>不限</span>
          <span f="but_search_cat" data-val="1" data-input="sflag"<!--{if $sflag == '1'}--> class="current"<!--{/if}-->>通过</span>
          <span f="but_search_cat" data-val="2" data-input="sflag"<!--{if $sflag == '2'}--> class="current"<!--{/if}-->>锁定</span>
        </div>
      </div>
      <div class="layui-form-item">
        <div class="layui-form-label">阅&#12288;读：</div>
        <div class="label_box">
          <input type="hidden" name="sread" id="sread" value="<!--{$sread}-->" />
          <span f="but_search_cat" data-val="0" data-input="sread"<!--{if $sread == '0'}--> class="current"<!--{/if}-->>不限</span>
          <span f="but_search_cat" data-val="1" data-input="sread"<!--{if $sread == '1'}--> class="current"<!--{/if}-->>已读</span>
          <span f="but_search_cat" data-val="2" data-input="sread"<!--{if $sread == '2'}--> class="current"<!--{/if}-->>未读</span>
        </div>
      </div>
          
    </div>
  </div>
  <!--//search End -->
  </form>

  <div class="oe_table_wrap layui-form">
    <div class="oe_tbl_tool clearfix">
      <div class="oe_gnbar clearfix">
        <div class="select btn fl">
          <input type="checkbox" name="allid[]" lay-skin="primary" title="全选/反选" lay-filter="selectAll">
        </div>
        <div class="btn del fl" f="handle-array" data-form="myform" data-a="del">
          <i class="layui-icon layui-icon-delete"></i>
          <span>删除选中</span>
        </div>
        <div class="btn del fl" f="handle-array" data-form="myform" data-a="pass">
          <i class="iconfont icon-tongguo"></i>
          <span>批量通过</span>
        </div>
        <div class="btn del fl del_line" f="handle-array" data-form="myform" data-a="fail">
          <i class=" iconfont icon-butongguo"></i>
          <span>批量不通过</span>
        </div>
      </div>
      <div class="oe_tongji_bar clearfix current">
        <span><b><!--{$total}--></b> 条记录</span>
      </div>
    </div>
    
    <form id="myform" action="<!--{$oefile}-->&c=<!--{$c}-->&<!--{$comeurl}-->" method="post">
    <input type="hidden" name="a" id="a" value="" />
    <table class="layui-table">
      <thead>
        <tr>
          <th width="2%">选</th>
          <th width="7%">ID</th>
          <th width="5%">头像1</th>
          <th width="12%">发件人(会员1)</th>
          <th width="5%">头像2</th>
          <th width="12%">收件人(会员2)</th>
          <th width="8%">时间</th>
          <th width="4%">来源</th>
          <th width="4%">状态</th>
          <th width="4%">阅读</th>
          <th>信件</th>
          <th width="110px">操作</th>
        </tr>
      </thead>
      <!--{if empty($message)}-->
      <tr>
        <td class="text_center" colspan="13">没有符合条件的信息</td>
      </tr>
      <!--{else}-->
      <!--{foreach $message as $volist}-->
      <tr>
        <td class="text_center check">
          <input type="checkbox" lay-skin="primary" name="id[]" class="selall" value="<!--{$volist.msgid}-->" />
        </td>
        <td class="text_center check">
          <!--{$volist.msgid}-->
        </td>
        <td class="text_center drop">
        
          <!--{if !empty($volist.from.headimg)}-->
          <div class="down">
            <div><img src="<!--{$urlpath}-->tpl/static/images/loading_img.png" data-src="<!--{$volist.from.headimg_0}-->" width="20px" height="20px" preload="0" f="zoom_avatar" /></div>
            <div class="sub">
              <img src="<!--{$urlpath}-->tpl/static/images/loading_img.png" data-src="<!--{$volist.from.headimg}-->" preload="0" f="viewimg" />
            </div>
          </div>
          <!--{/if}-->
          
        </td>
        <td class="text_center">
          <a href="<!--{$urlpath}-->index.php?c=home&a=detail&id=<!--{$volist.from.userid}-->" target="_blank">UID:<!--{$volist.from.userid}--></a>
          /
          <a href="<!--{$oefile}-->&c=user&a=view&id=<!--{$volist.from.userid}-->"><!--{$volist.from.username}--></a>
          <br />
          
          <!--{if $volist.from.gender=='1'}-->
          <i class="iconfont icon-nan" title="男"></i>
          <!--{else}-->
          <i class="iconfont icon-nv" title="女"></i>
          <!--{/if}-->
          <!--{$volist.from.age}-->岁 <!--{area type="text" value=$volist.from.dist2}-->
        </td>
        <td class="text_center drop">
          <!--{if !empty($volist.to.headimg)}-->
          <div class="down">
            <div><img src="<!--{$urlpath}-->tpl/static/images/loading_img.png" data-src="<!--{$volist.to.headimg_0}-->" width="20px" height="20px" preload="0" f="zoom_avatar" /></div>
            <div class="sub">
              <img src="<!--{$urlpath}-->tpl/static/images/loading_img.png" data-src="<!--{$volist.to.headimg}-->" preload="0" f="viewimg" />
            </div>
          </div>
          <!--{/if}-->
        </td>
        <td class="text_center">
          <a href="<!--{$urlpath}-->index.php?c=home&a=detail&id=<!--{$volist.to.userid}-->" target="_blank">UID:<!--{$volist.to.userid}--></a>/
          <a href="<!--{$oefile}-->&c=user&a=view&id=<!--{$volist.to.userid}-->"><!--{$volist.to.username}--></a>
          <br />
          <!--{if $volist.to.gender=='1'}-->
          <i class="iconfont icon-nan" title="男"></i>
          <!--{else}-->
          <i class="iconfont icon-nv" title="女"></i>
          <!--{/if}-->
          <!--{$volist.to.age}-->岁 <!--{area type="text" value=$volist.to.dist2}-->
        </td>
        <td class="text_center">
          <!--{$volist.sendtime|date_format:"%Y-%m-%d"}--><br />
          <!--{$volist.sendtime|date_format:"%H:%M:%S"}-->
        </td>
        <td class="text_center"><!--{$volist.comefrom}--></td>
        <td class="text_center">
          <input type="checkbox" name="flag" lay-skin="primary" value="1" lay-filter="updatestatus" data-id="<!--{$volist.msgid}-->" data-type="flag"<!--{if $volist.flag == '1'}--> checked<!--{/if}--> />
        </td>
        <td class="text_center">
          <!--{if $volist.readstatus == '1'}-->
          <font color="green">已读</font>
          <!--{else}-->
          <font color="red">未读</font>
          <!--{/if}-->
        </td>
        <td><!--{$volist.content}--></td>
        <td class="text_center">
          <a href="<!--{$oefile}-->&c=<!--{$c}-->&a=edit&id=<!--{$volist.msgid}-->&<!--{$comeurl}-->" class="layui-btn layui-btn-xs layui-btn-normal">编辑</a>
          <a href="javascript:;" f="handle-one" data-url="<!--{$oefile}-->&c=<!--{$c}-->&a=del&id[]=<!--{$volist.msgid}-->&<!--{$comeurl}-->" class="layui-btn layui-btn-xs layui-btn-danger">删除</a>
          <div class="oe_manager_btn">
            <div class="layui-nav">
              <div class="layui-nav-item">
                <!--//9.10.29 -->
                <a href="javascript:;">更多<span class="layui-nav-more"></span></a>
                <dl class="layui-nav-child layui-anim layui-anim-upbit" style="width:120px; left:-30px;">
                  <dd><a href="<!--{$oefile}-->&c=msglog&sid=<!--{$volist.bgsid}-->&userid=<!--{$volist.fromuid}-->&<!--{$urlitem}-->&from=message">给会员2发信</a></dd>
                  <dd><a href="<!--{$oefile}-->&c=msglog&sid=<!--{$volist.bgsid}-->&userid=<!--{$volist.touid}-->&<!--{$urlitem}-->&from=message">给会员1发信</a></dd>
                </dl>
              </div>
            </div>
          </div>
        </td>
      </tr>
      <!--{/foreach}-->
      <!--{/if}-->
    </table>
    </form>
    
    <div class="oe_page_box"><!--{$showpage}--></div>
    
  </div>
</div>
<!--//9.10.12 -->
<script src="<!--{$urlpath}-->tpl/static/js/amrplay.min.js?v=<!--{$copyright_version}-->"></script>
<script type="text/javascript">
$(function(){
    layui.use(['layer', 'element'], function(){

    });
    
    //预载图片 9.10.12
    preload_img();
});
</script>
<!--{/if}-->

<!--{if $a == 'edit'}-->
<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">
      <button class="layui-btn layui-btn-sm layui-btn-radius" id="but_submit_post2" lay-submit lay-filter="editform">
        编辑保存
        <span class="oe_btn_loading layui-anim layui-icon layui-anim-rotate layui-anim-loop" style="display:none;">&#xe63d;</span>
      </button>
      <a class="layui-btn layui-btn-sm layui-btn-primary layui-btn-radius" href="<!--{$oefile}-->&c=<!--{$c}-->&<!--{$comeurl}-->">返回列表</a>
    </div> 
  </div>
  
  <div class="layui-card oe_table_edit">
    <div class="layui-card-header">编辑信件</div>
    <form id="myform" action="<!--{$oefile}-->&c=<!--{$c}-->&<!--{$comeurl}-->" method="post" />
    <input type="hidden" name="a" id="a" value="saveedit" />
    <input type="hidden" name="id" id="id" value="<!--{$id}-->" />
    <div class="layui-card-body">
      <table class="oe_tbl_form layui-form">
        <tr>
          <th width="15%">发件人：<span class="f_red"></span></th>
          <td width="35%">
          （<!--{$message.fromuid}-->/<!--{$message.from.username}-->）<!--{hook mod="var" item="gender" type="text" value=$message.from.gender}--> <!--{area type="text" value=$message.from.dist2}-->
          </td>
          <th width="15%">收件人：</th>
          <td width="35%">
            （<!--{$message.touid}-->/<!--{$message.to.username}-->）<!--{hook mod="var" item="gender" type="text" value=$message.to.gender}--> <!--{area type="text" value=$message.to.dist2}-->
          </td>
        </tr>
        <tr>
          <th>发件时间：</th>
          <td><!--{$message.sendtime|date_format:"%Y-%m-%d %H:%M:%S"}--></td>
          <th>来源：</th>
          <td><!--{$message.comefrom}--></td>
        </tr>
        <tr>
          <th><span class="require">*</span> 审核状态：</th>
          <td>
            <div class="tbl_input input-200">
              <select name="flag" id="flag">
                <option value="">=请选择=</option>
                <option value="1"<!--{if $message.flag == '1'}--> selected<!--{/if}-->>通过</option>
                <option value="0"<!--{if $message.flag == '0'}--> selected<!--{/if}-->>锁定</option>
              </select>
            </div>
          </td>
          <th>阅读状态：<span class="f_red"></span> </th>
          <td>
          <!--{if $message.readstatus == '1'}-->
          <font color="green">已读</font>
          <!--{else}-->
          <font color="red">未读</font>
          <!--{/if}-->
          </td>
        </tr>
        <tr>
          <th><font color="red">*</font>信件内容： </th>
          <td colspan="3">
            <textarea class="layui-textarea" name="content" id="content" style="width:50%;height:120px;"><!--{$message.content}--></textarea>
          </td>
        </tr>
      </table>
    </div>
    </form>
  </div>
  
  <div class="oe_tbl_form_btn">
    <button class="layui-btn" id="but_submit_post" lay-submit lay-filter="editform">
      编辑保存
      <span class="oe_btn_loading layui-anim layui-icon layui-anim-rotate layui-anim-loop" style="display:none;">&#xe63d;</span>
    </button>
  </div>
  
</div>
<script type="text/javascript">
$(function(){
    layui.use('form', function(){
        $form = layui.form;
        //保存...
        $form.on('submit(editform)', function(data){
            $obj_id = data.elem.getAttribute("id");
            if (!$("#"+$obj_id).hasClass("forbid_submit")) {
                
                if ($("#flag").val().length  == 0) {
                    layer.msg("请选择审核状态");
                    return false;
                }
                
                if ($("#content").val().length  == 0) {
                    layer.msg("请输入信件内容");
                    return false;
                }
                
                $("#"+$obj_id).addClass("forbid_submit");
                if ($("#"+$obj_id).find("span").length > 0) {
                    $("#"+$obj_id).find("span").show();
                }
                $("#myform").submit();
            }
        });   
    });
    
});
</script>

<!--{/if}-->

<!--{if $a == 'write'}-->
<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 href="<!--{$oefile}-->&c=<!--{$c}-->&<!--{$comeurl}-->">信件列表</a><span lay-separator="">/</span>
      <a><cite>写信、发信</cite></a>
    </div>
    <div class="oe_tool_bar ft">
      <button class="layui-btn layui-btn-sm layui-btn-radius" id="but_submit_post2" lay-submit lay-filter="addform" style="display:none;">
        添加保存
        <span class="oe_btn_loading layui-anim layui-icon layui-anim-rotate layui-anim-loop" style="display:none;">&#xe63d;</span>
      </button>
      <a class="layui-btn layui-btn-sm layui-btn-primary layui-btn-radius" href="<!--{$oefile}-->&c=<!--{$c}-->&<!--{$comeurl}-->">返回列表</a>
    </div> 
  </div>
  <div class="layui-card oe_table_edit">
    <div class="layui-car-header">写信、发信</div>
    <div class="layui-card-body">
      <table class="oe_tbl_form layui-form">
        <tr>
          <th width="15%">发件人：<span class="f_red"></span></th>
          <td width="35%">
          （<!--{$fromuser.userid}-->/<!--{$fromuser.username}-->）<!--{hook mod="var" item="gender" type="text" value=$fromuser.gender}--> <!--{$fromuser.age}-->岁 <!--{area type="text" value=$fromuser.dist1}--> <!--{area type="text" value=$fromuser.dist2}-->
          </td>
          <th width="15%">收件人：</th>
          <td width="35%">
            （<!--{$touser.userid}-->/<!--{$touser.username}-->）<!--{hook mod="var" item="gender" type="text" value=$touser.gender}--> <!--{$touser.age}-->岁 <!--{area type="text" value=$touser.dist1}--> <!--{area type="text" value=$touser.dist2}-->
          </td>
        </tr>
        <tr>
          <th><span class="require">*</span>信件内容：</th>
          <td colspan="3">
            <textarea class="layui-textarea" name="content" id="content" style="width:70%;height:160px;"></textarea>
          <br />（500个字以内）
        </td>
        </tr>
        <tr>
          <th>其他：</th>
        <td colspan="3">
          <input type="checkbox" lay-skin="primary" name="isfree" id="isfree" value="1" />收件人免费看信
        </td>
        </tr>
        <tr>
          <td></td>
          <td colspan="3"><input type="button" id="btn_save" class="layui-btn">确定发送</button></td>
        </tr>
      </table>
    </div>
  </div>
</div>
<script type="text/javascript">
$(function(){
	$("#btn_save").bind("click", function(){
		$content = $("#content").val();
		if ($content.length == 0) {
			ToastTips("信件内容不能为空", "content");
			return false;
		}
		$isfree = $("input[name='isfree']:checked").val();
		if (typeof($isfree) == "undefined") {
			$isfree = 0;
		}
		
		$("#btn_save").val("发送中...");
		$.ajax({
			type: "POST",
			url: "<!--{$oefile}-->&c=<!--{$c}-->",
			cache: false,
			data: {
				a:"savewrite", fromuid:"<!--{$fromuid}-->", touid:"<!--{$touid}-->", 
				sid:"<!--{$sid}-->", content:$content, isfree:$isfree, r:Math.random()
			},
			dataType: "json",
			success: function(data) {
				$json = eval(data);
				$response = $json.response;
				$result = $json.result;
				if ($response == '1') {
					ToastTips("发送成功");
					setTimeout(function(){
						window.parent.location.reload();
					}, 500);
				}
				else {
					if ($result.length == 0) {
						$result = "发送失败";
					}
					ToastTips($result);
				}
				$("#btn_save").val("确定发送");
			},
			error: function() {
				ToastTips("系统繁忙，请稍后再试");
				$("#btn_save").val("确定发送");
			}
		});

	});
});
</script>
<!--{/if}-->
</body>
</html>