Skip to content

Commit 0da8f20

Browse files
committed
update: support jump user profile page from each page
1 parent 554bdb0 commit 0da8f20

File tree

7 files changed

+67
-43
lines changed

7 files changed

+67
-43
lines changed

src/components/topic-item/topic-item.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,18 @@ Component({
66
}
77
},
88
data: {},
9-
methods: {}
9+
methods: {
10+
// 点击跳转话题详情
11+
fnTapJumpTopicDetail() {
12+
wx.navigateTo({
13+
url: `/pages/topic/topic?id=${this.data.data.id}`
14+
});
15+
},
16+
// 点击跳转用户个人主页
17+
fnTapJumpUserProfile() {
18+
wx.navigateTo({
19+
url: `/pages/user/user?name=${this.data.data.loginname}`
20+
});
21+
}
22+
}
1023
});
Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
1-
<navigator class="topic-container" url="/pages/topic/topic?id={{data.id}}">
2-
<view class="topic-header">
3-
<view style="margin-bottom: 20rpx;">
4-
<!-- 主题标签 -->
5-
<topic-tag type="{{ data.tab }}"></topic-tag>
6-
<view class="topic-header-right">
7-
<!-- 主题回复数 -->
8-
<text style="color: #8EB63D;">{{ data.reply_count }}</text>
9-
<text style="padding: 0 5rpx;">/</text>
10-
<!-- 主题访问数 -->
11-
<text>{{ data.visit_count }}</text>
12-
<text style="padding: 0 5rpx;">·</text>
13-
<!-- 主题最后一次回复的时间 -->
14-
<text>{{ data.last_reply_at }}</text>
1+
<view class="topic-container">
2+
<view class="topic-main" hover-class="navigator-hover" bindtap="fnTapJumpTopicDetail">
3+
<view class="topic-header">
4+
<view style="margin-bottom: 20rpx;">
5+
<!-- 主题标签 -->
6+
<topic-tag type="{{ data.tab }}"></topic-tag>
7+
<view class="topic-header-right">
8+
<!-- 主题回复数 -->
9+
<text style="color: #8EB63D;">{{ data.reply_count }}</text>
10+
<text style="padding: 0 5rpx;">/</text>
11+
<!-- 主题访问数 -->
12+
<text>{{ data.visit_count }}</text>
13+
<text style="padding: 0 5rpx;">·</text>
14+
<!-- 主题最后一次回复的时间 -->
15+
<text>{{ data.last_reply_at }}</text>
16+
</view>
1517
</view>
18+
<!-- 主题标题 -->
19+
<view class="topic-title">{{ data.title }}</view>
1620
</view>
17-
<!-- 主题标题 -->
18-
<view class="topic-title">{{ data.title }}</view>
21+
<!-- 主题内容 -->
22+
<view class="topic-content">{{ data.content }}</view>
1923
</view>
20-
<!-- 主题内容 -->
21-
<view class="topic-content">{{ data.content }}</view>
2224
<view class="topic-divide"></view>
23-
<view class="topic-footer clear-float">
25+
<view class="topic-footer clear-float" hover-class="navigator-hover" bindtap="fnTapJumpUserProfile">
2426
<view class="topic-footer-left clear-float">
2527
<!-- 主题作者头像 -->
26-
<image class="topic-author-avatar" wx:if="{{ data.avatar_url }}" src="{{ data.avatar_url }}" />
28+
<image class="topic-author-avatar rounded-p50" wx:if="{{ data.avatar_url }}" src="{{ data.avatar_url }}" />
2729
<!-- 主题作者名称 -->
2830
<text class="topic-author-name" wx:if="{{ data.loginname }}">{{ data.loginname }}</text>
2931
</view>
@@ -33,4 +35,4 @@
3335
<text>{{ data.create_at }}</text>
3436
</view>
3537
</view>
36-
</navigator>
38+
</view>

