zhenghy

评论接入(不完整),关注获取积分(不完整)

... ... @@ -5,9 +5,9 @@ import {
ContentDetailRequest,
postInteractAccentionOperateParams
} from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest';
import { postBatchAttentionStatusParams, RmhInfoDTO } from 'wdBean/Index';
import { ContentDetailDTO, Params, postBatchAttentionStatusParams, RmhInfoDTO } from 'wdBean/Index';
import { SpConstants } from 'wdConstant/Index';
import { Logger, SPHelper } from 'wdKit/Index';
import { Logger, SPHelper, ToastUtils } from 'wdKit/Index';
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
import { MultiPictureDetailViewModel } from '../../viewmodel/MultiPictureDetailViewModel';
... ... @@ -16,6 +16,8 @@ const TAG = 'LiveFollowComponent'
@Component
export struct LiveFollowComponent {
@Prop rmhInfo: RmhInfoDTO
@Consume contentDetailData: ContentDetailDTO
@Consume @Watch('getBatchAttentionStatus') pageShow: number
aboutToAppear(): void {
this.getBatchAttentionStatus()
... ... @@ -42,6 +44,16 @@ export struct LiveFollowComponent {
.width(24)
.height(24)
.borderRadius(90)
.onClick(() => {
// 跳转到号主页
if (this.contentDetailData.rmhInfo?.cnMainControl === 1) {
const params: Params = {
creatorId: this.contentDetailData.rmhInfo.rmhId,
pageID: ''
}
WDRouterRule.jumpWithPage(WDRouterPage.peopleShipHomePage, params)
}
})
Text(this.rmhInfo.rmhName)
.fontColor(Color.White)
.maxLines(1)
... ... @@ -66,6 +78,7 @@ export struct LiveFollowComponent {
.borderRadius(2)
.margin({ right: 2 })
.backgroundColor(this.followStatus === '0' ? $r('app.color.color_ED2800') : $r('app.color.color_CCCCCC'))
.visibility(this.followStatus === '0' ? Visibility.Visible : Visibility.None)
.onClick(() => {
this.handleAccention()
})
... ... @@ -114,6 +127,13 @@ export struct LiveFollowComponent {
this.followStatus = '0'
} else {
this.followStatus = '1'
// 弹窗样式与何时调用待确认
ContentDetailRequest.postPointLevelOperate({ operateType: 6 }).then((res) => {
console.log('关注号主获取积分==', JSON.stringify(res.data))
if (res.data?.showToast) {
ToastUtils.showToast(res.data.ruleName + '+' + res.data.rulePoint + '积分', 1000);
}
})
}
})
}
... ...
... ... @@ -7,6 +7,8 @@ import { ContentDetailDTO } from 'wdBean/Index'
@Preview
@Component
export struct CommentTabComponent {
private onCommentFocus: () => void = () => {
}
@ObjectLink publishCommentModel: publishCommentModel
@Prop contentDetail: ContentDetailDTO
/*展示类型*/
... ... @@ -47,6 +49,7 @@ export struct CommentTabComponent {
}
}.width(151).height(30)
.onClick(() => {
this.onCommentFocus && this.onCommentFocus()
this.publishCommentModel.rootCommentId = '-1';
this.publishCommentModel.parentId = '-1';
... ... @@ -66,7 +69,6 @@ export struct CommentIconComponent {
@ObjectLink publishCommentModel: publishCommentModel
/*展示类型*/
@State type: number = 1
// aboutToAppear(): void {
// setTimeout(() => {
// this.publishCommentModel.totalCommentNumer = '444'
... ... @@ -87,11 +89,18 @@ export struct CommentIconComponent {
Stack({ alignContent: Alignment.TopEnd }) {
Image($r('app.media.comment_icon')).width(24).height(24)
// Stack({alignContent:Alignment.Start}) {
if(Number.parseInt(this.publishCommentModel.totalCommentNumer) != 0){
if (Number.parseInt(this.publishCommentModel.totalCommentNumer) != 0) {
RelativeContainer() {
Image($r('app.media.comment_icon_number_bg'))
.objectFit(ImageFit.Fill)
.resizable({ slice: { top: 1, left: 20, right: 1, bottom: 1 } })
.resizable({
slice: {
top: 1,
left: 20,
right: 1,
bottom: 1
}
})
.alignRules({
top: { anchor: "Text", align: VerticalAlign.Top },
left: { anchor: "Text", align: HorizontalAlign.Start },
... ... @@ -113,7 +122,8 @@ export struct CommentIconComponent {
})// .margin({left: 4,right:4
// })
/*动态计算文字宽度*/
.width(this.getMeasureText(this.publishCommentModel.totalCommentNumer) + 12)// .backgroundColor(Color.Green)
.width(this.getMeasureText(this.publishCommentModel.totalCommentNumer) +
12)// .backgroundColor(Color.Green)
.id("Text")
// .offset({
// x: 3
... ...
... ... @@ -45,6 +45,8 @@ const TAG = 'OperRowListView';
export struct OperRowListView {
private onBack: () => void = () => {
}
private onCommentFocus: () => void = () => {
}
@Prop @Watch('onDetailUpdated') contentDetailData: ContentDetailDTO // 稿件详情
@State operationButtonList: string[] = ['comment', 'collect', 'share'] // 组件展示条件
@ObjectLink publishCommentModel: publishCommentModel
... ... @@ -147,8 +149,10 @@ export struct OperRowListView {
builderComment() {
Column() {
if (this.publishCommentModel?.targetId) {
CommentTabComponent({ publishCommentModel: this.publishCommentModel,
contentDetail: this.contentDetailData
CommentTabComponent({
publishCommentModel: this.publishCommentModel,
contentDetail: this.contentDetailData,
onCommentFocus: this.onCommentFocus
})
}
}
... ... @@ -184,7 +188,8 @@ export struct OperRowListView {
builderCollect() {
Column() {
Stack({ alignContent: Alignment.TopEnd }) {
Image(this.newsStatusOfUser?.collectStatus == 1 ? $r('app.media.ic_collect_check1') : $r('app.media.iv_live_comment_collect_un'))
Image(this.newsStatusOfUser?.collectStatus == 1 ? $r('app.media.ic_collect_check1') :
$r('app.media.iv_live_comment_collect_un'))
.width(24)
.height(24)
.interpolation(ImageInterpolation.High)
... ...
... ... @@ -179,6 +179,12 @@ export interface postInteractAccentionOperateParams {
status: number;
}
export interface OperateRespDTO {
ruleName: string;
rulePoint: number;
showToast: boolean;
}
export class ContentDetailRequest {
static getContentDetailDataMock(context: Context): Promise<ResponseDTO<ContentDetailDTO[]>> {
Logger.info(TAG, `getContentDetailDataMock start`);
... ... @@ -216,7 +222,12 @@ export class ContentDetailRequest {
*/
static getRecCompInfo(params: getRecCompInfoParams): Promise<ResponseDTO<getRecCompInfoResult>> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.DISPLAY_REC_COMPINFO
return WDHttp.request({ url, method: 'GET', params, headers: HttpRequest.buildHeaderWithGlobalHeader() })
return WDHttp.request({
url,
method: 'GET',
params,
headers: HttpRequest.buildHeaderWithGlobalHeader()
})
}
/**
... ... @@ -296,7 +307,7 @@ export class ContentDetailRequest {
*用户等级/积分-APP根据业务场景动态增减成长值(APP)
* 操作类型:1阅读 2评论 3回复(积分任务同评论) 4分享 5点赞 6关注 7打开客户端 8上传头像 9打开推送开关
*/
static postPointLevelOperate(params: postPointLevelOperateParams): Promise<ResponseDTO> {
static postPointLevelOperate(params: postPointLevelOperateParams): Promise<ResponseDTO<OperateRespDTO>> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.USERPOINT_OPERATE
return WDHttp.post(url, params)
}
... ... @@ -344,7 +355,8 @@ export class ContentDetailRequest {
success(resDTO);
})
.catch((err: Error) => {
Logger.error(TAG, `postInteractAccentionOperate catch, error.name : ${err.name}, error.message:${err.message}`);
Logger.error(TAG,
`postInteractAccentionOperate catch, error.name : ${err.name}, error.message:${err.message}`);
error(err);
})
})
... ...
import { Action, LiveDetailsBean } from 'wdBean/Index';
import { Action, ContentDetailDTO, LiveDetailsBean } from 'wdBean/Index';
import { LiveViewModel } from '../viewModel/LiveViewModel';
import router from '@ohos.router';
import { DetailPlayLivePage } from './DetailPlayLivePage';
import { DetailPlayVLivePage } from './DetailPlayVLivePage';
import { Logger } from 'wdKit/Index';
import { publishCommentModel } from 'wdComponent/src/main/ets/components/comment/model/PublishCommentModel';
const TAG = 'DetailPlayLiveCommon'
... ... @@ -21,8 +22,10 @@ export struct DetailPlayLiveCommon {
@Provide pageShow: number = -1
@Provide pageHide: number = -1
@Provide pageBackPress: number = -1
@Provide contentDetailData: ContentDetailDTO = {} as ContentDetailDTO
@Provide publishCommentModel: publishCommentModel = new publishCommentModel()
aboutToAppear(): void {
async aboutToAppear(): Promise<void> {
Logger.debug(TAG, 'aboutToAppear')
//https://pdapis.pdnews.cn/api/rmrb-bff-display-zh/content/zh/c/content/detail?relId=500005302448&relType=1&contentId=20000016340
const par: Action = router.getParams() as Action;
... ... @@ -30,11 +33,13 @@ export struct DetailPlayLiveCommon {
this.relId = params?.extra?.relId || '';
this.relType = params?.extra?.relType || '';
this.contentId = params?.contentID || '';
await this.getContentDetail()
this.getLiveDetails()
}
build() {
Column() {
// 直播预约或横屏直播统一进横屏直播
if (this.liveState === 'wait' || this.liveStyle === 0) {
DetailPlayLivePage({ contentId: this.contentId, relId: this.relId, relType: this.relType })
} else if (this.liveStyle === 1) {
... ... @@ -47,6 +52,32 @@ export struct DetailPlayLiveCommon {
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP])
}
/**
* 查询视频详情用于评论展示
*/
async getContentDetail() {
await this.liveViewModel.getContentDetail(this.contentId, this.relId, this.relType)
.then((data: Array<ContentDetailDTO>) => {
console.log(TAG, '查询视频详情用于评论展示 getContentDetail:', JSON.stringify(data))
if (data) {
this.contentDetailData = data[0];
// if (this.contentDetailData.openComment === 1) {
console.log(TAG, '查询视频详情用于评论展示 openComment:', this.contentDetailData.openComment)
this.publishCommentModel.targetId = String(this.contentDetailData?.newsId || '')
this.publishCommentModel.targetRelId = String(this.contentDetailData?.reLInfo?.relId)
this.publishCommentModel.targetTitle = this.contentDetailData?.newsTitle
this.publishCommentModel.targetRelType = String(this.contentDetailData?.reLInfo?.relType)
this.publishCommentModel.targetRelObjectId = String(this.contentDetailData?.reLInfo?.relObjectId)
this.publishCommentModel.keyArticle = String(this.contentDetailData?.keyArticle)
this.publishCommentModel.targetType = String(this.contentDetailData?.newsType)
// }
}
})
}
/**
* 获取直播信息,可区分横竖屏直播
*/
getLiveDetails() {
this.liveViewModel.getLiveDetails(this.contentId, this.relId, this.relType)
.then(
... ... @@ -65,17 +96,17 @@ export struct DetailPlayLiveCommon {
onPageShow() {
this.pageShow = Math.random()
Logger.debug(TAG, 'onPageShow')
Logger.info(TAG, 'onPageShow')
}
onPageHide() {
this.pageHide = Math.random()
Logger.debug(TAG, 'onPageHide')
Logger.info(TAG, 'onPageHide')
}
onBackPress(): boolean | void {
this.pageBackPress = Math.random()
Logger.debug(TAG, 'onBackPress')
Logger.info(TAG, 'onBackPress')
return true
}
}
... ...
... ... @@ -27,13 +27,14 @@ export struct DetailPlayLivePage {
@Provide liveDetailsBean: LiveDetailsBean = {} as LiveDetailsBean
@Provide liveRoomDataBean: LiveRoomDataBean = {} as LiveRoomDataBean
@State tabs: string[] = []
@State changeToTab: number = -1
//监听屏幕横竖屏变化
listener = mediaquery.matchMediaSync('(orientation: landscape)');
@Consume @Watch('onPageShowCus') pageShow: number
@Consume @Watch('onPageHideCus') pageHide: number
@Consume @Watch('onBackPressCus') pageBackPress: number
@State contentDetailData: ContentDetailDTO = {} as ContentDetailDTO
@State publishCommentModel: publishCommentModel = new publishCommentModel()
@Consume contentDetailData: ContentDetailDTO
@Consume publishCommentModel: publishCommentModel
aboutToAppear(): void {
Logger.info(TAG, `wyj-aboutToAppear`)
... ... @@ -48,25 +49,30 @@ export struct DetailPlayLivePage {
})
this.getLiveDetails()
this.getLiveRoomData()
this.getContentDetail()
console.error(TAG, 'this.publishCommentModel', this.publishCommentModel.targetId)
}
build() {
Column() {
TopPlayComponent({ playerController: this.playerController })
.layoutWeight(211)
TabComponent({ tabs: this.tabs })
TabComponent({ tabs: this.tabs, changeToTab: this.changeToTab })
.layoutWeight(503)
.visibility(this.displayDirection == DisplayDirection.VERTICAL ? Visibility.Visible : Visibility.None)
if (this.contentDetailData?.newsId) {
OperRowListView({
operationButtonList: ['comment', 'collect', 'share', 'like'],
contentDetailData: this.contentDetailData,
publishCommentModel: this.publishCommentModel,
onCommentFocus: () => {
// 切换到大家聊
this.changeToTab = Math.random()
}
})
.visibility(this.displayDirection == DisplayDirection.VERTICAL ? Visibility.Visible : Visibility.None)
}
// LiveCommentComponent({ heartNum: this.liveRoomDataBean.likeNum })
// .visibility(this.displayDirection == DisplayDirection.VERTICAL ? Visibility.Visible : Visibility.None)
}
... ... @@ -106,28 +112,6 @@ export struct DetailPlayLivePage {
return true
}
/**
* 查询视频详情用于评论展示
*/
getContentDetail() {
this.liveViewModel.getContentDetail(this.contentId, this.relId, this.relType)
.then((data: Array<ContentDetailDTO>) => {
console.log(TAG, 'getContentDetail:', JSON.stringify(data))
if (data) {
this.contentDetailData = data?.[0];
if (this.contentDetailData?.openComment) {
this.publishCommentModel.targetId = String(this.contentDetailData?.newsId || '')
this.publishCommentModel.targetRelId = String(this.contentDetailData?.reLInfo?.relId)
this.publishCommentModel.targetTitle = this.contentDetailData?.newsTitle
this.publishCommentModel.targetRelType = String(this.contentDetailData?.reLInfo?.relType)
this.publishCommentModel.targetRelObjectId = String(this.contentDetailData?.reLInfo?.relObjectId)
this.publishCommentModel.keyArticle = String(this.contentDetailData?.keyArticle)
this.publishCommentModel.targetType = String(this.contentDetailData?.newsType)
}
}
})
}
getLiveDetails() {
this.liveViewModel.getLiveDetails(this.contentId, this.relId, this.relType)
.then(
... ...
... ... @@ -26,6 +26,8 @@ export struct DetailPlayVLivePage {
@Provide liveState: string = ''
@Provide playUrl: string = ''
@Provide displayDirection: DisplayDirection = DisplayDirection.VERTICAL //横竖屏,默认竖屏
@Consume @Watch('openFullScreen') pageShow: number
@Consume @Watch('closeFullScreen') pageHide: number
@State relId: string = ''
@State contentId: string = ''
@State relType: string = ''
... ... @@ -34,9 +36,7 @@ export struct DetailPlayVLivePage {
aboutToAppear(): void {
console.log(TAG, 'aboutToAppear')
WindowModel.shared.setWindowLayoutFullScreen(true)
WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#ffffff', })
this.openFullScreen()
//https://pdapis.pdnews.cn/api/rmrb-bff-display-zh/content/zh/c/content/detail?relId=500005302448&relType=1&contentId=20000016340
let par: Action = router.getParams() as Action;
let params = par?.params;
... ... @@ -48,6 +48,17 @@ export struct DetailPlayVLivePage {
}
aboutToDisappear(): void {
this.closeFullScreen()
}
openFullScreen() {
console.log(TAG, 'openFullScreen')
WindowModel.shared.setWindowLayoutFullScreen(true)
WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#ffffff', })
}
closeFullScreen() {
console.log(TAG, 'closeFullScreen')
WindowModel.shared.setWindowLayoutFullScreen(false)
WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#000000', })
}
... ...
... ... @@ -25,32 +25,6 @@ export class LiveViewModel {
}
// async getContentDetail(contentId: string, relId: string, relType: string) {
// return ContentDetailRequest.getContentDetail({
// contentId: contentId,
// relId: relId,
// relType: relType
// }).then(async (resDTO: ResponseDTO<ContentDetailDTO[]>) => {
// console.log(TAG, 'getContentDetail:', JSON.stringify(resDTO.data))
// if (resDTO.data) {
//
// this.contentDetailData = resDTO.data?.[0];
//
// if (this.contentDetailData?.openComment) {
// this.publishCommentModel.targetId = String(this.contentDetailData?.newsId || '')
// this.publishCommentModel.targetRelId = String(this.contentDetailData?.reLInfo?.relId)
// this.publishCommentModel.targetTitle = this.contentDetailData?.newsTitle
// this.publishCommentModel.targetRelType = String(this.contentDetailData?.reLInfo?.relType)
// this.publishCommentModel.targetRelObjectId = String(this.contentDetailData?.reLInfo?.relObjectId)
// this.publishCommentModel.keyArticle = String(this.contentDetailData?.keyArticle)
// this.publishCommentModel.targetType = String(this.contentDetailData?.newsType)
// }
//
//
// }
// })
// }
//直播详情
getLiveDetails(contentId: string, relId: string, relType: string) {
return new Promise<Array<LiveDetailsBean>>((success, fail) => {
... ...
... ... @@ -4,6 +4,7 @@ import { TabLiveComponent } from './TabLiveComponent'
@Component
export struct TabComponent {
@Prop @Watch('changeToChart') changeToTab: number
@State fontColor: string = '#999999'
@State selectedFontColor: string = '#222222'
@State currentIndex: number = 0
... ... @@ -14,6 +15,16 @@ export struct TabComponent {
}
/**
* 评论切换到大家聊
*/
changeToChart() {
const index = this.tabs.findIndex(item => item === '大家聊')
if (index !== -1) {
this.controller.changeIndex(index)
}
}
build() {
Tabs({ barPosition: BarPosition.Start, index: this.currentIndex, controller: this.controller }) {
ForEach(this.tabs, (item: string, index: number) => {
... ...
... ... @@ -22,15 +22,15 @@ export struct PlayerCommentComponent {
@Consume displayDirection: DisplayDirection
@State private pageModel: PageModel = new PageModel()
@State liveChatList: Array<LiveRoomItemBean> = []
@State contentDetailData: ContentDetailDTO = {} as ContentDetailDTO
@State publishCommentModel: publishCommentModel = new publishCommentModel()
@Consume contentDetailData: ContentDetailDTO
@Consume publishCommentModel: publishCommentModel
@State contentId: string = ''
@State relId: string = ''
@State relType: string = ''
scroller: Scroller = new Scroller()
aboutToAppear(): void {
this.getLiveChatList()
async aboutToAppear(): Promise<void> {
const action: Action = router.getParams() as Action
if (action) {
this.contentId = action.params?.contentID || ''
... ... @@ -38,8 +38,9 @@ export struct PlayerCommentComponent {
this.relId = action.params.extra.relId || ''
this.relType = action.params.extra.relType || ''
}
this.getContentDetail(this.contentId, this.relId, this.relType)
}
this.getLiveChatList()
}
... ... @@ -80,32 +81,6 @@ export struct PlayerCommentComponent {
})
}
async getContentDetail(contentId: string, relId: string, relType: string) {
await ContentDetailRequest.getContentDetail({
contentId: contentId,
relId: relId,
relType: relType
}).then(async (resDTO: ResponseDTO<ContentDetailDTO[]>) => {
console.log(TAG, 'getContentDetail:', JSON.stringify(resDTO.data))
if (resDTO.data) {
this.contentDetailData = resDTO.data?.[0];
if (this.contentDetailData?.openComment) {
this.publishCommentModel.targetId = String(this.contentDetailData?.newsId || '')
this.publishCommentModel.targetRelId = String(this.contentDetailData?.reLInfo?.relId)
this.publishCommentModel.targetTitle = this.contentDetailData?.newsTitle
this.publishCommentModel.targetRelType = String(this.contentDetailData?.reLInfo?.relType)
this.publishCommentModel.targetRelObjectId = String(this.contentDetailData?.reLInfo?.relObjectId)
this.publishCommentModel.keyArticle = String(this.contentDetailData?.keyArticle)
this.publishCommentModel.targetType = String(this.contentDetailData?.newsType)
}
}
})
}
build() {
Column() {
List({ scroller: this.scroller }) {
... ...
import { ContentDetailDTO } from 'wdBean/Index';
import { WDPlayerController } from 'wdPlayer/Index';
import { PlayerCommentComponent } from './PlayerCommentComponent';
import { PlayerTitleComponent } from './PlayerTitleComponent';
... ...
... ... @@ -152,6 +152,11 @@ export struct PlayerRightView {
this.followStatus = '0'
} else {
this.followStatus = '1'
ContentDetailRequest.postPointLevelOperate({ operateType: 6 }).then((res) => {
if (res.data?.showToast) {
ToastUtils.showToast(res.data.ruleName + '+' + res.data.rulePoint + '积分', 1000);
}
})
}
})
}
... ...