zhenghy

评论组件修改

1 -import { SPHelper,Logger,ToastUtils } from 'wdKit';  
2 -import { ContentDetailDTO, Action, ContentDTO,batchLikeAndCollectResult } from 'wdBean'; 1 +import { SPHelper, Logger, ToastUtils } from 'wdKit';
  2 +import { ContentDetailDTO, Action, ContentDTO, batchLikeAndCollectResult } from 'wdBean';
3 import { ProcessUtils } from 'wdRouter'; 3 import { ProcessUtils } from 'wdRouter';
4 import router from '@ohos.router'; 4 import router from '@ohos.router';
5 import { batchLikeAndCollectParams } from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest'; 5 import { batchLikeAndCollectParams } from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest';
6 import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel'; 6 import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel';
7 import { SpConstants } from 'wdConstant/Index'; 7 import { SpConstants } from 'wdConstant/Index';
8 import { WDShare } from 'wdShare/Index'; 8 import { WDShare } from 'wdShare/Index';
9 -import {LikeComponent} from './view/LikeComponent' 9 +import { LikeComponent } from './view/LikeComponent'
  10 +
10 const TAG = 'CarderInteraction' 11 const TAG = 'CarderInteraction'
  12 +
11 /** 13 /**
12 * 卡片 分享、评论、点赞公用组件 14 * 卡片 分享、评论、点赞公用组件
13 */ 15 */
@@ -15,9 +17,10 @@ const TAG = 'CarderInteraction' @@ -15,9 +17,10 @@ const TAG = 'CarderInteraction'
15 export struct CarderInteraction { 17 export struct CarderInteraction {
16 @Prop contentDTO: ContentDTO 18 @Prop contentDTO: ContentDTO
17 @State contentId: string = '' 19 @State contentId: string = ''
18 - @State contentDetailData: ContentDetailDTO = {} as ContentDetailDTO  
19 - @State newsStatusOfUser: batchLikeAndCollectResult = {} as batchLikeAndCollectResult// 点赞、收藏状态 20 + @Provide contentDetailData: ContentDetailDTO = {} as ContentDetailDTO
  21 + @State newsStatusOfUser: batchLikeAndCollectResult = {} as batchLikeAndCollectResult // 点赞、收藏状态
20 @State likeBean: Record<string, string> = {} 22 @State likeBean: Record<string, string> = {}
  23 +
21 async aboutToAppear() { 24 async aboutToAppear() {
22 await this.getContentDetailData() 25 await this.getContentDetailData()
23 // 点赞需要数据 26 // 点赞需要数据
@@ -28,51 +31,55 @@ export struct CarderInteraction { @@ -28,51 +31,55 @@ export struct CarderInteraction {
28 this.likeBean['userHeaderUrl'] = this.contentDetailData.userInfo?.headPhotoUrl + '' 31 this.likeBean['userHeaderUrl'] = this.contentDetailData.userInfo?.headPhotoUrl + ''
29 this.likeBean['channelId'] = this.contentDetailData.reLInfo?.channelId + '' 32 this.likeBean['channelId'] = this.contentDetailData.reLInfo?.channelId + ''
30 } 33 }
  34 +
31 build() { 35 build() {
32 - Row(){  
33 - Row(){ 36 + Row() {
  37 + Row() {
34 Image($r('app.media.CarderInteraction_share')) 38 Image($r('app.media.CarderInteraction_share'))
35 .width(18) 39 .width(18)
36 .height(18) 40 .height(18)
37 Text('分享') 41 Text('分享')
38 - .margin({left:4}) 42 + .margin({ left: 4 })
39 .fontSize(14) 43 .fontSize(14)
40 .fontColor('#666666') 44 .fontColor('#666666')
41 } 45 }
42 .justifyContent(FlexAlign.Center) 46 .justifyContent(FlexAlign.Center)
43 - .onClick(()=>{ 47 + .onClick(() => {
44 WDShare.shareContent(this.contentDetailData) 48 WDShare.shareContent(this.contentDetailData)
45 }) 49 })
46 - Row(){ 50 +
  51 + Row() {
47 Image($r('app.media.CarderInteraction_comment')) 52 Image($r('app.media.CarderInteraction_comment'))
48 .width(18) 53 .width(18)
49 .height(18) 54 .height(18)
50 Text('评论') 55 Text('评论')
51 - .margin({left:4}) 56 + .margin({ left: 4 })
52 .fontSize(14) 57 .fontSize(14)
53 .fontColor('#666666') 58 .fontColor('#666666')
54 } 59 }
55 .justifyContent(FlexAlign.Center) 60 .justifyContent(FlexAlign.Center)
56 - .onClick(()=>{ 61 + .onClick(() => {
57 ProcessUtils.processPage(this.contentDTO) 62 ProcessUtils.processPage(this.contentDTO)
58 }) 63 })
  64 +
59 this.builderLike() 65 this.builderLike()
60 } 66 }
61 .width('100%') 67 .width('100%')
62 - .margin({top:11}) 68 + .margin({ top: 11 })
63 .padding({ 69 .padding({
64 - left:21,  
65 - right:21 70 + left: 21,
  71 + right: 21
66 }) 72 })
67 .justifyContent(FlexAlign.SpaceBetween) 73 .justifyContent(FlexAlign.SpaceBetween)
68 .alignItems(VerticalAlign.Center) 74 .alignItems(VerticalAlign.Center)
69 } 75 }
  76 +
70 /** 77 /**
71 * 点赞组件 78 * 点赞组件
72 */ 79 */
73 @Builder 80 @Builder
74 builderLike() { 81 builderLike() {
75 - Row(){ 82 + Row() {
76 if (this.likeBean?.contentId) { 83 if (this.likeBean?.contentId) {
77 LikeComponent({ 84 LikeComponent({
78 data: this.likeBean, 85 data: this.likeBean,
@@ -88,13 +95,13 @@ export struct CarderInteraction { @@ -88,13 +95,13 @@ export struct CarderInteraction {
88 * */ 95 * */
89 private async getContentDetailData() { 96 private async getContentDetailData() {
90 try { 97 try {
91 - let data = await MultiPictureDetailViewModel.getDetailData(this.contentDTO.relId, this.contentDTO.objectId, this.contentDTO.relType) 98 + let data = await MultiPictureDetailViewModel.getDetailData(this.contentDTO.relId, this.contentDTO.objectId,
  99 + this.contentDTO.relType)
92 this.contentDetailData = data[0]; 100 this.contentDetailData = data[0];
93 - console.log('动态详情',JSON.stringify(this.contentDetailData)) 101 + console.log('动态详情', JSON.stringify(this.contentDetailData))
94 } catch (exception) { 102 } catch (exception) {
95 - console.log('请求失败',JSON.stringify(exception)) 103 + console.log('请求失败', JSON.stringify(exception))
96 } 104 }
97 } 105 }
98 -  
99 } 106 }
100 107
1 -import { AccountManagerUtils, Logger, DateTimeUtils, SPHelper, NumberFormatterUtils, DisplayUtils,  
2 - NetworkUtil } from 'wdKit'; 1 +import {
  2 + AccountManagerUtils,
  3 + Logger,
  4 + DateTimeUtils,
  5 + SPHelper,
  6 + NumberFormatterUtils,
  7 + DisplayUtils,
  8 + NetworkUtil
  9 +} from 'wdKit';
3 import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel'; 10 import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel';
4 -import { ContentDetailDTO,postBatchAttentionStatusParams, 11 +import {
  12 + ContentDetailDTO,
  13 + postBatchAttentionStatusParams,
5 PhotoListBean, 14 PhotoListBean,
6 ContentDTO, 15 ContentDTO,
7 batchLikeAndCollectResult, 16 batchLikeAndCollectResult,
8 RmhInfoDTO, 17 RmhInfoDTO,
9 - InteractDataDTO, } from 'wdBean'; 18 + InteractDataDTO,
  19 +} from 'wdBean';
10 import media from '@ohos.multimedia.media'; 20 import media from '@ohos.multimedia.media';
11 import { OperRowListView } from './view/OperRowListView'; 21 import { OperRowListView } from './view/OperRowListView';
12 import { WDPlayerController } from 'wdPlayer/Index'; 22 import { WDPlayerController } from 'wdPlayer/Index';
@@ -33,6 +43,7 @@ import { detailedSkeleton } from './skeleton/detailSkeleton'; @@ -33,6 +43,7 @@ import { detailedSkeleton } from './skeleton/detailSkeleton';
33 43
34 const TAG = 'DynamicDetailComponent' 44 const TAG = 'DynamicDetailComponent'
35 const PATTERN_DATE_CN_RN: string = 'yyyy年MM月dd日 HH:mm'; 45 const PATTERN_DATE_CN_RN: string = 'yyyy年MM月dd日 HH:mm';
  46 +
36 // @Preview 47 // @Preview
37 @Component 48 @Component
38 export struct DynamicDetailComponent { 49 export struct DynamicDetailComponent {
@@ -40,39 +51,34 @@ export struct DynamicDetailComponent { @@ -40,39 +51,34 @@ export struct DynamicDetailComponent {
40 private relId: string = '' 51 private relId: string = ''
41 private contentId: string = '' 52 private contentId: string = ''
42 private relType: string = '' 53 private relType: string = ''
43 -  
44 //出参 54 //出参
45 - @State contentDetailData: ContentDetailDTO = {} as ContentDetailDTO 55 + @Provide contentDetailData: ContentDetailDTO = {} as ContentDetailDTO
46 //UI 56 //UI
47 scroller: Scroller = new Scroller(); 57 scroller: Scroller = new Scroller();
48 -  
49 //点赞 收藏 评论 数量 58 //点赞 收藏 评论 数量
50 - @State interactDataDTO: InteractDataDTO = {likeNum:0} as InteractDataDTO 59 + @State interactDataDTO: InteractDataDTO = { likeNum: 0 } as InteractDataDTO
51 /** 60 /**
52 * 关注状态:默认未关注 点击去关注 61 * 关注状态:默认未关注 点击去关注
53 */ 62 */
54 @State followStatus: String = ''; 63 @State followStatus: String = '';
55 -  
56 - @State newsStatusOfUser: batchLikeAndCollectResult = {} as batchLikeAndCollectResult// 点赞、收藏状态 64 + @State newsStatusOfUser: batchLikeAndCollectResult = {} as batchLikeAndCollectResult // 点赞、收藏状态
57 //跳转 65 //跳转
58 private mJumpInfo: ContentDTO = new ContentDTO(); 66 private mJumpInfo: ContentDTO = new ContentDTO();
59 -  
60 @State publishTime: string = '' 67 @State publishTime: string = ''
61 @State isNetConnected: boolean = true 68 @State isNetConnected: boolean = true
62 @State isPageEnd: boolean = false 69 @State isPageEnd: boolean = false
63 -  
64 @State publishCommentModel: publishCommentModel = new publishCommentModel() 70 @State publishCommentModel: publishCommentModel = new publishCommentModel()
65 71
66 -  
67 async aboutToAppear() { 72 async aboutToAppear() {
68 await this.getContentDetailData() 73 await this.getContentDetailData()
69 } 74 }
  75 +
70 onPageHide() { 76 onPageHide() {
71 77
72 } 78 }
73 79
74 build() { 80 build() {
75 - Column(){ 81 + Column() {
76 //logo、日期 82 //logo、日期
77 Row() { 83 Row() {
78 Image($r('app.media.ic_article_rmh')) 84 Image($r('app.media.ic_article_rmh'))
@@ -89,12 +95,13 @@ export struct DynamicDetailComponent { @@ -89,12 +95,13 @@ export struct DynamicDetailComponent {
89 .height($r('app.float.margin_48')) 95 .height($r('app.float.margin_48'))
90 .width('100%') 96 .width('100%')
91 .alignItems(VerticalAlign.Bottom) 97 .alignItems(VerticalAlign.Bottom)
92 - .padding({bottom:5}) 98 + .padding({ bottom: 5 })
  99 +
93 //分割线 100 //分割线
94 Image($r('app.media.ic_news_detail_division')) 101 Image($r('app.media.ic_news_detail_division'))
95 .width('100%') 102 .width('100%')
96 .height($r('app.float.margin_7')) 103 .height($r('app.float.margin_7'))
97 - .padding({left: $r('app.float.margin_16'), right: $r('app.float.margin_16')} ) 104 + .padding({ left: $r('app.float.margin_16'), right: $r('app.float.margin_16') })
98 Stack({ alignContent: Alignment.Bottom }) { 105 Stack({ alignContent: Alignment.Bottom }) {
99 if (!this.isNetConnected) { 106 if (!this.isNetConnected) {
100 EmptyComponent({ 107 EmptyComponent({
@@ -107,7 +114,7 @@ export struct DynamicDetailComponent { @@ -107,7 +114,7 @@ export struct DynamicDetailComponent {
107 } else { 114 } else {
108 if (!this.isPageEnd) { 115 if (!this.isPageEnd) {
109 detailedSkeleton() 116 detailedSkeleton()
110 - }else{ 117 + } else {
111 Scroll(this.scroller) { 118 Scroll(this.scroller) {
112 Column() { 119 Column() {
113 //号主信息 120 //号主信息
@@ -115,7 +122,8 @@ export struct DynamicDetailComponent { @@ -115,7 +122,8 @@ export struct DynamicDetailComponent {
115 //头像 122 //头像
116 Stack() { 123 Stack() {
117 Image(this.contentDetailData.rmhInfo?.rmhHeadUrl) 124 Image(this.contentDetailData.rmhInfo?.rmhHeadUrl)
118 - .alt(this.contentDetailData.rmhInfo?.userType=='1'?$r('app.media.default_head'):$r('app.media.icon_default_head_mater')) 125 + .alt(this.contentDetailData.rmhInfo?.userType == '1' ? $r('app.media.default_head') :
  126 + $r('app.media.icon_default_head_mater'))
119 .width($r('app.float.margin_32')) 127 .width($r('app.float.margin_32'))
120 .height($r('app.float.margin_32')) 128 .height($r('app.float.margin_32'))
121 .objectFit(ImageFit.Cover) 129 .objectFit(ImageFit.Cover)
@@ -125,7 +133,7 @@ export struct DynamicDetailComponent { @@ -125,7 +133,7 @@ export struct DynamicDetailComponent {
125 .height($r('app.float.margin_48')) 133 .height($r('app.float.margin_48'))
126 .objectFit(ImageFit.Cover) 134 .objectFit(ImageFit.Cover)
127 .borderRadius($r('app.float.margin_24')) 135 .borderRadius($r('app.float.margin_24'))
128 - if(!StringUtils.isEmpty(this.contentDetailData.rmhInfo?.authIcon)){ 136 + if (!StringUtils.isEmpty(this.contentDetailData.rmhInfo?.authIcon)) {
129 Stack() { 137 Stack() {
130 Image(this.contentDetailData.rmhInfo?.authIcon) 138 Image(this.contentDetailData.rmhInfo?.authIcon)
131 .width($r('app.float.vp_12')) 139 .width($r('app.float.vp_12'))
@@ -141,9 +149,11 @@ export struct DynamicDetailComponent { @@ -141,9 +149,11 @@ export struct DynamicDetailComponent {
141 .height($r('app.float.margin_48')) 149 .height($r('app.float.margin_48'))
142 .alignContent(Alignment.Center) 150 .alignContent(Alignment.Center)
143 .onClick(() => { 151 .onClick(() => {
144 - ProcessUtils.gotoPeopleShipHomePage(this.contentDetailData.rmhInfo == null ?"":this.contentDetailData.rmhInfo.rmhId) 152 + ProcessUtils.gotoPeopleShipHomePage(this.contentDetailData.rmhInfo == null ? "" :
  153 + this.contentDetailData.rmhInfo.rmhId)
145 }) 154 })
146 - Column(){ 155 +
  156 + Column() {
147 //昵称 157 //昵称
148 Text(this.contentDetailData.rmhInfo?.rmhName) 158 Text(this.contentDetailData.rmhInfo?.rmhName)
149 .fontSize($r('app.float.font_size_14')) 159 .fontSize($r('app.float.font_size_14'))
@@ -162,15 +172,16 @@ export struct DynamicDetailComponent { @@ -162,15 +172,16 @@ export struct DynamicDetailComponent {
162 .alignSelf(ItemAlign.Start) 172 .alignSelf(ItemAlign.Start)
163 } 173 }
164 .width('63%') 174 .width('63%')
165 - .margin({right: $r('app.float.margin_6')})  
166 - if(!StringUtils.isEmpty(this.followStatus)){ 175 + .margin({ right: $r('app.float.margin_6') })
  176 +
  177 + if (!StringUtils.isEmpty(this.followStatus)) {
167 if (this.followStatus == '0') { 178 if (this.followStatus == '0') {
168 Row() { 179 Row() {
169 Blank().layoutWeight(1) 180 Blank().layoutWeight(1)
170 Image($r('app.media.icon_add_attention')) 181 Image($r('app.media.icon_add_attention'))
171 .width($r('app.float.vp_12')) 182 .width($r('app.float.vp_12'))
172 .height($r('app.float.vp_12')) 183 .height($r('app.float.vp_12'))
173 - .margin({right:2}) 184 + .margin({ right: 2 })
174 Text('关注') 185 Text('关注')
175 .textAlign(TextAlign.Center) 186 .textAlign(TextAlign.Center)
176 .fontSize($r('app.float.font_size_12')) 187 .fontSize($r('app.float.font_size_12'))
@@ -202,23 +213,26 @@ export struct DynamicDetailComponent { @@ -202,23 +213,26 @@ export struct DynamicDetailComponent {
202 } 213 }
203 } 214 }
204 .width('100%') 215 .width('100%')
205 - .margin({ left: $r('app.float.margin_16')}) 216 + .margin({ left: $r('app.float.margin_16') })
  217 +
206 //内容 218 //内容
207 Text(StringUtils.isEmpty(this.contentDetailData.newsContent) 219 Text(StringUtils.isEmpty(this.contentDetailData.newsContent)
208 - ?StringUtils.isEmpty(this.contentDetailData.newsSummary)  
209 - ?this.contentDetailData.newsTitle  
210 - :this.contentDetailData.newsSummary  
211 - :this.contentDetailData.newsContent) 220 + ? StringUtils.isEmpty(this.contentDetailData.newsSummary)
  221 + ? this.contentDetailData.newsTitle
  222 + : this.contentDetailData.newsSummary
  223 + : this.contentDetailData.newsContent)
212 .fontColor($r('app.color.color_222222')) 224 .fontColor($r('app.color.color_222222'))
213 .fontSize($r('app.float.font_size_18')) 225 .fontSize($r('app.float.font_size_18'))
214 .lineHeight($r('app.float.margin_25')) 226 .lineHeight($r('app.float.margin_25'))
215 - .margin({ top: $r('app.float.margin_6')  
216 - ,left: $r('app.float.margin_16')  
217 - ,right: $r('app.float.margin_16') }) 227 + .margin({
  228 + top: $r('app.float.margin_6')
  229 + , left: $r('app.float.margin_16')
  230 + , right: $r('app.float.margin_16')
  231 + })
218 .alignSelf(ItemAlign.Start) 232 .alignSelf(ItemAlign.Start)
219 - if(this.contentDetailData.newsType+"" == ContentConstants.TYPE_FOURTEEN){ 233 + if (this.contentDetailData.newsType + "" == ContentConstants.TYPE_FOURTEEN) {
220 //附件内容:图片/视频 234 //附件内容:图片/视频
221 - if(this.contentDetailData.photoList!= null && this.contentDetailData.photoList.length>0){ 235 + if (this.contentDetailData.photoList != null && this.contentDetailData.photoList.length > 0) {
222 // 图片-从无图到9图展示 236 // 图片-从无图到9图展示
223 GridRow({ 237 GridRow({
224 gutter: { x: 2, y: 2 } 238 gutter: { x: 2, y: 2 }
@@ -228,7 +242,7 @@ export struct DynamicDetailComponent { @@ -228,7 +242,7 @@ export struct DynamicDetailComponent {
228 if (this.getPicType(item) !== 3) { 242 if (this.getPicType(item) !== 3) {
229 GridCol({ 243 GridCol({
230 span: this.getPicType(item) === 1 ? 12 : 8 244 span: this.getPicType(item) === 1 ? 12 : 8
231 - }){ 245 + }) {
232 Stack({ 246 Stack({
233 alignContent: Alignment.BottomEnd 247 alignContent: Alignment.BottomEnd
234 }) { 248 }) {
@@ -249,7 +263,7 @@ export struct DynamicDetailComponent { @@ -249,7 +263,7 @@ export struct DynamicDetailComponent {
249 Image($r('app.media.icon_long_pic')) 263 Image($r('app.media.icon_long_pic'))
250 .width(14) 264 .width(14)
251 .height(14) 265 .height(14)
252 - .margin({right: 4}) 266 + .margin({ right: 4 })
253 Text('长图') 267 Text('长图')
254 .fontSize(12) 268 .fontSize(12)
255 .fontWeight(400) 269 .fontWeight(400)
@@ -257,12 +271,12 @@ export struct DynamicDetailComponent { @@ -257,12 +271,12 @@ export struct DynamicDetailComponent {
257 .fontFamily('PingFang SC') 271 .fontFamily('PingFang SC')
258 } 272 }
259 .width(48) 273 .width(48)
260 - .padding({bottom: 9}) 274 + .padding({ bottom: 9 })
261 275
262 } 276 }
263 } 277 }
264 .onClick((event: ClickEvent) => { 278 .onClick((event: ClickEvent) => {
265 - ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList,index) 279 + ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList, index)
266 }) 280 })
267 } else { 281 } else {
268 GridCol({ 282 GridCol({
@@ -279,7 +293,7 @@ export struct DynamicDetailComponent { @@ -279,7 +293,7 @@ export struct DynamicDetailComponent {
279 }) 293 })
280 } 294 }
281 .onClick((event: ClickEvent) => { 295 .onClick((event: ClickEvent) => {
282 - ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList,index) 296 + ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList, index)
283 }) 297 })
284 } 298 }
285 } else if (this.contentDetailData.photoList.length === 4) { 299 } else if (this.contentDetailData.photoList.length === 4) {
@@ -291,7 +305,7 @@ export struct DynamicDetailComponent { @@ -291,7 +305,7 @@ export struct DynamicDetailComponent {
291 .borderRadius(this.caclImageRadius(index)) 305 .borderRadius(this.caclImageRadius(index))
292 } 306 }
293 .onClick((event: ClickEvent) => { 307 .onClick((event: ClickEvent) => {
294 - ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList,index) 308 + ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList, index)
295 }) 309 })
296 } else { 310 } else {
297 GridCol({ 311 GridCol({
@@ -302,15 +316,19 @@ export struct DynamicDetailComponent { @@ -302,15 +316,19 @@ export struct DynamicDetailComponent {
302 .borderRadius(this.caclImageRadius(index)) 316 .borderRadius(this.caclImageRadius(index))
303 } 317 }
304 .onClick((event: ClickEvent) => { 318 .onClick((event: ClickEvent) => {
305 - ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList,index) 319 + ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList, index)
306 }) 320 })
307 } 321 }
308 }) 322 })
309 } 323 }
310 - .margin({ left: $r('app.float.margin_16'),right: $r('app.float.margin_16'),top: $r('app.float.margin_8')}) 324 + .margin({
  325 + left: $r('app.float.margin_16'),
  326 + right: $r('app.float.margin_16'),
  327 + top: $r('app.float.margin_8')
  328 + })
311 } 329 }
312 - }else{  
313 - if(this.contentDetailData.videoInfo!= null && this.contentDetailData.videoInfo.length>0){ 330 + } else {
  331 + if (this.contentDetailData.videoInfo != null && this.contentDetailData.videoInfo.length > 0) {
314 GridRow() { 332 GridRow() {
315 if (this.contentDetailData.videoInfo[0].videoLandScape === 1) { 333 if (this.contentDetailData.videoInfo[0].videoLandScape === 1) {
316 // 横屏 334 // 横屏
@@ -318,11 +336,13 @@ export struct DynamicDetailComponent { @@ -318,11 +336,13 @@ export struct DynamicDetailComponent {
318 span: { xs: 12 } 336 span: { xs: 12 }
319 }) { 337 }) {
320 Stack() { 338 Stack() {
321 - Image(this.contentDetailData.fullColumnImgUrls!= null && this.contentDetailData.fullColumnImgUrls.length>0&&!StringUtils.isEmpty(this.contentDetailData.fullColumnImgUrls[0].url)?  
322 - this.contentDetailData.fullColumnImgUrls[0].url: 339 + Image(this.contentDetailData.fullColumnImgUrls != null &&
  340 + this.contentDetailData.fullColumnImgUrls.length > 0 &&
  341 + !StringUtils.isEmpty(this.contentDetailData.fullColumnImgUrls[0].url) ?
  342 + this.contentDetailData.fullColumnImgUrls[0].url :
323 this.contentDetailData.videoInfo[0].firstFrameImageUri) 343 this.contentDetailData.videoInfo[0].firstFrameImageUri)
324 - .width(DisplayUtils.getDeviceWidth()- 32)  
325 - .height((DisplayUtils.getDeviceWidth()-32)* 9 / 16) 344 + .width(DisplayUtils.getDeviceWidth() - 32)
  345 + .height((DisplayUtils.getDeviceWidth() - 32) * 9 / 16)
326 .borderRadius($r('app.float.image_border_radius')) 346 .borderRadius($r('app.float.image_border_radius'))
327 CardMediaInfo({ contentDTO: this.mJumpInfo }) 347 CardMediaInfo({ contentDTO: this.mJumpInfo })
328 } 348 }
@@ -334,11 +354,13 @@ export struct DynamicDetailComponent { @@ -334,11 +354,13 @@ export struct DynamicDetailComponent {
334 span: { xs: 6 } 354 span: { xs: 6 }
335 }) { 355 }) {
336 Stack() { 356 Stack() {
337 - Image(this.contentDetailData.fullColumnImgUrls!= null && this.contentDetailData.fullColumnImgUrls.length>0&&!StringUtils.isEmpty(this.contentDetailData.fullColumnImgUrls[0].url)?  
338 - this.contentDetailData.fullColumnImgUrls[0].url: 357 + Image(this.contentDetailData.fullColumnImgUrls != null &&
  358 + this.contentDetailData.fullColumnImgUrls.length > 0 &&
  359 + !StringUtils.isEmpty(this.contentDetailData.fullColumnImgUrls[0].url) ?
  360 + this.contentDetailData.fullColumnImgUrls[0].url :
339 this.contentDetailData.videoInfo[0].firstFrameImageUri) 361 this.contentDetailData.videoInfo[0].firstFrameImageUri)
340 - .width(DisplayUtils.getDeviceWidth()/2)  
341 - .height(DisplayUtils.getDeviceWidth()/2* 4 / 3) 362 + .width(DisplayUtils.getDeviceWidth() / 2)
  363 + .height(DisplayUtils.getDeviceWidth() / 2 * 4 / 3)
342 .borderRadius($r('app.float.image_border_radius')) 364 .borderRadius($r('app.float.image_border_radius'))
343 CardMediaInfo({ contentDTO: this.mJumpInfo }) 365 CardMediaInfo({ contentDTO: this.mJumpInfo })
344 } 366 }
@@ -346,7 +368,10 @@ export struct DynamicDetailComponent { @@ -346,7 +368,10 @@ export struct DynamicDetailComponent {
346 } 368 }
347 } 369 }
348 } 370 }
349 - .padding({ left: this.contentDetailData.videoInfo[0].videoLandScape === 1?0: 25,top: $r('app.float.margin_8')}) 371 + .padding({
  372 + left: this.contentDetailData.videoInfo[0].videoLandScape === 1 ? 0 : 25,
  373 + top: $r('app.float.margin_8')
  374 + })
350 .onClick((event: ClickEvent) => { 375 .onClick((event: ClickEvent) => {
351 ProcessUtils.processPage(this.mJumpInfo) 376 ProcessUtils.processPage(this.mJumpInfo)
352 }) 377 })
@@ -357,9 +382,11 @@ export struct DynamicDetailComponent { @@ -357,9 +382,11 @@ export struct DynamicDetailComponent {
357 .fontColor($r('app.color.color_CCCCCC')) 382 .fontColor($r('app.color.color_CCCCCC'))
358 .fontSize($r('app.float.font_size_12')) 383 .fontSize($r('app.float.font_size_12'))
359 .lineHeight($r('app.float.margin_16')) 384 .lineHeight($r('app.float.margin_16'))
360 - .margin({ top: $r('app.float.margin_16')  
361 - ,left: $r('app.float.vp_12')  
362 - ,right: $r('app.float.vp_12') }) 385 + .margin({
  386 + top: $r('app.float.margin_16')
  387 + , left: $r('app.float.vp_12')
  388 + , right: $r('app.float.vp_12')
  389 + })
363 //微信/朋友圈/微博 390 //微信/朋友圈/微博
364 // Row(){ 391 // Row(){
365 // Image($r('app.media.xxhdpi_pic_wechat')) 392 // Image($r('app.media.xxhdpi_pic_wechat'))
@@ -379,27 +406,27 @@ export struct DynamicDetailComponent { @@ -379,27 +406,27 @@ export struct DynamicDetailComponent {
379 // } 406 // }
380 // .margin({ top: $r('app.float.margin_24')}) 407 // .margin({ top: $r('app.float.margin_24')})
381 //点赞 408 //点赞
382 - Row(){ 409 + Row() {
383 Blank().layoutWeight(1) 410 Blank().layoutWeight(1)
384 - Image(this.newsStatusOfUser?.likeStatus == '1'? 411 + Image(this.newsStatusOfUser?.likeStatus == '1' ?
385 $r('app.media.icon_like_selected_redheart') 412 $r('app.media.icon_like_selected_redheart')
386 - :$r('app.media.icon_like_unselect_grey_redheart')) 413 + : $r('app.media.icon_like_unselect_grey_redheart'))
387 .width($r('app.float.margin_36')) 414 .width($r('app.float.margin_36'))
388 .height($r('app.float.margin_36')) 415 .height($r('app.float.margin_36'))
389 .objectFit(ImageFit.Cover) 416 .objectFit(ImageFit.Cover)
390 - .margin({ left: $r('app.float.margin_6_negative'),right: $r('app.float.margin_6_negative')})  
391 - if(this.interactDataDTO?.likeNum != 0){ 417 + .margin({ left: $r('app.float.margin_6_negative'), right: $r('app.float.margin_6_negative') })
  418 + if (this.interactDataDTO?.likeNum != 0) {
392 Text(NumberFormatterUtils.formatNumberWithWan(this.interactDataDTO?.likeNum)) 419 Text(NumberFormatterUtils.formatNumberWithWan(this.interactDataDTO?.likeNum))
393 .fontColor($r('app.color.color_999999')) 420 .fontColor($r('app.color.color_999999'))
394 .fontSize($r('app.float.font_size_16')) 421 .fontSize($r('app.float.font_size_16'))
395 .lineHeight($r('app.float.margin_20')) 422 .lineHeight($r('app.float.margin_20'))
396 - .margin({ left: $r('app.float.margin_2')}) 423 + .margin({ left: $r('app.float.margin_2') })
397 } 424 }
398 Blank().layoutWeight(1) 425 Blank().layoutWeight(1)
399 } 426 }
400 .width($r('app.float.margin_154')) 427 .width($r('app.float.margin_154'))
401 .height($r('app.float.margin_40')) 428 .height($r('app.float.margin_40'))
402 - .margin({top:$r('app.float.margin_16')}) 429 + .margin({ top: $r('app.float.margin_16') })
403 .borderWidth($r('app.float.margin_1')) 430 .borderWidth($r('app.float.margin_1'))
404 .borderColor($r('app.color.color_EDEDED')) 431 .borderColor($r('app.color.color_EDEDED'))
405 .borderRadius($r('app.float.margin_20')) 432 .borderRadius($r('app.float.margin_20'))
@@ -407,9 +434,10 @@ export struct DynamicDetailComponent { @@ -407,9 +434,10 @@ export struct DynamicDetailComponent {
407 //点赞操作 434 //点赞操作
408 this.toggleLikeStatus() 435 this.toggleLikeStatus()
409 }) 436 })
  437 +
410 // 评论 438 // 评论
411 if (this.contentDetailData?.openComment) { 439 if (this.contentDetailData?.openComment) {
412 - Divider().strokeWidth(6).color('#f5f5f5').margin({top:$r('app.float.margin_24')}) 440 + Divider().strokeWidth(6).color('#f5f5f5').margin({ top: $r('app.float.margin_24') })
413 CommentComponent({ 441 CommentComponent({
414 publishCommentModel: { 442 publishCommentModel: {
415 targetId: String(this.contentDetailData?.newsId || ''), 443 targetId: String(this.contentDetailData?.newsId || ''),
@@ -447,6 +475,7 @@ export struct DynamicDetailComponent { @@ -447,6 +475,7 @@ export struct DynamicDetailComponent {
447 .width('100%') 475 .width('100%')
448 .height('100%') 476 .height('100%')
449 } 477 }
  478 +
450 /** 479 /**
451 * 请求(动态)详情页数据 480 * 请求(动态)详情页数据
452 * */ 481 * */
@@ -460,9 +489,9 @@ export struct DynamicDetailComponent { @@ -460,9 +489,9 @@ export struct DynamicDetailComponent {
460 DateTimeUtils.parseDate(this.contentDetailData?.publishTime, DateTimeUtils.PATTERN_DATE_TIME_HYPHEN); 489 DateTimeUtils.parseDate(this.contentDetailData?.publishTime, DateTimeUtils.PATTERN_DATE_TIME_HYPHEN);
461 let _publishTime = DateTimeUtils.formatDate(dateTime, PATTERN_DATE_CN_RN) 490 let _publishTime = DateTimeUtils.formatDate(dateTime, PATTERN_DATE_CN_RN)
462 this.publishTime = DateTimeUtils.removeTrailingZeros(_publishTime) 491 this.publishTime = DateTimeUtils.removeTrailingZeros(_publishTime)
463 - console.log('动态详情',JSON.stringify(this.contentDetailData)) 492 + console.log('动态详情', JSON.stringify(this.contentDetailData))
464 } catch (exception) { 493 } catch (exception) {
465 - console.log('请求失败',JSON.stringify(exception)) 494 + console.log('请求失败', JSON.stringify(exception))
466 this.isPageEnd = true; 495 this.isPageEnd = true;
467 } 496 }
468 this.getBatchAttentionStatus() 497 this.getBatchAttentionStatus()
@@ -471,10 +500,11 @@ export struct DynamicDetailComponent { @@ -471,10 +500,11 @@ export struct DynamicDetailComponent {
471 this.interactDataV2() 500 this.interactDataV2()
472 } 501 }
473 502
474 -  
475 private async interactDataV2() { 503 private async interactDataV2() {
476 this.interactDataDTO = await MultiPictureDetailViewModel.interactDataV2( 504 this.interactDataDTO = await MultiPictureDetailViewModel.interactDataV2(
477 - this.contentDetailData?.newsId+'',this.contentDetailData?.newsType+'',this.contentDetailData.reLInfo == null ?'':this.contentDetailData.reLInfo?.relId,this.contentDetailData.rmhPlatform) 505 + this.contentDetailData?.newsId + '', this.contentDetailData?.newsType + '',
  506 + this.contentDetailData.reLInfo == null ? '' : this.contentDetailData.reLInfo?.relId,
  507 + this.contentDetailData.rmhPlatform)
478 } 508 }
479 509
480 // 已登录->查询用户对作品点赞、收藏状态 510 // 已登录->查询用户对作品点赞、收藏状态
@@ -526,18 +556,19 @@ export struct DynamicDetailComponent { @@ -526,18 +556,19 @@ export struct DynamicDetailComponent {
526 } 556 }
527 557
528 //创建跳转信息 558 //创建跳转信息
529 - makeJumpInfo(){ 559 + makeJumpInfo() {
530 this.mJumpInfo.pageId = 'dynamicDetailPage' 560 this.mJumpInfo.pageId = 'dynamicDetailPage'
531 - this.mJumpInfo.objectId = this.contentDetailData.newsId+""  
532 - this.mJumpInfo.relType = this.contentDetailData.reLInfo?.relType+""  
533 - this.mJumpInfo.relId = this.contentDetailData.reLInfo?.relId+""  
534 - this.mJumpInfo.objectType = (this.contentDetailData.newsType+"") == ContentConstants.TYPE_FOURTEEN?this.contentDetailData.newsType+"":ContentConstants.TYPE_VOD  
535 - if(this.contentDetailData.videoInfo!= null && this.contentDetailData.videoInfo.length>0){ 561 + this.mJumpInfo.objectId = this.contentDetailData.newsId + ""
  562 + this.mJumpInfo.relType = this.contentDetailData.reLInfo?.relType + ""
  563 + this.mJumpInfo.relId = this.contentDetailData.reLInfo?.relId + ""
  564 + this.mJumpInfo.objectType =
  565 + (this.contentDetailData.newsType + "") == ContentConstants.TYPE_FOURTEEN ? this.contentDetailData.newsType + "" :
  566 + ContentConstants.TYPE_VOD
  567 + if (this.contentDetailData.videoInfo != null && this.contentDetailData.videoInfo.length > 0) {
536 this.mJumpInfo.videoInfo = this.contentDetailData.videoInfo[0] 568 this.mJumpInfo.videoInfo = this.contentDetailData.videoInfo[0]
537 } 569 }
538 } 570 }
539 571
540 -  
541 caclImageRadius(index: number) { 572 caclImageRadius(index: number) {
542 let radius: radiusType = { 573 let radius: radiusType = {
543 topLeft: index === 0 ? $r('app.float.image_border_radius') : 0, 574 topLeft: index === 0 ? $r('app.float.image_border_radius') : 0,
@@ -561,11 +592,11 @@ export struct DynamicDetailComponent { @@ -561,11 +592,11 @@ export struct DynamicDetailComponent {
561 return radius 592 return radius
562 } 593 }
563 594
564 - getPicType(item: PhotoListBean){ 595 + getPicType(item: PhotoListBean) {
565 if (item.width && item.width) { 596 if (item.width && item.width) {
566 - if (item.width / item.height > 343/172) { 597 + if (item.width / item.height > 343 / 172) {
567 return 1; //横长图 598 return 1; //横长图
568 - } else if (item.height / item.width > 305/228) { 599 + } else if (item.height / item.width > 305 / 228) {
569 return 2; //竖长图 600 return 2; //竖长图
570 } else { 601 } else {
571 return 3 602 return 3
@@ -590,7 +621,7 @@ export struct DynamicDetailComponent { @@ -590,7 +621,7 @@ export struct DynamicDetailComponent {
590 attentionUserType: this.contentDetailData?.rmhInfo?.userType || '', //被关注用户类型(1 普通用户 2 视频号 3 矩阵号) 621 attentionUserType: this.contentDetailData?.rmhInfo?.userType || '', //被关注用户类型(1 普通用户 2 视频号 3 矩阵号)
591 attentionUserId: this.contentDetailData?.rmhInfo?.userId || '', // 被关注用户号主id 622 attentionUserId: this.contentDetailData?.rmhInfo?.userId || '', // 被关注用户号主id
592 attentionCreatorId: this.contentDetailData?.rmhInfo?.rmhId || '', // 被关注用户号主id 623 attentionCreatorId: this.contentDetailData?.rmhInfo?.rmhId || '', // 被关注用户号主id
593 - status: this.followStatus == '0'? 1:0, 624 + status: this.followStatus == '0' ? 1 : 0,
594 } 625 }
595 ContentDetailRequest.postInteractAccentionOperate(params2).then(res => { 626 ContentDetailRequest.postInteractAccentionOperate(params2).then(res => {
596 console.log('关注号主==', JSON.stringify(res.data)) 627 console.log('关注号主==', JSON.stringify(res.data))
@@ -40,7 +40,7 @@ const TAG: string = 'ImageAndTextPageComponent' @@ -40,7 +40,7 @@ const TAG: string = 'ImageAndTextPageComponent'
40 export struct ImageAndTextPageComponent { 40 export struct ImageAndTextPageComponent {
41 scroller: Scroller = new Scroller(); 41 scroller: Scroller = new Scroller();
42 action: Action = {} as Action 42 action: Action = {} as Action
43 - @State contentDetailData: ContentDetailDTO [] = [] as ContentDetailDTO [] 43 + @Provide contentDetailData: ContentDetailDTO = {} as ContentDetailDTO
44 @State recommendList: ContentDTO[] = [] 44 @State recommendList: ContentDTO[] = []
45 @State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态 45 @State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态
46 @State interactData: InteractDataDTO = {} as InteractDataDTO 46 @State interactData: InteractDataDTO = {} as InteractDataDTO
@@ -52,11 +52,12 @@ export struct ImageAndTextPageComponent { @@ -52,11 +52,12 @@ export struct ImageAndTextPageComponent {
52 @State isNetConnected: boolean = true 52 @State isNetConnected: boolean = true
53 @State info: Area | null = null 53 @State info: Area | null = null
54 @State likeNum: number = 0 54 @State likeNum: number = 0
  55 +
55 build() { 56 build() {
56 Column() { 57 Column() {
57 // 发布时间 58 // 发布时间
58 Row() { 59 Row() {
59 - Image(this.contentDetailData[0]?.rmhInfo ? $r('app.media.logo_rmh') : $r('app.media.logo_rmrb')) 60 + Image(this.contentDetailData?.rmhInfo ? $r('app.media.logo_rmh') : $r('app.media.logo_rmrb'))
60 .width(80) 61 .width(80)
61 .height(28) 62 .height(28)
62 Text(this.publishTime) 63 Text(this.publishTime)
@@ -83,26 +84,26 @@ export struct ImageAndTextPageComponent { @@ -83,26 +84,26 @@ export struct ImageAndTextPageComponent {
83 Scroll(this.scroller) { 84 Scroll(this.scroller) {
84 Column() { 85 Column() {
85 ImageAndTextWebComponent({ 86 ImageAndTextWebComponent({
86 - contentDetailData: this.contentDetailData, 87 + contentDetailData: [this.contentDetailData],
87 action: this.action, 88 action: this.action,
88 isPageEnd: $isPageEnd 89 isPageEnd: $isPageEnd
89 }) 90 })
90 - .padding({bottom:10}) 91 + .padding({ bottom: 10 })
91 Column() { 92 Column() {
92 // 点赞 93 // 点赞
93 - if (this.contentDetailData[0]?.openLikes && this.contentDetailData[0]?.likesStyle !== 4) { 94 + if (this.contentDetailData?.openLikes && this.contentDetailData?.likesStyle !== 4) {
94 Row() { 95 Row() {
95 Row() { 96 Row() {
96 if (this.newsStatusOfUser?.likeStatus === '1') { 97 if (this.newsStatusOfUser?.likeStatus === '1') {
97 - Image(this.contentDetailData[0]?.likesStyle === 1 ? $r('app.media.ic_like_check') :  
98 - (this.contentDetailData[0]?.likesStyle === 2 ? $r('app.media.icon_prayer_active') : 98 + Image(this.contentDetailData?.likesStyle === 1 ? $r('app.media.ic_like_check') :
  99 + (this.contentDetailData?.likesStyle === 2 ? $r('app.media.icon_prayer_active') :
99 $r('app.media.icon_candle_active'))) 100 $r('app.media.icon_candle_active')))
100 .width(24) 101 .width(24)
101 .height(24) 102 .height(24)
102 .margin({ right: 5 }) 103 .margin({ right: 5 })
103 } else { 104 } else {
104 - Image(this.contentDetailData[0]?.likesStyle === 1 ? $r('app.media.icon_like') :  
105 - (this.contentDetailData[0]?.likesStyle === 2 ? $r('app.media.icon_prayer') : 105 + Image(this.contentDetailData?.likesStyle === 1 ? $r('app.media.icon_like') :
  106 + (this.contentDetailData?.likesStyle === 2 ? $r('app.media.icon_prayer') :
106 $r('app.media.icon_candle'))) 107 $r('app.media.icon_candle')))
107 .width(24) 108 .width(24)
108 .height(24) 109 .height(24)
@@ -129,7 +130,7 @@ export struct ImageAndTextPageComponent { @@ -129,7 +130,7 @@ export struct ImageAndTextPageComponent {
129 }) 130 })
130 131
131 }.width(CommonConstants.FULL_WIDTH) 132 }.width(CommonConstants.FULL_WIDTH)
132 - .padding({top:14,bottom:24}) 133 + .padding({ top: 14, bottom: 24 })
133 .justifyContent(FlexAlign.Center) 134 .justifyContent(FlexAlign.Center)
134 } 135 }
135 if (this.recommendList.length > 0) { 136 if (this.recommendList.length > 0) {
@@ -137,7 +138,7 @@ export struct ImageAndTextPageComponent { @@ -137,7 +138,7 @@ export struct ImageAndTextPageComponent {
137 RecommendList({ recommendList: this.recommendList }) 138 RecommendList({ recommendList: this.recommendList })
138 } 139 }
139 // 评论 140 // 评论
140 - if (this.contentDetailData[0]?.openComment) { 141 + if (this.contentDetailData?.openComment) {
141 Divider().strokeWidth(6).color('#f5f5f5') 142 Divider().strokeWidth(6).color('#f5f5f5')
142 CommentComponent({ 143 CommentComponent({
143 publishCommentModel: this.publishCommentModel 144 publishCommentModel: this.publishCommentModel
@@ -173,7 +174,7 @@ export struct ImageAndTextPageComponent { @@ -173,7 +174,7 @@ export struct ImageAndTextPageComponent {
173 //底部交互区 174 //底部交互区
174 if (this.operationButtonList.length) { 175 if (this.operationButtonList.length) {
175 OperRowListView({ 176 OperRowListView({
176 - contentDetailData: this.contentDetailData[0], 177 + contentDetailData: this.contentDetailData,
177 publishCommentModel: this.publishCommentModel, 178 publishCommentModel: this.publishCommentModel,
178 operationButtonList: this.operationButtonList, 179 operationButtonList: this.operationButtonList,
179 styleType: 1, 180 styleType: 1,
@@ -207,29 +208,29 @@ export struct ImageAndTextPageComponent { @@ -207,29 +208,29 @@ export struct ImageAndTextPageComponent {
207 } 208 }
208 let detailBeans = await DetailViewModel.getDetailPageData(relId, contentId, relType) 209 let detailBeans = await DetailViewModel.getDetailPageData(relId, contentId, relType)
209 if (detailBeans && detailBeans.length > 0) { 210 if (detailBeans && detailBeans.length > 0) {
210 - this.contentDetailData = detailBeans; 211 + this.contentDetailData = detailBeans[0];
211 let dateTime = 212 let dateTime =
212 - DateTimeUtils.parseDate(this.contentDetailData[0]?.publishTime, DateTimeUtils.PATTERN_DATE_TIME_HYPHEN); 213 + DateTimeUtils.parseDate(this.contentDetailData?.publishTime, DateTimeUtils.PATTERN_DATE_TIME_HYPHEN);
213 let _publishTime = DateTimeUtils.formatDate(dateTime, PATTERN_DATE_CN_RN) 214 let _publishTime = DateTimeUtils.formatDate(dateTime, PATTERN_DATE_CN_RN)
214 this.publishTime = DateTimeUtils.removeTrailingZeros(_publishTime) 215 this.publishTime = DateTimeUtils.removeTrailingZeros(_publishTime)
215 - if (this.contentDetailData[0]?.recommendShow === 1) { 216 + if (this.contentDetailData?.recommendShow === 1) {
216 this.getRecommend() 217 this.getRecommend()
217 } 218 }
218 - if (this.contentDetailData[0]?.openLikes === 1) { 219 + if (this.contentDetailData?.openLikes === 1) {
219 this.getInteractDataStatus() 220 this.getInteractDataStatus()
220 this.queryContentInteractCount() 221 this.queryContentInteractCount()
221 } 222 }
222 - if (this.contentDetailData[0]?.openComment) {  
223 - this.publishCommentModel.targetId = String(this.contentDetailData[0]?.newsId || '')  
224 - this.publishCommentModel.targetRelId = String(this.contentDetailData[0]?.reLInfo?.relId)  
225 - this.publishCommentModel.targetTitle = this.contentDetailData[0]?.newsTitle  
226 - this.publishCommentModel.targetRelType = String(this.contentDetailData[0]?.reLInfo?.relType)  
227 - this.publishCommentModel.targetRelObjectId = String(this.contentDetailData[0]?.reLInfo?.relObjectId)  
228 - this.publishCommentModel.keyArticle = String(this.contentDetailData[0]?.keyArticle)  
229 - this.publishCommentModel.targetType = String(this.contentDetailData[0]?.newsType)  
230 - }  
231 - if (this.contentDetailData[0]?.openAudio && this.contentDetailData[0]?.audioList?.length &&  
232 - this.contentDetailData[0]?.audioList[0].audioUrl) { 223 + if (this.contentDetailData?.openComment) {
  224 + this.publishCommentModel.targetId = String(this.contentDetailData?.newsId || '')
  225 + this.publishCommentModel.targetRelId = String(this.contentDetailData?.reLInfo?.relId)
  226 + this.publishCommentModel.targetTitle = this.contentDetailData?.newsTitle
  227 + this.publishCommentModel.targetRelType = String(this.contentDetailData?.reLInfo?.relType)
  228 + this.publishCommentModel.targetRelObjectId = String(this.contentDetailData?.reLInfo?.relObjectId)
  229 + this.publishCommentModel.keyArticle = String(this.contentDetailData?.keyArticle)
  230 + this.publishCommentModel.targetType = String(this.contentDetailData?.newsType)
  231 + }
  232 + if (this.contentDetailData?.openAudio && this.contentDetailData?.audioList?.length &&
  233 + this.contentDetailData?.audioList[0].audioUrl) {
233 this.operationButtonList = ['comment', 'collect', 'listen', 'share'] 234 this.operationButtonList = ['comment', 'collect', 'listen', 'share']
234 } else { 235 } else {
235 this.operationButtonList = ['comment', 'collect', 'share'] 236 this.operationButtonList = ['comment', 'collect', 'share']
@@ -242,11 +243,11 @@ export struct ImageAndTextPageComponent { @@ -242,11 +243,11 @@ export struct ImageAndTextPageComponent {
242 let params: postRecommendListParams = { 243 let params: postRecommendListParams = {
243 imei: HttpUtils.getImei(), 244 imei: HttpUtils.getImei(),
244 userId: HttpUtils.getUserId(), 245 userId: HttpUtils.getUserId(),
245 - contentId: String(this.contentDetailData[0]?.newsId),  
246 - recType: Number(this.contentDetailData[0]?.reLInfo?.relType),  
247 - contentType: this.contentDetailData[0]?.newsType,  
248 - relId: this.contentDetailData[0]?.reLInfo?.relId,  
249 - channelId: String(this.contentDetailData[0]?.reLInfo?.channelId) 246 + contentId: String(this.contentDetailData?.newsId),
  247 + recType: Number(this.contentDetailData?.reLInfo?.relType),
  248 + contentType: this.contentDetailData?.newsType,
  249 + relId: this.contentDetailData?.reLInfo?.relId,
  250 + channelId: String(this.contentDetailData?.reLInfo?.channelId)
250 } 251 }
251 let recommendList = await DetailViewModel.postRecommendList(params) 252 let recommendList = await DetailViewModel.postRecommendList(params)
252 this.recommendList = recommendList; 253 this.recommendList = recommendList;
@@ -258,8 +259,8 @@ export struct ImageAndTextPageComponent { @@ -258,8 +259,8 @@ export struct ImageAndTextPageComponent {
258 const params: batchLikeAndCollectParams = { 259 const params: batchLikeAndCollectParams = {
259 contentList: [ 260 contentList: [
260 { 261 {
261 - contentId: this.contentDetailData[0]?.newsId + '',  
262 - contentType: this.contentDetailData[0]?.newsType + '', 262 + contentId: this.contentDetailData?.newsId + '',
  263 + contentType: this.contentDetailData?.newsType + '',
263 } 264 }
264 ] 265 ]
265 } 266 }
@@ -284,8 +285,8 @@ export struct ImageAndTextPageComponent { @@ -284,8 +285,8 @@ export struct ImageAndTextPageComponent {
284 } 285 }
285 const params: postExecuteLikeParams = { 286 const params: postExecuteLikeParams = {
286 status: this.newsStatusOfUser?.likeStatus === '1' ? '0' : '1', 287 status: this.newsStatusOfUser?.likeStatus === '1' ? '0' : '1',
287 - contentId: this.contentDetailData[0]?.newsId + '',  
288 - contentType: this.contentDetailData[0]?.newsType + '', 288 + contentId: this.contentDetailData?.newsId + '',
  289 + contentType: this.contentDetailData?.newsType + '',
289 } 290 }
290 PageRepository.postExecuteLike(params).then(res => { 291 PageRepository.postExecuteLike(params).then(res => {
291 console.log(TAG, '点赞、取消点赞', 'toggleLikeStatus==',) 292 console.log(TAG, '点赞、取消点赞', 'toggleLikeStatus==',)
@@ -304,8 +305,8 @@ export struct ImageAndTextPageComponent { @@ -304,8 +305,8 @@ export struct ImageAndTextPageComponent {
304 console.error(TAG, 'contentDetailData2222', JSON.stringify(this.contentDetailData)) 305 console.error(TAG, 'contentDetailData2222', JSON.stringify(this.contentDetailData))
305 const params: contentListParams = { 306 const params: contentListParams = {
306 contentList: [{ 307 contentList: [{
307 - contentId: this.contentDetailData[0]?.newsId + '',  
308 - contentType: this.contentDetailData[0]?.newsType, 308 + contentId: this.contentDetailData?.newsId + '',
  309 + contentType: this.contentDetailData?.newsType,
309 }] 310 }]
310 } 311 }
311 PageRepository.getContentInteract(params).then(res => { 312 PageRepository.getContentInteract(params).then(res => {
1 -import { NetworkUtil, Logger, NetworkType, SPHelper, WindowModel, StringUtils} from 'wdKit'; 1 +import { NetworkUtil, Logger, NetworkType, SPHelper, WindowModel, StringUtils } from 'wdKit';
2 import { ResponseDTO } from 'wdNetwork'; 2 import { ResponseDTO } from 'wdNetwork';
3 import { 3 import {
4 ContentDetailDTO, 4 ContentDetailDTO,
@@ -35,7 +35,7 @@ export struct MultiPictureDetailPageComponent { @@ -35,7 +35,7 @@ export struct MultiPictureDetailPageComponent {
35 private picWidth: number = 0 35 private picWidth: number = 0
36 @State picHeight: number = 0 36 @State picHeight: number = 0
37 @State titleHeight: number = 0 37 @State titleHeight: number = 0
38 - @State contentDetailData: ContentDetailDTO = {} as ContentDetailDTO 38 + @Provide contentDetailData: ContentDetailDTO = {} as ContentDetailDTO
39 @Provide @Watch('onCurrentPageNumUpdated') currentPageNum: string = '01' 39 @Provide @Watch('onCurrentPageNumUpdated') currentPageNum: string = '01'
40 private swiperController: SwiperController = new SwiperController() 40 private swiperController: SwiperController = new SwiperController()
41 private swiperControllerItem: SwiperController = new SwiperController() 41 private swiperControllerItem: SwiperController = new SwiperController()
@@ -49,8 +49,8 @@ export struct MultiPictureDetailPageComponent { @@ -49,8 +49,8 @@ export struct MultiPictureDetailPageComponent {
49 @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') as number; 49 @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') as number;
50 @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') as number; 50 @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') as number;
51 @State windowHeight: number = AppStorage.get<number>('windowHeight') as number; 51 @State windowHeight: number = AppStorage.get<number>('windowHeight') as number;
52 - @State currentOffset:number = 0  
53 - @State duration:number = 0 52 + @State currentOffset: number = 0
  53 + @State duration: number = 0
54 54
55 //watch监听页码回调 55 //watch监听页码回调
56 onCurrentPageNumUpdated(): void { 56 onCurrentPageNumUpdated(): void {
@@ -83,7 +83,6 @@ export struct MultiPictureDetailPageComponent { @@ -83,7 +83,6 @@ export struct MultiPictureDetailPageComponent {
83 } 83 }
84 } 84 }
85 85
86 -  
87 aboutToDisappear() { 86 aboutToDisappear() {
88 87
89 } 88 }
@@ -101,10 +100,10 @@ export struct MultiPictureDetailPageComponent { @@ -101,10 +100,10 @@ export struct MultiPictureDetailPageComponent {
101 @Builder 100 @Builder
102 init() { 101 init() {
103 if (this.contentDetailData.rmhPlatform == 1) { 102 if (this.contentDetailData.rmhPlatform == 1) {
104 - if(!this.showDownload) { 103 + if (!this.showDownload) {
105 Row() { 104 Row() {
106 Row({ space: 8 }) { 105 Row({ space: 8 }) {
107 - if (this.getImgUrl()){ 106 + if (this.getImgUrl()) {
108 Row() { 107 Row() {
109 Stack() { 108 Stack() {
110 Image(this.getImgUrl()) 109 Image(this.getImgUrl())
@@ -115,7 +114,7 @@ export struct MultiPictureDetailPageComponent { @@ -115,7 +114,7 @@ export struct MultiPictureDetailPageComponent {
115 .height(36) 114 .height(36)
116 .objectFit(ImageFit.Fill) 115 .objectFit(ImageFit.Fill)
117 .interpolation(ImageInterpolation.High) 116 .interpolation(ImageInterpolation.High)
118 - if(!StringUtils.isEmpty(this.contentDetailData.rmhInfo?.authIcon)){ 117 + if (!StringUtils.isEmpty(this.contentDetailData.rmhInfo?.authIcon)) {
119 Stack() { 118 Stack() {
120 Image(this.contentDetailData.rmhInfo?.authIcon) 119 Image(this.contentDetailData.rmhInfo?.authIcon)
121 .width($r('app.float.vp_13')) 120 .width($r('app.float.vp_13'))
@@ -219,7 +218,7 @@ export struct MultiPictureDetailPageComponent { @@ -219,7 +218,7 @@ export struct MultiPictureDetailPageComponent {
219 .width('100%') 218 .width('100%')
220 .height(44) 219 .height(44)
221 .zIndex(10) 220 .zIndex(10)
222 - .margin({top:`${this.topSafeHeight + 12}px`}) 221 + .margin({ top: `${this.topSafeHeight + 12}px` })
223 .alignRules({ 222 .alignRules({
224 top: { anchor: "__container__", align: VerticalAlign.Top }, 223 top: { anchor: "__container__", align: VerticalAlign.Top },
225 middle: { anchor: "__container__", align: HorizontalAlign.Center } 224 middle: { anchor: "__container__", align: HorizontalAlign.Center }
@@ -249,12 +248,12 @@ export struct MultiPictureDetailPageComponent { @@ -249,12 +248,12 @@ export struct MultiPictureDetailPageComponent {
249 this.currentOffset = Math.abs(extraInfo.currentOffset) 248 this.currentOffset = Math.abs(extraInfo.currentOffset)
250 }) 249 })
251 .onTouch((event: TouchEvent) => { 250 .onTouch((event: TouchEvent) => {
252 - if(this.duration === 0) { 251 + if (this.duration === 0) {
253 this.duration = 500 252 this.duration = 500
254 } 253 }
255 - if(event.type === 1) { 254 + if (event.type === 1) {
256 // if(this.currentOffset > px2vp((this.windowHeight - item.height)/2 - 100)) { 255 // if(this.currentOffset > px2vp((this.windowHeight - item.height)/2 - 100)) {
257 - if(this.currentOffset > 160) { 256 + if (this.currentOffset > 160) {
258 router.back() 257 router.back()
259 } 258 }
260 } 259 }
@@ -296,9 +295,9 @@ export struct MultiPictureDetailPageComponent { @@ -296,9 +295,9 @@ export struct MultiPictureDetailPageComponent {
296 middle: { anchor: "__container__", align: HorizontalAlign.Center } 295 middle: { anchor: "__container__", align: HorizontalAlign.Center }
297 }) 296 })
298 } 297 }
299 - Column(){  
300 - if(!this.showDownload) {  
301 - Column(){ 298 + Column() {
  299 + if (!this.showDownload) {
  300 + Column() {
302 Row() { 301 Row() {
303 Scroll(this.scroller) { 302 Scroll(this.scroller) {
304 Row() { 303 Row() {
@@ -306,7 +305,7 @@ export struct MultiPictureDetailPageComponent { @@ -306,7 +305,7 @@ export struct MultiPictureDetailPageComponent {
306 direction: FlexDirection.Column, 305 direction: FlexDirection.Column,
307 justifyContent: FlexAlign.Start 306 justifyContent: FlexAlign.Start
308 }) { 307 }) {
309 - if(this.contentDetailData?.photoList?.length) { 308 + if (this.contentDetailData?.photoList?.length) {
310 Text() { 309 Text() {
311 Span(`${this.swiperIndex + 1}`) 310 Span(`${this.swiperIndex + 1}`)
312 .fontSize(24) 311 .fontSize(24)
@@ -322,7 +321,7 @@ export struct MultiPictureDetailPageComponent { @@ -322,7 +321,7 @@ export struct MultiPictureDetailPageComponent {
322 .fontColor(Color.White) 321 .fontColor(Color.White)
323 .margin(4) 322 .margin(4)
324 } 323 }
325 - if(this.contentDetailData.newsTitle) { 324 + if (this.contentDetailData.newsTitle) {
326 Text(`${this.contentDetailData.newsTitle}`) 325 Text(`${this.contentDetailData.newsTitle}`)
327 .fontColor(Color.White) 326 .fontColor(Color.White)
328 .fontSize(16) 327 .fontSize(16)
@@ -336,7 +335,7 @@ export struct MultiPictureDetailPageComponent { @@ -336,7 +335,7 @@ export struct MultiPictureDetailPageComponent {
336 right: 0 335 right: 0
337 }) 336 })
338 } 337 }
339 - if(this.contentDetailData.photoList?.[this.swiperIndex].picDesc) { 338 + if (this.contentDetailData.photoList?.[this.swiperIndex].picDesc) {
340 Text(`${this.contentDetailData.photoList?.[this.swiperIndex].picDesc}`) 339 Text(`${this.contentDetailData.photoList?.[this.swiperIndex].picDesc}`)
341 .fontColor(Color.White) 340 .fontColor(Color.White)
342 .fontSize(14) 341 .fontSize(14)
@@ -361,6 +360,7 @@ export struct MultiPictureDetailPageComponent { @@ -361,6 +360,7 @@ export struct MultiPictureDetailPageComponent {
361 .height(px2vp(this.titleHeight)) 360 .height(px2vp(this.titleHeight))
362 .align(Alignment.Bottom) 361 .align(Alignment.Bottom)
363 } 362 }
  363 +
364 OperRowListView({ 364 OperRowListView({
365 contentDetailData: this.contentDetailData, 365 contentDetailData: this.contentDetailData,
366 publishCommentModel: this.publishCommentModel, 366 publishCommentModel: this.publishCommentModel,
@@ -372,14 +372,14 @@ export struct MultiPictureDetailPageComponent { @@ -372,14 +372,14 @@ export struct MultiPictureDetailPageComponent {
372 TransitionEffect.translate({ x: 0, y: `-${this.bottomSafeHeight}px` }) 372 TransitionEffect.translate({ x: 0, y: `-${this.bottomSafeHeight}px` })
373 )) 373 ))
374 } 374 }
375 - if(this.showDownload) {  
376 - Column(){ 375 + if (this.showDownload) {
  376 + Column() {
377 Row() { 377 Row() {
378 Flex({ 378 Flex({
379 direction: FlexDirection.Row, 379 direction: FlexDirection.Row,
380 justifyContent: FlexAlign.SpaceBetween 380 justifyContent: FlexAlign.SpaceBetween
381 }) { 381 }) {
382 - if(this.contentDetailData?.photoList?.length) { 382 + if (this.contentDetailData?.photoList?.length) {
383 Text() { 383 Text() {
384 Span(`${this.swiperIndex + 1}`) 384 Span(`${this.swiperIndex + 1}`)
385 .fontSize(24) 385 .fontSize(24)
@@ -396,7 +396,7 @@ export struct MultiPictureDetailPageComponent { @@ -396,7 +396,7 @@ export struct MultiPictureDetailPageComponent {
396 .margin(4) 396 .margin(4)
397 } 397 }
398 398
399 - if(this.contentDetailData.photoList?.[this.swiperIndex].picPath) { 399 + if (this.contentDetailData.photoList?.[this.swiperIndex].picPath) {
400 ImageDownloadComponent({ url: this.contentDetailData.photoList?.[this.swiperIndex].picPath }) 400 ImageDownloadComponent({ url: this.contentDetailData.photoList?.[this.swiperIndex].picPath })
401 .margin({ 401 .margin({
402 top: 8, 402 top: 8,
@@ -18,7 +18,7 @@ export struct SpacialTopicPageComponent { @@ -18,7 +18,7 @@ export struct SpacialTopicPageComponent {
18 action: Action = {} as Action 18 action: Action = {} as Action
19 @State webUrl: string = ''; 19 @State webUrl: string = '';
20 @State isPageEnd: boolean = false 20 @State isPageEnd: boolean = false
21 - @State contentDetailData: ContentDetailDTO [] = [] as ContentDetailDTO [] 21 + @Provide contentDetailData: ContentDetailDTO = {} as ContentDetailDTO
22 private h5ReceiveAppData: H5ReceiveDetailBean = { dataSource: '2' } as H5ReceiveDetailBean 22 private h5ReceiveAppData: H5ReceiveDetailBean = { dataSource: '2' } as H5ReceiveDetailBean
23 private webPrepared = false; 23 private webPrepared = false;
24 private dataPrepared = false; 24 private dataPrepared = false;
@@ -63,15 +63,15 @@ export struct SpacialTopicPageComponent { @@ -63,15 +63,15 @@ export struct SpacialTopicPageComponent {
63 } 63 }
64 let detailBeans = await DetailViewModel.getDetailPageData(relId, contentId, relType) 64 let detailBeans = await DetailViewModel.getDetailPageData(relId, contentId, relType)
65 if (detailBeans && detailBeans.length > 0) { 65 if (detailBeans && detailBeans.length > 0) {
66 - this.contentDetailData = detailBeans; 66 + this.contentDetailData = detailBeans[0];
67 // if (this.contentDetailData[0]?.openComment) { 67 // if (this.contentDetailData[0]?.openComment) {
68 - this.publishCommentModel.targetId = String(this.contentDetailData[0]?.newsId || '')  
69 - this.publishCommentModel.targetRelId = String(this.contentDetailData[0]?.reLInfo?.relId)  
70 - this.publishCommentModel.targetTitle = this.contentDetailData[0]?.newsTitle  
71 - this.publishCommentModel.targetRelType = String(this.contentDetailData[0]?.reLInfo?.relType)  
72 - this.publishCommentModel.targetRelObjectId = String(this.contentDetailData[0]?.reLInfo?.relObjectId)  
73 - this.publishCommentModel.keyArticle = String(this.contentDetailData[0]?.keyArticle)  
74 - this.publishCommentModel.targetType = String(this.contentDetailData[0]?.newsType) 68 + this.publishCommentModel.targetId = String(this.contentDetailData?.newsId || '')
  69 + this.publishCommentModel.targetRelId = String(this.contentDetailData?.reLInfo?.relId)
  70 + this.publishCommentModel.targetTitle = this.contentDetailData?.newsTitle
  71 + this.publishCommentModel.targetRelType = String(this.contentDetailData?.reLInfo?.relType)
  72 + this.publishCommentModel.targetRelObjectId = String(this.contentDetailData?.reLInfo?.relObjectId)
  73 + this.publishCommentModel.keyArticle = String(this.contentDetailData?.keyArticle)
  74 + this.publishCommentModel.targetType = String(this.contentDetailData?.newsType)
75 // } 75 // }
76 this.trySendData2H5() 76 this.trySendData2H5()
77 } 77 }
@@ -92,14 +92,14 @@ export struct SpacialTopicPageComponent { @@ -92,14 +92,14 @@ export struct SpacialTopicPageComponent {
92 } 92 }
93 .width(CommonConstants.FULL_WIDTH) 93 .width(CommonConstants.FULL_WIDTH)
94 .height(CommonConstants.FULL_HEIGHT) 94 .height(CommonConstants.FULL_HEIGHT)
95 - .padding({bottom:75}) 95 + .padding({ bottom: 75 })
96 96
97 if (!this.isPageEnd) { 97 if (!this.isPageEnd) {
98 detailedSkeleton() 98 detailedSkeleton()
99 } 99 }
100 //底部交互区 100 //底部交互区
101 OperRowListView({ 101 OperRowListView({
102 - contentDetailData: this.contentDetailData[0], 102 + contentDetailData: this.contentDetailData,
103 publishCommentModel: this.publishCommentModel, 103 publishCommentModel: this.publishCommentModel,
104 operationButtonList: this.operationButtonList, 104 operationButtonList: this.operationButtonList,
105 }) 105 })
@@ -3,18 +3,26 @@ import { LikeViewModel } from '../../viewmodel/LikeViewModel' @@ -3,18 +3,26 @@ import { LikeViewModel } from '../../viewmodel/LikeViewModel'
3 import { SPHelper } from 'wdKit'; 3 import { SPHelper } from 'wdKit';
4 import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'; 4 import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
5 import { SpConstants } from 'wdConstant/Index'; 5 import { SpConstants } from 'wdConstant/Index';
  6 +import { ContentDetailDTO } from 'wdBean/Index';
6 7
7 8
8 const TAG = 'LikeComponent'; 9 const TAG = 'LikeComponent';
9 10
  11 +interface ILikeStyleResp {
  12 + url: Resource;
  13 + name: string;
  14 +}
  15 +
10 @Component 16 @Component
11 export struct LikeComponent { 17 export struct LikeComponent {
  18 + @Consume contentDetailData: ContentDetailDTO
  19 + @State likesStyle: number = this.contentDetailData.likesStyle // 赞样式 1红心(点赞) 2大拇指(祈福) 3蜡烛(默哀) 4置空
12 @State likeStatus: boolean = false 20 @State likeStatus: boolean = false
13 viewModel: LikeViewModel = new LikeViewModel() 21 viewModel: LikeViewModel = new LikeViewModel()
14 @Prop data: Record<string, string> 22 @Prop data: Record<string, string>
15 enableBtn = true 23 enableBtn = true
16 - componentType : number = 1 //1: 底部栏目样式 2: 新闻页中间位置样式 3:动态Tab内容下的互动入口  
17 - styleType : number = 1 //1: 白色背景(图文底部栏) 2: 黑色背景(图集底部栏) 24 + componentType: number = 1 //1: 底部栏目样式 2: 新闻页中间位置样式 3:动态Tab内容下的互动入口
  25 + styleType: number = 1 //1: 白色背景(图文底部栏) 2: 黑色背景(图集底部栏)
18 @State likeCount: number = 0 //点赞数 26 @State likeCount: number = 0 //点赞数
19 27
20 //上层传值 样例 28 //上层传值 样例
@@ -37,13 +45,51 @@ export struct LikeComponent { @@ -37,13 +45,51 @@ export struct LikeComponent {
37 } 45 }
38 46
39 build() { 47 build() {
40 - if (this.componentType == 2){ 48 +
  49 + if (this.componentType == 2) {
41 //2: 新闻页中间位置样式 50 //2: 新闻页中间位置样式
42 - Column() { 51 + this.likeCompStyle2()
  52 + } else if (this.componentType == 3) {
  53 + this.likeCompStyle3()
  54 + } else {
  55 + //1: 底部栏目样式 默认样式
  56 + this.likeCompStyle1()
  57 + }
  58 + }
43 59
44 - Button(){ 60 + /**
  61 + * 将点赞样式转换为icon
  62 + */
  63 + transLikeStyle(): ILikeStyleResp {
  64 + if (this.likesStyle === 1) {
  65 + return {
  66 + url: this.likeStatus ? $r(`app.media.ic_like_check`) : $r(`app.media.ic_like_uncheck`),
  67 + name: '赞'
  68 + }
  69 + } else if (this.likesStyle === 2) {
  70 + return {
  71 + url: this.likeStatus ? $r(`app.media.ic_thub_check`) : $r(`app.media.ic_thub_uncheck`),
  72 + name: '祈祷'
  73 + }
  74 + } else if (this.likesStyle === 3) {
  75 + return {
  76 + url: this.likeStatus ? $r(`app.media.ic_candle_check`) :
  77 + $r(`app.media.ic_candle_uncheck`),
  78 + name: '默哀'
  79 + }
  80 + }
  81 + return {
  82 + url: $r(`app.media.icon_like_ckeck`), name: '点赞'
  83 + }
  84 + }
  85 +
  86 + @Builder
  87 + likeCompStyle2() {
  88 + //2: 新闻页中间位置样式
  89 + Column() {
  90 + Button() {
45 91
46 - Row(){ 92 + Row() {
47 Image(this.likeStatus ? $r('app.media.icon_like_select') : $r('app.media.icon_like_default')) 93 Image(this.likeStatus ? $r('app.media.icon_like_select') : $r('app.media.icon_like_default'))
48 .width(20) 94 .width(20)
49 .height(20) 95 .height(20)
@@ -68,21 +114,25 @@ export struct LikeComponent { @@ -68,21 +114,25 @@ export struct LikeComponent {
68 .borderColor('#EDEDED') 114 .borderColor('#EDEDED')
69 .borderRadius(20) 115 .borderRadius(20)
70 .borderWidth(1) 116 .borderWidth(1)
71 - .onClick(()=>{ 117 + .onClick(() => {
72 this.clickButtonEvent() 118 this.clickButtonEvent()
73 }) 119 })
74 } 120 }
75 .width(154) 121 .width(154)
76 .height(40) 122 .height(40)
77 - }else if(this.componentType == 3){  
78 - Row(){  
79 - Image(this.likeStatus ? $r('app.media.icon_like_select') : this.styleType == 1 ? $r('app.media.CarderInteraction_like') : 123 + }
  124 +
  125 + @Builder
  126 + likeCompStyle3() {
  127 + Row() {
  128 + Image(this.likeStatus ? $r('app.media.icon_like_select') :
  129 + this.styleType == 1 ? $r('app.media.CarderInteraction_like') :
80 $r('app.media.icon_like_default_white')) 130 $r('app.media.icon_like_default_white'))
81 .width(18) 131 .width(18)
82 .height(18) 132 .height(18)
83 - // Text(this.likeCount >0?this.likeCount.toString(): '点赞')  
84 - Text(this.likeStatus ?'已赞': '点赞')  
85 - .margin({left:4}) 133 + // Text(this.likeStatus ? '已赞' : '点赞')
  134 + Text(this.likeCount > 0 ? this.likeCount.toString() : '点赞')
  135 + .margin({ left: 4 })
86 .fontSize(14) 136 .fontSize(14)
87 .fontColor(this.likeStatus ? '#ED2800' : '#666666') 137 .fontColor(this.likeStatus ? '#ED2800' : '#666666')
88 } 138 }
@@ -90,11 +140,15 @@ export struct LikeComponent { @@ -90,11 +140,15 @@ export struct LikeComponent {
90 .onClick(() => { 140 .onClick(() => {
91 this.clickButtonEvent() 141 this.clickButtonEvent()
92 }) 142 })
93 - }else{ 143 + }
  144 +
  145 + @Builder
  146 + likeCompStyle1() {
94 //1: 底部栏目样式 默认样式 147 //1: 底部栏目样式 默认样式
95 Column() { 148 Column() {
96 // Image(this.likeStatus ? $r('app.media.icon_like_select') : $r('app.media.icon_like_default')) 149 // Image(this.likeStatus ? $r('app.media.icon_like_select') : $r('app.media.icon_like_default'))
97 - Image(this.likeStatus ? $r('app.media.icon_like_select') : this.styleType == 1 ? $r('app.media.icon_like_default') : 150 + Image(this.likeStatus ? $r('app.media.icon_like_select') :
  151 + this.styleType == 1 ? $r('app.media.icon_like_default') :
98 $r('app.media.icon_like_default_white')) 152 $r('app.media.icon_like_default_white'))
99 .width(24) 153 .width(24)
100 .height(24) 154 .height(24)
@@ -104,39 +158,44 @@ export struct LikeComponent { @@ -104,39 +158,44 @@ export struct LikeComponent {
104 }.width(24).height(24) 158 }.width(24).height(24)
105 } 159 }
106 160
107 - }  
108 -  
109 - async clickButtonEvent(){ 161 + async clickButtonEvent() {
  162 + console.log(TAG, '点赞点击')
110 // 未登录,跳转登录 163 // 未登录,跳转登录
111 const user_id = await SPHelper.default.get(SpConstants.USER_ID, '') 164 const user_id = await SPHelper.default.get(SpConstants.USER_ID, '')
112 if (!user_id) { 165 if (!user_id) {
  166 + console.log(TAG, '点赞点击,未登录')
113 WDRouterRule.jumpWithPage(WDRouterPage.loginPage) 167 WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
114 return 168 return
115 } 169 }
116 170
117 - if (!this.enableBtn) {  
118 - return  
119 - }  
120 - if (this.likeStatus) {  
121 - //1  
122 - this.executeLike('0')  
123 - } else {  
124 - //0  
125 - this.executeLike('1')  
126 - } 171 + // if (!this.enableBtn) {
  172 + // return
  173 + // }
  174 + this.executeLike(this.likeStatus ? '0' : '1')
127 175
128 } 176 }
129 177
130 executeLike(status: string) { 178 executeLike(status: string) {
  179 + console.log(TAG, '点赞接口调用', status)
131 this.data['status'] = status 180 this.data['status'] = status
  181 + this.data['contentId'] = this.contentDetailData?.newsId + ''
  182 + this.data['contentType'] = this.contentDetailData?.newsType + ''
  183 +
132 this.viewModel.executeLike2(this.data).then(() => { 184 this.viewModel.executeLike2(this.data).then(() => {
  185 +
  186 + console.log(TAG, '点赞接口调用成功')
133 this.likeStatus = !this.likeStatus 187 this.likeStatus = !this.likeStatus
134 //点赞和取消点赞成功后更新点赞数 188 //点赞和取消点赞成功后更新点赞数
135 - if(this.likeStatus){  
136 - this.likeCount ++  
137 - }else {  
138 - this.likeCount -- 189 + if (this.likeStatus) {
  190 + this.likeCount++
  191 + } else {
  192 + this.likeCount--
139 } 193 }
  194 +
  195 + if (this.likeCount <= 0) {
  196 + this.likeCount = 0
  197 + }
  198 +
140 this.enableBtn = true 199 this.enableBtn = true
141 }).catch(() => { 200 }).catch(() => {
142 this.enableBtn = true 201 this.enableBtn = true
@@ -147,7 +206,7 @@ export struct LikeComponent { @@ -147,7 +206,7 @@ export struct LikeComponent {
147 this.viewModel.getLikeStatus(this.data).then((data) => { 206 this.viewModel.getLikeStatus(this.data).then((data) => {
148 if (data && data['data'].length && data['data'][0]['likeStatus']) { 207 if (data && data['data'].length && data['data'][0]['likeStatus']) {
149 this.likeStatus = data['data'][0]['likeStatus'] 208 this.likeStatus = data['data'][0]['likeStatus']
150 - }else { 209 + } else {
151 this.likeStatus = false 210 this.likeStatus = false
152 } 211 }
153 }).catch(() => { 212 }).catch(() => {
@@ -160,14 +219,11 @@ export struct LikeComponent { @@ -160,14 +219,11 @@ export struct LikeComponent {
160 this.viewModel.getLikeCount(this.data).then((data) => { 219 this.viewModel.getLikeCount(this.data).then((data) => {
161 if (data && data['data']) { 220 if (data && data['data']) {
162 this.likeCount = data['data']['likeNum'] 221 this.likeCount = data['data']['likeNum']
163 - }else { 222 + } else {
164 this.likeCount = 0 223 this.likeCount = 0
165 } 224 }
166 }).catch(() => { 225 }).catch(() => {
167 this.likeCount = 0 226 this.likeCount = 0
168 }) 227 })
169 } 228 }
170 -  
171 -  
172 -  
173 } 229 }
@@ -33,7 +33,7 @@ const TAG = 'OperRowListView'; @@ -33,7 +33,7 @@ const TAG = 'OperRowListView';
33 * 2、(非必传) operationButtonList---组件展示条件, 33 * 2、(非必传) operationButtonList---组件展示条件,
34 * ['comment', 'like', 'collect', 'share'],需要展示什么传什么 34 * ['comment', 'like', 'collect', 'share'],需要展示什么传什么
35 * comment--评论;like--点赞;collect--收藏;listen--音频;share--分享; 35 * comment--评论;like--点赞;collect--收藏;listen--音频;share--分享;
36 - * 36 + * 注意:外层需注册 @Provide contentDetailData:contentDetailData = {} as contentDetailData
37 * 传值示例: 37 * 传值示例:
38 OperRowListView({ 38 OperRowListView({
39 contentDetailData: this.contentDetailData[0], 39 contentDetailData: this.contentDetailData[0],
@@ -48,17 +48,18 @@ export struct OperRowListView { @@ -48,17 +48,18 @@ export struct OperRowListView {
48 private onCommentFocus: () => void = () => { 48 private onCommentFocus: () => void = () => {
49 } 49 }
50 @Prop @Watch('onDetailUpdated') contentDetailData: ContentDetailDTO // 稿件详情 50 @Prop @Watch('onDetailUpdated') contentDetailData: ContentDetailDTO // 稿件详情
  51 + @State likesStyle: number = this.contentDetailData.likesStyle // 赞样式 1红心(点赞) 2大拇指(祈福) 3蜡烛(默哀) 4置空
51 @State operationButtonList: string[] = ['comment', 'collect', 'share'] // 组件展示条件 52 @State operationButtonList: string[] = ['comment', 'collect', 'share'] // 组件展示条件
  53 + @State needLike: boolean = true
52 @ObjectLink publishCommentModel: publishCommentModel 54 @ObjectLink publishCommentModel: publishCommentModel
53 @State styleType: number = 1 55 @State styleType: number = 1
  56 + @State showCommentIcon: boolean = true
  57 + @State bgColor: ResourceColor = Color.White
54 @State interactData: InteractDataDTO = {} as InteractDataDTO 58 @State interactData: InteractDataDTO = {} as InteractDataDTO
55 @State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态 59 @State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态
56 @State likeBean: Record<string, string> = {} 60 @State likeBean: Record<string, string> = {}
57 @State audioUrl: string = '' 61 @State audioUrl: string = ''
58 - @State bgColor: ResourceColor = Color.White  
59 - @State showCommentIcon: boolean = true  
60 @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 62 @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0
61 - needLike: boolean = true  
62 63
63 async aboutToAppear() { 64 async aboutToAppear() {
64 console.info(TAG, '22222----', this.styleType) 65 console.info(TAG, '22222----', this.styleType)
@@ -183,15 +184,17 @@ export struct OperRowListView { @@ -183,15 +184,17 @@ export struct OperRowListView {
183 */ 184 */
184 @Builder 185 @Builder
185 builderLike() { 186 builderLike() {
  187 + // 点赞根据字段判断是否显示待添加
186 Column() { 188 Column() {
187 - if (this.likeBean?.contentId) { 189 + // if (this.likeBean?.contentId) {
188 LikeComponent({ 190 LikeComponent({
189 data: this.likeBean, 191 data: this.likeBean,
190 styleType: this.styleType 192 styleType: this.styleType
191 }) 193 })
192 - } 194 + // }
193 } 195 }
194 .width(42) 196 .width(42)
  197 + .visibility(this.likesStyle !== 4 ? Visibility.Visible : Visibility.None)
195 } 198 }
196 199
197 /** 200 /**
@@ -301,10 +304,11 @@ export struct OperRowListView { @@ -301,10 +304,11 @@ export struct OperRowListView {
301 * 收藏、取消收藏 304 * 收藏、取消收藏
302 */ 305 */
303 async toggleCollectStatus() { 306 async toggleCollectStatus() {
304 - // console.log(TAG, '收藏--') 307 + console.log(TAG, '收藏点击')
305 // 未登录,跳转登录 308 // 未登录,跳转登录
306 const user_id = await SPHelper.default.get(SpConstants.USER_ID, '') 309 const user_id = await SPHelper.default.get(SpConstants.USER_ID, '')
307 if (!user_id) { 310 if (!user_id) {
  311 + console.log(TAG, '收藏点击,用户未登录')
308 WDRouterRule.jumpWithPage(WDRouterPage.loginPage) 312 WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
309 return 313 return
310 } 314 }
@@ -316,7 +320,9 @@ export struct OperRowListView { @@ -316,7 +320,9 @@ export struct OperRowListView {
316 }], 320 }],
317 321
318 } 322 }
  323 + console.log(TAG, '收藏点击', JSON.stringify(params))
319 PageRepository.postExecuteCollectRecord(params).then(res => { 324 PageRepository.postExecuteCollectRecord(params).then(res => {
  325 + console.log(TAG, '收藏点击 res', JSON.stringify(res))
320 if (this.newsStatusOfUser) { 326 if (this.newsStatusOfUser) {
321 this.newsStatusOfUser.collectStatus = this.newsStatusOfUser?.collectStatus === 1 ? 0 : 1 327 this.newsStatusOfUser.collectStatus = this.newsStatusOfUser?.collectStatus === 1 ? 0 : 1
322 if (this.newsStatusOfUser.collectStatus === 1) { 328 if (this.newsStatusOfUser.collectStatus === 1) {
@@ -339,7 +345,9 @@ export struct OperRowListView { @@ -339,7 +345,9 @@ export struct OperRowListView {
339 contentType: this.contentDetailData?.newsType, 345 contentType: this.contentDetailData?.newsType,
340 }] 346 }]
341 } 347 }
  348 + console.log(TAG, '点赞点击', JSON.stringify(params))
342 PageRepository.getContentInteract(params).then(res => { 349 PageRepository.getContentInteract(params).then(res => {
  350 + console.log(TAG, '点赞点击 res', JSON.stringify(res))
343 if (res.data) { 351 if (res.data) {
344 this.interactData.likeNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.likeNum) 352 this.interactData.likeNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.likeNum)
345 this.interactData.collectNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.collectNum) 353 this.interactData.collectNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.collectNum)
@@ -9,7 +9,8 @@ export class LikeViewModel { @@ -9,7 +9,8 @@ export class LikeViewModel {
9 this.likeModel = new LikeModel(); 9 this.likeModel = new LikeModel();
10 } 10 }
11 11
12 - executeLike(contentId: string, userName: string, contentType: string, title: string, userHeaderUrl: string, channelId: string, status: string) { 12 + executeLike(contentId: string, userName: string, contentType: string, title: string, userHeaderUrl: string,
  13 + channelId: string, status: string) {
13 let bean: Record<string, string> = {} 14 let bean: Record<string, string> = {}
14 bean['contentId'] = contentId 15 bean['contentId'] = contentId
15 bean['userName'] = userName 16 bean['userName'] = userName
@@ -23,7 +24,6 @@ export class LikeViewModel { @@ -23,7 +24,6 @@ export class LikeViewModel {
23 24
24 //点赞 25 //点赞
25 executeLike2(bean: Record<string, string>) { 26 executeLike2(bean: Record<string, string>) {
26 -  
27 return new Promise<object>((success, fail) => { 27 return new Promise<object>((success, fail) => {
28 this.likeModel.executeLike(bean).then((data) => { 28 this.likeModel.executeLike(bean).then((data) => {
29 success(data) 29 success(data)
@@ -60,7 +60,4 @@ export class LikeViewModel { @@ -60,7 +60,4 @@ export class LikeViewModel {
60 }) 60 })
61 61
62 } 62 }
63 -  
64 -  
65 -  
66 } 63 }