index.html
4.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
{extend name="layout/default"}
{block name="content"}
<div class="main">
<div class="list_nav">
{foreach $left as $le}
<div class="list_navLi">
<a href="/api/huiyuan/index?pid={$le.id}">
<p class="{$pid==$le['id']?'list_active':''} list_navTxt">{$le.title}</p>
</a>
</div>
{/foreach}
</div>
<!-- 列表 -->
<div class="list_item">
<ul>
{foreach($list as $l) }
<li id="huiyuan_List2">
<div class="list_Img"><img src="{$l.image}" alt=""></div>
<div class="list_Box">
<div class="list_Txt txt-cut">{$l.title}</div>
<div class="list_Box2">
<p class="list_Txt2 ">{$l.createtime}</p>
<a class="list_Txt3" href="/api/huiyuan/detail?id={$l.id}">[详情]</a>
</div>
</div>
</li>
{/foreach}
</ul>
</div>
</div>
<script>
$('.list_navLi').click(function() {
$(".list_navdown").show();
$(this).find('.list_navTxt').addClass('list_active').parents('.list_navLi').siblings().find('.list_navTxt').removeClass('list_active');
});
//上拉加载
var page = 2;
var data_status = true;
var pid="{$pid}";
$('.list_navLi').click(function() {
$(".list_navdown").show();
$(this).find('.list_navTxt').addClass('list_active').parents('.list_navLi').siblings().find('.list_navTxt').removeClass('list_active');
});
function ajax2(data) {
ajax("/api/huiyuan/index",data,"post",function (res) {
var html="";
if(page==res.msg.last_page){
data_status=false;
}else{
data_status=true;
}
var msg=res.msg.data;
var num=msg.length;
for(var i=0;i<num;i++) {
var res = msg[i];
var image="";
if(res['image']!=""){
image=res['image'];
}
var title="";
if(res['title']!=""){
title=res['title'];
}
var createtime="";
if(res['createtime']!=""){
createtime=res['createtime'];
}
html+='<li>'+
' <div class="list_Img"><img src='+image+' alt=""></div>'+
' <div class="list_Box">'+
'<div class="list_Txt txt-cut">'+title+'</div>'+
' <div class="list_Box2">'+
' <p class="list_Txt2 ">'+createtime+'</p>'+
' <a class="list_Txt3" href="/api/huiyuan/detail?id='+res['id']+'">[详情]</a>'+
' </div>'+
' </div>'+
' </li>';
}
$("#huiyuan_List2").append(html);
},"false");
}
function get_data(page) {
var data = {
page: page,
pid:pid
};
ajax2(data);
};
get_data(page)
//滚动事件触发
window.onscroll = function(ev) {
if (getScrollTop() + getClientHeight() >= getScrollHeight() && data_status) {
// 后台数据调用
if (data_status === true) {
++page;
get_data(page);
}
} else if (getScrollTop() + getClientHeight() >= getScrollHeight() && !data_status) {
w("无更多数据")
}
};
</script>
{/block}