This repository has been archived by the owner on Nov 23, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
tag.php
166 lines (119 loc) · 8.57 KB
/
tag.php
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<?php get_header(); ?>
<?php
$tag = get_the_tags();
$id = $tag[0]->term_id;
?>
<div id="header_info">
<nav class="header-nav reveal">
<a class="top1 header-logo" style="text-decoration:none;" href="https://www.ouorz.com">XXXXX</a>
<p class="top2 lead" style="margin-top: 0px;display:block">XXXXXXXXXXXXXXXXXXXXXXXXXXX</p>
<div class="btn-group" style="float: right;margin-top: -80px;">
<button type="button" class="btn btn-primary"><a href="https://www.ouorz.com/" style="text-decoration:none;color:white"><i class="czs-hand-slide" style="margin-right:5px" ></i>回到首页</a></button>
</div>
</nav>
<div class="index-cates">
<li class="cat-item cat-item-4 cat-real" style="display:none" v-for="de in des" v-if="de.count !== 0"> <a :href="de.link" :title="de.description">{{ de.name }}</a>
</li>
<li class="cat-item cat-item-4" style="display: inline-block;width: 98%;height: 35px;box-shadow: none;border-radius: 0px;background: rgb(236, 237, 239);" v-if="loading_des"></li>
</div>
</div>
<ul class="article-list" style="opacity:0">
<!-- 占位DIV -->
<!-- <li v-if="loading" uk-scrollspy="cls:uk-animation-slide-left-small" class="article-list-item reveal index-post-list uk-scrollspy-inview" style="padding: 50px 30px !important;"><div style="float: left;margin-right: 40px;margin-top: -10px;background: #eee;height: 100px;width: 100px;border-radius: 8px;"></div> <a href="https://www.zeo.im" style="text-decoration: none;"><h5 style="margin-top: 10px;background: #eee;height: 30px;width: 72%;float: right;"></h5></a> <p style="height: 20px;background: #eee;width: 72%;margin: 0px;float: right;"></p> <div class="article-list-footer"> <span class="article-list-minutes"> </span><span class="article-list-minutes"> </span><span class="article-list-minutes"> </span><span class="article-list-minutes"> </span><span class="article-list-minutes"> </span></div></li> -->
<li v-if="loading" uk-scrollspy="cls:uk-animation-slide-left-small" class="article-list-item reveal index-post-list uk-scrollspy-inview"><em class="article-list-type1" style="padding: 5.5px 45px;"> </em> <a style="text-decoration: none;"><h5 style="background: rgb(236, 237, 238);"> </h5></a><p style="background: rgb(246, 247, 248);width: 90%;"> </p><p style="background: rgb(246, 247, 248);width: 60%;"> </p>
</li>
<!-- 占位DIV -->
<li class="article-list-item reveal index-post-list" uk-scrollspy="cls:uk-animation-slide-left-small" v-for="post in posts">
<em v-if="post.post_categories[0].term_id === 7" class="article-list-type1">{{ post.post_categories[0].name }}</em>
<div v-if="post.post_categories[0].term_id === 2 || post.post_categories[0].term_id === 5" style="float: left;margin-right: 40px;"><img :src="post.post_metas.img[0]" style="width: 110px;height: 110px;border-radius: 8px;margin: 8px 0;"></div>
<a v-if="post.post_categories[0].term_id === 2 || post.post_categories[0].term_id === 5" :href="post.post_metas.link" style="text-decoration: none;"><h5 style="margin-top: 10px;" v-html="post.title.rendered"></h5></a>
<a v-else :href="post.link" style="text-decoration: none;"><h5 v-html="post.title.rendered"></h5></a>
<p v-html="post.post_excerpt"></p>
<div class="article-list-footer">
<span class="article-list-date" style="color: #ada8a8;">{{ post.post_date }}</span>
<span class="article-list-divider">-</span>
<span class="article-list-minutes">{{ post.post_metas.views }} Views</span>
</div>
</li>
<!-- 加载占位DIV -->
<!-- <li uk-scrollspy="cls:uk-animation-slide-left-small" class="article-list-item reveal index-post-list uk-scrollspy-inview bottom" style="padding: 50px 30px !important;"><div style="float: left;margin-right: 40px;margin-top: -10px;background: #eee;height: 100px;width: 100px;border-radius: 8px;"></div> <a href="https://www.zeo.im" style="text-decoration: none;"><h5 style="margin-top: 10px;background: #eee;height: 30px;width: 72%;float: right;"></h5></a> <p style="height: 20px;background: #eee;width: 72%;margin: 0px;float: right;"></p> <div class="article-list-footer"> <span class="article-list-minutes"> </span><span class="article-list-minutes"> </span><span class="article-list-minutes"> </span><span class="article-list-minutes"> </span><span class="article-list-minutes"> </span></div></li> -->
<li uk-scrollspy="cls:uk-animation-slide-left-small" class="article-list-item reveal index-post-list uk-scrollspy-inview bottom"><em class="article-list-type1" style="padding: 5.5px 45px;"> </em> <a style="text-decoration: none;"><h5 style="background: rgb(236, 237, 238);"> </h5></a><p style="background: rgb(246, 247, 248);width: 90%;"> </p><p style="background: rgb(246, 247, 248);width: 60%;"> </p>
</li>
<!-- 加载占位DIV -->
<!-- 加载按钮 -->
<button @click="new_page" id="scoll_new_list" style="opacity:0"></button>
<!-- 加载按钮 -->
</ul>
<script>
window.onload = function(){ //避免爆代码
var click = 0; //初始化加载次数
var paged = 1; //获取当前页数
var incate = <?php echo $id; ?>;
/* 展现内容(避免爆代码) */
$('.article-list').css('opacity','1');
$('.top1').html('<?php echo $tag[0]->name; ?>');
$('.top2').html('标签文章数 : <?php echo get_tag_post_count_by_id($tag[0]->term_id); ?>');
$('.cat-real').attr('style','display:inline-block');
/* 展现内容(避免爆代码) */
new Vue({ //axios获取顶部信息
el : '#grid-cell',
data() {
return {
posts: null,
cates: null,
des: null,
loading: true, //v-if判断显示占位符
loading_des: true,
errored: true
}
},
mounted () {
//获取分类
axios.get('https://www.ouorz.com/wp-json/wp/v2/categories?exclude=1')
.then(response => {
this.des = response.data;
}).finally(() => {
this.loading_des = false;
});
//获取文章列表
axios.get('https://www.ouorz.com/wp-json/wp/v2/posts?per_page=10&page='+paged+'&tags='+incate)
.then(response => {
this.posts = response.data
})
.catch(e => {
this.errored = false
})
.finally(() => {
this.loading = false;
paged++; //加载完1页后累加页数
//加载完文章列表后监听滑动事件
$(window).scroll(function(){
var scrollTop = $(window).scrollTop();
var scrollHeight = $('.bottom').offset().top - 500;
if(scrollTop >= scrollHeight){
if(click == 0){ //接近底部加载一次新文章
$('#scoll_new_list').click();
click++; //加载次数计次
}
}
});
})
},
methods: { //定义方法
new_page : function(){ //加载下一页文章列表
axios.get('https://www.ouorz.com/wp-json/wp/v2/posts?per_page=10&page='+paged+'&tags='+incate)
.then(response => {
if(response.data.length !== 0){ //判断是否最后一页
this.posts.push.apply(this.posts,response.data); //拼接在上一页之后
click = 0;
paged++;
}else{
$('.bottom h5').html('暂无更多文章了 O__O "…').css({'background':'#fff','color':'#999'});
}
})
}
},
});
}
</script>
<?php get_footer(); ?>