11Page ( {
22 data : {
33 bIsReady : false , // 页面是否准备就绪
4+ bIsFetchingUserCollectTopicList : false , // 是否正在获取用户收藏话题列表
45 nActiveTabIndex : 0 ,
56 aTabBar : [
67 {
@@ -14,11 +15,13 @@ Page({
1415 text : '话题收藏'
1516 }
1617 ] ,
18+ aUserCollectTopicList : [ ] , // 用户收藏话题列表
1719 oUserProfile : { }
1820 } ,
1921 onLoad ( options ) {
2022 if ( options . name ) {
2123 this . fnGetUserProfile ( options . name ) ;
24+ this . fnGetUserCollectTopicList ( options . name ) ;
2225 }
2326 } ,
2427 // 点击切换tab
@@ -28,6 +31,39 @@ Page({
2831 nActiveTabIndex : oDataSet . index
2932 } ) ;
3033 } ,
34+ // 获取用户收藏话题
35+ fnGetUserCollectTopicList ( sUserName ) {
36+ // 显示标题栏加载效果
37+ wx . showNavigationBarLoading ( ) ;
38+ this . setData ( {
39+ bIsFetchingUserCollectTopicList : true
40+ } ) ;
41+ wx . dc . topicCollect
42+ . list (
43+ {
44+ urlData : {
45+ loginname : sUserName
46+ }
47+ } ,
48+ this . fnUserCollectTopicListDataModel
49+ )
50+ . then ( res => {
51+ // 停止加载效果
52+ this . setData ( {
53+ aUserCollectTopicList : res . aTopicList ,
54+ bIsFetchingUserCollectTopicList : false
55+ } ) ;
56+ wx . hideNavigationBarLoading ( ) ;
57+ } )
58+ . catch ( err => {
59+ console . log ( err ) ;
60+ // 停止加载效果
61+ wx . hideNavigationBarLoading ( ) ;
62+ this . setData ( {
63+ bIsFetchingUserCollectTopicList : false
64+ } ) ;
65+ } ) ;
66+ } ,
3167 // 获取用户资料
3268 fnGetUserProfile ( sUserName ) {
3369 // 显示标题栏加载效果
@@ -57,6 +93,19 @@ Page({
5793 wx . hideNavigationBarLoading ( ) ;
5894 } ) ;
5995 } ,
96+ fnUserCollectTopicListDataModel ( aData ) {
97+ let oResult = { } ;
98+ if ( ! Array . isArray ( aData ) ) {
99+ aData = [ ] ;
100+ }
101+ oResult . aTopicList = aData . map ( oItem => {
102+ return {
103+ ...oItem ,
104+ last_reply_at : wx . moment ( oItem . last_reply_at ) . fromNow ( )
105+ } ;
106+ } ) ;
107+ return oResult ;
108+ } ,
60109 fnUserProfileDataModel ( oData ) {
61110 let oResult = {
62111 ...oData ,
0 commit comments