<!--{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-120">
          <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-120">
          <input type="text" name="smobile" id="smobile" class="layui-input" value="<!--{$smobile}-->" />
        </div>
      </div>
      <div class="layui-inline">
        <div class="layui-form-label">发送状态：</div>
        <div class="layui-input-inline input-120">
          <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_sms" 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="2%"></th>
          <th width="7%">ID</th>
          <th width="11%">用户</th>
          <th width="10%">手机号</th>
          <th width="9%">IP</th>
          <th width="6%">端口</th>
          <th width="9%">时间</th>
          <th width="5%">状态</th>
          <th>内容</th>
          <th width="15%">来源</th>
          <th width="6%">操作</th>
        </tr> 
      </thead>
      
      <!--{if empty($smslog)}-->
      <tr>
        <td colspan="11" class="text_center">没有符合条件的信息</td>
      </tr>
      <!--{else}-->
      <!--{foreach $smslog 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.userid}--> / <!--{$volist.username}-->
          <!--{else}-->
          --
          <!--{/if}-->
        </td>
        <td class="text_center"><!--{$volist.mobile}--></td>
        <td class="text_center"><!--{$volist.ipaddr}--></td>
        <td class="text_center"><!--{$volist.clientport}--></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">
          <!--{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><!--{$volist.content}--></td>
        <td><!--{$volist.refurl}--></td>
        <td class="text_center">
          <div class="btn_box">
            <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 == "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="25%"><font color="red"></font>接收用户：</th>
          <td width="75%">
            <!--{if $uid > 0}-->
            <!--{$user.username}-->/uid:<!--{$user.userid}-->
            <!--{else}-->
            --
            <!--{/if}-->
          </td>
        </tr>
        <tr>
          <th><font color="red">*</font>手机号码：</th>
          <td>
            <input type="text" name="mobile" id="mobile" class="layui-input" style="width:80%;" placeholder="请输入手机号码" value="<!--{$user.mobile}-->" />
          </td>
        </tr>
        <tr>
          <th><font color="red">*</font>短信内容：</th>
          <td>
            <textarea name="content" id="content" class="layui-textarea" style="width:80%;height:90px;" placeholder="请输入短信内容，70个字以内"></textarea>
            <span class="text_tip_inline">（短信内容含签名不能超过70个字）</font>
          </td>
        </tr>
      </table>
    </div>
  </div>

  
  <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")) {
                
                $mobile = $("#mobile").val();
                $content = $("#content").val();
                
                if ($mobile.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}-->", 
                        mobile:$mobile, 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>