thinkphp5 手动加载

html代码:
{egt name="list|count" value="20"}
<button id="loadMore" οnclick="loadMore();" style="background: grey; color: white; padding: 5px; width: 100%; border: 0px;">点击加载更多...</button>
{/egt}

 
jquery代码
var pageNum = 0;
function loadMore() {
    pageNum++;
    showLoad();
    $.ajax({
        type:'POST',
        dataType:'json',
        data:{'pageNum':pageNum},
        url:'{$Think.config.url}index/Account/loadList',
        success:function(data){
            hideLoad();
            if(data.status == 1){
                $("#contentList").append(data.data);               
            }else{
                show_msg("操作失败");
            }
        }
    });
}

 
php代码
$list = $this->getList();
$this->assign("list",$list);

 
 
public function loadList(){
    $page = ($_POST["pageNum"] * 20).",20";

    $list = $this->getList($page);
    $html = "";
    foreach($list as $v){
        if($v["type"] == 0){
            $html .= '<div class="box-item"><p class="txt-item">'.date("Y-m-d ",$v["estTime"]).'&nbsp;&nbsp;&nbsp;赞助'.$v["nick"].'
        <span class="pull-right">'.$v["amount"].'&nbsp;<i class="glyphicon glyphicon-circle-arrow-up clr-wc-red"></i> </span>
    </p>
    <hr></div>';
        }elseif($v["type"] == 1){
            if($v["status"] == 0){
                $html .= '<div class="box-item"><p class="txt-item">'.date("Y-m-d ",$v["estTime"]).'&nbsp;&nbsp;&nbsp;提现-扣除5%手续费(提现中)
        <span class="pull-right">'.$v["amount"].'&nbsp;<i class="glyphicon glyphicon-circle-arrow-up clr-wc-red"></i> </span>
    </p>
    <hr></div>';
            }
            if($v["status"] == 2){
                $html .= '<div class="box-item"><p class="txt-item">'.date("Y-m-d ",$v["estTime"]).'&nbsp;&nbsp;&nbsp;提现-扣除5%手续费(已提现)
        <span class="pull-right">'.$v["amount"].'&nbsp;<i class="glyphicon glyphicon-circle-arrow-up clr-wc-red"></i> </span>
    </p>
    <hr></div>';
            }
        }elseif($v["type"] == 2){
            $html .= '<div class="box-item">
    <p class="txt-item">'.date("Y-m-d ",$v["estTime"]).'&nbsp;&nbsp;&nbsp;小目标达成
        <span class="pull-right">'.$v["amount"].'&nbsp;<i class="glyphicon glyphicon-circle-arrow-down clr-wc-green"></i> </span>
    </p>
    <hr></div>';
        }else{
            $html .= '<div class="box-item">
    <p class="txt-item">'.date("Y-m-d ",$v["estTime"]).'&nbsp;&nbsp;&nbsp;'.$v["nick"].'小目标未达成退款
        <span class="pull-right">'.$v["amount"].'&nbsp;<i class="glyphicon glyphicon-circle-arrow-down clr-wc-green"></i> </span>
    </p></div>';
        }

    }
    ajaxReturn($html,count($list),1);
}

public function getList($limit='0,20'){
    $where["a.userID"] = Session::get("userInfo.userID");
    $field = "a.amount,a.type,a.estTime,a.status,u.nick";
    return db("user_account")->alias("a")->field($field)->limit($limit)->join("target_info t","a.typeID = t.targetID","left")->join("user_info u","t.userID = u.userID","left")->where($where)->where("a.status != 1")->order("a.estTime desc")->select();
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值