File tree Expand file tree Collapse file tree 5 files changed +117
-17
lines changed Expand file tree Collapse file tree 5 files changed +117
-17
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,7 @@ Page({
127127 if ( res ) {
128128 // 页面onShow时,更新主题部分信息
129129 if ( bIsOnShow ) {
130+ // TODO: 增量更新评论列表数据
130131 this . setData ( {
131132 'oTopicDetail.tab' : res . top ? 'top' : res . good ? 'good' : res . tab ,
132133 'oTopicDetail.visit_count' : res . visit_count ,
Original file line number Diff line number Diff line change 11Page ( {
22 data : {
3- sUserName : ''
3+ bIsReady : false , // 页面是否准备就绪
4+ aTabBar : [
5+ {
6+ active : true ,
7+ text : '最近回复'
8+ } ,
9+ {
10+ text : '最新发布'
11+ } ,
12+ {
13+ text : '话题收藏'
14+ }
15+ ] ,
16+ oUserProfile : { }
417 } ,
518 onLoad ( options ) {
619 if ( options . name ) {
720 this . fnGetUserProfile ( options . name ) ;
8- this . setData ( {
9- sUserName : options . name
10- } ) ;
1121 }
1222 } ,
1323 // 获取用户资料
1424 fnGetUserProfile ( sUserName ) {
25+ // 显示标题栏加载效果
26+ wx . showNavigationBarLoading ( ) ;
1527 wx . dc . user
16- . detail ( {
17- urlData : {
18- loginname : sUserName
19- }
20- } )
28+ . detail (
29+ {
30+ urlData : {
31+ loginname : sUserName
32+ }
33+ } ,
34+ this . fnUserProfileDataModel
35+ )
2136 . then ( res => {
22- console . log ( res ) ;
37+ this . setData ( {
38+ bIsReady : true ,
39+ oUserProfile : res
40+ } ) ;
41+ // 停止加载效果
42+ wx . hideNavigationBarLoading ( ) ;
2343 } )
2444 . catch ( err => {
25- console . log ( err ) ;
45+ this . setData ( {
46+ bIsReady : true
47+ } ) ;
48+ // 停止加载效果
49+ wx . hideNavigationBarLoading ( ) ;
2650 } ) ;
51+ } ,
52+ fnUserProfileDataModel ( oData ) {
53+ let oResult = {
54+ ...oData ,
55+ create_at : wx . moment ( oData . create_at ) . format ( 'YYYY-MM-DD HH:mm:ss' )
56+ } ;
57+ if ( ! Array . isArray ( oResult . recent_replies ) ) {
58+ oResult . recent_replies = [ ] ;
59+ }
60+ if ( ! Array . isArray ( oResult . recent_topics ) ) {
61+ oResult . recent_topics = [ ] ;
62+ }
63+ oResult . recent_replies = oResult . recent_replies . map ( oItem => {
64+ return {
65+ ...oItem ,
66+ last_reply_at : wx . moment ( oItem . last_reply_at ) . fromNow ( )
67+ } ;
68+ } ) ;
69+ oResult . recent_topics = oResult . recent_topics . map ( oItem => {
70+ return {
71+ ...oItem ,
72+ last_reply_at : wx . moment ( oItem . last_reply_at ) . fromNow ( )
73+ } ;
74+ } ) ;
75+ return oResult ;
2776 }
2877} ) ;
Original file line number Diff line number Diff line change 1- <!-- TODO: 完善页面结构与样式 -->
2- <view class="ta-c">敬请期待</view>
1+ <view class="fadein-init {{bIsReady ? 'fadein' : ''}}">
2+ <!-- 用户资料 -->
3+ <view class="user-profile-wrap ta-c">
4+ <image class="user-avatrl mlr-auto rounded-p50" src="{{oUserProfile.avatar_url}}"></image>
5+ <view class="user-name color-white">{{oUserProfile.loginname}}</view>
6+ <view class="user-github-link">{{oUserProfile.githubUsername}}@github.com</view>
7+ <view class="clf" style="font-size: 24rpx;">
8+ <view class="fl-left color-white">注册时间:{{oUserProfile.create_at}}</view>
9+ <view class="fl-right color-green">积分:{{oUserProfile.score}}</view>
10+ </view>
11+ </view>
12+ <!-- 用户动态 -->
13+ <view class="user-activity-wrap">
14+ <!-- tabbar -->
15+ <view class="tabbar-wrap ta-c">
16+ <view class="tab {{item.active ? 'tab-active color-white' : 'color-grey'}}" wx:for="{{aTabBar}}" wx:key="{{index}}">
17+ <view>{{item.text}}</view>
18+ </view>
19+ </view>
20+ <!-- TODO: tab对应的列表 -->
21+ </view>
22+ </view>
Original file line number Diff line number Diff line change 1+ .user-profile-wrap {
2+ padding: 40rpx 30rpx 20rpx 30rpx;
3+ background: #333;
4+ box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
5+ }
6+ .user-avatrl {
7+ display: block;
8+ width: 200rpx;
9+ height: 200rpx;
10+ }
11+ .user-name {
12+ margin-top: 10rpx;
13+ margin-bottom: 10rpx;
14+ }
15+ .user-github-link {
16+ margin-bottom: 60rpx;
17+ font-size: 28rpx;
18+ color: #A2A099;
19+ text-decoration: underline;
20+ }
21+ /* 用户动态 */
22+ .tabbar-wrap {
23+ display: flex;
24+ background: #2e3331;
25+ }
26+ .tabbar-wrap .tab {
27+ flex: 1;
28+ height: 100rpx;
29+ line-height: 100rpx;
30+ font-size: 28rpx;
31+ }
32+ .tabbar-wrap .tab.tab-active {
33+ border-bottom: 6rpx solid #80bd01;
34+ }
Original file line number Diff line number Diff line change 8080/* 谈入谈出 */
8181.fadein-init {
8282 opacity: 0;
83- -webkit-transition: opacity 0.2s ease-in;
84- -moz-transition: opacity 0.2s ease-in;
85- -ms-transition: opacity 0.2s ease-in;
86- -o-transition: opacity 0.2s ease-in;
8783 transition: opacity 0.2s ease-in;
8884}
8985.fadein {
You can’t perform that action at this time.
0 commit comments