<!--{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-100">
          <input type="text" name="suserid" id="suserid" class="layui-input" value="<!--{if $suserid > 0}--><!--{$suserid}--><!--{/if}-->" />
        </div>
      </div>
      <div class="layui-inline">
        <div class="layui-form-label">用户名：</div>
        <div class="layui-input-inline input-150">
          <input type="text" name="susername" id="susername" class="layui-input" value="<!--{$susername}-->" />
        </div>
      </div>
      <div class="layui-inline">
        <div class="layui-form-label">邮箱：</div>
        <div class="layui-input-inline input-150">
          <input type="text" name="semail" id="semail" class="layui-input" value="<!--{$semail}-->" />
        </div>
      </div>
      <div class="layui-inline">
        <div class="layui-form-label">状态：</div>
        <div class="layui-input-inline input-150">
          <select name="sflag" id="sflag">
            <option value="">不限</option>
            <option value="1"<!--{if $sflag == '1'}--> selected<!--{/if}-->>成功</option>
            <option value="2"<!--{if $sflag == '2'}--> selected<!--{/if}-->>失败</option>
          </select>
        </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>
  </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">
          <i class="layui-icon layui-icon-delete"></i>
          <span>删除选定</span>
        </div>
        <a href="javascript:;" f="pop_send_email" data-uid="" class="btn add fl">
          <i class="layui-icon layui-icon-friends"></i>
          <span>发送邮件</span>
        </a>
      </div>
    </div>
    
    <form class="layui-form" id="myform" action="<!--{$oefile}-->&c=<!--{$c}-->" method="post">
    <input type="hidden" name="a" id="a" value="del" />
    
    <table class="layui-table">
      <thead>
        <tr>
          <th width="4%"></th>
          <th width="8%">ID</th>
          <th width="15%">用户</th>
          <th width="15%">邮箱</th>
          <th width="12%">时间</th>
          <th>标题</th>
          <th width="15%">状态</th>
          <th width="10%">操作</th>
        </tr>
      </thead>
      
      <!--{if empty($maillog)}-->
      <tr>
        <td colspan="8" class="text_center">没有符合条件的信息</td>
      </tr>
      <!--{else}-->
      <!--{foreach $maillog as $volist}-->
      <tr>
        <td class="check text_center">
          <input type="checkbox" name="id[]" lay-skin="primary" value="<!--{$volist.logid}-->" />
        </td>
        <td class="text_center">
          <!--{$volist.logid}-->
        </td>
        <td class="text_center">
          <!--{if $volist.userid > 0}-->
          <!--{$volist.username}-->/(uid:<!--{$volist.userid}-->)
          <!--{else}-->
          --
          <!--{/if}-->
        </td>
        <td class="text_center">
          <!--{$volist.email}-->
        </td>
        <td class="text_center"><!--{$volist.sendtime|date_format:"%Y/%m/%d %H:%M"}--></td>
        <td><!--{$volist.title}--></td>
        <td class="text_center">
          <!--{if $volist.flag == '1'}-->
          <font color="green">成功</font>
          <!--{else}-->
          <font color="gray">失败</font>
          <!--{if !empty($volist.response)}-->
          <br /><font color="red"><!--{$volist.response}--></font>
          <!--{/if}-->
          <!--{/if}-->
        </td>
        <td class="text_center">
          <div class="btn_box">
            <a href="<!--{$oefile}-->&c=<!--{$c}-->&a=view&id=<!--{$volist.logid}-->&<!--{$comeurl}-->" class="layui-btn layui-btn-xs">查看</a>
            <a href="javascript:;" f="handle-one" data-url="<!--{$oefile}-->&c=<!--{$c}-->&a=del&id[]=<!--{$volist.logid}-->&<!--{$comeurl}-->" class="layui-btn layui-btn-xs layui-btn-danger">删除</a>
          </div>
        </td>
      </tr>
      <!--{/foreach}-->
      <!--{/if}-->
    </table>
    </form>
    <div class="oe_page_box"><!--{$showpage}--></div>

  </div>
</div>
<!--{/if}-->

<!--{if $a == 'view'}-->
<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}-->">邮件通知</a><span lay-separator="">/</span>
      <a><cite>查看</cite></a>
    </div>
    <div class="oe_tool_bar ft">
      <a href="<!--{$oefile}-->&c=<!--{$c}-->&<!--{$comeurl}-->" class="layui-btn layui-btn-sm layui-btn-primary layui-btn-radius">
        <span>返回列表</span>
      </a>
    </div>
  </div>
  <div class="layui-card oe_table_edit">
    <div class="layui-card-header">查看邮件</div>
    <div class="layui-card-body">
      <table class="oe_tbl_form layui-form">
        <tbody>
          <tr>
            <th width="15%">接收用户：<span class="f_red"></span></th>
            <td width="85%">
            <!--{if $maillog.userid > 0}-->
            <!--{$maillog.username}-->&nbsp;&nbsp;(uid:<!--{$maillog.userid}-->) 
            <!--{else}-->
            --
            <!--{/if}-->
            </td>
          </tr>
          <tr>
            <th>接收邮箱：<span class="f_red"></span></th>
            <td><!--{$maillog.email}--></td>
          </tr>

          <tr>
            <th>发送时间：<span class="f_red"></span></th>
            <td><!--{$maillog.sendtime|date_format:"%Y-%m-%d %H:%M:%S"}--></td>
          </tr>
          <tr>
            <th>邮件标题：<span class="f_red"></span></th>
            <td><!--{$maillog.title}--></td>
          </tr>

          <tr>
            <th>邮件内容：<span class="f_red"></span> </th>
            <td><!--{$maillog.content}--></td>
          </tr>
        </tbody>
      </table>
    </div>
  </div> 
