Showing
11 changed files
with
451 additions
and
69 deletions
| 1 | -import mediaquery from '@ohos.mediaquery'; | ||
| 2 | import { ContentDetailDTO, InteractDataDTO } from 'wdBean'; | 1 | import { ContentDetailDTO, InteractDataDTO } from 'wdBean'; |
| 3 | import { PlayerConstants, WDPlayerController, WDPlayerRenderView } from 'wdPlayer'; | 2 | import { PlayerConstants, WDPlayerController, WDPlayerRenderView } from 'wdPlayer'; |
| 4 | -import { ContentDetailRequest, devicePLSensorManager } from 'wdDetailPlayApi'; | ||
| 5 | -import { PlayControlViewContainer } from '../view/PlayControlViewContainer'; | ||
| 6 | -import { PlayerDetailContainer } from '../view/PlayerDetailContainer'; | ||
| 7 | -import { DetailContainer } from '../view/DetailContainer'; | 3 | +import { ContentDetailRequest } from 'wdDetailPlayApi'; |
| 8 | import { | 4 | import { |
| 9 | batchLikeAndCollectParams, | 5 | batchLikeAndCollectParams, |
| 10 | batchLikeAndCollectResult, | 6 | batchLikeAndCollectResult, |
| @@ -13,6 +9,8 @@ import { | @@ -13,6 +9,8 @@ import { | ||
| 13 | } from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest'; | 9 | } from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest'; |
| 14 | import { HttpUrlUtils } from 'wdNetwork/Index'; | 10 | import { HttpUrlUtils } from 'wdNetwork/Index'; |
| 15 | import { DateTimeUtils } from 'wdKit/Index'; | 11 | import { DateTimeUtils } from 'wdKit/Index'; |
| 12 | +import { PlayerBottomView } from '../view/PlayerBottomView'; | ||
| 13 | +import { PlayerRightView } from '../view/PlayerRightView'; | ||
| 16 | 14 | ||
| 17 | const TAG = 'DetailPlayShortVideoPage'; | 15 | const TAG = 'DetailPlayShortVideoPage'; |
| 18 | 16 | ||
| @@ -32,6 +30,7 @@ export struct DetailPlayShortVideoPage { | @@ -32,6 +30,7 @@ export struct DetailPlayShortVideoPage { | ||
| 32 | @Provide videoLandScape?: number = 1; // 视频朝向, 横屏视频:1;竖屏视频:2 | 30 | @Provide videoLandScape?: number = 1; // 视频朝向, 横屏视频:1;竖屏视频:2 |
| 33 | @Provide newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态 | 31 | @Provide newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态 |
| 34 | @Provide followStatus: string = '0' // 关注状态 | 32 | @Provide followStatus: string = '0' // 关注状态 |
| 33 | + @Provide isOpenDetail: boolean = false | ||
| 35 | @Consume @Watch('pageShowChange') pageShow: number | 34 | @Consume @Watch('pageShowChange') pageShow: number |
| 36 | @Consume @Watch('pageHideChange') pageHide: number | 35 | @Consume @Watch('pageHideChange') pageHide: number |
| 37 | 36 | ||
| @@ -45,14 +44,15 @@ export struct DetailPlayShortVideoPage { | @@ -45,14 +44,15 @@ export struct DetailPlayShortVideoPage { | ||
| 45 | pageHideChange() { | 44 | pageHideChange() { |
| 46 | if (this.currentIndex === this.index && this.playerController.getStatus() === PlayerConstants.STATUS_START) { | 45 | if (this.currentIndex === this.index && this.playerController.getStatus() === PlayerConstants.STATUS_START) { |
| 47 | this.playerController.pause() | 46 | this.playerController.pause() |
| 48 | - | ||
| 49 | } | 47 | } |
| 50 | } | 48 | } |
| 51 | 49 | ||
| 50 | + /** | ||
| 51 | + * 监听下标变化手动创建或销毁视频 | ||
| 52 | + */ | ||
| 52 | currentIndexChange() { | 53 | currentIndexChange() { |
| 53 | if (this.currentIndex != this.index) { | 54 | if (this.currentIndex != this.index) { |
| 54 | this.playerController.pause() | 55 | this.playerController.pause() |
| 55 | - | ||
| 56 | if (this.index < this.currentIndex - 3 && this.playerController.getPlayer()) { | 56 | if (this.index < this.currentIndex - 3 && this.playerController.getPlayer()) { |
| 57 | this.playerController.release() | 57 | this.playerController.release() |
| 58 | } | 58 | } |
| @@ -64,11 +64,12 @@ export struct DetailPlayShortVideoPage { | @@ -64,11 +64,12 @@ export struct DetailPlayShortVideoPage { | ||
| 64 | } else { | 64 | } else { |
| 65 | this.playerController.play() | 65 | this.playerController.play() |
| 66 | } | 66 | } |
| 67 | - | ||
| 68 | } | 67 | } |
| 69 | } | 68 | } |
| 70 | 69 | ||
| 71 | - // 查询用户点赞、收藏、关注等状态 | 70 | + /** |
| 71 | + * 查询用户点赞、收藏、关注状态、记录浏览历史 | ||
| 72 | + */ | ||
| 72 | queryNewsInfoOfUser() { | 73 | queryNewsInfoOfUser() { |
| 73 | if (HttpUrlUtils.getUserId()) { | 74 | if (HttpUrlUtils.getUserId()) { |
| 74 | const params: batchLikeAndCollectParams = { | 75 | const params: batchLikeAndCollectParams = { |
| @@ -98,7 +99,7 @@ export struct DetailPlayShortVideoPage { | @@ -98,7 +99,7 @@ export struct DetailPlayShortVideoPage { | ||
| 98 | } | 99 | } |
| 99 | }) | 100 | }) |
| 100 | 101 | ||
| 101 | - // 记录浏览历史 | 102 | + // 记录浏览历史 |
| 102 | const params2: postInteractBrowsOperateParams = { | 103 | const params2: postInteractBrowsOperateParams = { |
| 103 | delStatus: 0, | 104 | delStatus: 0, |
| 104 | contentList: [{ | 105 | contentList: [{ |
| @@ -134,19 +135,19 @@ export struct DetailPlayShortVideoPage { | @@ -134,19 +135,19 @@ export struct DetailPlayShortVideoPage { | ||
| 134 | this.playerController?.release(); | 135 | this.playerController?.release(); |
| 135 | } | 136 | } |
| 136 | 137 | ||
| 137 | - onPageShow() { | ||
| 138 | - console.log(TAG, 'onPageShow') | ||
| 139 | - this.queryNewsInfoOfUser() | ||
| 140 | - // this.playerController?.play(); | ||
| 141 | - } | ||
| 142 | - | ||
| 143 | - onPageHide() { | ||
| 144 | - console.log(TAG, 'onPageHide') | ||
| 145 | - this.playerController?.pause(); | 138 | + build() { |
| 139 | + Stack({ alignContent: Alignment.Top }) { | ||
| 140 | + this.playerViewBuilder() | ||
| 141 | + PlayerBottomView() | ||
| 142 | + PlayerRightView() | ||
| 143 | + | ||
| 144 | + } | ||
| 145 | + .height('100%') | ||
| 146 | + .width('100%') | ||
| 146 | } | 147 | } |
| 147 | 148 | ||
| 148 | @Builder | 149 | @Builder |
| 149 | - playerViewContainerBuilder() { | 150 | + playerViewBuilder() { |
| 150 | // 播放窗口 | 151 | // 播放窗口 |
| 151 | WDPlayerRenderView({ | 152 | WDPlayerRenderView({ |
| 152 | playerController: this.playerController, | 153 | playerController: this.playerController, |
| @@ -165,36 +166,4 @@ export struct DetailPlayShortVideoPage { | @@ -165,36 +166,4 @@ export struct DetailPlayShortVideoPage { | ||
| 165 | this.playerController?.switchPlayOrPause(); | 166 | this.playerController?.switchPlayOrPause(); |
| 166 | }) | 167 | }) |
| 167 | } | 168 | } |
| 168 | - | ||
| 169 | - @Builder | ||
| 170 | - playControlViewContainerBuilder() { | ||
| 171 | - // 播放窗口控制bar | ||
| 172 | - PlayControlViewContainer({ | ||
| 173 | - playerController: this.playerController | ||
| 174 | - }) | ||
| 175 | - } | ||
| 176 | - | ||
| 177 | - @Builder | ||
| 178 | - detailContainerBuilder() { | ||
| 179 | - DetailContainer({ | ||
| 180 | - playerController: this.playerController | ||
| 181 | - }) | ||
| 182 | - } | ||
| 183 | - | ||
| 184 | - build() { | ||
| 185 | - Column() { | ||
| 186 | - PlayerDetailContainer({ | ||
| 187 | - playerView: () => { | ||
| 188 | - this.playerViewContainerBuilder() | ||
| 189 | - }, playControlView: () => { | ||
| 190 | - // this.playControlViewContainerBuilder() | ||
| 191 | - }, detailView: () => { | ||
| 192 | - this.detailContainerBuilder() | ||
| 193 | - } | ||
| 194 | - }) | ||
| 195 | - } | ||
| 196 | - .height('100%') | ||
| 197 | - .width('100%') | ||
| 198 | - | ||
| 199 | - } | ||
| 200 | } | 169 | } |
| @@ -18,6 +18,7 @@ export struct DetailVideoListPage { | @@ -18,6 +18,7 @@ export struct DetailVideoListPage { | ||
| 18 | private swiperController: SwiperController = new SwiperController() | 18 | private swiperController: SwiperController = new SwiperController() |
| 19 | @Provide bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 | 19 | @Provide bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 |
| 20 | @Provide topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0 | 20 | @Provide topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0 |
| 21 | + @Provide windowWidth: number = AppStorage.get<number>('windowWidth') || 0 | ||
| 21 | @Provide showComment: boolean = true | 22 | @Provide showComment: boolean = true |
| 22 | @Provide pageShow: number = -1 | 23 | @Provide pageShow: number = -1 |
| 23 | @Provide pageHide: number = -1 | 24 | @Provide pageHide: number = -1 |
| @@ -2,11 +2,22 @@ | @@ -2,11 +2,22 @@ | ||
| 2 | @Component | 2 | @Component |
| 3 | export struct Test { | 3 | export struct Test { |
| 4 | build() { | 4 | build() { |
| 5 | - Column() { | 5 | + Stack({ alignContent: Alignment.Top }) { |
| 6 | + | ||
| 7 | + Text('视频').width('100%').height('50%').backgroundColor('#000').fontColor(Color.White) | ||
| 8 | + | ||
| 6 | Row() { | 9 | Row() { |
| 7 | - Text('111') | 10 | + Text('title') |
| 11 | + Text('contentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontent') | ||
| 8 | } | 12 | } |
| 9 | - }.width('100%') | 13 | + .backgroundColor('#ff0000') |
| 14 | + .align(Alignment.BottomStart) | ||
| 15 | + .position({ y: '100%' }) | ||
| 16 | + .markAnchor({ y: '100%' }) | ||
| 17 | + | ||
| 18 | + } | ||
| 19 | + .width(300) | ||
| 20 | + .height(600) | ||
| 10 | .backgroundColor('#cccccc') | 21 | .backgroundColor('#cccccc') |
| 11 | } | 22 | } |
| 12 | } | 23 | } |
| @@ -25,7 +25,9 @@ interface loadMoreData { | @@ -25,7 +25,9 @@ interface loadMoreData { | ||
| 25 | const TAG = 'VideoChannelDetail' | 25 | const TAG = 'VideoChannelDetail' |
| 26 | let timer: number = -1 | 26 | let timer: number = -1 |
| 27 | 27 | ||
| 28 | -@Entry | 28 | +const storage = LocalStorage.getShared(); |
| 29 | + | ||
| 30 | +@Entry(storage) | ||
| 29 | @Component | 31 | @Component |
| 30 | export struct VideoChannelDetail { | 32 | export struct VideoChannelDetail { |
| 31 | private groupId: string = '' // 楼层id | 33 | private groupId: string = '' // 楼层id |
| @@ -43,6 +45,7 @@ export struct VideoChannelDetail { | @@ -43,6 +45,7 @@ export struct VideoChannelDetail { | ||
| 43 | @Link barBackgroundColor: Color | 45 | @Link barBackgroundColor: Color |
| 44 | private swiperController: SwiperController = new SwiperController() | 46 | private swiperController: SwiperController = new SwiperController() |
| 45 | @Provide showComment: boolean = false | 47 | @Provide showComment: boolean = false |
| 48 | + @Provide windowWidth: number = AppStorage.get<number>('windowWidth') || 0 | ||
| 46 | @State data: ContentDetailDTO[] = [] | 49 | @State data: ContentDetailDTO[] = [] |
| 47 | @State currentIndex: number = 0 | 50 | @State currentIndex: number = 0 |
| 48 | @State interactDataList: InteractDataDTO[] = [] | 51 | @State interactDataList: InteractDataDTO[] = [] |
| @@ -5,7 +5,7 @@ export struct DetailDialog { | @@ -5,7 +5,7 @@ export struct DetailDialog { | ||
| 5 | @Prop name: string | 5 | @Prop name: string |
| 6 | @Prop title: string | 6 | @Prop title: string |
| 7 | @Prop summary: string | 7 | @Prop summary: string |
| 8 | - @Link isOpen: boolean | 8 | + @Link isOpenDetail: boolean |
| 9 | 9 | ||
| 10 | build() { | 10 | build() { |
| 11 | Column() { | 11 | Column() { |
| @@ -15,6 +15,7 @@ export struct DetailDialog { | @@ -15,6 +15,7 @@ export struct DetailDialog { | ||
| 15 | .fontSize(14) | 15 | .fontSize(14) |
| 16 | .fontWeight(600) | 16 | .fontWeight(600) |
| 17 | .lineHeight(17) | 17 | .lineHeight(17) |
| 18 | + .margin({ top: 8 }) | ||
| 18 | } | 19 | } |
| 19 | 20 | ||
| 20 | if (this.title) { | 21 | if (this.title) { |
| @@ -37,8 +38,8 @@ export struct DetailDialog { | @@ -37,8 +38,8 @@ export struct DetailDialog { | ||
| 37 | Image($r('app.media.ic_close')) | 38 | Image($r('app.media.ic_close')) |
| 38 | .height(24).margin({ top: 20 }).onClick(() => { | 39 | .height(24).margin({ top: 20 }).onClick(() => { |
| 39 | this.controller.close() | 40 | this.controller.close() |
| 40 | - if (this.isOpen) { | ||
| 41 | - this.isOpen = !this.isOpen | 41 | + if (this.isOpenDetail) { |
| 42 | + this.isOpenDetail = !this.isOpenDetail | ||
| 42 | } | 43 | } |
| 43 | }) | 44 | }) |
| 44 | }.width('100%').justifyContent(FlexAlign.Center) | 45 | }.width('100%').justifyContent(FlexAlign.Center) |
| 1 | import { WDPlayerController } from 'wdPlayer/Index'; | 1 | import { WDPlayerController } from 'wdPlayer/Index'; |
| 2 | import { PlayerTitleView } from './PlayerTitleView' | 2 | import { PlayerTitleView } from './PlayerTitleView' |
| 3 | +import { PlayerProgressView } from './PlayerProgressView' | ||
| 4 | +import { PlayerCommentView } from './PlayerCommentView' | ||
| 3 | 5 | ||
| 4 | @Component | 6 | @Component |
| 5 | export struct PlayerBottomView { | 7 | export struct PlayerBottomView { |
| 8 | + @Consume showComment?: boolean | ||
| 9 | + @Consume isOpenDetail?: boolean | ||
| 6 | private playerController?: WDPlayerController; | 10 | private playerController?: WDPlayerController; |
| 7 | 11 | ||
| 8 | build() { | 12 | build() { |
| 9 | Column() { | 13 | Column() { |
| 10 | PlayerTitleView() | 14 | PlayerTitleView() |
| 15 | + PlayerProgressView({ playerController: this.playerController }) | ||
| 16 | + .visibility(this.isOpenDetail ? Visibility.None : Visibility.Visible) | ||
| 17 | + if (this.showComment) { | ||
| 18 | + PlayerCommentView().visibility(this.isOpenDetail ? Visibility.None : Visibility.Visible) | ||
| 19 | + } | ||
| 11 | } | 20 | } |
| 21 | + .alignItems(HorizontalAlign.Start) | ||
| 12 | .position({ x: 0, y: '100%' }) | 22 | .position({ x: 0, y: '100%' }) |
| 13 | - | ||
| 14 | - // .markAnchor({ x: 56, y: 56 }) | 23 | + .markAnchor({ y: '100%' }) |
| 15 | } | 24 | } |
| 16 | } | 25 | } |
| 1 | +import router from '@ohos.router'; | ||
| 2 | + | ||
| 3 | +@Component | ||
| 4 | +export struct PlayerCommentView { | ||
| 5 | + @Consume showComment?: boolean | ||
| 6 | + @State comment: string = ''; | ||
| 7 | + | ||
| 8 | + build() { | ||
| 9 | + Row() { | ||
| 10 | + Image($r('app.media.ic_back')) | ||
| 11 | + .width(24) | ||
| 12 | + .height(24) | ||
| 13 | + .aspectRatio(1) | ||
| 14 | + .onClick(() => { | ||
| 15 | + router.back(); | ||
| 16 | + }) | ||
| 17 | + | ||
| 18 | + TextInput({ placeholder: '说两句...', text: this.comment }) | ||
| 19 | + .placeholderColor(Color.White) | ||
| 20 | + .placeholderFont({ size: 14 }) | ||
| 21 | + .fontColor(Color.White) | ||
| 22 | + .fontSize(14) | ||
| 23 | + .maxLines(1) | ||
| 24 | + .layoutWeight(1) | ||
| 25 | + .backgroundColor('#1a1a1a') | ||
| 26 | + .borderRadius(2) | ||
| 27 | + .height(30) | ||
| 28 | + .margin({ left: 12 }) | ||
| 29 | + } | ||
| 30 | + .backgroundColor(Color.Black) | ||
| 31 | + .alignItems(VerticalAlign.Center) | ||
| 32 | + .padding({ left: 16, right: 16, top: 11, bottom: 11 }) | ||
| 33 | + } | ||
| 34 | +} |
| 1 | +import { PlayerConstants, WDPlayerController } from 'wdPlayer/Index'; | ||
| 2 | + | ||
| 3 | +@Component | ||
| 4 | +export struct PlayerProgressView { | ||
| 5 | + private playerController?: WDPlayerController; | ||
| 6 | + @Consume progressVal: number; | ||
| 7 | + @State status: number = PlayerConstants.STATUS_START; | ||
| 8 | + | ||
| 9 | + aboutToAppear() { | ||
| 10 | + if (this.playerController) { | ||
| 11 | + this.playerController.onStatusChange = (status: number) => { | ||
| 12 | + this.status = status | ||
| 13 | + } | ||
| 14 | + } | ||
| 15 | + } | ||
| 16 | + | ||
| 17 | + build() { | ||
| 18 | + Slider({ | ||
| 19 | + value: this.progressVal, | ||
| 20 | + step: 0.01, | ||
| 21 | + // style: SliderStyle.OutSet | ||
| 22 | + }) | ||
| 23 | + .blockColor(this.status === PlayerConstants.STATUS_START ? Color.Transparent : $r('app.color.play_block_color')) | ||
| 24 | + .trackColor(this.status === PlayerConstants.STATUS_START ? $r('app.color.play_track_color') : $r('app.color.pause_track_color')) | ||
| 25 | + .selectedColor(this.status === PlayerConstants.STATUS_START ? $r('app.color.play_selected_color') : $r('app.color.pause_selected_color')) | ||
| 26 | + .trackThickness(this.status === PlayerConstants.STATUS_START ? 1 : 4) | ||
| 27 | + .blockStyle({ | ||
| 28 | + type: this.status === PlayerConstants.STATUS_START ? SliderBlockType.DEFAULT : SliderBlockType.IMAGE, | ||
| 29 | + image: $r('app.media.ic_player_block') | ||
| 30 | + }) | ||
| 31 | + .blockSize({ width: 18, height: 12 }) | ||
| 32 | + .width('100%') | ||
| 33 | + .height(19) | ||
| 34 | + .onChange((value: number, mode: SliderChangeMode) => { | ||
| 35 | + this.playerController?.setSeekTime(Math.floor(value), mode); | ||
| 36 | + }) | ||
| 37 | + } | ||
| 38 | +} |
| 1 | +import { ContentDetailDTO, InteractDataDTO, Params, RmhInfoDTO, UserInfoDTO } from 'wdBean/Index'; | ||
| 2 | +import { | ||
| 3 | + batchLikeAndCollectParams, | ||
| 4 | + batchLikeAndCollectResult, | ||
| 5 | + ContentDetailRequest, | ||
| 6 | + contentListParams, | ||
| 7 | + postExecuteCollectRecordParams, | ||
| 8 | + postExecuteLikeParams, | ||
| 9 | + postInteractAccentionOperateParams | ||
| 10 | +} from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest'; | ||
| 11 | +import { SPHelper, ToastUtils } from 'wdKit'; | ||
| 12 | +import { HttpUrlUtils } from 'wdNetwork/Index'; | ||
| 13 | +import { WDPlayerController } from 'wdPlayer/Index'; | ||
| 14 | +import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'; | ||
| 15 | +import { SpConstants } from 'wdConstant/Index' | ||
| 16 | + | ||
| 17 | +export interface OperationItem { | ||
| 18 | + icon: Resource; | ||
| 19 | + icon_check?: Resource; | ||
| 20 | + | ||
| 21 | + // icon_selected: Resource; | ||
| 22 | + text: string | Resource; | ||
| 23 | + num?: number; // 个数 | ||
| 24 | +} | ||
| 25 | + | ||
| 26 | +const TAG = 'PlayerRightView'; | ||
| 27 | + | ||
| 1 | @Component | 28 | @Component |
| 2 | export struct PlayerRightView { | 29 | export struct PlayerRightView { |
| 30 | + private playerController?: WDPlayerController; | ||
| 31 | + @Consume interactData: InteractDataDTO | ||
| 32 | + @Consume contentDetailData: ContentDetailDTO | ||
| 33 | + @Consume newsStatusOfUser: batchLikeAndCollectResult | ||
| 34 | + @Consume followStatus: string | ||
| 35 | + @Consume isOpenDetail: boolean | ||
| 36 | + @State operationList: OperationItem[] = [ | ||
| 37 | + { | ||
| 38 | + icon: $r('app.media.ic_like_uncheck'), | ||
| 39 | + icon_check: $r('app.media.ic_like_check'), | ||
| 40 | + text: "赞", | ||
| 41 | + // num: 6622 | ||
| 42 | + }, | ||
| 43 | + { | ||
| 44 | + icon: $r('app.media.ic_collect_uncheck'), | ||
| 45 | + icon_check: $r('app.media.ic_collect_check'), | ||
| 46 | + text: "收藏", | ||
| 47 | + // num: 662, | ||
| 48 | + }, | ||
| 49 | + { | ||
| 50 | + icon: $r('app.media.ic_comment'), | ||
| 51 | + text: "抢首评", | ||
| 52 | + // num: 500, | ||
| 53 | + }, | ||
| 54 | + { | ||
| 55 | + icon: $r('app.media.ic_share'), | ||
| 56 | + text: "分享" | ||
| 57 | + } | ||
| 58 | + ] | ||
| 59 | + | ||
| 60 | + aboutToAppear() { | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + /** | ||
| 64 | + * 点赞、取消点赞 | ||
| 65 | + */ | ||
| 66 | + async toggleLikeStatus() { | ||
| 67 | + // 未登录,跳转登录 | ||
| 68 | + const user_id = await SPHelper.default.get(SpConstants.USER_ID, '') | ||
| 69 | + if (!user_id) { | ||
| 70 | + this.playerController?.pause() | ||
| 71 | + WDRouterRule.jumpWithPage(WDRouterPage.loginPage) | ||
| 72 | + return | ||
| 73 | + } | ||
| 74 | + const params: postExecuteLikeParams = { | ||
| 75 | + status: this.newsStatusOfUser?.likeStatus === '1' ? '0' : '1', | ||
| 76 | + contentId: this.contentDetailData?.newsId + '', | ||
| 77 | + contentType: this.contentDetailData?.newsType + '', | ||
| 78 | + } | ||
| 79 | + ContentDetailRequest.postExecuteLike(params).then(res => { | ||
| 80 | + | ||
| 81 | + if (this.newsStatusOfUser) { | ||
| 82 | + this.newsStatusOfUser.likeStatus = this.newsStatusOfUser?.likeStatus === '1' ? '0' : '1' | ||
| 83 | + if (this.newsStatusOfUser.likeStatus === '1') { | ||
| 84 | + this.interactData.likeNum = Number(this.interactData.likeNum) + 1 | ||
| 85 | + } else { | ||
| 86 | + this.interactData.likeNum = Number(this.interactData.likeNum) - 1 | ||
| 87 | + } | ||
| 88 | + console.log('点赞、取消点赞==', this.newsStatusOfUser?.likeStatus, this.interactData?.likeNum) | ||
| 89 | + // this.queryContentInteractCount() | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + }) | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + /** | ||
| 96 | + * 收藏、取消收藏 | ||
| 97 | + */ | ||
| 98 | + async toggleCollectStatus() { | ||
| 99 | + // 未登录,跳转登录 | ||
| 100 | + const user_id = await SPHelper.default.get(SpConstants.USER_ID, '') | ||
| 101 | + if (!user_id) { | ||
| 102 | + WDRouterRule.jumpWithPage(WDRouterPage.loginPage) | ||
| 103 | + return | ||
| 104 | + } | ||
| 105 | + const params: postExecuteCollectRecordParams = { | ||
| 106 | + status: this.newsStatusOfUser?.collectStatus === 1 ? '0' : '1', | ||
| 107 | + contentList: [{ | ||
| 108 | + contentId: this.contentDetailData?.newsId + '', | ||
| 109 | + contentType: this.contentDetailData?.newsType + '', | ||
| 110 | + }], | ||
| 111 | + | ||
| 112 | + } | ||
| 113 | + ContentDetailRequest.postExecuteCollectRecord(params).then(res => { | ||
| 114 | + if (this.newsStatusOfUser) { | ||
| 115 | + this.newsStatusOfUser.collectStatus = this.newsStatusOfUser?.collectStatus === 1 ? 0 : 1 | ||
| 116 | + // this.queryContentInteractCount() | ||
| 117 | + if (this.newsStatusOfUser.collectStatus === 1) { | ||
| 118 | + this.interactData.collectNum = Number(this.interactData.collectNum) + 1 | ||
| 119 | + } else { | ||
| 120 | + this.interactData.collectNum = Number(this.interactData.collectNum) - 1 | ||
| 121 | + } | ||
| 122 | + console.log('收藏、取消收藏==', this.newsStatusOfUser?.collectStatus, this.interactData?.collectNum) | ||
| 123 | + } | ||
| 124 | + }) | ||
| 125 | + | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + /** | ||
| 129 | + * 查询点赞、收藏数量 | ||
| 130 | + */ | ||
| 131 | + queryContentInteractCount() { | ||
| 132 | + const params: contentListParams = { | ||
| 133 | + contentList: [{ | ||
| 134 | + contentId: this.contentDetailData?.newsId + '', | ||
| 135 | + contentType: this.contentDetailData?.newsType, | ||
| 136 | + }] | ||
| 137 | + } | ||
| 138 | + ContentDetailRequest.getContentInteract(params).then(res => { | ||
| 139 | + if (res.data && this.interactData) { | ||
| 140 | + this.interactData.likeNum = res.data[0]?.likeNum | ||
| 141 | + this.interactData.collectNum = res.data[0]?.collectNum | ||
| 142 | + this.interactData.commentNum = res.data[0]?.commentNum | ||
| 143 | + } | ||
| 144 | + console.log('获取互动点赞等数据===', JSON.stringify(res)) | ||
| 145 | + }) | ||
| 146 | + } | ||
| 147 | + | ||
| 148 | + getImgUrl() { | ||
| 149 | + return this.contentDetailData?.rmhInfo?.rmhHeadUrl || this.contentDetailData?.userInfo?.userHeadUrl | ||
| 150 | + } | ||
| 151 | + | ||
| 152 | + /** | ||
| 153 | + * 关注号主 | ||
| 154 | + */ | ||
| 155 | + async handleAccention() { | ||
| 156 | + // 未登录,跳转登录 | ||
| 157 | + const user_id = await SPHelper.default.get(SpConstants.USER_ID, '') | ||
| 158 | + if (!user_id) { | ||
| 159 | + WDRouterRule.jumpWithPage(WDRouterPage.loginPage) | ||
| 160 | + return | ||
| 161 | + } | ||
| 162 | + | ||
| 163 | + const params2: postInteractAccentionOperateParams = { | ||
| 164 | + attentionUserType: this.contentDetailData?.rmhInfo?.userType || '', //被关注用户类型(1 普通用户 2 视频号 3 矩阵号) | ||
| 165 | + attentionUserId: this.contentDetailData?.rmhInfo?.userId || '', // 被关注用户号主id | ||
| 166 | + attentionCreatorId: this.contentDetailData?.rmhInfo?.rmhId || '', // 被关注用户号主id | ||
| 167 | + // userType: 1, | ||
| 168 | + // userId: '1', | ||
| 169 | + status: 1, | ||
| 170 | + } | ||
| 171 | + ContentDetailRequest.postInteractAccentionOperate(params2).then(res => { | ||
| 172 | + console.log('关注号主==', JSON.stringify(res.data)) | ||
| 173 | + if (this.followStatus == '1') { | ||
| 174 | + this.followStatus = '0' | ||
| 175 | + } else { | ||
| 176 | + this.followStatus = '1' | ||
| 177 | + } | ||
| 178 | + }) | ||
| 179 | + } | ||
| 180 | + | ||
| 181 | + @Builder | ||
| 182 | + buildUserComp() { | ||
| 183 | + Column() { | ||
| 184 | + if (this.getImgUrl()) { | ||
| 185 | + RelativeContainer() { | ||
| 186 | + Image(this.getImgUrl()) | ||
| 187 | + .width('100%') | ||
| 188 | + .borderRadius(24) | ||
| 189 | + .aspectRatio(1) | ||
| 190 | + .border({ width: 1, color: Color.White, style: BorderStyle.Solid }) | ||
| 191 | + .alignRules({ | ||
| 192 | + top: { anchor: "__container__", align: VerticalAlign.Top }, | ||
| 193 | + left: { anchor: "__container__", align: HorizontalAlign.Start } | ||
| 194 | + }) | ||
| 195 | + .id("row1") | ||
| 196 | + .onClick(() => { | ||
| 197 | + if (this.contentDetailData.rmhInfo?.cnMainControl === 1) { | ||
| 198 | + // 号主页 | ||
| 199 | + const params: Params = { | ||
| 200 | + creatorId: this.contentDetailData.rmhInfo.rmhId, | ||
| 201 | + pageID: '' | ||
| 202 | + } | ||
| 203 | + WDRouterRule.jumpWithPage(WDRouterPage.peopleShipHomePage, params) | ||
| 204 | + } | ||
| 205 | + | ||
| 206 | + }) | ||
| 207 | + if (this.followStatus == '0') { | ||
| 208 | + Image($r('app.media.ic_add')) | ||
| 209 | + .width(24) | ||
| 210 | + .borderRadius(12) | ||
| 211 | + .alignRules({ | ||
| 212 | + left: { anchor: "__container__", align: HorizontalAlign.Center }, | ||
| 213 | + bottom: { anchor: "__container__", align: VerticalAlign.Bottom }, | ||
| 214 | + }) | ||
| 215 | + .margin({ left: -12 }) | ||
| 216 | + .id("row2") | ||
| 217 | + .onClick(() => { | ||
| 218 | + // 关注 | ||
| 219 | + this.handleAccention() | ||
| 220 | + }) | ||
| 221 | + } | ||
| 222 | + | ||
| 223 | + }.height(60) | ||
| 224 | + } | ||
| 225 | + }.margin({ bottom: 18 }) | ||
| 226 | + } | ||
| 227 | + | ||
| 228 | + @Builder | ||
| 229 | + buildOperationItem(item: OperationItem, index: number) { | ||
| 230 | + Column() { | ||
| 231 | + if (item.text === '赞') { | ||
| 232 | + Image(this.newsStatusOfUser?.likeStatus == '1' ? item.icon_check : item.icon) | ||
| 233 | + .width(32) | ||
| 234 | + .aspectRatio(1) | ||
| 235 | + .onClick(() => { | ||
| 236 | + this.toggleLikeStatus() | ||
| 237 | + }) | ||
| 238 | + Text(this.interactData?.likeNum ? (this.interactData.likeNum + '') : item.text) | ||
| 239 | + .width('100%')// .margin({ top: 4, left: 6, right: 6 })// .backgroundColor(Color.Brown) | ||
| 240 | + .fontWeight(500) | ||
| 241 | + .textAlign(TextAlign.Center) | ||
| 242 | + .fontSize(13) | ||
| 243 | + .fontColor('#FFFFFF') | ||
| 244 | + .maxLines(1) | ||
| 245 | + .textOverflow({ overflow: TextOverflow.Ellipsis }) | ||
| 246 | + } else if (item.text === '收藏') { | ||
| 247 | + Image(this.newsStatusOfUser?.collectStatus == 1 ? item.icon_check : item.icon) | ||
| 248 | + .width(32) | ||
| 249 | + .aspectRatio(1) | ||
| 250 | + .onClick(() => { | ||
| 251 | + this.toggleCollectStatus() | ||
| 252 | + }) | ||
| 253 | + Text(this.interactData?.collectNum ? (this.interactData.collectNum + '') : item.text) | ||
| 254 | + .width('100%')// .margin({ top: 4, left: 6, right: 6 })// .backgroundColor(Color.Brown) | ||
| 255 | + .fontWeight(500) | ||
| 256 | + .textAlign(TextAlign.Center) | ||
| 257 | + .fontSize(13) | ||
| 258 | + .fontColor('#FFFFFF') | ||
| 259 | + .maxLines(1) | ||
| 260 | + .textOverflow({ overflow: TextOverflow.Ellipsis }) | ||
| 261 | + } else if (item.text === '抢首评') { | ||
| 262 | + Image(item.icon) | ||
| 263 | + .width(32) | ||
| 264 | + .aspectRatio(1) | ||
| 265 | + .onClick((event: ClickEvent) => { | ||
| 266 | + ToastUtils.showToast('评论为公共方法,待开发', 1000); | ||
| 267 | + }) | ||
| 268 | + Text(this.interactData?.commentNum ? (this.interactData.commentNum + '') : item.text) | ||
| 269 | + .width('100%')// .margin({ top: 4, left: 6, right: 6 })// .backgroundColor(Color.Brown) | ||
| 270 | + .fontWeight(500) | ||
| 271 | + .textAlign(TextAlign.Center) | ||
| 272 | + .fontSize(13) | ||
| 273 | + .fontColor('#FFFFFF') | ||
| 274 | + .maxLines(1) | ||
| 275 | + .textOverflow({ overflow: TextOverflow.Ellipsis }) | ||
| 276 | + } else { | ||
| 277 | + Image(item.icon) | ||
| 278 | + .width(32) | ||
| 279 | + .aspectRatio(1) | ||
| 280 | + .onClick((event: ClickEvent) => { | ||
| 281 | + ToastUtils.showToast('分享为公共方法,待开发', 1000); | ||
| 282 | + }) | ||
| 283 | + Text(item.text) | ||
| 284 | + .width('100%')// .margin({ top: 4, left: 6, right: 6 })// .backgroundColor(Color.Brown) | ||
| 285 | + .fontWeight(500) | ||
| 286 | + .textAlign(TextAlign.Center) | ||
| 287 | + .fontSize(13) | ||
| 288 | + .fontColor('#FFFFFF') | ||
| 289 | + .maxLines(1) | ||
| 290 | + .textOverflow({ overflow: TextOverflow.Ellipsis }) | ||
| 291 | + } | ||
| 292 | + | ||
| 293 | + } | ||
| 294 | + // .width(48) | ||
| 295 | + .margin({ bottom: 20 }) | ||
| 296 | + .alignItems(HorizontalAlign.Center) | ||
| 297 | + .hoverEffect(HoverEffect.Scale) | ||
| 298 | + | ||
| 299 | + } | ||
| 300 | + | ||
| 3 | build() { | 301 | build() { |
| 302 | + Column() { | ||
| 303 | + this.buildUserComp() | ||
| 304 | + ForEach(this.operationList, (item: OperationItem, index: number) => { | ||
| 305 | + this.buildOperationItem(item, index) | ||
| 306 | + }, (item: OperationItem, index: number) => JSON.stringify(item)) | ||
| 307 | + } | ||
| 308 | + .width(48) | ||
| 309 | + .position({ x: '100%', y: '100%' }) | ||
| 310 | + .markAnchor({ x: '100%', y: '100%' }) | ||
| 311 | + .padding({ bottom: 72 }) | ||
| 312 | + .visibility(this.isOpenDetail ? Visibility.None : Visibility.Visible) | ||
| 4 | } | 313 | } |
| 5 | } | 314 | } |
| @@ -7,14 +7,15 @@ import { componentUtils } from '@kit.ArkUI' | @@ -7,14 +7,15 @@ import { componentUtils } from '@kit.ArkUI' | ||
| 7 | @Component | 7 | @Component |
| 8 | export struct PlayerTitleView { | 8 | export struct PlayerTitleView { |
| 9 | @Consume contentDetailData: ContentDetailDTO | 9 | @Consume contentDetailData: ContentDetailDTO |
| 10 | - @State isOpen: boolean = false | 10 | + @Consume windowWidth: number |
| 11 | + @Consume isOpenDetail: boolean | ||
| 11 | @State titleHeight: number = 0 | 12 | @State titleHeight: number = 0 |
| 12 | dialogController: CustomDialogController = new CustomDialogController({ | 13 | dialogController: CustomDialogController = new CustomDialogController({ |
| 13 | builder: DetailDialog({ | 14 | builder: DetailDialog({ |
| 14 | name: this.getName(), | 15 | name: this.getName(), |
| 15 | title: this.getTitle(), | 16 | title: this.getTitle(), |
| 16 | summary: this.getSummary(), | 17 | summary: this.getSummary(), |
| 17 | - isOpen: this.isOpen | 18 | + isOpenDetail: this.isOpenDetail |
| 18 | 19 | ||
| 19 | }), | 20 | }), |
| 20 | autoCancel: false, | 21 | autoCancel: false, |
| @@ -36,7 +37,7 @@ export struct PlayerTitleView { | @@ -36,7 +37,7 @@ export struct PlayerTitleView { | ||
| 36 | } | 37 | } |
| 37 | 38 | ||
| 38 | getSummary(): string { | 39 | getSummary(): string { |
| 39 | - return this.contentDetailData?.newsSummary || '' | 40 | + return this.contentDetailData?.newIntroduction || '' |
| 40 | } | 41 | } |
| 41 | 42 | ||
| 42 | aboutToAppear(): void { | 43 | aboutToAppear(): void { |
| @@ -45,10 +46,11 @@ export struct PlayerTitleView { | @@ -45,10 +46,11 @@ export struct PlayerTitleView { | ||
| 45 | fontSize: 15, | 46 | fontSize: 15, |
| 46 | fontWeight: 400, | 47 | fontWeight: 400, |
| 47 | lineHeight: 20, | 48 | lineHeight: 20, |
| 48 | - constraintWidth: 287 - 16 - 22, | 49 | + constraintWidth: this.windowWidth - 100 - 16 - 22 + 'px', |
| 49 | 50 | ||
| 50 | }) | 51 | }) |
| 51 | this.titleHeight = info?.height as number || 0 | 52 | this.titleHeight = info?.height as number || 0 |
| 53 | + console.log('titleHeight:', this.titleHeight,) | ||
| 52 | } | 54 | } |
| 53 | 55 | ||
| 54 | build() { | 56 | build() { |
| @@ -82,7 +84,7 @@ export struct PlayerTitleView { | @@ -82,7 +84,7 @@ export struct PlayerTitleView { | ||
| 82 | /** | 84 | /** |
| 83 | * 标题大于三行或存在简介显示查看详情按钮 | 85 | * 标题大于三行或存在简介显示查看详情按钮 |
| 84 | */ | 86 | */ |
| 85 | - if (this.titleHeight > 180 || this.contentDetailData?.newsSummary) { | 87 | + if (this.titleHeight > 200 || this.getSummary()) { |
| 86 | Text('查看详情 > ') | 88 | Text('查看详情 > ') |
| 87 | .padding({ left: 6, right: 6, top: 4, bottom: 4 }) | 89 | .padding({ left: 6, right: 6, top: 4, bottom: 4 }) |
| 88 | .borderRadius(2) | 90 | .borderRadius(2) |
| @@ -91,16 +93,17 @@ export struct PlayerTitleView { | @@ -91,16 +93,17 @@ export struct PlayerTitleView { | ||
| 91 | .fontSize(12) | 93 | .fontSize(12) |
| 92 | .lineHeight(14) | 94 | .lineHeight(14) |
| 93 | .fontWeight(400) | 95 | .fontWeight(400) |
| 96 | + .margin({ bottom: 8 }) | ||
| 94 | .onClick(() => { | 97 | .onClick(() => { |
| 95 | - this.isOpen = true | 98 | + this.isOpenDetail = true |
| 96 | this.dialogController?.open() | 99 | this.dialogController?.open() |
| 97 | }) | 100 | }) |
| 98 | } | 101 | } |
| 99 | 102 | ||
| 100 | } | 103 | } |
| 101 | - .backgroundColor(Color.Black) | ||
| 102 | - .width(287) | 104 | + .width(this.windowWidth - 100 + 'px') |
| 103 | .padding({ left: 16, right: 22 }) | 105 | .padding({ left: 16, right: 22 }) |
| 104 | .alignItems(HorizontalAlign.Start) | 106 | .alignItems(HorizontalAlign.Start) |
| 107 | + .visibility(this.isOpenDetail ? Visibility.None : Visibility.Visible) | ||
| 105 | } | 108 | } |
| 106 | } | 109 | } |
| @@ -59,8 +59,12 @@ export default class EntryAbility extends UIAbility { | @@ -59,8 +59,12 @@ export default class EntryAbility extends UIAbility { | ||
| 59 | const SYSTEM_AREA = windowClass.getWindowAvoidArea(TYPE_SYSTEM); | 59 | const SYSTEM_AREA = windowClass.getWindowAvoidArea(TYPE_SYSTEM); |
| 60 | const bottomSafeHeight = NAV_AREA.bottomRect.height; // 获取到导航条区域的高度 | 60 | const bottomSafeHeight = NAV_AREA.bottomRect.height; // 获取到导航条区域的高度 |
| 61 | const topSafeHeight = SYSTEM_AREA.topRect.height; // 获取到状态栏区域的高度 | 61 | const topSafeHeight = SYSTEM_AREA.topRect.height; // 获取到状态栏区域的高度 |
| 62 | + const width = windowClass.getWindowProperties().windowRect.width | ||
| 63 | + const height = windowClass.getWindowProperties().windowRect.height | ||
| 62 | AppStorage.setOrCreate('bottomSafeHeight', bottomSafeHeight); | 64 | AppStorage.setOrCreate('bottomSafeHeight', bottomSafeHeight); |
| 63 | AppStorage.setOrCreate('topSafeHeight', topSafeHeight); | 65 | AppStorage.setOrCreate('topSafeHeight', topSafeHeight); |
| 66 | + AppStorage.setOrCreate('windowWidth', width); | ||
| 67 | + AppStorage.setOrCreate('windowHeight', height); | ||
| 64 | 68 | ||
| 65 | 69 | ||
| 66 | // let a = new WindowModel(); | 70 | // let a = new WindowModel(); |
-
Please register or login to post a comment