最终实现效果图
前台html代码
{layout name="common/header_footer" /}
<div class="admin-main">
<div class="layui-tab layui-tab-brief">
<ul class="layui-tab-title">
<li class="layui-this">兑换信息管理</li>
</ul>
</div>
<div class="layui-tab-content">
<div class="layui-tab-item layui-show">
<form action="{:url('index')}" class="layui-form" method="post">
<div class="layui-inline">
<input class="layui-input" placeholder="开始日" name="startTime" {if isset($date_start_time_show) } value="{$date_start_time_show}" {/if} οnclick="layui.laydate({elem: this, istime: true})">
</div>
<div class="layui-inline">
<input class="layui-input" placeholder="截止日" name="endTime" {if isset($date_end_time_show) } value="{$date_end_time_show}" {/if} οnclick="layui.laydate({elem: this, festival: true})">
</div>
<div class="layui-input-inline">
<select name="mch_id" lay-filter="mch_id" lay-verify="required" lay-search="">
<option value="">请选择所属法人</option>
{volist name="mch_info" id="mch"}
<option {if isset($mch_info_id) && $mch_info_id == $mch.id} selected {/if} value="{$mch.id}">{$mch.name}</option>
{/volist}
</select>
</div>
<div class="layui-input-inline">
<select name="store_id" lay-verify="" lay-search="">
<option value="">请选择所门店</option>
{if isset($store_info_id)}
{volist name="store_info_id" id="store_info"}
<option {if $data_store_id == $store_info.id} selected {/if} value="{$store_info.id}">{$store_info.username}</option>
{/volist}
{/if}
</select>
</div>
<div class="layui-inline">
<button class="layui-btn" lay-submit >搜索</button>
</div>
</form>
</div>
<table class="layui-table">
<thead>
<tr>
<th style="width:50px">序号</th>
<th>门店</th>
<th>兑换时间</th>
<th>商品名称</th>
<th>订单状态</th>
<th>商品金额</th>
<th>短信验证码</th>
</tr>
</thead>
<tbody>
{if isset($data)}
{volist name="cards" id="card" key="k"}
<tr>
<td>{$k+($page-1)*10}</td>
<td>{$card.store_name}</td>
<td>{$card.create_time}</td>
<td>{$card.goods_name}</td>
<td>{if $card.order_state==1}成功{elseif $card.order_state==0}未知{else}失败{/if}</td>
<td>{$card.card_total_fee}</td>
<th>{$card.sms_code}</th>
</tr>
{/volist}
{/if}
</tbody>
</table><br>
//分页
{if isset($data)}
<div style="float: right;">
<div id="page" class="page">
{$cards->render()}
</div>
</div>
{/if}
</div>
</div>
<script>
layui.use('element', function(){
var $ = layui.jquery
,element = layui.element(); //Tab的切换功能,切换事件监听等,需要依赖element模块
});
</script>
<script>
layui.use(['form', 'layedit', 'laydate'], function(){
//时间
var form = layui.form()
,layer = layui.layer
,layedit = layui.layedit
,laydate = layui.laydate
,$ = layui.jquery;
//下拉框
var form = layui.form();
form.on('select(mch_id)', function(data) {
var mch_id = data.value;
$.ajax({
type:"POST",
url:"{:url('get_store')}",
dataType:"json",
data:{'mch_id':mch_id},
success:function(e){
//empty() 方法从被选元素移除所有内容
$("select[name='store_id']").empty();
var html = "<option value='0'>请选择所属门店</option>";
$(e).each(function (v, k) {
html += "<option value='" + k.id + "'>" + k.username + "</option>";
});
//把遍历的数据放到select表里面
$("select[name='store_id']").append(html);
//从新刷新了一下下拉框
form.render('select');
}
})
})
});
</script>
后台控制器中的代码
public function index()
{
//form表单是post提交,但是点击第二页是get提交,所以这里接收的时候不用get或post
$data = input();
//Array ( [startTime] => 2017-12-01 [endTime] => 2017-12-20 [mch_id] => 2 [store_id] => 79 )
if (!empty($data)) {
$page = request()->param('page');
$page || $page = 1;
//将发送过来的门店id发送回前台与再次查询出来的多个门店作比较是否相等
$data_store_id = $data['store_id'];
(
$date_start_time = strtotime($data['startTime']);
$date_end_time = strtotime($data['endTime']) + 86400;
)