</div>
<!--{/if}-->

<!--{if $a == "send"}-->
<div class="layui-fluid oe_fluid" style="padding-top:10px;">

  <div class="layui-card">
    <div class="layui-card-header">发送邮件通知</div>
    <div class="layui-card-body">
      <table class="oe_tbl_form layui-form">
        <tr>
          <th width="15%"><font color="red"></font>接收用户：</th>
          <td width="85%">
            <!--{if $uid > 0}-->
            <!--{$user.username}-->/uid:<!--{$user.userid}-->
            <!--{else}-->
            --
            <!--{/if}-->
          </td>
        </tr>
        <tr>
          <th><font color="red">*</font>邮箱地址：</th>
          <td>
            <input type="text" name="email" id="email" class="layui-input" style="width:80%;" placeholder="请输入邮箱地址" value="<!--{$user.email}-->" />
          </td>
        </tr>
        <tr>
          <th><font color="red">*</font>邮件标题：</th>
          <td>
            <input type="text" name="title" id="title" class="layui-input" style="width:80%;" placeholder="请输入邮件标题" value="<!--{$title}-->" />
          </td>
        </tr>
        <tr>
          <th><font color="red">*</font>邮件内容：</th>
          <td>
            <textarea name="content" id="content" class="layui-textarea" style="width:99%;height:220px;" placeholder="请输入邮件内容"></textarea>
          </td>
        </tr>
      </table>
    </div>
  </div>
  <!--{include file="<!--{$oetplpath}-->widget_editor.tpl"}-->
  
  <div class="oe_tbl_form_btn">
    <button class="layui-btn" id="but_submit_post" lay-submit lay-filter="sendform">
      确定发送
      <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(sendform)', function(data){
            $obj_id = data.elem.getAttribute("id");
            if (!$("#"+$obj_id).hasClass("forbid_submit")) {
                
                $email = $("#email").val();
                $title = $("#title").val();
                $content = OEeditor.html();
                
                if ($email.length == 0) {
                    layer.msg("请输入邮箱地址");
                    return false;
                }
                if ($title.length == 0) {
                    layer.msg("请输入邮件标题");
                    return false;
                }
                if ($content.length == 0) {
                    layer.msg("请输入邮件内容");
                    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=<!--{$c}-->",
                    cache: false,
                    data: {
                        a:"savesend", userid:"<!--{$uid}-->", 
                        email:$email, title:$title, content:$content, r:get_rndnum(8)
                    },
                    dataType: "json",
                    success: function($data) {
                        $json = eval($data);
                        $response = $json.response;
                        $result = $json.result;
                        if ($response == '1') {
                            layer.msg("发送成功");
                            setTimeout(function(){
                              window.location.reload();
                            }, 600);
                        }
                        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();
                        }
                    }
                });
            }
        });   
    });
    
});
</script>
<!--{/if}-->
</body>
</html>