Skip to content

Commit b273141

Browse files
committed
update: optimize the page jump of the user profile page
1 parent 230d324 commit b273141

File tree

4 files changed

+48
-11
lines changed

4 files changed

+48
-11
lines changed
Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,38 @@
11
Component({
22
properties: {
3+
name: {
4+
type: String,
5+
value: ''
6+
},
37
list: {
48
type: Array,
59
value: []
610
}
711
},
8-
data: {},
9-
methods: {}
12+
methods: {
13+
// 点击用户头像
14+
fnTapAuthorAvatar(e) {
15+
let oDataSet = e.currentTarget.dataset;
16+
// 判断是否已经处于该用户的个人主页
17+
if (oDataSet.loginname === this.data.name) {
18+
// 终止执行,并留下一句话
19+
return wx.showToast({
20+
icon: 'none',
21+
title: '你一直都在,从未曾离开'
22+
});
23+
}
24+
// 跳转用户详情
25+
wx.navigateTo({
26+
url: `/pages/user/user?name=${oDataSet.loginname}`
27+
});
28+
},
29+
// 点击话题卡片
30+
fnTapTopicItem(e) {
31+
let oDataSet = e.currentTarget.dataset;
32+
// 跳转话题详情
33+
wx.navigateTo({
34+
url: `/pages/topic/topic?id=${oDataSet.id}`
35+
});
36+
}
37+
}
1038
});
Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
11
<view class="topic-list">
2-
<navigator
2+
<view
33
class="topic-item"
44
wx:for="{{list}}"
55
wx:key="{{index}}"
6-
url="/pages/topic/topic?id={{item.id}}"
6+
data-id="{{item.id}}"
7+
hover-class="navigator-hover"
8+
bindtap="fnTapTopicItem"
79
>
8-
<navigator class="topic-left inbl vtal-top rounded-p50" url="/pages/user/user?name={{item.author.loginname}}" hover-stop-propagation="{{true}}">
10+
<view
11+
class="topic-left inbl vtal-top rounded-p50"
12+
data-loginname="{{item.author.loginname}}"
13+
hover-class="navigator-hover"
14+
hover-stop-propagation="{{true}}"
15+
catchtap="fnTapAuthorAvatar"
16+
>
917
<image class="w-p100 h-p100 rounded-p50" src="{{item.author.avatar_url}}"/>
10-
</navigator>
18+
</view>
1119
<view class="topic-right inbl vtal-top">
1220
<view class="topic-title text-ellipsis">{{item.title}}</view>
1321
<view class="clf color-grey">
1422
<view class="fl-left">{{item.author.loginname}}</view>
1523
<view class="fl-right">{{item.last_reply_at}}</view>
1624
</view>
1725
</view>
18-
</navigator>
26+
</view>
1927
</view>

src/pages/user/user.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"usingComponents": {
33
"topic-list": "./components/topic-list/topic-list"
4-
}
4+
},
5+
"navigationBarTitleText": "个人主页"
56
}

src/pages/user/user.wxml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@
2626
<view class="topic-list-wrap">
2727
<!-- 最近回复列表 -->
2828
<block wx:if="{{nActiveTabIndex === 0}}">
29-
<topic-list list="{{oUserProfile.recent_replies}}"></topic-list>
29+
<topic-list list="{{oUserProfile.recent_replies}}" name="{{oUserProfile.loginname}}"></topic-list>
3030
</block>
3131
<!-- 最新发布话题列表 -->
3232
<block wx:elif="{{nActiveTabIndex === 1}}">
33-
<topic-list list="{{oUserProfile.recent_topics}}"></topic-list>
33+
<topic-list list="{{oUserProfile.recent_topics}}" name="{{oUserProfile.loginname}}"></topic-list>
3434
</block>
3535
<!-- 话题收藏列表 -->
3636
<block wx:elif="{{nActiveTabIndex === 2}}">
37-
<topic-list wx:if="{{!bIsFetchingUserCollectTopicList}}" list="{{aUserCollectTopicList}}"></topic-list>
37+
<topic-list wx:if="{{!bIsFetchingUserCollectTopicList}}" list="{{aUserCollectTopicList}}" name="{{oUserProfile.loginname}}"></topic-list>
3838
<view wx:else class="topic-collection-list ta-c">
3939
<view>正在加载...</view>
4040
</view>

0 commit comments

Comments
 (0)