Skip to content

Commit 4256501

Browse files
committed
update: add recent reply list in the user profile
1 parent bf9aa14 commit 4256501

File tree

4 files changed

+86
-3
lines changed

4 files changed

+86
-3
lines changed

src/pages/user/user.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Page({
22
data: {
33
bIsReady: false, // 页面是否准备就绪
4+
nActiveTabIndex: 0,
45
aTabBar: [
56
{
67
active: true,
@@ -20,6 +21,13 @@ Page({
2021
this.fnGetUserProfile(options.name);
2122
}
2223
},
24+
// 点击切换tab
25+
fnClickSwitchTab(e) {
26+
let oDataSet = e.currentTarget.dataset;
27+
this.setData({
28+
nActiveTabIndex: oDataSet.index
29+
});
30+
},
2331
// 获取用户资料
2432
fnGetUserProfile(sUserName) {
2533
// 显示标题栏加载效果

src/pages/user/user.wxml

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,43 @@
1313
<view class="user-activity-wrap">
1414
<!-- tabbar -->
1515
<view class="tabbar-wrap ta-c">
16-
<view class="tab {{item.active ? 'tab-active color-white' : 'color-grey'}}" wx:for="{{aTabBar}}" wx:key="{{index}}">
16+
<view
17+
class="tab {{index === nActiveTabIndex ? 'tab-active color-white' : 'color-grey'}}"
18+
wx:for="{{aTabBar}}"
19+
wx:key="{{index}}"
20+
data-index="{{index}}"
21+
bindtap="fnClickSwitchTab"
22+
>
1723
<view>{{item.text}}</view>
1824
</view>
1925
</view>
20-
<!-- TODO: tab对应的列表 -->
26+
<!-- 最近回复列表 -->
27+
<block wx:if="{{nActiveTabIndex === 0}}">
28+
<view class="recent-reply-list" >
29+
<!-- TODO: 点击头像跳转用户资料页,点击文字跳转话题详情 -->
30+
<view class="reply-item" wx:for="{{oUserProfile.recent_replies}}" wx:key="{{index}}">
31+
<image class="reply-left inbl vtal-top rounded-p50" src="{{item.author.avatar_url}}"/>
32+
<view class="reply-right inbl vtal-top">
33+
<view class="reply-topic-title text-ellipsis">{{item.title}}</view>
34+
<view class="clf color-grey">
35+
<view class="fl-left">{{item.author.loginname}}</view>
36+
<view class="fl-right">{{item.last_reply_at}}</view>
37+
</view>
38+
</view>
39+
</view>
40+
</view>
41+
</block>
42+
<!-- TODO: 最新发布列表 -->
43+
<block wx:elif="{{nActiveTabIndex === 1}}">
44+
<view class="recent-topic-list ta-c">
45+
<view>敬请期待</view>
46+
</view>
47+
</block>
48+
<!-- TODO: 话题收藏列表 -->
49+
<block wx:elif="{{nActiveTabIndex === 2}}">
50+
<view class="topic-collection-list ta-c">
51+
<view>敬请期待</view>
52+
</view>
53+
</block>
2154
</view>
2255
</view>

src/pages/user/user.wxss

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,43 @@
2828
height: 100rpx;
2929
line-height: 100rpx;
3030
font-size: 28rpx;
31+
border-bottom: 6rpx solid #2e3331;
32+
box-sizing: border-box;
3133
}
3234
.tabbar-wrap .tab.tab-active {
33-
border-bottom: 6rpx solid #80bd01;
35+
border-color: #80bd01;
36+
}
37+
/* 最近回复列表 */
38+
.recent-reply-list {
39+
padding: 30rpx 20rpx;
40+
}
41+
.reply-item {
42+
padding: 30rpx;
43+
margin-bottom: 10rpx;
44+
/* border-bottom: 0.01rem solid #7c7c7c; */
45+
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
46+
border-radius: 8rpx;
47+
}
48+
.reply-left {
49+
width: 100rpx;
50+
height: 100rpx;
51+
}
52+
.reply-right {
53+
width: 520rpx;
54+
margin-left: 30rpx;
55+
font-size: 28rpx;
56+
}
57+
.reply-topic-title {
58+
margin-bottom: 20rpx;
59+
font-size: 32rpx;
60+
}
61+
/* 最近话题列表 */
62+
.recent-topic-list {
63+
padding: 30rpx 20rpx;
64+
font-size: 28rpx;
65+
}
66+
/* 话题收藏列表 */
67+
.topic-collection-list {
68+
padding: 30rpx 20rpx;
69+
font-size: 28rpx;
3470
}

src/style/base.wxss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@
7777
.color-green {
7878
color: #80bd01;
7979
}
80+
/* 文本溢出隐藏 */
81+
.text-ellipsis {
82+
overflow: hidden;
83+
text-overflow: ellipsis;
84+
white-space: nowrap;
85+
}
8086
/* 谈入谈出 */
8187
.fadein-init {
8288
opacity: 0;

0 commit comments

Comments
 (0)