陈剑华

Merge remote-tracking branch 'origin/main'

@@ -6,6 +6,7 @@ import { batchLikeAndCollectParams } from 'wdDetailPlayApi/src/main/ets/request/ @@ -6,6 +6,7 @@ import { batchLikeAndCollectParams } from 'wdDetailPlayApi/src/main/ets/request/
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 const TAG = 'CarderInteraction' 10 const TAG = 'CarderInteraction'
10 /** 11 /**
11 * 卡片 分享、评论、点赞公用组件 12 * 卡片 分享、评论、点赞公用组件
@@ -16,6 +17,17 @@ export struct CarderInteraction { @@ -16,6 +17,17 @@ export struct CarderInteraction {
16 @State contentId: string = '' 17 @State contentId: string = ''
17 @State contentDetailData: ContentDetailDTO = {} as ContentDetailDTO 18 @State contentDetailData: ContentDetailDTO = {} as ContentDetailDTO
18 @State newsStatusOfUser: batchLikeAndCollectResult = {} as batchLikeAndCollectResult// 点赞、收藏状态 19 @State newsStatusOfUser: batchLikeAndCollectResult = {} as batchLikeAndCollectResult// 点赞、收藏状态
  20 + @State likeBean: Record<string, string> = {}
  21 + async aboutToAppear() {
  22 + await this.getContentDetailData()
  23 + // 点赞需要数据
  24 + this.likeBean['contentId'] = this.contentDetailData.newsId + ''
  25 + this.likeBean['userName'] = this.contentDetailData.userInfo?.userName + ''
  26 + this.likeBean['contentType'] = this.contentDetailData.newsType + ''
  27 + this.likeBean['title'] = this.contentDetailData.newsTitle + ''
  28 + this.likeBean['userHeaderUrl'] = this.contentDetailData.userInfo?.headPhotoUrl + ''
  29 + this.likeBean['channelId'] = this.contentDetailData.reLInfo?.channelId + ''
  30 + }
19 build() { 31 build() {
20 Row(){ 32 Row(){
21 Row(){ 33 Row(){
@@ -29,7 +41,7 @@ export struct CarderInteraction { @@ -29,7 +41,7 @@ export struct CarderInteraction {
29 } 41 }
30 .justifyContent(FlexAlign.Center) 42 .justifyContent(FlexAlign.Center)
31 .onClick(()=>{ 43 .onClick(()=>{
32 - this.getContentDetailData() 44 + WDShare.shareContent(this.contentDetailData)
33 }) 45 })
34 Row(){ 46 Row(){
35 Image($r('app.media.CarderInteraction_comment')) 47 Image($r('app.media.CarderInteraction_comment'))
@@ -44,20 +56,7 @@ export struct CarderInteraction { @@ -44,20 +56,7 @@ export struct CarderInteraction {
44 .onClick(()=>{ 56 .onClick(()=>{
45 ProcessUtils.processPage(this.contentDTO) 57 ProcessUtils.processPage(this.contentDTO)
46 }) 58 })
47 - Row(){  
48 - Image($r('app.media.CarderInteraction_like'))  
49 - .width(18)  
50 - .height(18)  
51 - Text('点赞')  
52 - .margin({left:4})  
53 - .fontSize(14)  
54 - .fontColor('#666666')  
55 - }  
56 - .justifyContent(FlexAlign.Center)  
57 - .onClick(()=>{  
58 - ProcessUtils.processPage(this.contentDTO)  
59 - // ToastUtils.showToast('点赞为公共方法,待开发', 1000)  
60 - }) 59 + this.builderLike()
61 } 60 }
62 .width('100%') 61 .width('100%')
63 .margin({top:11}) 62 .margin({top:11})
@@ -69,6 +68,22 @@ export struct CarderInteraction { @@ -69,6 +68,22 @@ export struct CarderInteraction {
69 .alignItems(VerticalAlign.Center) 68 .alignItems(VerticalAlign.Center)
70 } 69 }
71 /** 70 /**
  71 + * 点赞组件
  72 + */
  73 + @Builder
  74 + builderLike() {
  75 + Row(){
  76 + if (this.likeBean?.contentId) {
  77 + LikeComponent({
  78 + data: this.likeBean,
  79 + componentType: 3
  80 + })
  81 + }
  82 + }
  83 + .width(42)
  84 + }
  85 +
  86 + /**
72 * 请求(动态)详情页数据 87 * 请求(动态)详情页数据
73 * */ 88 * */
74 private async getContentDetailData() { 89 private async getContentDetailData() {
@@ -76,36 +91,9 @@ export struct CarderInteraction { @@ -76,36 +91,9 @@ export struct CarderInteraction {
76 let data = await MultiPictureDetailViewModel.getDetailData(this.contentDTO.relId, this.contentDTO.objectId, this.contentDTO.relType) 91 let data = await MultiPictureDetailViewModel.getDetailData(this.contentDTO.relId, this.contentDTO.objectId, this.contentDTO.relType)
77 this.contentDetailData = data[0]; 92 this.contentDetailData = data[0];
78 console.log('动态详情',JSON.stringify(this.contentDetailData)) 93 console.log('动态详情',JSON.stringify(this.contentDetailData))
79 - WDShare.shareContent(this.contentDetailData)  
80 } catch (exception) { 94 } catch (exception) {
81 console.log('请求失败',JSON.stringify(exception)) 95 console.log('请求失败',JSON.stringify(exception))
82 } 96 }
83 - this.getInteractDataStatus()  
84 - }  
85 - // 已登录->查询用户对作品点赞、收藏状态  
86 - private async getInteractDataStatus() {  
87 - // 未登录,跳转登录  
88 - const user_id = await SPHelper.default.get(SpConstants.USER_ID, '')  
89 - if (!user_id) {  
90 - return  
91 - }  
92 - try {  
93 - const params: batchLikeAndCollectParams = {  
94 - contentList: [  
95 - {  
96 - contentId: this.contentDetailData?.newsId + '',  
97 - contentType: this.contentDetailData?.newsType + '',  
98 - }  
99 - ]  
100 - }  
101 - console.error(TAG, JSON.stringify(this.contentDetailData))  
102 - let data = await MultiPictureDetailViewModel.getInteractDataStatus(params)  
103 - console.error(TAG, '查询用户对作品点赞、收藏状态', JSON.stringify(data))  
104 - this.newsStatusOfUser = data[0];  
105 - Logger.info(TAG, `newsStatusOfUser:${JSON.stringify(this.newsStatusOfUser)}`)  
106 - } catch (exception) {  
107 - console.error(TAG, JSON.stringify(exception))  
108 - }  
109 } 97 }
110 98
111 } 99 }
@@ -259,10 +259,11 @@ export struct MineSettingComponent { @@ -259,10 +259,11 @@ export struct MineSettingComponent {
259 Text((item.itemType=='clear_cache') ? this.cacheSize.toFixed(2) + 'M' : '') 259 Text((item.itemType=='clear_cache') ? this.cacheSize.toFixed(2) + 'M' : '')
260 .fontColor('#999999') 260 .fontColor('#999999')
261 .maxLines(1) 261 .maxLines(1)
262 - Image($r('app.media.mine_user_arrow')) 262 + Image($r('app.media.mine_user_arrow_2'))
263 .width('27lpx') 263 .width('27lpx')
264 .height('27lpx') 264 .height('27lpx')
265 .objectFit(ImageFit.Auto) 265 .objectFit(ImageFit.Auto)
  266 + .interpolation(ImageInterpolation.High)
266 Column().width('29lpx') 267 Column().width('29lpx')
267 }.width('40%') 268 }.width('40%')
268 .margin({ right: '29lpx' }) 269 .margin({ right: '29lpx' })
@@ -13,7 +13,7 @@ export struct LikeComponent { @@ -13,7 +13,7 @@ export struct LikeComponent {
13 viewModel: LikeViewModel = new LikeViewModel() 13 viewModel: LikeViewModel = new LikeViewModel()
14 @Prop data: Record<string, string> 14 @Prop data: Record<string, string>
15 enableBtn = true 15 enableBtn = true
16 - componentType : number = 1 //1: 底部栏目样式 2: 新闻页中间位置样式 16 + componentType : number = 1 //1: 底部栏目样式 2: 新闻页中间位置样式 3:动态Tab内容下的互动入口
17 styleType : number = 1 //1: 白色背景(图文底部栏) 2: 黑色背景(图集底部栏) 17 styleType : number = 1 //1: 白色背景(图文底部栏) 2: 黑色背景(图集底部栏)
18 @State likeCount: number = 0 //点赞数 18 @State likeCount: number = 0 //点赞数
19 19
@@ -69,17 +69,27 @@ export struct LikeComponent { @@ -69,17 +69,27 @@ export struct LikeComponent {
69 .borderRadius(20) 69 .borderRadius(20)
70 .borderWidth(1) 70 .borderWidth(1)
71 .onClick(()=>{ 71 .onClick(()=>{
72 -  
73 this.clickButtonEvent() 72 this.clickButtonEvent()
74 -  
75 }) 73 })
76 -  
77 } 74 }
78 .width(154) 75 .width(154)
79 .height(40) 76 .height(40)
80 -  
81 -  
82 - }else { 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') :
  80 + $r('app.media.icon_like_default_white'))
  81 + .width(18)
  82 + .height(18)
  83 + Text(this.likeCount >0?this.likeCount.toString(): '点赞')
  84 + .margin({left:4})
  85 + .fontSize(14)
  86 + .fontColor(this.likeStatus ? '#ED2800' : '#666666')
  87 + }
  88 + .justifyContent(FlexAlign.Center)
  89 + .onClick(() => {
  90 + this.clickButtonEvent()
  91 + })
  92 + }else{
83 //1: 底部栏目样式 默认样式 93 //1: 底部栏目样式 默认样式
84 Column() { 94 Column() {
85 // Image(this.likeStatus ? $r('app.media.icon_like_select') : $r('app.media.icon_like_default')) 95 // Image(this.likeStatus ? $r('app.media.icon_like_select') : $r('app.media.icon_like_default'))