Skip to content

Commit 846f785

Browse files
committed
优化首页文章列表循环函数
1 parent 480e287 commit 846f785

1 file changed

Lines changed: 13 additions & 111 deletions

File tree

templates/common-list.wxml

Lines changed: 13 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<view class="common-list">
44
<block wx:key="id" wx:for="{{postsList}}">
55
<!-- 开始判断列表内容的第3列,样式重新排列 //大图模式 -->
6-
<view wx:if="{{index%10==2}}">
6+
<view wx:if="{{index%10==0 || index%10==4 || index%10==8 || index%10==12 || index%10==16 || index%10==20 || index%10==24 || index%10==28}}">
77
<view class="list-item has-img w-100" index="{{index}}" id="{{item.id}}" bindtap="redictDetail">
88
<view class="content-title content-title-100">
99
<vpush-view>
@@ -12,7 +12,9 @@
1212
</view>
1313

1414
<view class="content-title content-title-100" style='margin-top:0;margin-bottom:0'>
15-
<vpush-view><text style='font-size:26rpx;color:#959595;margin:32rpx auto;'>{{item.excerpt.rendered}}</text></vpush-view>
15+
<vpush-view>
16+
<text style='font-size:26rpx;color:#959595;margin:10rpx auto;'>{{item.excerpt.rendered}}</text>
17+
</vpush-view>
1618
</view>
1719

1820
<view class="content-date" style='margin-right:0;'>
@@ -38,7 +40,7 @@
3840
</view>
3941
</view>
4042
<!-- 开始判断列表内容的第4列,样式重新排列 // 双图模式 -->
41-
<view wx:elif="{{index%10==3}}">
43+
<view wx:elif="{{index%10==5 || index%10==5 || index%10==13 || index%10==17 || index%10==21 || index%10==25 || index%10==29}}">
4244
<view class="list-item has-img w-100" index="{{index}}" id="{{item.id}}" bindtap="redictDetail">
4345
<view class="content-title content-title-100" style="margin-top:180px;">
4446
<vpush-view>
@@ -47,52 +49,11 @@
4749
</view>
4850

4951
<view class="content-title content-title-100" style='margin-top:0;margin-bottom:0'>
50-
<vpush-view><text style='font-size:26rpx;color:#959595;margin:32rpx auto;'>{{item.excerpt.rendered}}</text></vpush-view>
51-
</view>
52-
53-
<view class="content-date" style='margin-right:0;'>
54-
<block wx:if="{{item.category_name !=null}}">
55-
<text>{{item.category_name}}</text>
56-
</block>
57-
58-
<!--image src="../../images/calendar.png"></image>
59-
<text>{{item.date}}</text-->
60-
61-
<image src="../../images/pageviews.png"></image>
62-
<text class="">{{item.pageviews}}</text>
63-
64-
<image src="../../images/comments.png"></image>
65-
<text class="">{{item.total_comments}}</text>
66-
67-
<image src="../../images/home-like.png"></image>
68-
<text class="">{{item.like_count}}</text>
69-
70-
</view>
71-
72-
<!-- 调取文章首图、特色图,进行重新排版 -->
73-
<view wx:if="{{item.content_first_image}}">
74-
<image src="{{item.post_thumbnail_image}}" mode="aspectFill" class="cover cover-100" style='width:50%;height:165px;margin-right:50%'></image>
75-
<image src="{{item.content_first_image}}" mode="aspectFill" class="cover cover-100" style='width:48%;height:165px;'></image>
76-
</view>
77-
<view wx:else>
78-
<image src="{{item.post_thumbnail_image}}" mode="aspectFill" class="cover cover-100"></image>
79-
</view>
80-
81-
</view>
82-
</view>
83-
<!-- 开始判断列表内容的第9列,样式重新排列 // 大图模式-->
84-
<view wx:elif="{{index%10==8}}">
85-
<view class="list-item has-img w-100" index="{{index}}" id="{{item.id}}" bindtap="redictDetail">
86-
<view class="content-title content-title-100">
8752
<vpush-view>
88-
<text>{{item.title.rendered}}</text>
53+
<text style='font-size:26rpx;color:#959595;margin:10rpx auto;'>{{item.excerpt.rendered}}</text>
8954
</vpush-view>
9055
</view>
9156

