Merge branch 'main' of http://192.168.1.42/developOne/harmonyPool into main
* 'main' of http://192.168.1.42/developOne/harmonyPool: 多图(图集)详情页(人民号)关注增加部分代码 多图(图集)详情页点赞、收藏联调完成 卡片组件样式优化 多图(图集)详情页评论、点赞调接口中 切换至现网环境 音乐详情-切换页面后释放音乐
Showing
18 changed files
with
748 additions
and
95 deletions
| @@ -32,4 +32,6 @@ export { SystemUtils } from './src/main/ets/utils/SystemUtils' | @@ -32,4 +32,6 @@ export { SystemUtils } from './src/main/ets/utils/SystemUtils' | ||
| 32 | 32 | ||
| 33 | export { PermissionUtil } from './src/main/ets/utils/PermissionUtil' | 33 | export { PermissionUtil } from './src/main/ets/utils/PermissionUtil' |
| 34 | 34 | ||
| 35 | -export { UserDataLocal } from './src/main/ets/utils/UserDataLocal' | ||
| 35 | +export { UserDataLocal } from './src/main/ets/utils/UserDataLocal' | ||
| 36 | + | ||
| 37 | +export { NumberFormatterUtils } from './src/main/ets/utils/NumberFormatterUtils' |
| 1 | + | ||
| 2 | +export class NumberFormatterUtils { | ||
| 3 | + | ||
| 4 | + /** | ||
| 5 | + * 数据小于一万返回原数据,大于一万保留小数点后一位,加上万字 | ||
| 6 | + * @param num | ||
| 7 | + * @returns | ||
| 8 | + */ | ||
| 9 | + static formatNumberWithWan(inputNumber: number | String): string { | ||
| 10 | + const num = typeof inputNumber === 'number' ? inputNumber : Number(inputNumber); | ||
| 11 | + if (isNaN(num) || num < 10000) { | ||
| 12 | + return num.toString(); | ||
| 13 | + } else { | ||
| 14 | + const wanUnit = num / 10000; | ||
| 15 | + return `${wanUnit.toFixed(1)}万`; | ||
| 16 | + } | ||
| 17 | + } | ||
| 18 | +} |
| @@ -179,7 +179,7 @@ export class HttpUrlUtils { | @@ -179,7 +179,7 @@ export class HttpUrlUtils { | ||
| 179 | * */ | 179 | * */ |
| 180 | static readonly MORNING_EVENING_PAGE_INFO_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/pageInfo"; | 180 | static readonly MORNING_EVENING_PAGE_INFO_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/pageInfo"; |
| 181 | static readonly MORNING_EVENING_COMP_INFO_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/compInfo"; | 181 | static readonly MORNING_EVENING_COMP_INFO_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/compInfo"; |
| 182 | - private static _hostUrl: string = HttpUrlUtils.HOST_UAT; | 182 | + private static _hostUrl: string = HttpUrlUtils.HOST_PRODUCT; |
| 183 | 183 | ||
| 184 | public static set hostUrl(value: string) { | 184 | public static set hostUrl(value: string) { |
| 185 | HttpUrlUtils._hostUrl = value; | 185 | HttpUrlUtils._hostUrl = value; |
| @@ -23,7 +23,19 @@ export { Pic } from './src/main/ets/bean/content/Pic' | @@ -23,7 +23,19 @@ export { Pic } from './src/main/ets/bean/content/Pic' | ||
| 23 | 23 | ||
| 24 | export { InteractDataDTO } from './src/main/ets/bean/content/InteractDataDTO'; | 24 | export { InteractDataDTO } from './src/main/ets/bean/content/InteractDataDTO'; |
| 25 | 25 | ||
| 26 | -export { InteractDataStatusBean, PhotoListBean, InputMethodProperty } from './src/main/ets/bean/detail/MultiPictureDetailPageDTO'; | 26 | +export { |
| 27 | + PhotoListBean, | ||
| 28 | + InputMethodProperty, | ||
| 29 | + batchLikeAndCollectParams, | ||
| 30 | + postBatchAttentionStatusParams, | ||
| 31 | + postInteractBrowsOperateParams, | ||
| 32 | + postBatchAttentionStatusResult, | ||
| 33 | + batchLikeAndCollectResult, | ||
| 34 | + postExecuteLikeParams, | ||
| 35 | + postExecuteCollectRecordParams, | ||
| 36 | + contentListParams, | ||
| 37 | + postInteractAccentionOperateParams | ||
| 38 | +} from './src/main/ets/bean/detail/MultiPictureDetailPageDTO'; | ||
| 27 | 39 | ||
| 28 | export { InteractParam, ContentBean } from './src/main/ets/bean/content/InteractParam'; | 40 | export { InteractParam, ContentBean } from './src/main/ets/bean/content/InteractParam'; |
| 29 | 41 |
| @@ -2,11 +2,11 @@ | @@ -2,11 +2,11 @@ | ||
| 2 | * 批查接口查询互动相关数据,返回数据bean | 2 | * 批查接口查询互动相关数据,返回数据bean |
| 3 | */ | 3 | */ |
| 4 | export interface InteractDataDTO { | 4 | export interface InteractDataDTO { |
| 5 | - collectNum: number; | ||
| 6 | - commentNum: number; | 5 | + collectNum: number | String; |
| 6 | + commentNum: number | String; | ||
| 7 | contentId: string; | 7 | contentId: string; |
| 8 | contentType: number; | 8 | contentType: number; |
| 9 | - likeNum: number; | 9 | + likeNum: number | String; |
| 10 | readNum: number; | 10 | readNum: number; |
| 11 | shareNum: number; | 11 | shareNum: number; |
| 12 | } | 12 | } |
| 1 | /* | 1 | /* |
| 2 | * 多图(图集)详情 | 2 | * 多图(图集)详情 |
| 3 | * */ | 3 | * */ |
| 4 | -// 批量查询内容当前用户点赞、收藏状态 | ||
| 5 | -export interface InteractDataStatusBean { | ||
| 6 | - contentId: string; | ||
| 7 | - contentType: number; | ||
| 8 | - contentRelId: string; | ||
| 9 | - relType: number; | ||
| 10 | - likeStatus: number; | ||
| 11 | - collectStatus: number; | ||
| 12 | -} | ||
| 13 | 4 | ||
| 14 | // 【图文、图集稿件正文图片】图片信息数组 | 5 | // 【图文、图集稿件正文图片】图片信息数组 |
| 15 | export interface PhotoListBean { | 6 | export interface PhotoListBean { |
| @@ -97,4 +88,93 @@ export interface InputMethodProperty { | @@ -97,4 +88,93 @@ export interface InputMethodProperty { | ||
| 97 | * @since 10 | 88 | * @since 10 |
| 98 | */ | 89 | */ |
| 99 | extra?: object; | 90 | extra?: object; |
| 91 | +} | ||
| 92 | + | ||
| 93 | +export interface IStatusContentList { | ||
| 94 | + contentId: string; | ||
| 95 | + | ||
| 96 | + // relType: string; | ||
| 97 | + contentType: string; | ||
| 98 | + // contentRelId: string; | ||
| 99 | +} | ||
| 100 | +export interface batchLikeAndCollectParams { | ||
| 101 | + // userType: number; | ||
| 102 | + // userId: string; | ||
| 103 | + contentList: IStatusContentList[] | ||
| 104 | +} | ||
| 105 | + | ||
| 106 | +export interface postBatchAttentionStatusParamsItem { | ||
| 107 | + creatorId: string; | ||
| 108 | +} | ||
| 109 | + | ||
| 110 | +export interface postBatchAttentionStatusParams { | ||
| 111 | + creatorIds: postBatchAttentionStatusParamsItem[] | ||
| 112 | +} | ||
| 113 | + | ||
| 114 | +export interface postInteractBrowsOperateParamsContent { | ||
| 115 | + browseTime: string; | ||
| 116 | + contentId: string; | ||
| 117 | + contentType: number; | ||
| 118 | +} | ||
| 119 | + | ||
| 120 | +export interface postInteractBrowsOperateParams { | ||
| 121 | + delStatus: number; | ||
| 122 | + contentList: postInteractBrowsOperateParamsContent[] | ||
| 123 | +} | ||
| 124 | + | ||
| 125 | +export interface postBatchAttentionStatusResult { | ||
| 126 | + creatorId: string; | ||
| 127 | + status: string; | ||
| 128 | + userId: string; | ||
| 129 | +} | ||
| 130 | + | ||
| 131 | +export interface batchLikeAndCollectResult { | ||
| 132 | + collectStatus: number; | ||
| 133 | + contentType: string; | ||
| 134 | + likeStatus: string; | ||
| 135 | + relType: string; | ||
| 136 | + contentId: string; | ||
| 137 | + contentRelId: string; | ||
| 138 | +} | ||
| 139 | + | ||
| 140 | +export interface postExecuteLikeParams { | ||
| 141 | + status: string; | ||
| 142 | + contentId: string; | ||
| 143 | + contentType: string; | ||
| 144 | + relType?: string; | ||
| 145 | + userName?: string; | ||
| 146 | + title?: string; | ||
| 147 | + contentRelId?: string; | ||
| 148 | + userHeaderUrl?: string; | ||
| 149 | + channelId?: string; | ||
| 150 | +} | ||
| 151 | +export interface postExecuteCollectRecordParamsItem { | ||
| 152 | + contentId: string; | ||
| 153 | + contentType: string; | ||
| 154 | + relType?: string; | ||
| 155 | + contentRelId?: string; | ||
| 156 | +} | ||
| 157 | + | ||
| 158 | +export interface postExecuteCollectRecordParams { | ||
| 159 | + status: string; | ||
| 160 | + contentList: postExecuteCollectRecordParamsItem[] | ||
| 161 | +} | ||
| 162 | + | ||
| 163 | +interface contentListItem { | ||
| 164 | + contentId: string; | ||
| 165 | + contentType: number; | ||
| 166 | +} | ||
| 167 | + | ||
| 168 | +export interface contentListParams { | ||
| 169 | + contentList: contentListItem[]; | ||
| 170 | +} | ||
| 171 | + | ||
| 172 | +export interface postInteractAccentionOperateParams { | ||
| 173 | + attentionUserType: string; | ||
| 174 | + attentionUserId: string; | ||
| 175 | + attentionCreatorId: string; | ||
| 176 | + | ||
| 177 | + // userType: number; | ||
| 178 | + // userId: string; | ||
| 179 | + status: number; | ||
| 100 | } | 180 | } |
| @@ -47,6 +47,9 @@ export struct AudioDetailComponent { | @@ -47,6 +47,9 @@ export struct AudioDetailComponent { | ||
| 47 | this.duration = totalSeconds | 47 | this.duration = totalSeconds |
| 48 | } | 48 | } |
| 49 | } | 49 | } |
| 50 | + onPageHide() { | ||
| 51 | + this.playerController?.pause(); | ||
| 52 | + } | ||
| 50 | build() { | 53 | build() { |
| 51 | Row() { | 54 | Row() { |
| 52 | Column() { | 55 | Column() { |
| 1 | import { Logger } from 'wdKit'; | 1 | import { Logger } from 'wdKit'; |
| 2 | -import { ContentDetailDTO, PhotoListBean } from 'wdBean'; | 2 | +import { |
| 3 | + ContentDetailDTO, | ||
| 4 | + PhotoListBean, | ||
| 5 | + postInteractBrowsOperateParams, | ||
| 6 | + postBatchAttentionStatusParams, | ||
| 7 | + postInteractAccentionOperateParams | ||
| 8 | +} from 'wdBean'; | ||
| 3 | import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel'; | 9 | import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel'; |
| 4 | import display from '@ohos.display'; | 10 | import display from '@ohos.display'; |
| 5 | import font from '@ohos.font'; | 11 | import font from '@ohos.font'; |
| 6 | import { OperRowListView } from './view/OperRowListView'; | 12 | import { OperRowListView } from './view/OperRowListView'; |
| 7 | import { MultiPictureDetailItemComponent } from './MultiPictureDetailItemComponent'; | 13 | import { MultiPictureDetailItemComponent } from './MultiPictureDetailItemComponent'; |
| 14 | +import { DateTimeUtils } from 'wdKit/Index'; | ||
| 15 | +import { HttpUrlUtils } from 'wdNetwork/Index'; | ||
| 16 | +import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'; | ||
| 17 | +import { PageRepository } from '../repository/PageRepository'; | ||
| 8 | 18 | ||
| 9 | const TAG = 'MultiPictureDetailPageComponent'; | 19 | const TAG = 'MultiPictureDetailPageComponent'; |
| 10 | 20 | ||
| @@ -17,10 +27,11 @@ export struct MultiPictureDetailPageComponent { | @@ -17,10 +27,11 @@ export struct MultiPictureDetailPageComponent { | ||
| 17 | private screenWidth: number = 0 | 27 | private screenWidth: number = 0 |
| 18 | private picWidth: number = 0 | 28 | private picWidth: number = 0 |
| 19 | @State picHeight: number = 0 | 29 | @State picHeight: number = 0 |
| 20 | - @State contentDetailData: ContentDetailDTO[] = [] as ContentDetailDTO[] | 30 | + @State contentDetailData: ContentDetailDTO = {} as ContentDetailDTO |
| 21 | @Provide @Watch('onCurrentPageNumUpdated') currentPageNum: string = '01' | 31 | @Provide @Watch('onCurrentPageNumUpdated') currentPageNum: string = '01' |
| 22 | private swiperController: SwiperController = new SwiperController() | 32 | private swiperController: SwiperController = new SwiperController() |
| 23 | @State swiperIndex: number = 0; | 33 | @State swiperIndex: number = 0; |
| 34 | + @Provide followStatus: string = '0' // 关注状态 | ||
| 24 | 35 | ||
| 25 | //watch监听页码回调 | 36 | //watch监听页码回调 |
| 26 | onCurrentPageNumUpdated(): void { | 37 | onCurrentPageNumUpdated(): void { |
| @@ -43,6 +54,10 @@ export struct MultiPictureDetailPageComponent { | @@ -43,6 +54,10 @@ export struct MultiPictureDetailPageComponent { | ||
| 43 | familySrc: $rawfile('font/BebasNeue_Regular.otf') | 54 | familySrc: $rawfile('font/BebasNeue_Regular.otf') |
| 44 | }) | 55 | }) |
| 45 | this.getContentDetailData() | 56 | this.getContentDetailData() |
| 57 | + if (HttpUrlUtils.getUserId()) { | ||
| 58 | + this.getInteractBrowsOperate() | ||
| 59 | + this.getBatchAttentionStatus() | ||
| 60 | + } | ||
| 46 | } | 61 | } |
| 47 | 62 | ||
| 48 | aboutToDisappear() { | 63 | aboutToDisappear() { |
| @@ -51,10 +66,10 @@ export struct MultiPictureDetailPageComponent { | @@ -51,10 +66,10 @@ export struct MultiPictureDetailPageComponent { | ||
| 51 | 66 | ||
| 52 | build() { | 67 | build() { |
| 53 | RelativeContainer() { | 68 | RelativeContainer() { |
| 54 | - if (this.contentDetailData && this.contentDetailData.length > 0 && this.contentDetailData[0].photoList && this.contentDetailData[0].photoList?.length > 0) { | 69 | + if (this.contentDetailData?.photoList && this.contentDetailData?.photoList?.length > 0) { |
| 55 | Swiper(this.swiperController) { | 70 | Swiper(this.swiperController) { |
| 56 | - ForEach(this.contentDetailData[0].photoList, (item: PhotoListBean, index: number) => { | ||
| 57 | - MultiPictureDetailItemComponent({ photoListLength: this.contentDetailData[0].photoList?.length , index: index, newsTitle: this.contentDetailData[0].newsTitle, MultiPictureDetailItem: item }) | 71 | + ForEach(this.contentDetailData.photoList, (item: PhotoListBean, index: number) => { |
| 72 | + MultiPictureDetailItemComponent({ photoListLength: this.contentDetailData.photoList?.length , index: index, newsTitle: this.contentDetailData.newsTitle, MultiPictureDetailItem: item }) | ||
| 58 | }) | 73 | }) |
| 59 | } | 74 | } |
| 60 | .index(this.swiperIndex) | 75 | .index(this.swiperIndex) |
| @@ -73,15 +88,96 @@ export struct MultiPictureDetailPageComponent { | @@ -73,15 +88,96 @@ export struct MultiPictureDetailPageComponent { | ||
| 73 | .onChange((index: number) => { | 88 | .onChange((index: number) => { |
| 74 | this.swiperIndex = index | 89 | this.swiperIndex = index |
| 75 | }) | 90 | }) |
| 91 | + if(this.contentDetailData.rmhPlatform == 1) { | ||
| 92 | + Row() { | ||
| 93 | + Row(){ | ||
| 94 | + Row({space: 8}) { | ||
| 95 | + Image(this.contentDetailData?.rmhInfo?.rmhHeadUrl) | ||
| 96 | + .borderRadius('50%') | ||
| 97 | + .alt($r('app.media.picture_loading')) | ||
| 98 | + .width(36) | ||
| 99 | + .height(36) | ||
| 100 | + .objectFit(ImageFit.Fill) | ||
| 101 | + .interpolation(ImageInterpolation.High) | ||
| 102 | + } | ||
| 103 | + .width('13%') | ||
| 104 | + .height('100%') | ||
| 105 | + Row() { | ||
| 106 | + Flex({ | ||
| 107 | + direction: FlexDirection.Column, | ||
| 108 | + justifyContent: FlexAlign.Start | ||
| 109 | + }) { | ||
| 110 | + Text(`${this.contentDetailData?.rmhInfo?.rmhName}`) | ||
| 111 | + .fontColor(Color.White) | ||
| 112 | + .fontSize(14) | ||
| 113 | + .fontFamily('PingFang PingFang SC-Medium') | ||
| 114 | + .fontWeight(500) | ||
| 115 | + .lineHeight(17) | ||
| 116 | + .margin(0) | ||
| 117 | + Text(`${this.contentDetailData?.rmhInfo?.rmhDesc}`) | ||
| 118 | + .fontColor('#676767') | ||
| 119 | + .fontSize(12) | ||
| 120 | + .fontFamily('PingFang SC-Regular') | ||
| 121 | + .fontWeight(400) | ||
| 122 | + .lineHeight(14) | ||
| 123 | + .textOverflow({ overflow: TextOverflow.Clip }) | ||
| 124 | + .margin (0) | ||
| 125 | + } | ||
| 126 | + } | ||
| 127 | + .width('81%') | ||
| 128 | + .height('100%') | ||
| 129 | + } | ||
| 130 | + .width('74.4%') | ||
| 131 | + .height('100%') | ||
| 132 | + .margin({ | ||
| 133 | + top: 0, | ||
| 134 | + bottom: 0, | ||
| 135 | + left: 16, | ||
| 136 | + right:0 | ||
| 137 | + }) | ||
| 138 | + if(this.followStatus == '0') { | ||
| 139 | + Row(){ | ||
| 140 | + Button('+关注', { type: ButtonType.Normal, stateEffect: true }) | ||
| 141 | + .borderRadius(4) | ||
| 142 | + .backgroundColor('#ED2800') | ||
| 143 | + .width(48) | ||
| 144 | + .height(24) | ||
| 145 | + .onClick(() => { | ||
| 146 | + this.handleAccention() | ||
| 147 | + }) | ||
| 148 | + .margin({ | ||
| 149 | + top: 10, | ||
| 150 | + bottom: 10, | ||
| 151 | + left: 16, | ||
| 152 | + right:16 | ||
| 153 | + }) | ||
| 154 | + .fontSize(12) | ||
| 155 | + .fontColor(Color.White) | ||
| 156 | + } | ||
| 157 | + .width('21.6%') | ||
| 158 | + .height('100%') | ||
| 159 | + } | ||
| 160 | + } | ||
| 161 | + .width('100%') | ||
| 162 | + .height(44) | ||
| 163 | + .alignRules({ | ||
| 164 | + top: { anchor: "e_swiper_content", align: VerticalAlign.Top }, | ||
| 165 | + middle: { anchor: "e_swiper_content", align: HorizontalAlign.Center } | ||
| 166 | + }) | ||
| 167 | + .id('e_attention') | ||
| 168 | + } | ||
| 169 | + | ||
| 170 | + OperRowListView({ | ||
| 171 | + contentDetailData: this.contentDetailData, | ||
| 172 | + }) | ||
| 173 | + .alignRules({ | ||
| 174 | + bottom: { anchor: "__container__", align: VerticalAlign.Bottom }, | ||
| 175 | + middle: { anchor: "__container__", align: HorizontalAlign.Center } | ||
| 176 | + }) | ||
| 177 | + .width('100%').height(56).margin(16) | ||
| 178 | + .border({ width: {top: 0.5}, color: '#FFFFFF' }) | ||
| 179 | + .id('e_oper_row') | ||
| 76 | } | 180 | } |
| 77 | - OperRowListView() | ||
| 78 | - .alignRules({ | ||
| 79 | - bottom: { anchor: "__container__", align: VerticalAlign.Bottom }, | ||
| 80 | - middle: { anchor: "__container__", align: HorizontalAlign.Center } | ||
| 81 | - }) | ||
| 82 | - .width('100%').height(56).margin(16) | ||
| 83 | - .border({ width: {top: 0.5}, color: '#FFFFFF' }) | ||
| 84 | - .id('e_oper_row') | ||
| 85 | } | 181 | } |
| 86 | .width('100%') | 182 | .width('100%') |
| 87 | .height('100%') | 183 | .height('100%') |
| @@ -92,10 +188,70 @@ export struct MultiPictureDetailPageComponent { | @@ -92,10 +188,70 @@ export struct MultiPictureDetailPageComponent { | ||
| 92 | private async getContentDetailData() { | 188 | private async getContentDetailData() { |
| 93 | try { | 189 | try { |
| 94 | let data = await MultiPictureDetailViewModel.getDetailData(this.relId, this.contentId, this.relType) | 190 | let data = await MultiPictureDetailViewModel.getDetailData(this.relId, this.contentId, this.relType) |
| 95 | - this.contentDetailData = data; | 191 | + this.contentDetailData = data?.[0]; |
| 96 | Logger.info(TAG, `contentDetailData:${JSON.stringify(this.contentDetailData)}`) | 192 | Logger.info(TAG, `contentDetailData:${JSON.stringify(this.contentDetailData)}`) |
| 97 | } catch (exception) { | 193 | } catch (exception) { |
| 98 | 194 | ||
| 99 | } | 195 | } |
| 100 | } | 196 | } |
| 197 | + | ||
| 198 | + // 记录浏览历史 | ||
| 199 | + private getInteractBrowsOperate() { | ||
| 200 | + try { | ||
| 201 | + const params: postInteractBrowsOperateParams = { | ||
| 202 | + delStatus: 0, | ||
| 203 | + contentList: [{ | ||
| 204 | + browseTime: DateTimeUtils.getCurDate(DateTimeUtils.PATTERN_DATE_TIME_HYPHEN), | ||
| 205 | + contentId: this.contentDetailData?.newsId + '', | ||
| 206 | + contentType: this.contentDetailData?.newsType || 0, | ||
| 207 | + }] | ||
| 208 | + } | ||
| 209 | + MultiPictureDetailViewModel.getInteractBrowsOperate(params).then(res => { | ||
| 210 | + console.log(TAG, '记录浏览历史==', JSON.stringify(res.data)) | ||
| 211 | + }) | ||
| 212 | + } catch (exception) { | ||
| 213 | + | ||
| 214 | + } | ||
| 215 | + } | ||
| 216 | + | ||
| 217 | + // 已登录->批量查作品是否被号主关注 | ||
| 218 | + private async getBatchAttentionStatus() { | ||
| 219 | + try { | ||
| 220 | + const params: postBatchAttentionStatusParams = { | ||
| 221 | + creatorIds: [{ creatorId: this.contentDetailData?.rmhInfo?.rmhId ?? '' }] | ||
| 222 | + } | ||
| 223 | + let data = await MultiPictureDetailViewModel.getBatchAttentionStatus(params) | ||
| 224 | + this.followStatus = data[0]?.status; | ||
| 225 | + Logger.info(TAG, `followStatus:${JSON.stringify(this.followStatus)}`) | ||
| 226 | + } catch (exception) { | ||
| 227 | + | ||
| 228 | + } | ||
| 229 | + } | ||
| 230 | + /** | ||
| 231 | + * 关注号主 | ||
| 232 | + */ | ||
| 233 | + handleAccention() { | ||
| 234 | + // 未登录,跳转登录 | ||
| 235 | + if (!HttpUrlUtils.getUserId()) { | ||
| 236 | + WDRouterRule.jumpWithPage(WDRouterPage.loginPage) | ||
| 237 | + return | ||
| 238 | + } | ||
| 239 | + | ||
| 240 | + const params: postInteractAccentionOperateParams = { | ||
| 241 | + attentionUserType: this.contentDetailData?.rmhInfo?.userType || '', //被关注用户类型(1 普通用户 2 视频号 3 矩阵号) | ||
| 242 | + attentionUserId: this.contentDetailData?.rmhInfo?.userId || '', // 被关注用户号主id | ||
| 243 | + attentionCreatorId: this.contentDetailData?.rmhInfo?.rmhId || '', // 被关注用户号主id | ||
| 244 | + // userType: 1, | ||
| 245 | + // userId: '1', | ||
| 246 | + status: 1, | ||
| 247 | + } | ||
| 248 | + PageRepository.postInteractAccentionOperate(params).then(res => { | ||
| 249 | + console.log(TAG, '关注号主==', JSON.stringify(res.data)) | ||
| 250 | + if (this.followStatus == '1') { | ||
| 251 | + this.followStatus = '0' | ||
| 252 | + } else { | ||
| 253 | + this.followStatus = '1' | ||
| 254 | + } | ||
| 255 | + }) | ||
| 256 | + } | ||
| 101 | } | 257 | } |
| @@ -25,7 +25,7 @@ export struct CarouselLayout01CardView { | @@ -25,7 +25,7 @@ export struct CarouselLayout01CardView { | ||
| 25 | .width(CommonConstants.FULL_PARENT) | 25 | .width(CommonConstants.FULL_PARENT) |
| 26 | .height(CommonConstants.FULL_PARENT) | 26 | .height(CommonConstants.FULL_PARENT) |
| 27 | .objectFit(ImageFit.Cover) | 27 | .objectFit(ImageFit.Cover) |
| 28 | - .borderRadius($r("app.float.border_radius_6")) | 28 | + // .borderRadius($r("app.float.border_radius_6")) |
| 29 | .alignRules({ | 29 | .alignRules({ |
| 30 | top: { anchor: '__container__', align: VerticalAlign.Top }, | 30 | top: { anchor: '__container__', align: VerticalAlign.Top }, |
| 31 | left: { anchor: '__container__', align: HorizontalAlign.Start } | 31 | left: { anchor: '__container__', align: HorizontalAlign.Start } |
| @@ -45,7 +45,7 @@ export struct CarouselLayout01CardView { | @@ -45,7 +45,7 @@ export struct CarouselLayout01CardView { | ||
| 45 | // .id('img_corner_top_Left') | 45 | // .id('img_corner_top_Left') |
| 46 | // } | 46 | // } |
| 47 | 47 | ||
| 48 | - Text(this.item.title) | 48 | + Text(this.item.newsTitle) |
| 49 | .width(CommonConstants.FULL_PARENT) | 49 | .width(CommonConstants.FULL_PARENT) |
| 50 | .height(39) | 50 | .height(39) |
| 51 | .padding({ left: 8, right: 69, bottom: 8 }) | 51 | .padding({ left: 8, right: 69, bottom: 8 }) |
| @@ -49,6 +49,7 @@ export struct BannerComponent { | @@ -49,6 +49,7 @@ export struct BannerComponent { | ||
| 49 | } | 49 | } |
| 50 | .margin({ left: $r('app.float.main_margin'), right: $r('app.float.main_margin') }) | 50 | .margin({ left: $r('app.float.main_margin'), right: $r('app.float.main_margin') }) |
| 51 | .padding({ bottom: 14 }) | 51 | .padding({ bottom: 14 }) |
| 52 | + .borderRadius($r('app.float.image_border_radius')) | ||
| 52 | .displayCount(this.buildDisplayCount()) // 仅展示1个图片 | 53 | .displayCount(this.buildDisplayCount()) // 仅展示1个图片 |
| 53 | .cachedCount(2) | 54 | .cachedCount(2) |
| 54 | .index(1) // The default index of Swiper. | 55 | .index(1) // The default index of Swiper. |
| @@ -22,9 +22,18 @@ export struct CompStyle_09 { | @@ -22,9 +22,18 @@ export struct CompStyle_09 { | ||
| 22 | .margin({ bottom: 19 }) | 22 | .margin({ bottom: 19 }) |
| 23 | } | 23 | } |
| 24 | // 大图 | 24 | // 大图 |
| 25 | - Image(this.compDTO.operDataList[0].coverUrl) | ||
| 26 | - .width('100%') | ||
| 27 | - .borderRadius({topLeft: $r('app.float.image_border_radius'), topRight: $r('app.float.image_border_radius')}) | 25 | + Stack(){ |
| 26 | + Image(this.compDTO.operDataList[0].coverUrl) | ||
| 27 | + .width('100%') | ||
| 28 | + .borderRadius({topLeft: $r('app.float.image_border_radius'), topRight: $r('app.float.image_border_radius')}) | ||
| 29 | + Text('专题') | ||
| 30 | + .fontSize($r('app.float.font_size_12')) | ||
| 31 | + .padding({left: 8, right: 8, top: 3, bottom: 3}) | ||
| 32 | + .backgroundColor(Color.Red) | ||
| 33 | + .fontColor(Color.White) | ||
| 34 | + .borderRadius($r('app.float.button_border_radius')) | ||
| 35 | + .margin({left: 5, bottom: 5}) | ||
| 36 | + }.alignContent(Alignment.BottomStart) | ||
| 28 | // 时间线--后端返回三个, | 37 | // 时间线--后端返回三个, |
| 29 | Column(){ | 38 | Column(){ |
| 30 | ForEach(this.compDTO.operDataList[0].slideShows, (item:slideShows, index:number) => { | 39 | ForEach(this.compDTO.operDataList[0].slideShows, (item:slideShows, index:number) => { |
| @@ -68,20 +77,27 @@ export struct CompStyle_09 { | @@ -68,20 +77,27 @@ export struct CompStyle_09 { | ||
| 68 | Column(){ | 77 | Column(){ |
| 69 | Stack() { | 78 | Stack() { |
| 70 | if(index < this.compDTO.operDataList[0].slideShows.length - 1) { | 79 | if(index < this.compDTO.operDataList[0].slideShows.length - 1) { |
| 71 | - Line() | ||
| 72 | - .width(1) | ||
| 73 | - .startPoint([4, index > 0 ? 0 : 20]) | ||
| 74 | - .endPoint([4, 100]) | ||
| 75 | - .stroke($r('app.color.color_EDEDED')) | 80 | + Divider() |
| 81 | + .vertical(true) | ||
| 82 | + .color($r('app.color.color_EDEDED')) | ||
| 76 | .strokeWidth(1) | 83 | .strokeWidth(1) |
| 77 | - .strokeLineCap(LineCapStyle.Butt) | 84 | + .margin({top: index > 0 ? 0 : 16, left: 4}) |
| 78 | } | 85 | } |
| 86 | + if(index > 0 && index == this.compDTO.operDataList[0].slideShows.length - 1) { | ||
| 87 | + Divider() | ||
| 88 | + .vertical(true) | ||
| 89 | + .color($r('app.color.color_EDEDED')) | ||
| 90 | + .strokeWidth(1) | ||
| 91 | + .height(16) | ||
| 92 | + .margin({left: 4}) | ||
| 93 | + } | ||
| 94 | + | ||
| 79 | Column(){ | 95 | Column(){ |
| 80 | Row() { | 96 | Row() { |
| 81 | // 标题 | 97 | // 标题 |
| 82 | Image($r("app.media.point_icon")) | 98 | Image($r("app.media.point_icon")) |
| 83 | .width(9) | 99 | .width(9) |
| 84 | - .height(6) | 100 | + .height(9) |
| 85 | .margin({ right: 5 }) | 101 | .margin({ right: 5 }) |
| 86 | Text(DateTimeUtils.formatDate(item.publishTime, "MM月dd日 HH:mm")) | 102 | Text(DateTimeUtils.formatDate(item.publishTime, "MM月dd日 HH:mm")) |
| 87 | .fontSize($r('app.float.font_size_12')) | 103 | .fontSize($r('app.float.font_size_12')) |
| @@ -90,6 +106,7 @@ export struct CompStyle_09 { | @@ -90,6 +106,7 @@ export struct CompStyle_09 { | ||
| 90 | } | 106 | } |
| 91 | .width(CommonConstants.FULL_WIDTH) | 107 | .width(CommonConstants.FULL_WIDTH) |
| 92 | .height(32) | 108 | .height(32) |
| 109 | + .alignItems(VerticalAlign.Center) | ||
| 93 | Row() { | 110 | Row() { |
| 94 | Text(item.newsTitle) | 111 | Text(item.newsTitle) |
| 95 | .fontSize($r('app.float.font_size_17')) | 112 | .fontSize($r('app.float.font_size_17')) |
| @@ -109,8 +126,9 @@ export struct CompStyle_09 { | @@ -109,8 +126,9 @@ export struct CompStyle_09 { | ||
| 109 | } | 126 | } |
| 110 | } | 127 | } |
| 111 | } | 128 | } |
| 112 | - .alignContent(Alignment.Start) | 129 | + .alignContent(Alignment.TopStart) |
| 113 | } | 130 | } |
| 114 | .height(item.fullColumnImgUrls[0] && item.fullColumnImgUrls[0].url ? 100 : 78) | 131 | .height(item.fullColumnImgUrls[0] && item.fullColumnImgUrls[0].url ? 100 : 78) |
| 132 | + .alignItems(HorizontalAlign.Start) | ||
| 115 | } | 133 | } |
| 116 | } | 134 | } |
| @@ -24,12 +24,21 @@ export struct CompStyle_10 { | @@ -24,12 +24,21 @@ export struct CompStyle_10 { | ||
| 24 | .margin({ bottom: 19 }) | 24 | .margin({ bottom: 19 }) |
| 25 | } | 25 | } |
| 26 | // 大图 | 26 | // 大图 |
| 27 | - Image(this.compDTO.operDataList[0] && this.compDTO.operDataList[0].coverUrl) | ||
| 28 | - .width('100%') | ||
| 29 | - .borderRadius({topLeft: $r('app.float.image_border_radius'), topRight: $r('app.float.image_border_radius')}) | ||
| 30 | - .onClick((event: ClickEvent) => { | ||
| 31 | - ProcessUtils.processPage(this.compDTO?.operDataList[0]) | ||
| 32 | - }) | 27 | + Stack(){ |
| 28 | + Image(this.compDTO.operDataList[0] && this.compDTO.operDataList[0].coverUrl) | ||
| 29 | + .width('100%') | ||
| 30 | + .borderRadius({topLeft: $r('app.float.image_border_radius'), topRight: $r('app.float.image_border_radius')}) | ||
| 31 | + .onClick((event: ClickEvent) => { | ||
| 32 | + ProcessUtils.processPage(this.compDTO?.operDataList[0]) | ||
| 33 | + }) | ||
| 34 | + Text('专题') | ||
| 35 | + .fontSize($r('app.float.font_size_12')) | ||
| 36 | + .padding({left: 8, right: 8, top: 3, bottom: 3}) | ||
| 37 | + .backgroundColor(Color.Red) | ||
| 38 | + .fontColor(Color.White) | ||
| 39 | + .borderRadius($r('app.float.button_border_radius')) | ||
| 40 | + .margin({left: 5, bottom: 5}) | ||
| 41 | + }.alignContent(Alignment.BottomStart) | ||
| 33 | // 专题列表--后端返回三个, | 42 | // 专题列表--后端返回三个, |
| 34 | Column(){ | 43 | Column(){ |
| 35 | ForEach(this.compDTO.operDataList[0].slideShows, (item:slideShows, index:number) => { | 44 | ForEach(this.compDTO.operDataList[0].slideShows, (item:slideShows, index:number) => { |
| @@ -10,8 +10,8 @@ export struct HeadPictureCardComponent { | @@ -10,8 +10,8 @@ export struct HeadPictureCardComponent { | ||
| 10 | Stack() { | 10 | Stack() { |
| 11 | Image(this.compDTO.operDataList[0].coverUrl) | 11 | Image(this.compDTO.operDataList[0].coverUrl) |
| 12 | .width(CommonConstants.FULL_WIDTH) | 12 | .width(CommonConstants.FULL_WIDTH) |
| 13 | - .height(CommonConstants.FULL_HEIGHT) | ||
| 14 | .autoResize(true) | 13 | .autoResize(true) |
| 14 | + .borderRadius($r('app.float.image_border_radius')) | ||
| 15 | if (this.compDTO.operDataList[0].newsTitle) { | 15 | if (this.compDTO.operDataList[0].newsTitle) { |
| 16 | Row() | 16 | Row() |
| 17 | .width(CommonConstants.FULL_WIDTH) | 17 | .width(CommonConstants.FULL_WIDTH) |
| @@ -38,7 +38,6 @@ export struct HeadPictureCardComponent { | @@ -38,7 +38,6 @@ export struct HeadPictureCardComponent { | ||
| 38 | } | 38 | } |
| 39 | .alignContent(Alignment.Bottom) | 39 | .alignContent(Alignment.Bottom) |
| 40 | .width(CommonConstants.FULL_WIDTH) | 40 | .width(CommonConstants.FULL_WIDTH) |
| 41 | - .height(200) | ||
| 42 | .padding( | 41 | .padding( |
| 43 | { top: 16, bottom: 16, left: 14, right: 14 }) | 42 | { top: 16, bottom: 16, left: 14, right: 14 }) |
| 44 | .onClick((event: ClickEvent) => { | 43 | .onClick((event: ClickEvent) => { |
| 1 | -import { ToastUtils, Logger } from 'wdKit'; | ||
| 2 | -import { InputMethodProperty } from 'wdBean'; | 1 | +import { ToastUtils, Logger, NumberFormatterUtils } from 'wdKit'; |
| 2 | +import { | ||
| 3 | + InputMethodProperty, | ||
| 4 | + batchLikeAndCollectResult, | ||
| 5 | + batchLikeAndCollectParams, | ||
| 6 | + ContentDetailDTO, | ||
| 7 | + postExecuteLikeParams, | ||
| 8 | + contentListParams, | ||
| 9 | + InteractDataDTO, | ||
| 10 | + postExecuteCollectRecordParams | ||
| 11 | +} from 'wdBean'; | ||
| 3 | import router from '@ohos.router'; | 12 | import router from '@ohos.router'; |
| 4 | import inputMethod from '@ohos.inputMethod'; | 13 | import inputMethod from '@ohos.inputMethod'; |
| 14 | +import { MultiPictureDetailViewModel } from '../../viewmodel/MultiPictureDetailViewModel'; | ||
| 15 | +import { HttpUrlUtils } from 'wdNetwork/Index'; | ||
| 16 | +import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'; | ||
| 17 | +import { PageRepository } from '../../repository/PageRepository'; | ||
| 5 | 18 | ||
| 6 | export interface OperationItem { | 19 | export interface OperationItem { |
| 7 | icon: Resource; | 20 | icon: Resource; |
| 21 | + icon_check?: Resource; | ||
| 8 | text: string | Resource; | 22 | text: string | Resource; |
| 9 | num?: number; // 个数 | 23 | num?: number; // 个数 |
| 10 | } | 24 | } |
| @@ -14,19 +28,23 @@ const TAG = 'OperRowListView'; | @@ -14,19 +28,23 @@ const TAG = 'OperRowListView'; | ||
| 14 | @Preview | 28 | @Preview |
| 15 | @Component | 29 | @Component |
| 16 | export struct OperRowListView { | 30 | export struct OperRowListView { |
| 31 | + private contentDetailData: ContentDetailDTO = {} as ContentDetailDTO | ||
| 32 | + @State interactData: InteractDataDTO = {} as InteractDataDTO | ||
| 33 | + @State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态 | ||
| 34 | + | ||
| 17 | @State operationList: OperationItem[] = [ | 35 | @State operationList: OperationItem[] = [ |
| 18 | { | 36 | { |
| 19 | icon: $r('app.media.ic_comment'), | 37 | icon: $r('app.media.ic_comment'), |
| 20 | text: "评论", | 38 | text: "评论", |
| 21 | - num: 500, | ||
| 22 | }, | 39 | }, |
| 23 | { | 40 | { |
| 24 | icon: $r('app.media.ic_like_uncheck'), | 41 | icon: $r('app.media.ic_like_uncheck'), |
| 42 | + icon_check: $r('app.media.ic_like_check'), | ||
| 25 | text: "点赞", | 43 | text: "点赞", |
| 26 | - num: 6622 | ||
| 27 | }, | 44 | }, |
| 28 | { | 45 | { |
| 29 | icon: $r('app.media.ic_collect_uncheck'), | 46 | icon: $r('app.media.ic_collect_uncheck'), |
| 47 | + icon_check: $r('app.media.ic_collect_check'), | ||
| 30 | text: "收藏", | 48 | text: "收藏", |
| 31 | }, | 49 | }, |
| 32 | { | 50 | { |
| @@ -36,6 +54,10 @@ export struct OperRowListView { | @@ -36,6 +54,10 @@ export struct OperRowListView { | ||
| 36 | ] | 54 | ] |
| 37 | 55 | ||
| 38 | aboutToAppear() { | 56 | aboutToAppear() { |
| 57 | + if (HttpUrlUtils.getUserId()) { | ||
| 58 | + this.getInteractDataStatus() | ||
| 59 | + } | ||
| 60 | + this.queryContentInteractCount() | ||
| 39 | } | 61 | } |
| 40 | 62 | ||
| 41 | build() { | 63 | build() { |
| @@ -100,55 +122,166 @@ export struct OperRowListView { | @@ -100,55 +122,166 @@ export struct OperRowListView { | ||
| 100 | @Builder | 122 | @Builder |
| 101 | buildOperationItem(item: OperationItem, index: number) { | 123 | buildOperationItem(item: OperationItem, index: number) { |
| 102 | Column() { | 124 | Column() { |
| 103 | - RelativeContainer() { | ||
| 104 | - Row() { | ||
| 105 | - Image(item.icon) | ||
| 106 | - .width(24) | ||
| 107 | - .height(24) | ||
| 108 | - .aspectRatio(1) | ||
| 109 | - .interpolation(ImageInterpolation.High) | 125 | + if (item.text === '点赞') { |
| 126 | + RelativeContainer() { | ||
| 127 | + Row() { | ||
| 128 | + Image(this.newsStatusOfUser?.likeStatus == '1' ? item.icon_check : item.icon) | ||
| 129 | + .width(24) | ||
| 130 | + .height(24) | ||
| 131 | + .aspectRatio(1) | ||
| 132 | + .interpolation(ImageInterpolation.High) | ||
| 133 | + .onClick(() => { | ||
| 134 | + this.toggleLikeStatus() | ||
| 135 | + }) | ||
| 136 | + } | ||
| 137 | + .alignRules({ | ||
| 138 | + center: { anchor: '__container__', align: VerticalAlign.Center }, | ||
| 139 | + middle: { anchor: '__container__', align: HorizontalAlign.Center } | ||
| 140 | + }) | ||
| 141 | + .id(`e_row1_${index}`) | ||
| 142 | + if(this.interactData?.likeNum > 0) { | ||
| 143 | + Row() { | ||
| 144 | + Image($r('app.media.corner_mark')) | ||
| 145 | + .width(25) | ||
| 146 | + .height(12) | ||
| 147 | + .interpolation(ImageInterpolation.High) | ||
| 148 | + } | ||
| 149 | + .alignRules({ | ||
| 150 | + top: { anchor: `e_row1_${index}`, align: VerticalAlign.Top }, | ||
| 151 | + left: { anchor: `e_row1_${index}`, align: HorizontalAlign.Center } | ||
| 152 | + }) | ||
| 153 | + .id(`e_row2_${index}`) | ||
| 154 | + | ||
| 155 | + Row() { | ||
| 156 | + Text(`${this.interactData?.likeNum}`) | ||
| 157 | + .fontSize(8) | ||
| 158 | + .textAlign(TextAlign.Center) | ||
| 159 | + .fontColor(Color.White) | ||
| 160 | + .lineHeight(12) | ||
| 161 | + } | ||
| 162 | + .alignRules({ | ||
| 163 | + top: { anchor: `e_row2_${index}`, align: VerticalAlign.Top }, | ||
| 164 | + middle: { anchor: `e_row2_${index}`, align: HorizontalAlign.Center } | ||
| 165 | + }) | ||
| 166 | + .id(`e_row3_${index}`) | ||
| 167 | + } | ||
| 110 | } | 168 | } |
| 111 | - .alignRules({ | ||
| 112 | - center: { anchor: '__container__', align: VerticalAlign.Center }, | ||
| 113 | - middle: { anchor: '__container__', align: HorizontalAlign.Center } | ||
| 114 | - }) | ||
| 115 | - .id(`e_row1_${index}`) | ||
| 116 | - if(item.num) { | 169 | + .id(`e_icon_${index}`) |
| 170 | + } else if (item.text === '收藏') { | ||
| 171 | + RelativeContainer() { | ||
| 117 | Row() { | 172 | Row() { |
| 118 | - Image($r('app.media.corner_mark')) | ||
| 119 | - .width(25) | ||
| 120 | - .height(12) | 173 | + Image(this.newsStatusOfUser?.collectStatus == 1 ? item.icon_check : item.icon) |
| 174 | + .width(24) | ||
| 175 | + .height(24) | ||
| 176 | + .aspectRatio(1) | ||
| 121 | .interpolation(ImageInterpolation.High) | 177 | .interpolation(ImageInterpolation.High) |
| 178 | + .onClick(() => { | ||
| 179 | + this.toggleCollectStatus() | ||
| 180 | + }) | ||
| 122 | } | 181 | } |
| 123 | .alignRules({ | 182 | .alignRules({ |
| 124 | - top: { anchor: `e_row1_${index}`, align: VerticalAlign.Top }, | ||
| 125 | - left: { anchor: `e_row1_${index}`, align: HorizontalAlign.Center } | 183 | + center: { anchor: '__container__', align: VerticalAlign.Center }, |
| 184 | + middle: { anchor: '__container__', align: HorizontalAlign.Center } | ||
| 126 | }) | 185 | }) |
| 127 | - .id(`e_row2_${index}`) | 186 | + .id(`e_row1_${index}`) |
| 187 | + if(this.interactData?.collectNum > 0) { | ||
| 188 | + Row() { | ||
| 189 | + Image($r('app.media.corner_mark')) | ||
| 190 | + .width(25) | ||
| 191 | + .height(12) | ||
| 192 | + .interpolation(ImageInterpolation.High) | ||
| 193 | + } | ||
| 194 | + .alignRules({ | ||
| 195 | + top: { anchor: `e_row1_${index}`, align: VerticalAlign.Top }, | ||
| 196 | + left: { anchor: `e_row1_${index}`, align: HorizontalAlign.Center } | ||
| 197 | + }) | ||
| 198 | + .id(`e_row2_${index}`) | ||
| 199 | + | ||
| 200 | + Row() { | ||
| 201 | + Text(`${this.interactData?.collectNum}`) | ||
| 202 | + .fontSize(8) | ||
| 203 | + .textAlign(TextAlign.Center) | ||
| 204 | + .fontColor(Color.White) | ||
| 205 | + .lineHeight(12) | ||
| 206 | + } | ||
| 207 | + .alignRules({ | ||
| 208 | + top: { anchor: `e_row2_${index}`, align: VerticalAlign.Top }, | ||
| 209 | + middle: { anchor: `e_row2_${index}`, align: HorizontalAlign.Center } | ||
| 210 | + }) | ||
| 211 | + .id(`e_row3_${index}`) | ||
| 212 | + } | ||
| 213 | + } | ||
| 214 | + .id(`e_icon_${index}`) | ||
| 215 | + } else if (item.text === '评论') { | ||
| 216 | + RelativeContainer() { | ||
| 217 | + Row() { | ||
| 218 | + Image(item.icon) | ||
| 219 | + .width(24) | ||
| 220 | + .height(24) | ||
| 221 | + .aspectRatio(1) | ||
| 222 | + .interpolation(ImageInterpolation.High) | ||
| 223 | + .onClick((event: ClickEvent) => { | ||
| 224 | + ToastUtils.showToast('评论为公共方法,待开发', 1000); | ||
| 225 | + }) | ||
| 226 | + } | ||
| 227 | + .alignRules({ | ||
| 228 | + center: { anchor: '__container__', align: VerticalAlign.Center }, | ||
| 229 | + middle: { anchor: '__container__', align: HorizontalAlign.Center } | ||
| 230 | + }) | ||
| 231 | + .id(`e_row1_${index}`) | ||
| 232 | + if(this.interactData?.commentNum > 0) { | ||
| 233 | + Row() { | ||
| 234 | + Image($r('app.media.corner_mark')) | ||
| 235 | + .width(25) | ||
| 236 | + .height(12) | ||
| 237 | + .interpolation(ImageInterpolation.High) | ||
| 238 | + } | ||
| 239 | + .alignRules({ | ||
| 240 | + top: { anchor: `e_row1_${index}`, align: VerticalAlign.Top }, | ||
| 241 | + left: { anchor: `e_row1_${index}`, align: HorizontalAlign.Center } | ||
| 242 | + }) | ||
| 243 | + .id(`e_row2_${index}`) | ||
| 128 | 244 | ||
| 245 | + Row() { | ||
| 246 | + Text(`${this.interactData?.commentNum}`) | ||
| 247 | + .fontSize(8) | ||
| 248 | + .textAlign(TextAlign.Center) | ||
| 249 | + .fontColor(Color.White) | ||
| 250 | + .lineHeight(12) | ||
| 251 | + } | ||
| 252 | + .alignRules({ | ||
| 253 | + top: { anchor: `e_row2_${index}`, align: VerticalAlign.Top }, | ||
| 254 | + middle: { anchor: `e_row2_${index}`, align: HorizontalAlign.Center } | ||
| 255 | + }) | ||
| 256 | + .id(`e_row3_${index}`) | ||
| 257 | + } | ||
| 258 | + } | ||
| 259 | + .id(`e_icon_${index}`) | ||
| 260 | + } else { | ||
| 261 | + RelativeContainer() { | ||
| 129 | Row() { | 262 | Row() { |
| 130 | - Text('99+') | ||
| 131 | - .fontSize(8) | ||
| 132 | - .textAlign(TextAlign.Center) | ||
| 133 | - .fontColor(Color.White) | ||
| 134 | - .lineHeight(12) | 263 | + Image(item.icon) |
| 264 | + .width(24) | ||
| 265 | + .height(24) | ||
| 266 | + .aspectRatio(1) | ||
| 267 | + .interpolation(ImageInterpolation.High) | ||
| 268 | + .onClick((event: ClickEvent) => { | ||
| 269 | + ToastUtils.showToast('分享为公共方法,待开发', 1000); | ||
| 270 | + }) | ||
| 135 | } | 271 | } |
| 136 | .alignRules({ | 272 | .alignRules({ |
| 137 | - top: { anchor: `e_row2_${index}`, align: VerticalAlign.Top }, | ||
| 138 | - middle: { anchor: `e_row2_${index}`, align: HorizontalAlign.Center } | 273 | + center: { anchor: '__container__', align: VerticalAlign.Center }, |
| 274 | + middle: { anchor: '__container__', align: HorizontalAlign.Center } | ||
| 139 | }) | 275 | }) |
| 140 | - .id(`e_row3_${index}`) | 276 | + .id(`e_row1_${index}`) |
| 141 | } | 277 | } |
| 278 | + .id(`e_icon_${index}`) | ||
| 142 | } | 279 | } |
| 143 | - .id(`e_icon_${index}`) | 280 | + |
| 144 | } | 281 | } |
| 145 | .margin(5) | 282 | .margin(5) |
| 146 | .alignItems(HorizontalAlign.Center) | 283 | .alignItems(HorizontalAlign.Center) |
| 147 | .hoverEffect(HoverEffect.Scale) | 284 | .hoverEffect(HoverEffect.Scale) |
| 148 | - .onClick(() => { | ||
| 149 | - Logger.info(TAG, `buildOperationItem onClick event index: ${index}`); | ||
| 150 | - ToastUtils.showToast('体验版,本功能暂未开发', 1000); | ||
| 151 | - }) | ||
| 152 | } | 285 | } |
| 153 | 286 | ||
| 154 | /** | 287 | /** |
| @@ -180,4 +313,97 @@ export struct OperRowListView { | @@ -180,4 +313,97 @@ export struct OperRowListView { | ||
| 180 | console.error('Failed to switchInputMethod: ' + JSON.stringify(err)); | 313 | console.error('Failed to switchInputMethod: ' + JSON.stringify(err)); |
| 181 | } | 314 | } |
| 182 | } | 315 | } |
| 316 | + | ||
| 317 | + // 已登录->查询用户对作品点赞、收藏状态 | ||
| 318 | + private async getInteractDataStatus() { | ||
| 319 | + try { | ||
| 320 | + const params: batchLikeAndCollectParams = { | ||
| 321 | + contentList: [ | ||
| 322 | + { | ||
| 323 | + contentId: this.contentDetailData?.newsId + '', | ||
| 324 | + contentType: this.contentDetailData?.newsType + '', | ||
| 325 | + } | ||
| 326 | + ] | ||
| 327 | + } | ||
| 328 | + console.error(TAG, JSON.stringify(this.contentDetailData)) | ||
| 329 | + let data = await MultiPictureDetailViewModel.getInteractDataStatus(params) | ||
| 330 | + console.error(TAG, '查询用户对作品点赞、收藏状态', JSON.stringify(data)) | ||
| 331 | + this.newsStatusOfUser = data[0]; | ||
| 332 | + Logger.info(TAG, `newsStatusOfUser:${JSON.stringify(this.newsStatusOfUser)}`) | ||
| 333 | + } catch (exception) { | ||
| 334 | + console.error(TAG, JSON.stringify(exception)) | ||
| 335 | + } | ||
| 336 | + } | ||
| 337 | + | ||
| 338 | + /** | ||
| 339 | + * 点赞、取消点赞 | ||
| 340 | + */ | ||
| 341 | + toggleLikeStatus() { | ||
| 342 | + // 未登录,跳转登录 | ||
| 343 | + if (!HttpUrlUtils.getUserId()) { | ||
| 344 | + WDRouterRule.jumpWithPage(WDRouterPage.loginPage) | ||
| 345 | + return | ||
| 346 | + } | ||
| 347 | + const params: postExecuteLikeParams = { | ||
| 348 | + status: this.newsStatusOfUser?.likeStatus === '1' ? '0' : '1', | ||
| 349 | + contentId: this.contentDetailData?.newsId + '', | ||
| 350 | + contentType: this.contentDetailData?.newsType + '', | ||
| 351 | + } | ||
| 352 | + PageRepository.postExecuteLike(params).then(res => { | ||
| 353 | + console.log(TAG, '点赞、取消点赞', 'toggleLikeStatus==',) | ||
| 354 | + if (this.newsStatusOfUser) { | ||
| 355 | + this.newsStatusOfUser.likeStatus = this.newsStatusOfUser?.likeStatus === '1' ? '0' : '1' | ||
| 356 | + this.queryContentInteractCount() | ||
| 357 | + } | ||
| 358 | + | ||
| 359 | + }) | ||
| 360 | + } | ||
| 361 | + /** | ||
| 362 | + * 收藏、取消收藏 | ||
| 363 | + */ | ||
| 364 | + toggleCollectStatus() { | ||
| 365 | + // 未登录,跳转登录 | ||
| 366 | + if (!HttpUrlUtils.getUserId()) { | ||
| 367 | + WDRouterRule.jumpWithPage(WDRouterPage.loginPage) | ||
| 368 | + return | ||
| 369 | + } | ||
| 370 | + const params: postExecuteCollectRecordParams = { | ||
| 371 | + status: this.newsStatusOfUser?.collectStatus === 1 ? '0' : '1', | ||
| 372 | + contentList: [{ | ||
| 373 | + contentId: this.contentDetailData?.newsId + '', | ||
| 374 | + contentType: this.contentDetailData?.newsType + '', | ||
| 375 | + }], | ||
| 376 | + | ||
| 377 | + } | ||
| 378 | + PageRepository.postExecuteCollectRecord(params).then(res => { | ||
| 379 | + console.log(TAG, '收藏、取消收藏','toggleLikeStatus==',) | ||
| 380 | + if (this.newsStatusOfUser) { | ||
| 381 | + this.newsStatusOfUser.collectStatus = this.newsStatusOfUser?.collectStatus === 1 ? 0 : 1 | ||
| 382 | + this.queryContentInteractCount() | ||
| 383 | + } | ||
| 384 | + }) | ||
| 385 | + | ||
| 386 | + } | ||
| 387 | + | ||
| 388 | + /** | ||
| 389 | + * 查询点赞、收藏数量 | ||
| 390 | + */ | ||
| 391 | + queryContentInteractCount() { | ||
| 392 | + console.error(TAG,'contentDetailData2222', JSON.stringify(this.contentDetailData)) | ||
| 393 | + const params: contentListParams = { | ||
| 394 | + contentList: [{ | ||
| 395 | + contentId: this.contentDetailData?.newsId + '', | ||
| 396 | + contentType: this.contentDetailData?.newsType, | ||
| 397 | + }] | ||
| 398 | + } | ||
| 399 | + PageRepository.getContentInteract(params).then(res => { | ||
| 400 | + if (res.data) { | ||
| 401 | + this.interactData.likeNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.likeNum) | ||
| 402 | + this.interactData.collectNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.collectNum) | ||
| 403 | + this.interactData.commentNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.commentNum) | ||
| 404 | + } | ||
| 405 | + console.log(TAG, '获取互动点赞等数据===', JSON.stringify(res)) | ||
| 406 | + console.log(TAG, 'this.interactData', JSON.stringify(this.interactData)) | ||
| 407 | + }) | ||
| 408 | + } | ||
| 183 | } | 409 | } |
| @@ -5,13 +5,19 @@ import { | @@ -5,13 +5,19 @@ import { | ||
| 5 | CompInfoBean, | 5 | CompInfoBean, |
| 6 | ContentDetailDTO, | 6 | ContentDetailDTO, |
| 7 | InteractDataDTO, | 7 | InteractDataDTO, |
| 8 | - InteractDataStatusBean, | 8 | + batchLikeAndCollectResult, |
| 9 | MorningEveningPaperDTO, | 9 | MorningEveningPaperDTO, |
| 10 | NavigationBodyDTO, | 10 | NavigationBodyDTO, |
| 11 | NewspaperListBean, | 11 | NewspaperListBean, |
| 12 | NewspaperTimeInfoBean, | 12 | NewspaperTimeInfoBean, |
| 13 | PageDTO, | 13 | PageDTO, |
| 14 | - PageInfoBean | 14 | + PageInfoBean, |
| 15 | + postBatchAttentionStatusParams, | ||
| 16 | + postBatchAttentionStatusResult, | ||
| 17 | + postExecuteLikeParams, | ||
| 18 | + postExecuteCollectRecordParams, | ||
| 19 | + contentListParams, | ||
| 20 | + postInteractAccentionOperateParams | ||
| 15 | } from 'wdBean'; | 21 | } from 'wdBean'; |
| 16 | 22 | ||
| 17 | const TAG = 'HttpRequest'; | 23 | const TAG = 'HttpRequest'; |
| @@ -174,9 +180,41 @@ export class PageRepository { | @@ -174,9 +180,41 @@ export class PageRepository { | ||
| 174 | static fetchInteractDataStatus(param: object) { | 180 | static fetchInteractDataStatus(param: object) { |
| 175 | let url = PageRepository.getInteractDataStatusUrl() | 181 | let url = PageRepository.getInteractDataStatusUrl() |
| 176 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 182 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 177 | - return WDHttp.post<ResponseDTO<InteractDataStatusBean[]>>(url, param, headers) | 183 | + return WDHttp.post<ResponseDTO<batchLikeAndCollectResult[]>>(url, param, headers) |
| 178 | }; | 184 | }; |
| 179 | 185 | ||
| 186 | + /** | ||
| 187 | + * 用户点赞、取消点赞 | ||
| 188 | + * @param params | ||
| 189 | + * @returns | ||
| 190 | + */ | ||
| 191 | + static postExecuteLike(params: postExecuteLikeParams): Promise<ResponseDTO> { | ||
| 192 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_EXECUTELIKE | ||
| 193 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 194 | + return WDHttp.post0(url, params, headers) | ||
| 195 | + } | ||
| 196 | + | ||
| 197 | + /** | ||
| 198 | + * 用户收藏、取消收藏 | ||
| 199 | + * @param params | ||
| 200 | + * @returns | ||
| 201 | + */ | ||
| 202 | + static postExecuteCollectRecord(params: postExecuteCollectRecordParams): Promise<ResponseDTO> { | ||
| 203 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_EXECUTECOLLECTRECORD | ||
| 204 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 205 | + return WDHttp.post0(url, params, headers) | ||
| 206 | + } | ||
| 207 | + | ||
| 208 | + /** | ||
| 209 | + * | ||
| 210 | + * @returns | ||
| 211 | + */ | ||
| 212 | + static getContentInteract(params: contentListParams): Promise<ResponseDTO<InteractDataDTO[]>> { | ||
| 213 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_DATA_PATH | ||
| 214 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 215 | + return WDHttp.post0(url, params, headers) | ||
| 216 | + } | ||
| 217 | + | ||
| 180 | // 浏览历史新增、删除接口 | 218 | // 浏览历史新增、删除接口 |
| 181 | static fetchInteractBrowsOperate(param: object) { | 219 | static fetchInteractBrowsOperate(param: object) { |
| 182 | let url = PageRepository.getInteractBrowsOperateUrl() | 220 | let url = PageRepository.getInteractBrowsOperateUrl() |
| @@ -184,6 +222,25 @@ export class PageRepository { | @@ -184,6 +222,25 @@ export class PageRepository { | ||
| 184 | return WDHttp.post<ResponseDTO<null>>(url, param, headers) | 222 | return WDHttp.post<ResponseDTO<null>>(url, param, headers) |
| 185 | }; | 223 | }; |
| 186 | 224 | ||
| 225 | + /** | ||
| 226 | + * 批量查号主是否为用户关注 | ||
| 227 | + * @returns | ||
| 228 | + */ | ||
| 229 | + static fetchBatchAttentionStatus(params: postBatchAttentionStatusParams): Promise<ResponseDTO<postBatchAttentionStatusResult[]>> { | ||
| 230 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.FOLLOW_LIST_STATUS_DATA_PATH | ||
| 231 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 232 | + return WDHttp.post0(url, params, headers) | ||
| 233 | + } | ||
| 234 | + | ||
| 235 | + /** | ||
| 236 | + * 关注号主 | ||
| 237 | + */ | ||
| 238 | + static postInteractAccentionOperate(params: postInteractAccentionOperateParams): Promise<ResponseDTO> { | ||
| 239 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_ACCENTION_OPERATION | ||
| 240 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 241 | + return WDHttp.post0(url, params, headers) | ||
| 242 | + } | ||
| 243 | + | ||
| 187 | static fetchNewspaperInfo(date: string) { | 244 | static fetchNewspaperInfo(date: string) { |
| 188 | let url = PageRepository.getNewspaperInfoUrl(date) | 245 | let url = PageRepository.getNewspaperInfoUrl(date) |
| 189 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 246 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 1 | import { Logger } from 'wdKit'; | 1 | import { Logger } from 'wdKit'; |
| 2 | import { ResponseDTO } from 'wdNetwork'; | 2 | import { ResponseDTO } from 'wdNetwork'; |
| 3 | -import { ContentDetailDTO } from 'wdBean'; | 3 | +import { ContentDetailDTO, |
| 4 | + batchLikeAndCollectParams, | ||
| 5 | + batchLikeAndCollectResult, | ||
| 6 | + postBatchAttentionStatusParams, | ||
| 7 | + postBatchAttentionStatusResult, | ||
| 8 | + postInteractBrowsOperateParams | ||
| 9 | +} from 'wdBean'; | ||
| 4 | import { PageRepository } from '../repository/PageRepository'; | 10 | import { PageRepository } from '../repository/PageRepository'; |
| 5 | 11 | ||
| 6 | const TAG = 'MultiPictureDetailViewModel'; | 12 | const TAG = 'MultiPictureDetailViewModel'; |
| 7 | 13 | ||
| 8 | export class MultiPictureDetailViewModel { | 14 | export class MultiPictureDetailViewModel { |
| 9 | 15 | ||
| 10 | - /*fetchDetailData | ||
| 11 | - fetchInteractData | ||
| 12 | - fetchInteractDataStatus | ||
| 13 | - fetchInteractBrowsOperate*/ | ||
| 14 | - | ||
| 15 | static async getDetailData(relId: string, contentId: string, relType: string): Promise<ContentDetailDTO[]> { | 16 | static async getDetailData(relId: string, contentId: string, relType: string): Promise<ContentDetailDTO[]> { |
| 16 | return new Promise<ContentDetailDTO[]>((success, error) => { | 17 | return new Promise<ContentDetailDTO[]>((success, error) => { |
| 17 | Logger.info(TAG, `fetchDetailData start`); | 18 | Logger.info(TAG, `fetchDetailData start`); |
| @@ -34,4 +35,75 @@ export class MultiPictureDetailViewModel { | @@ -34,4 +35,75 @@ export class MultiPictureDetailViewModel { | ||
| 34 | }) | 35 | }) |
| 35 | }) | 36 | }) |
| 36 | } | 37 | } |
| 38 | + | ||
| 39 | + /** | ||
| 40 | + * 批量查询作品查询点赞、收藏状态 | ||
| 41 | + * @returns | ||
| 42 | + */ | ||
| 43 | + static async getInteractDataStatus(params:batchLikeAndCollectParams): Promise<batchLikeAndCollectResult[]> { | ||
| 44 | + return new Promise<batchLikeAndCollectResult[]>((success, error) => { | ||
| 45 | + Logger.info(TAG, `fetchInteractDataStatus start`); | ||
| 46 | + PageRepository.fetchInteractDataStatus(params).then((resDTO: ResponseDTO<batchLikeAndCollectResult[]>) => { | ||
| 47 | + if (!resDTO || !resDTO.data) { | ||
| 48 | + Logger.error(TAG, 'fetchInteractDataStatus is empty'); | ||
| 49 | + error('resDTO is empty'); | ||
| 50 | + return | ||
| 51 | + } | ||
| 52 | + if (resDTO.code != 0) { | ||
| 53 | + Logger.error(TAG, `fetchInteractDataStatus then code:${resDTO.code}, message:${resDTO.message}`); | ||
| 54 | + error('resDTO Response Code is failure'); | ||
| 55 | + return | ||
| 56 | + } | ||
| 57 | + Logger.info(TAG, "fetchInteractDataStatus then,navResDTO.timestamp:" + resDTO.timestamp); | ||
| 58 | + success(resDTO.data); | ||
| 59 | + }).catch((err: Error) => { | ||
| 60 | + Logger.error(TAG, `fetchInteractDataStatus catch, error.name : ${err.name}, error.message:${err.message}`); | ||
| 61 | + error(err); | ||
| 62 | + }) | ||
| 63 | + }) | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + // 已登录->批量查作品是否被号主关注 | ||
| 67 | + static async getBatchAttentionStatus(params: postBatchAttentionStatusParams): Promise<postBatchAttentionStatusResult[]> { | ||
| 68 | + return new Promise<postBatchAttentionStatusResult[]>((success, error) => { | ||
| 69 | + Logger.info(TAG, `fetchBatchAttentionStatus start`); | ||
| 70 | + PageRepository.fetchBatchAttentionStatus(params).then((resDTO: ResponseDTO<postBatchAttentionStatusResult[]>) => { | ||
| 71 | + if (!resDTO || !resDTO.data) { | ||
| 72 | + Logger.error(TAG, 'fetchBatchAttentionStatus is empty'); | ||
| 73 | + error('resDTO is empty'); | ||
| 74 | + return | ||
| 75 | + } | ||
| 76 | + if (resDTO.code != 0) { | ||
| 77 | + Logger.error(TAG, `fetchBatchAttentionStatus then code:${resDTO.code}, message:${resDTO.message}`); | ||
| 78 | + error('resDTO Response Code is failure'); | ||
| 79 | + return | ||
| 80 | + } | ||
| 81 | + Logger.info(TAG, "fetchBatchAttentionStatus then,navResDTO.timestamp:" + resDTO.timestamp); | ||
| 82 | + success(resDTO.data); | ||
| 83 | + }).catch((err: Error) => { | ||
| 84 | + Logger.error(TAG, `fetchBatchAttentionStatus catch, error.name : ${err.name}, error.message:${err.message}`); | ||
| 85 | + error(err); | ||
| 86 | + }) | ||
| 87 | + }) | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + // 记录浏览历史 | ||
| 91 | + static async getInteractBrowsOperate(params: postInteractBrowsOperateParams): Promise<ResponseDTO<null>> { | ||
| 92 | + return new Promise<ResponseDTO<null>>((success, error) => { | ||
| 93 | + Logger.info(TAG, `fetchInteractBrowsOperate start`); | ||
| 94 | + PageRepository.fetchInteractBrowsOperate(params).then((resDTO: ResponseDTO<null>) => { | ||
| 95 | + if (resDTO.code != 0) { | ||
| 96 | + Logger.error(TAG, `fetchInteractBrowsOperate then code:${resDTO.code}, message:${resDTO.message}`); | ||
| 97 | + error('resDTO Response Code is failure'); | ||
| 98 | + return | ||
| 99 | + } | ||
| 100 | + Logger.info(TAG, "fetchInteractBrowsOperate then,navResDTO.timestamp:" + resDTO.timestamp); | ||
| 101 | + success(resDTO); | ||
| 102 | + }).catch((err: Error) => { | ||
| 103 | + Logger.error(TAG, `fetchInteractBrowsOperate catch, error.name : ${err.name}, error.message:${err.message}`); | ||
| 104 | + error(err); | ||
| 105 | + }) | ||
| 106 | + }) | ||
| 107 | + } | ||
| 108 | + | ||
| 37 | } | 109 | } |
3.02 KB
-
Please register or login to post a comment