thinkphp5 Ajax搜索分页

function sousuo($page){
            var URL='';
            if($page){
                URL='__URL__/index/usercenter/selectorder?page='+$page;
            }else {
                URL='__URL__/index/usercenter/selectorder';
            }
            var ktime=$("#some_class_1").val();
            var eyime=$("#some_class_2").val();
            var content=$(".content");
            content.remove();
            $('.pagecss').empty();
            $('.va-m').remove();
            $.ajax({
                type: "post",
                data: {ktime:ktime,etime:eyime},
                url: URL,
                dataType: "json",
                success: function (arr) {
                    var html ="";
                    for (var i= 0;i<arr[0]['data'].length;i++){
                        html+='<tr class="text-c va-m"> ' +
                                '<td>'+arr[0]['data'][i]["orderId"]+'</td>' +
                                ' <td>'+arr[0]['data'][i]["username"]+'</td>' +
                                ' <td>'+arr[0]['data'][i]["totalPrice"]+'</td>' +
                                ' <td>'+arr[0]['data'][i]["creatTime"]+'</td>' +
                                ' <td>';
                        if(arr[0]['data'][i]['state']==0){
                            html+='待支付'
                        }else if(arr[0]['data'][i]['state']==1){
                            html+='已完成'
                        }else if(arr[0]['data'][i]['state']==2){
                            html+='已发货'
                        }else if(arr[0]['data'][i]['state']==3){
                            html+='待发货'
                        }else if(arr[0]['data'][i]['state']==4){
                            html+='取消'
                        }
                        html+='</td>' +
                                ' <td>'+arr[0]['data'][i]["goodsName"]+'</td>' +
                                ' <td> ' +
                                '<button type="button" class="btn btn-primary btn-xs" data-toggle="modal" data-target=".bs-example-modal-lg">再次购买</button>' +
                                ' <button type="button" class="btn btn-success btn-xs" onclick=\'show_order("订单详情","__URL__/index/usercenter/showorder?orderid='+arr[0]['data'][i]['orderId']+'","1000","1200")\'>查看订单</button>' +
                                ' </td>' +
                                ' </tr>';
                    }
                    $('.abc').append(html);
                    $('.pagecss').append(arr[1]);
                    $('.pagination>li>a').attr('href','#');
                    $('.pagination>li>a').each(function(index){
                        $('.pagination>li>a').eq(index).click(function(){
//                            alert($('.pagination>li>a').eq(index).html());
                            if($('.pagination>li>a').eq(index).html()=='»'){
                                var a=$('.active>span').html();
                                sousuo(parseInt(a)+1);
                            }else if($('.pagination>li>a').eq(index).html()=='«') {
                                var b=$('.active>span').html();
                                sousuo(parseInt(b)-1);
                            }else{
                                sousuo($('.pagination>li>a').eq(index).html());
                            }

                        });

                    })
                }
            });
        }

 

posted @ 2017-09-14 14:58  Harry-  阅读(599)  评论(0编辑  收藏  举报