src/components/topic-item/topic-item.wxss

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
@import '/style/base.wxss';
2+
13
.topic-container {
2-
padding: 25rpx;
3-
background: #ffffff;
44
margin-bottom: 20rpx;
55
box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);
66
border-radius: 8rpx;
77
}
8+
/* 主要内容 */
9+
.topic-container .topic-main {
10+
padding: 25rpx 25rpx 20rpx 25rpx;
11+
}
812
/* 头部 */
913
.topic-container .topic-header {
1014
font-size: 24rpx;
@@ -26,13 +30,14 @@
2630
/* 分隔线 */
2731
.topic-container .topic-divide {
2832
height: 1px;
29-
margin: 20rpx 0;
33+
margin: 0 25rpx;
3034
background: #E3E3E3;
3135
}
3236
/* 主题底部 */
3337
.topic-container .topic-footer {
34-
font-size: 24rpx;
3538
height: 60rpx;
39+
padding: 20rpx 25rpx 25rpx 25rpx;
40+
font-size: 24rpx;
3641
}
3742
.topic-container .topic-footer .topic-footer-left {
3843
float: left;
@@ -41,7 +46,6 @@
4146
float: left;
4247
width: 60rpx;
4348
height: 60rpx;
44-
border-radius: 50%;
4549
}
4650
.topic-container .topic-footer .topic-footer-left .topic-author-name {
4751
display:inline-block;

src/pages/message/components/message-item.wxml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<view class="message-item">
22
<!-- 消息头部 -->
33
<view class="message-header vh-parent clf ">
4-
<view class="message-header-avatar fl-left">
4+
<navigator class="message-header-avatar fl-left rounded-p50" url="/pages/user/user?name={{data.author.loginname}}">
55
<image class="w-p100 h-p100 rounded-p50" src="{{data.author.avatar_url}}" />
6-
</view>
6+
</navigator>
77
<view
88
class="message-header-content v w-p100"
99
hover-class="message-header-content-hover"

src/pages/mine/mine.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ Page({
2424
onShow() {
2525
this.fnInitPageData();
2626
},
27+
// 点击跳转登录或者用户个人主页
28+
fnTapJumpLoginOrUserProfile() {
29+
if (this.data.bIsLogin) {
30+
wx.navigateTo({
31+
url: `/pages/user/user?name=${this.data.oUserInfo.loginname}`
32+
});
33+
} else {
34+
wx.navigateTo({
35+
url: `/pages/login/login`
36+
});
37+
}
38+
},
2739
// 注销登录
2840
fnTapLogout() {
2941
wx.showModal({

src/pages/mine/mine.wxml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
<view class="fadein-init {{bIsReady ? 'fadein': ''}}">
22
<!-- 用户基本信息 -->
33
<view class="user-info-container ta-c">
4-
<block wx:if="{{!bIsLogin}}">
5-
<navigator class="user-avatar-wrap mlr-auto" url="/pages/login/login" hover-class="none">
6-
<image class="user-avatar" src="{{oUserInfo.avatar_url}}" />
7-
</navigator>
8-
</block>
9-
<block wx:else>
10-
<view class="user-avatar-wrap mlr-auto">
11-
<image class="user-avatar" src="{{oUserInfo.avatar_url}}" />
12-
</view>
13-
</block>
4+
<view class="user-avatar-wrap mlr-auto" hover-class="navigator-hover" bindtap="fnTapJumpLoginOrUserProfile">
5+
<image class="user-avatar" src="{{oUserInfo.avatar_url}}" />
6+
</view>
147
<view>
158
<view style="color: #707070;">{{oUserInfo.loginname}}</view>
169
</view>

src/pages/topic/topic.wxml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
<h3 class="fw-500">{{oTopicDetail.title}}</h3>
55
<!-- 基本信息 -->
66
<view class="topic-info vh-parent">
7-
<view class="topic-info-left fl-left">
7+
<navigator class="topic-info-left fl-left rounded-p50" url="/pages/user/user?name={{oTopicDetail.loginname}}">
88
<image class="w-p100 h-p100 rounded-p50" src="{{oTopicDetail.avatar_url}}" />
9-
</view>
9+
</navigator>
1010
<view class="topic-info-center">
1111
<view style="margin-bottom: 15rpx;">
1212
<topic-tag type="{{oTopicDetail.tab}}" style="margin-right: 15rpx;"></topic-tag>
@@ -35,9 +35,9 @@
3535
<view class="topic-comment-item" wx:for="{{oTopicDetail.replies}}" wx:key="{{index}}">
3636
<view class="vh-parent clf">
3737
<!-- 评论者信息 -->
38-
<view class="topic-comment-left fl-left">
38+
<navigator class="topic-comment-left fl-left rounded-p50" url="/pages/user/user?name={{item.loginname}}">
3939
<image class="w-p100 h-p100 rounded-p50" src="{{item.avatar_url}}" />
40-
</view>
40+
</navigator>
4141
<view class="topic-comment-center">
4242
<view style="margin-bottom: 15rpx;">{{item.loginname}}</view>
4343
<view class="color-grey" style="font-size: 28rpx;">

0 commit comments

Comments
 (0)