本来都休假了,结果客户打电话要加上手机上的点击排序和筛选
排序的话,jq获取点击的data数值,然后传给后台,后台获取之后从数据库再查询
筛选就很简单的form提交
<script type="text/javascript">
$('#do-search').click(function() {
$('.search-block').removeClass('hidden');
});
$("#close-search").click(function(event) {
$('.search-block').addClass('hidden');
});
//排序降序操作
$('.wap-order-list li a').click(function(event) {
var the_list_order=$(this).attr("data-list-order");
var the_order_by=$(this).attr("data-order-by");
$('.fa-check').remove();
$(this).append('<i class="fa fa-check"></i>');
$('#order_by').val(the_list_order);
$('#order_by_es').val(the_order_by);
$.ajax({
url: "<?php echo url('portal/index/index'); ?>",
type: 'POST',
dataType: "json",
cache:false,
data: {
order_by: the_list_order,
order_by_es:the_order_by
}
})
.done(function(res) {
console.log("success");
console.log(res);
window.location.reload();
});
});
</script>
因为用的是thinkcmf基于thinkphp5.0的,传参接受之后不自动刷新,研究半天决定把排序方法放到session里,然后前台刷新次页面
if (!empty($param['order_by']) && !empty($param['order_by_es']) ) {
$order_by=$param['order_by'];
$order_by_esc=$param['order_by_es'];
session('order_by',$order_by);
session('order_by_esc',$order_by_esc);
return $order_by;
}
if (empty($param['order_by'])) {
$order=array(
'list_order' => 'desc'
);
}
if(!empty(session('order_by'))){
$order_by=session('order_by');
$order_by_esc=session('order_by_esc');
$order=array(
$order_by => $order_by_esc
);
}
if (isset($param['keywords']) && !empty($param['keywords'])) {
$where['issuer']=array('like','%'.$param['keywords'].'%');
}
if (isset($param['bill_sn']) ) {
if (!empty($param['bill_sn'])) {
$where['sn']=$param['bill_sn'];
}
}
if (empty($param['max_money']) && !empty($param['min_money'])) {
$where['money']=array('EGT',$param['min_money']);
}
if (empty($param['min_money'])) {
$param['min_money']=0;
}
if (!empty($param['max_money'])) {
$where['money']=array(array('EGT',$param['min_money']),array('ELT',$param['max_money'])) ;
}
这里是搭配的查询
$BillList=Db:
:name('bill')->where($where)->where('status', 0)->order($order)->paginate(20);