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"]).' 赞助'.$v["nick"].'
<span class="pull-right">'.$v["amount"].' <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"]).' 提现-扣除5%手续费(提现中)
<span class="pull-right">'.$v["amount"].' <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"]).' 提现-扣除5%手续费(已提现)
<span class="pull-right">'.$v["amount"].' <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"]).' 小目标达成
<span class="pull-right">'.$v["amount"].' <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"]).' '.$v["nick"].'小目标未达成退款
<span class="pull-right">'.$v["amount"].' <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();
}