92-
<view class="content-title content-title-100" style='margin-top:0;margin-bottom:0'>
93-
<vpush-view><text style='font-size:26rpx;color:#959595;margin:32rpx auto;'>{{item.excerpt.rendered}}</text></vpush-view>
94-
</view>
95-
9657
<view class="content-date" style='margin-right:0;'>
9758
<block wx:if="{{item.category_name !=null}}">
9859
<text>{{item.category_name}}</text>
@@ -110,71 +71,6 @@
11071
<image src="../../images/home-like.png"></image>
11172
<text class="">{{item.like_count}}</text>
11273

113-
</view>
114-
<image src="{{item.post_thumbnail_image}}" mode="aspectFill" class="cover cover-100"></image>
115-
</view>
116-
</view>
117-
<!-- 开始判断列表内容的第12列,样式重新排列 // 大图模式-->
118-
<view wx:elif="{{index%10==11}}">
119-
<view class="list-item has-img w-100" index="{{index}}" id="{{item.id}}" bindtap="redictDetail">
120-
<view class="content-title content-title-100">
121-
<vpush-view>
122-
<text>{{item.title.rendered}}</text>
123-
</vpush-view>
124-
</view>
125-
126-
<view class="content-title content-title-100" style='margin-top:0;margin-bottom:0'>
127-
<vpush-view><text style='font-size:26rpx;color:#959595;margin:32rpx auto;'>{{item.excerpt.rendered}}</text></vpush-view>
128-
</view>
129-
130-
<view class="content-date" style='margin-right:0;'>
131-
<block wx:if="{{item.category_name !=null}}">
132-
<text>{{item.category_name}}</text>
133-
</block>
134-
135-
<!--image src="../../images/calendar.png"></image>
136-
<text>{{item.date}}</text-->
137-
138-
<image src="../../images/pageviews.png"></image>
139-
<text class="">{{item.pageviews}}</text>
140-
141-
<image src="../../images/comments.png"></image>
142-
<text class="">{{item.total_comments}}</text>
143-
144-
<image src="../../images/home-like.png"></image>
145-
<text class="">{{item.like_count}}</text>
146-
147-
</view>
148-
<image src="{{item.post_thumbnail_image}}" mode="aspectFill" class="cover cover-100"></image>
149-
</view>
150-
</view>
151-
<!-- 开始判断列表内容的第17列,样式重新排列 // 双图模式 -->
152-
<view wx:elif="{{index%10==16}}">
153-
<view class="list-item has-img w-100" index="{{index}}" id="{{item.id}}" bindtap="redictDetail">
154-
<view class="content-title content-title-100" style="margin-top:180px;">
155-
<vpush-view>
156-
<text>{{item.title.rendered}}</text>
157-
</vpush-view>
158-
</view>
159-
160-
<view class="content-title content-title-100" style='margin-top:0;margin-bottom:0'>
161-
<vpush-view><text style='font-size:26rpx;color:#959595;margin:32rpx auto;'>{{item.excerpt.rendered}}</text></vpush-view>
162-
</view>
163-
164-
<view class="content-date" style='margin-right:0;'>
165-
<block wx:if="{{item.category_name !=null}}">
166-
<text>{{item.category_name}}</text>
167-
</block>
168-
169-
<image src="../../images/pageviews.png"></image>
170-
<text class="">{{item.pageviews}}</text>
171-
172-
<image src="../../images/comments.png"></image>
173-
<text class="">{{item.total_comments}}</text>
174-
175-
<image src="../../images/home-like.png"></image>
176-
<text class="">{{item.like_count}}</text>
177-
17874
</view>
17975

18076
<!-- 调取文章首图、特色图,进行重新排版 -->
@@ -191,12 +87,18 @@
19187
<!-- 除去满足以上条件以外的列表内容,默认排列 // 右图模式 -->
19288
<view wx:else>
19389
<view class="list-item has-img" index="{{index}}" id="{{item.id}}" bindtap="redictDetail">
194-
<view class="content-title">
90+
<view class="content-title" style='margin-bottom:10rpx;'>
19591
<vpush-view>
19692
<text>{{item.title.rendered}}</text>
19793
</vpush-view>
19894
</view>
19995

96+
<view class="content-title" style='margin-top:0;margin-bottom:10rpx;'>
97+
<vpush-view>
98+
<text style='font-size:26rpx;color:#959595;margin:10rpx auto;-webkit-line-clamp:1;'>{{item.excerpt.rendered}}</text>
99+
</vpush-view>
100+
</view>
101+
200102
<view class="content-date">
201103
<block wx:if="{{item.category_name !=null}}">
202104
<text>{{item.category_name}}</text>

0 commit comments

Comments
 (0)