Showing
1 changed file
with
20 additions
and
16 deletions
| @@ -41,7 +41,7 @@ const TAG = 'OperRowListView'; | @@ -41,7 +41,7 @@ const TAG = 'OperRowListView'; | ||
| 41 | @Preview | 41 | @Preview |
| 42 | @Component | 42 | @Component |
| 43 | export struct OperRowListView { | 43 | export struct OperRowListView { |
| 44 | - @Prop contentDetailData: ContentDetailDTO // 稿件详情 | 44 | + @Prop @Watch('onDetailUpdated') contentDetailData: ContentDetailDTO // 稿件详情 |
| 45 | @State operationButtonList: string[] = ['comment', 'collect', 'share'] // 组件展示条件 | 45 | @State operationButtonList: string[] = ['comment', 'collect', 'share'] // 组件展示条件 |
| 46 | @ObjectLink publishCommentModel: publishCommentModel | 46 | @ObjectLink publishCommentModel: publishCommentModel |
| 47 | // @State contentDetailData: ContentDetailDTO = {} as ContentDetailDTO | 47 | // @State contentDetailData: ContentDetailDTO = {} as ContentDetailDTO |
| @@ -52,7 +52,9 @@ export struct OperRowListView { | @@ -52,7 +52,9 @@ export struct OperRowListView { | ||
| 52 | @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 | 52 | @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 |
| 53 | needLike: boolean = true | 53 | needLike: boolean = true |
| 54 | 54 | ||
| 55 | - async aboutToAppear() { | 55 | + // async aboutToAppear() { |
| 56 | + async onDetailUpdated() { | ||
| 57 | + if (!this.contentDetailData) return | ||
| 56 | const user_id = await SPHelper.default.get(SpConstants.USER_ID, '') | 58 | const user_id = await SPHelper.default.get(SpConstants.USER_ID, '') |
| 57 | if (user_id) { | 59 | if (user_id) { |
| 58 | this.getInteractDataStatus() | 60 | this.getInteractDataStatus() |
| @@ -99,20 +101,22 @@ export struct OperRowListView { | @@ -99,20 +101,22 @@ export struct OperRowListView { | ||
| 99 | }) | 101 | }) |
| 100 | .width(42) | 102 | .width(42) |
| 101 | 103 | ||
| 102 | - ForEach(this.operationButtonList, (item: string, index: number) => { | ||
| 103 | - if (item == 'comment') { | ||
| 104 | - this.builderComment() | ||
| 105 | - } else if (item == 'like' && this.needLike) { | ||
| 106 | - this.builderLike() | ||
| 107 | - } else if (item == 'collect') { | ||
| 108 | - this.builderCollect() | ||
| 109 | - } else if (item == 'listen') { | ||
| 110 | - this.builderListen() | ||
| 111 | - } else if (item == 'share') { | ||
| 112 | - this.builderShare() | ||
| 113 | - } else { | ||
| 114 | - } | ||
| 115 | - }) | 104 | + if (this.contentDetailData) { |
| 105 | + ForEach(this.operationButtonList, (item: string, index: number) => { | ||
| 106 | + if (item == 'comment') { | ||
| 107 | + this.builderComment() | ||
| 108 | + } else if (item == 'like' && this.needLike) { | ||
| 109 | + this.builderLike() | ||
| 110 | + } else if (item == 'collect') { | ||
| 111 | + this.builderCollect() | ||
| 112 | + } else if (item == 'listen') { | ||
| 113 | + this.builderListen() | ||
| 114 | + } else if (item == 'share') { | ||
| 115 | + this.builderShare() | ||
| 116 | + } else { | ||
| 117 | + } | ||
| 118 | + }) | ||
| 119 | + } | ||
| 116 | } | 120 | } |
| 117 | .width('100%') | 121 | .width('100%') |
| 118 | .justifyContent(FlexAlign.Start) | 122 | .justifyContent(FlexAlign.Start) |
-
Please register or login to post a comment