陈剑华

Merge remote-tracking branch 'origin/main'

Showing 19 changed files with 334 additions and 180 deletions
... ... @@ -9,6 +9,7 @@ export interface PageInfoDTO {
name: string; // 名称
hasPopUp: number;
baselineShow: number;
baselineCopywriting: string;
groups: GroupInfoDTO[];
channelInfo: ChannelInfoDTO;
... ... @@ -20,11 +21,11 @@ export interface PageInfoDTO {
/**
* 挂角广告数据
*/
cornersAdv:AdvRuleBean
cornersAdv: AdvRuleBean
/**
* 广告中心-挂角广告信息
*/
cornersAdv2:CompAdvBean[]
cornersAdv2: CompAdvBean[]
}
... ...
import { AccountManagerUtils, Logger, DateTimeUtils } from 'wdKit';
import { AccountManagerUtils, Logger, DateTimeUtils, SPHelper } from 'wdKit';
import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel';
import { ContentDetailDTO,batchLikeAndCollectResult,batchLikeAndCollectParams,postBatchAttentionStatusParams,
import { ContentDetailDTO,postBatchAttentionStatusParams,
PhotoListBean,
ContentDTO,
RmhInfoDTO, } from 'wdBean';
import media from '@ohos.multimedia.media';
import { OperRowListView } from './view/OperRowListView';
import { WDPlayerController } from 'wdPlayer/Index';
import {
batchLikeAndCollectParams,
batchLikeAndCollectResult,
ContentDetailRequest,
contentListParams,
postExecuteCollectRecordParams,
postExecuteLikeParams,
postInteractAccentionOperateParams
} from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest';
import { ContentConstants } from '../constants/ContentConstants';
import { ProcessUtils } from 'wdRouter';
import { ProcessUtils, WDRouterPage, WDRouterRule } from 'wdRouter';
import { StringUtils } from 'wdKit/src/main/ets/utils/StringUtils';
import display from '@ohos.display';
import { BusinessError } from '@ohos.base';
import { CommonConstants } from 'wdConstant/Index';
import { CommonConstants, SpConstants } from 'wdConstant/Index';
import { CardMediaInfo } from '../components/cardCommon/CardMediaInfo'
import router from '@ohos.router';
const TAG = 'DynamicDetailComponent'
... ... @@ -24,20 +33,13 @@ export struct DynamicDetailComponent {
private contentId: string = ''
private relType: string = ''
//出参 fixme 模拟数据用json转换
@State contentDetailData: ContentDetailDTO = {
publishTime: "2023年03月14日 08:16",
rmhInfo:{rmhHeadUrl:"",rmhName:"人民号名称",rmhDesc:"人民号描述单行展示"},
newsContent:"优先展示这个内容",
newsSummary:"其次展示这个内容",
newsTitle:"上面两个都没有再展示这个内容",
newsType:15
} as ContentDetailDTO
@State contentDetailData: ContentDetailDTO = {} as ContentDetailDTO
//变量
scroller: Scroller = new Scroller();
/**
* 默认未关注 点击去关注
*/
private followStatus: String = '0';
@State followStatus: String = '0';
@State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态
//跳转
... ... @@ -130,7 +132,7 @@ export struct DynamicDetailComponent {
.backgroundColor($r('app.color.color_ED2800'))
.fontColor($r('app.color.color_fff'))
.onClick(() => {
// this.handleAccention(this.item, 1)
this.handleAccention()
})
} else {
Text('已关注')
... ... @@ -143,7 +145,7 @@ export struct DynamicDetailComponent {
.borderColor($r('app.color.color_CCCCCC'))
.fontColor($r('app.color.color_CCCCCC'))
.onClick(() => {
// this.handleAccention(this.item, 0)
this.handleAccention()
})
}
}
... ... @@ -224,6 +226,9 @@ export struct DynamicDetailComponent {
item.height = callback?.height || 0;
})
}
.onClick((event: ClickEvent) => {
ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList)
})
}
} else if (this.contentDetailData.photoList.length === 4) {
GridCol({
... ... @@ -233,6 +238,9 @@ export struct DynamicDetailComponent {
.aspectRatio(1)
.borderRadius(this.caclImageRadius(index))
}
.onClick((event: ClickEvent) => {
ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList)
})
} else {
GridCol({
span: { sm: 4, lg: 3 }
... ... @@ -241,6 +249,9 @@ export struct DynamicDetailComponent {
.aspectRatio(1)
.borderRadius(this.caclImageRadius(index))
}
.onClick((event: ClickEvent) => {
ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList)
})
}
})
}
... ... @@ -414,7 +425,7 @@ export struct DynamicDetailComponent {
console.error(TAG, JSON.stringify(this.contentDetailData))
let data = await MultiPictureDetailViewModel.getInteractDataStatus(params)
console.error(TAG, '查询用户对作品点赞、收藏状态', JSON.stringify(data))
this.newsStatusOfUser = data[0];
// this.newsStatusOfUser = data[0];
Logger.info(TAG, `newsStatusOfUser:${JSON.stringify(this.newsStatusOfUser)}`)
} catch (exception) {
console.error(TAG, JSON.stringify(exception))
... ... @@ -486,6 +497,33 @@ export struct DynamicDetailComponent {
return 3; //普通图
}
}
/**
* 关注号主
*/
async handleAccention() {
// 未登录,跳转登录
const user_id = await SPHelper.default.get(SpConstants.USER_ID, '')
if (!user_id) {
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
return
}
const params2: postInteractAccentionOperateParams = {
attentionUserType: this.contentDetailData?.rmhInfo?.userType || '', //被关注用户类型(1 普通用户 2 视频号 3 矩阵号)
attentionUserId: this.contentDetailData?.rmhInfo?.userId || '', // 被关注用户号主id
attentionCreatorId: this.contentDetailData?.rmhInfo?.rmhId || '', // 被关注用户号主id
status: this.followStatus == '0'? 1:0,
}
ContentDetailRequest.postInteractAccentionOperate(params2).then(res => {
console.log('关注号主==', JSON.stringify(res.data))
if (this.followStatus == '1') {
this.followStatus = '0'
} else {
this.followStatus = '1'
}
})
}
}
interface radiusType {
... ...
... ... @@ -12,6 +12,7 @@ import {
} from 'wdBean';
import DetailViewModel from '../viewmodel/DetailViewModel';
import { ImageAndTextWebComponent } from './ImageAndTextWebComponent';
import { OperRowListView } from './view/OperRowListView';
import router from '@ohos.router';
import { RecommendList } from '../components/view/RecommendList'
import { CommonConstants } from 'wdConstant';
... ... @@ -91,7 +92,8 @@ export struct ImageAndTextPageComponent {
}
//底部交互区
Row() {
OperRowListView({contentDetailData: this.contentDetailData[0]})
/* Row() {
Image($r('app.media.icon_arrow_left'))
.width(24)
.height(24)
... ... @@ -126,7 +128,7 @@ export struct ImageAndTextPageComponent {
.height(56)
.padding({ left: 15, right: 15, bottom: 50, top: 20 })
.justifyContent(FlexAlign.SpaceBetween)
.backgroundColor(Color.White)
.backgroundColor(Color.White)*/
}
}
... ...
... ... @@ -6,7 +6,8 @@ import {
H5ReceiveDetailBean,
ResponseBean
} from 'wdBean';
import { Logger } from 'wdKit';
import { Logger, SPHelper } from 'wdKit';
import { SpConstants } from 'wdConstant';
import { WdWebLocalComponent } from 'wdWebComponent';
import { NativeCallH5Type } from 'wdWebComponent/src/main/ets/pages/NativeCallH5Type';
import { BridgeWebViewControl } from 'wdJsBridge/Index';
... ... @@ -22,7 +23,7 @@ export struct ImageAndTextWebComponent {
private webPrepared = false;
private dataPrepared = false;
onDetailDataUpdated() {
async onDetailDataUpdated() {
if (this.action) {
let contentId: string = ''
let contentType: string = ''
... ... @@ -30,6 +31,8 @@ export struct ImageAndTextWebComponent {
let channelId: string = ''
let compId: string = ''
let sourcePage: string = '5'
let creatorId = await SPHelper.default.get(SpConstants.USER_CREATOR_ID, '') || ''
let isLogin = await SPHelper.default.get(SpConstants.USER_STATUS, '') || '0'
if (this.action.params) {
if (this.action.params.contentID) {
contentId = this.action.params?.contentID
... ... @@ -56,8 +59,8 @@ export struct ImageAndTextWebComponent {
// TODO 对接user信息、登录情况
let h5ReceiveDataExtraBean: H5ReceiveDataExtraBean = {
creatorId: '',
isLogin: '0',
creatorId: creatorId,
isLogin: isLogin,
networkStatus: 1,
loadImageOnlyWifiSwitch: '2',
... ...
/**
* 已到底UI,数据bean封装【page接口返回配置信息:文字、文字颜色】
*/
@Observed
export class NoMoreBean {
text: string = '';
textColor: string = '';
constructor(text: string) {
this.text = text;
}
}
\ No newline at end of file
... ...
import { CommonConstants, ViewType } from 'wdConstant';
import { Logger } from 'wdKit';
import PageViewModel from '../../viewmodel/PageViewModel';
import { EmptyComponent } from '../view/EmptyComponent';
import { EmptyComponent, WDViewDefaultType } from '../view/EmptyComponent';
import { ErrorComponent } from '../view/ErrorComponent';
import PageModel from '../../viewmodel/PageModel';
import { listTouchEvent } from '../../utils/PullDownRefresh';
... ... @@ -16,6 +16,8 @@ import PageHelper from '../../viewmodel/PageHelper';
import { channelSkeleton } from '../skeleton/channelSkeleton'
import { ProcessUtils } from 'wdRouter/Index';
import PageAdModel from '../../viewmodel/PageAdvModel';
import PageNoMoreLayout from './PageNoMoreLayout';
import { NoMoreBean } from './NoMoreBean';
const TAG = 'PageComponent';
... ... @@ -31,14 +33,18 @@ export struct PageComponent {
build() {
Column() {
if (this.pageModel.viewType == ViewType.LOADING) {
// LoadingComponent()
this.LoadingLayout()
} else if (this.pageModel.viewType == ViewType.ERROR) {
ErrorComponent()
} else if (this.pageModel.viewType == ViewType.EMPTY) {
EmptyComponent()
} else {
} else if (this.pageModel.viewType == ViewType.LOADED) {
this.ListLayout()
} else if (this.pageModel.viewType == ViewType.EMPTY) {
//缺省页
EmptyComponent({
emptyType: this.pageModel.emptyType,
emptyButton: true,
retry: () => {
this.getData()
}
})
}
}
.width(CommonConstants.FULL_PARENT)
... ... @@ -83,7 +89,7 @@ export struct PageComponent {
this.pageModel.pullUpLoadText, this.pageModel.pullUpLoadHeight)
})
} else if (!this.pageModel.contentNeedScroll) {
NoMoreLayout()
PageNoMoreLayout({ noMoreBean: new NoMoreBean(this.pageModel.pageInfo.baselineCopywriting) })
}
}
}
... ...
import { RefreshConstants } from '../../utils/RefreshConstants'
import { NoMoreBean } from './NoMoreBean';
/**
* The No more data layout component.
*/
@Component
export default struct PageNoMoreLayout {
@ObjectLink noMoreBean: NoMoreBean;
text: string | Resource = $r('app.string.footer_text')
aboutToAppear(): void {
if (this.noMoreBean && this.noMoreBean.text.length > 0) {
this.text = this.noMoreBean.text
}
}
build() {
Row() {
Text(this.text)
.margin({ left: RefreshConstants.NoMoreLayoutConstant_NORMAL_PADDING })
.fontSize(RefreshConstants.NoMoreLayoutConstant_TITLE_FONT)
.textAlign(TextAlign.Center)
}
.width(RefreshConstants.FULL_WIDTH)
.justifyContent(FlexAlign.Center)
.height(RefreshConstants.CUSTOM_LAYOUT_HEIGHT)
}
}
\ No newline at end of file
... ...
... ... @@ -12,6 +12,7 @@ import {
import router from '@ohos.router';
import inputMethod from '@ohos.inputMethod';
import { MultiPictureDetailViewModel } from '../../viewmodel/MultiPictureDetailViewModel';
import { LikeComponent } from './LikeComponent';
import { HttpUrlUtils } from 'wdNetwork/Index';
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
import { PageRepository } from '../../repository/PageRepository';
... ... @@ -29,9 +30,11 @@ const TAG = 'OperRowListView';
@Preview
@Component
export struct OperRowListView {
private contentDetailData: ContentDetailDTO = {} as ContentDetailDTO
// private contentDetailData: ContentDetailDTO = {} as ContentDetailDTO
@Prop contentDetailData: ContentDetailDTO
@State interactData: InteractDataDTO = {} as InteractDataDTO
@State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态
@State likeBean: Record<string, string> = {}
@State operationList: OperationItem[] = [
{
... ... @@ -60,6 +63,20 @@ export struct OperRowListView {
this.getInteractDataStatus()
}
this.queryContentInteractCount()
// 点赞需要数据
// this.data['userName'] = '人民日报网友2kD2xW'
// this.data['contentType'] = '8' //必须
// this.data['title'] = '开创两校交流先河!克罗地亚教育代表团访问同济大学'
// this.data['userHeaderUrl'] = ""
// this.data['channelId'] = "2059" //必须
// this.data['status'] = "1" //必须
this.likeBean['contentId'] = this.contentDetailData.newsId + ''
this.likeBean['userName'] = this.contentDetailData.editorName + ''
this.likeBean['contentType'] = this.contentDetailData.newsType + ''
this.likeBean['title'] = this.contentDetailData.newsTitle + ''
this.likeBean['userHeaderUrl'] = ''
this.likeBean['channelId'] = this.contentDetailData.reLInfo?.channelId + ''
this.likeBean['status'] = ''
}
build() {
... ... @@ -83,7 +100,7 @@ export struct OperRowListView {
.onClick(() => {
router.back();
})
TextInput({placeholder:'说两句...'})
TextInput({placeholder:'说两句11...'})
.placeholderColor('#999999')
.placeholderFont(
{
... ... @@ -112,10 +129,9 @@ export struct OperRowListView {
.width('54.5%')
}
.width('100%')
.height(56)
.height(126)
.backgroundColor(Color.Black)
}
/**
* 组件项
*
... ... @@ -125,7 +141,11 @@ export struct OperRowListView {
buildOperationItem(item: OperationItem, index: number) {
Column() {
if (item.text === '点赞') {
RelativeContainer() {
LikeComponent({
data: this.likeBean
})
/* RelativeContainer() {
Row() {
Image(this.newsStatusOfUser?.likeStatus == '1' ? item.icon_check : item.icon)
.width(24)
... ... @@ -134,6 +154,7 @@ export struct OperRowListView {
.interpolation(ImageInterpolation.High)
.onClick(() => {
this.toggleLikeStatus()
console.log('点赞_111', JSON.stringify(this.contentDetailData))
})
}
.alignRules({
... ... @@ -168,7 +189,7 @@ export struct OperRowListView {
.id(`e_row3_${index}`)
}
}
.id(`e_icon_${index}`)
.id(`e_icon_${index}`)*/
} else if (item.text === '收藏') {
RelativeContainer() {
Row() {
... ...
import { PageDTO, CompDTO, PageInfoDTO, ContentDTO } from 'wdBean';
import { CompStyle, ViewType } from 'wdConstant/Index';
import { CollectionUtils, DateTimeUtils, Logger } from 'wdKit';
import { CollectionUtils, DateTimeUtils, Logger, NetworkUtil } from 'wdKit';
import { closeRefresh } from '../utils/PullDownRefresh';
import PageModel from './PageModel';
import PageViewModel from './PageViewModel';
import { promptAction } from '@kit.ArkUI';
import { AdvRuleBean } from 'wdBean/src/main/ets/bean/adv/AdvsRuleBean';
import PageAdModel from './PageAdvModel';
import { WDViewDefaultType } from '../components/view/EmptyComponent';
const TAG = 'PageHelper';
... ... @@ -14,14 +15,12 @@ const TAG = 'PageHelper';
* 处理返回后的数据
*/
export class PageHelper {
/**
* 刷新数据
*/
async refreshUI(pageModel: PageModel,pageAdvModel:PageAdModel) {
async refreshUI(pageModel: PageModel, pageAdvModel: PageAdModel) {
pageModel.loadStrategy = 2
this.getPageInfo(pageModel,pageAdvModel)
this.getPageInfo(pageModel, pageAdvModel)
}
/**
... ... @@ -36,28 +35,36 @@ export class PageHelper {
/**
* 进页面请求数据
*/
async getInitData(pageModel: PageModel,pageAdvModel:PageAdModel) {
async getInitData(pageModel: PageModel, pageAdvModel: PageAdModel) {
pageModel.loadStrategy = 1
this.getPageInfo(pageModel,pageAdvModel)
let netStatus = NetworkUtil.isNetConnected()
if (netStatus) {
this.getPageInfo(pageModel, pageAdvModel)
} else {
pageModel.viewType = ViewType.EMPTY;
pageModel.emptyType = WDViewDefaultType.WDViewDefaultType_NoNetwork;
}
}
async getPageInfo(pageModel: PageModel,pageAdvModel:PageAdModel) {
getPageInfo(pageModel: PageModel, pageAdvModel: PageAdModel) {
pageModel.currentPage = 1;
let pageInfo = await PageViewModel.getPageInfo(pageModel.pageId);
PageViewModel.getPageInfo(pageModel.pageId).then(pageInfo => {
if (pageInfo == null) {
pageModel.viewType = ViewType.EMPTY;
pageModel.emptyType = WDViewDefaultType.WDViewDefaultType_NoListContent;
return;
}
pageModel.pageInfo = pageInfo;
//解析广告资源
pageAdvModel.analysisAdvSource(pageInfo)
pageAdvModel.analysisAdvSource(pageInfo);
this.parseGroup(pageModel)
}).catch(() => {
pageModel.viewType = ViewType.EMPTY;
pageModel.emptyType = WDViewDefaultType.WDViewDefaultType_ContentFailed;
})
}
async parseGroup(pageModel: PageModel) {
let pageInfo: PageInfoDTO = pageModel.pageInfo
pageModel.groupList = []
... ... @@ -84,6 +91,8 @@ export class PageHelper {
// 没数据,展示空页面
Logger.debug(TAG, 'aboutToAppear, data response page ' + pageModel.pageId + ', comp list is empty.');
pageModel.viewType = ViewType.EMPTY;
pageModel.emptyType = WDViewDefaultType.WDViewDefaultType_NoListContent;
}
}
... ...
... ... @@ -5,6 +5,7 @@ import { RefreshConstants as Const } from '../utils/RefreshConstants';
import { PageUIReqBean } from '../components/page/bean/PageUIReqBean';
import { GroupInfoDTO, PageInfoDTO } from 'wdBean/src/main/ets/bean/navigation/PageInfoDTO';
import { AdvRuleBean, CompAdvBean } from 'wdBean/src/main/ets/bean/adv/AdvsRuleBean';
import { WDViewDefaultType } from '../components/view/EmptyComponent';
/**
* 页面下拉刷新、上拉加载数据bean。
... ... @@ -38,6 +39,7 @@ export default class PageModel {
isVisiblePullUpLoad: boolean = false;
offsetY: number = 0;
viewType: number = ViewType.LOADING;
emptyType: WDViewDefaultType = WDViewDefaultType.WDViewDefaultType_Default
hasMore: boolean = true;
startIndex = 0;
endIndex = 0;
... ...
... ... @@ -6,7 +6,7 @@
},
{
"name": "footer_text",
"value": "已经到底了"
"value": "已显示全部内容"
},
{
"name": "pull_up_load_text",
... ...
... ... @@ -23,12 +23,12 @@ export struct DetailPlayShortVideoPage {
@Prop index: number = 0
@Prop @Watch('currentIndexChange') currentIndex: number = 0
@State playerController: WDPlayerController = new WDPlayerController();
@Provide contentDetailData: ContentDetailDTO | undefined = undefined
@Provide interactData: InteractDataDTO | undefined = undefined
@Provide contentDetailData: ContentDetailDTO = {} as ContentDetailDTO
@Provide interactData: InteractDataDTO = {} as InteractDataDTO
@Provide isFullScreen: boolean = false;
@Provide progressVal: number = 0;
@Provide videoLandScape?: number = 1; // 视频朝向, 横屏视频:1;竖屏视频:2
@Provide newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态
@Provide newsStatusOfUser: batchLikeAndCollectResult = {} as batchLikeAndCollectResult // 点赞、收藏状态
@Provide followStatus: string = '0' // 关注状态
@Provide isOpenDetail: boolean = false // 查看详情按钮点击
@Provide isDragging: boolean = false // 拖动时间进度条
... ...
... ... @@ -24,10 +24,8 @@ export struct DetailVideoListPage {
@Provide pageHide: number = -1
@Provide switchVideoStatus: boolean = false
@State data: ContentDetailDTO[] = []
@State testData: string[] = ['111', '222', '333']
@State currentIndex: number = 0
@State interactDataList: InteractDataDTO[] = []
@State isFullScreen: boolean = false
async aboutToAppear(): Promise<void> {
this.openFullScreen()
... ... @@ -41,10 +39,7 @@ export struct DetailVideoListPage {
}
await this.getContentDetail(this.contentId, this.relId, this.relType)
}
await this.queryVideoList()
this.getContentInteract()
console.log(TAG, 'aboutToAppear', JSON.stringify(action.params))
}
... ... @@ -93,9 +88,22 @@ export struct DetailVideoListPage {
contentId: contentId,
relId: relId,
relType: relType
}).then((resDTO: ResponseDTO<ContentDetailDTO[]>) => {
console.error('getContentDetail==', JSON.stringify(resDTO.data))
}).then(async (resDTO: ResponseDTO<ContentDetailDTO[]>) => {
console.log(TAG, 'getContentDetail:', JSON.stringify(resDTO.data))
if (resDTO.data) {
const params: contentListParams = {
contentList: [{
contentId: resDTO.data[0].newsId + '',
contentType: resDTO.data[0].newsType
}]
}
// 批量查询内容当前用户点赞、收藏状态
await ContentDetailRequest.getContentInteract(params).then(res => {
if (res.data) {
this.interactDataList = this.interactDataList.concat(res.data)
}
console.log('获取互动点赞等数据===', JSON.stringify(res))
})
this.data.push(resDTO.data[0])
}
})
... ... @@ -108,8 +116,9 @@ export struct DetailVideoListPage {
await ContentDetailRequest.postRecommendVideoList({
pageSize: 5,
refreshCnt: 1
}).then(res => {
}).then(async res => {
if (res.data) {
await this.getContentInteract(res.data)
this.data = this.data.concat(res.data)
console.log('视频列表===', JSON.stringify(res.data))
}
... ... @@ -119,21 +128,21 @@ export struct DetailVideoListPage {
/**
* 批量查询内容当前用户点赞、收藏状态
*/
getContentInteract() {
if (this.data.length > 0) {
async getContentInteract(data: ContentDetailDTO[]) {
if (data.length > 0) {
const params: contentListParams = {
contentList: []
}
this.data.map(item => {
data.map(item => {
params.contentList.push({
contentId: item.newsId + '',
contentType: item.newsType
})
})
// 批量查询内容当前用户点赞、收藏状态
ContentDetailRequest.getContentInteract(params).then(res => {
await ContentDetailRequest.getContentInteract(params).then(res => {
if (res.data) {
this.interactDataList = res.data || []
this.interactDataList = this.interactDataList.concat(res.data)
}
console.log('获取互动点赞等数据===', JSON.stringify(res))
})
... ...
... ... @@ -145,7 +145,7 @@ export struct VideoChannelDetail {
refreshTime: this.refreshTime,
}
await ContentDetailRequest.getRecCompInfo(params).then(res => {
await ContentDetailRequest.getRecCompInfo(params).then(async res => {
this.isRequestError = false
console.log('根据视频频道传参查询视频楼层信息totalCount', res.data?.totalCount + '')
... ... @@ -174,8 +174,8 @@ export struct VideoChannelDetail {
})
}
this.batchContentDetail(list1)
this.getContentInteract(list2)
await this.batchContentDetail(list1, list2)
setTimeout(() => {
this.isMouted = true
}, 500)
... ... @@ -189,11 +189,14 @@ export struct VideoChannelDetail {
/**
* 根据视频楼层信息批量查询视频列表
*/
async batchContentDetail(list: batchContentDetailParams) {
async batchContentDetail(list: batchContentDetailParams, list2: contentListParams) {
if (list.contents.length > 0) {
await ContentDetailRequest.batchContentDetail(list).then(res => {
await ContentDetailRequest.batchContentDetail(list).then(async res => {
if (res.data) {
await this.getContentInteract(list2)
this.data = this.data.concat(res.data)
}
console.log('根据视频楼层信息批量查询视频列表', res.data)
this.data = this.data.concat(res.data as [])
})
}
}
... ... @@ -204,7 +207,9 @@ export struct VideoChannelDetail {
async getContentInteract(list: contentListParams) {
if (list.contentList.length > 0) {
await ContentDetailRequest.getContentInteract(list).then(res => {
this.interactDataList = res.data || []
if (res.data) {
this.interactDataList = this.interactDataList.concat(res.data)
}
console.log('根据视频信息批量查询点赞、收藏状态', res.data)
})
}
... ...
import { ContentDetailDTO, InteractDataDTO, Params, RmhInfoDTO, UserInfoDTO } from 'wdBean/Index';
import { ContentDetailDTO, InteractDataDTO, Params, } from 'wdBean/Index';
import {
batchLikeAndCollectParams,
batchLikeAndCollectResult,
ContentDetailRequest,
contentListParams,
... ... @@ -8,23 +7,15 @@ import {
postExecuteLikeParams,
postInteractAccentionOperateParams
} from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest';
import { SPHelper, ToastUtils } from 'wdKit';
import { HttpUrlUtils } from 'wdNetwork/Index';
import { SPHelper, ToastUtils, NumberFormatterUtils } from 'wdKit';
import { WDPlayerController } from 'wdPlayer/Index';
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
import { SpConstants } from 'wdConstant/Index'
export interface OperationItem {
icon: Resource;
icon_check?: Resource;
// icon_selected: Resource;
text: string | Resource;
num?: number; // 个数
}
const TAG = 'PlayerRightView';
//视频点播页右侧操作栏:点赞/收藏/评论/分享 竖着排列
@Component
export struct PlayerRightView {
private playerController?: WDPlayerController;
... ... @@ -34,31 +25,10 @@ export struct PlayerRightView {
@Consume followStatus: string
@Consume isOpenDetail: boolean
@Consume isDragging: boolean
@State operationList: OperationItem[] = [
{
icon: $r('app.media.ic_like_uncheck'),
icon_check: $r('app.media.ic_like_check'),
text: "赞",
// num: 6622
},
{
icon: $r('app.media.ic_collect_uncheck'),
icon_check: $r('app.media.ic_collect_check'),
text: "收藏",
// num: 662,
},
{
icon: $r('app.media.ic_comment'),
text: "抢首评",
// num: 500,
},
{
icon: $r('app.media.ic_share'),
text: "分享"
}
]
@State likesStyle: number = this.contentDetailData.likesStyle // 赞样式 1红心(点赞) 2大拇指(祈福) 3蜡烛(默哀) 4置空
aboutToAppear() {
}
/**
... ... @@ -82,11 +52,11 @@ export struct PlayerRightView {
if (this.newsStatusOfUser) {
this.newsStatusOfUser.likeStatus = this.newsStatusOfUser?.likeStatus === '1' ? '0' : '1'
if (this.newsStatusOfUser.likeStatus === '1') {
this.interactData.likeNum = Number(this.interactData.likeNum) + 1
this.interactData.likeNum = Number(this.interactData.likeNum || 0) + 1
} else {
this.interactData.likeNum = Number(this.interactData.likeNum) - 1
this.interactData.likeNum = Number(this.interactData.likeNum || 0) - 1
}
console.log('点赞、取消点赞==', this.newsStatusOfUser?.likeStatus, this.interactData?.likeNum)
console.log(TAG, '点赞、取消点赞==', this.newsStatusOfUser?.likeStatus, this.interactData?.likeNum)
// this.queryContentInteractCount()
}
... ... @@ -116,11 +86,11 @@ export struct PlayerRightView {
this.newsStatusOfUser.collectStatus = this.newsStatusOfUser?.collectStatus === 1 ? 0 : 1
// this.queryContentInteractCount()
if (this.newsStatusOfUser.collectStatus === 1) {
this.interactData.collectNum = Number(this.interactData.collectNum) + 1
this.interactData.collectNum = Number(this.interactData.collectNum || 0) + 1
} else {
this.interactData.collectNum = Number(this.interactData.collectNum) - 1
this.interactData.collectNum = Number(this.interactData.collectNum || 0) - 1
}
console.log('收藏、取消收藏==', this.newsStatusOfUser?.collectStatus, this.interactData?.collectNum)
console.log(TAG, '收藏、取消收藏==', this.newsStatusOfUser?.collectStatus, this.interactData?.collectNum)
}
})
... ... @@ -138,15 +108,15 @@ export struct PlayerRightView {
}
ContentDetailRequest.getContentInteract(params).then(res => {
if (res.data && this.interactData) {
this.interactData.likeNum = res.data[0]?.likeNum
this.interactData.collectNum = res.data[0]?.collectNum
this.interactData.commentNum = res.data[0]?.commentNum
this.interactData.likeNum = res.data[0]?.likeNum || 0
this.interactData.collectNum = res.data[0]?.collectNum || 0
this.interactData.commentNum = res.data[0]?.commentNum || 0
}
console.log('获取互动点赞等数据===', JSON.stringify(res))
})
}
getImgUrl() {
getHeadUrl() {
return this.contentDetailData?.rmhInfo?.rmhHeadUrl || this.contentDetailData?.userInfo?.userHeadUrl
}
... ... @@ -170,7 +140,7 @@ export struct PlayerRightView {
status: 1,
}
ContentDetailRequest.postInteractAccentionOperate(params2).then(res => {
console.log('关注号主==', JSON.stringify(res.data))
console.log(TAG, '关注号主==', JSON.stringify(res.data))
if (this.followStatus == '1') {
this.followStatus = '0'
} else {
... ... @@ -179,110 +149,177 @@ export struct PlayerRightView {
})
}
@Builder
buildUserComp() {
build() {
Column() {
if (this.getImgUrl()) {
RelativeContainer() {
Image(this.getImgUrl())
this.userBuilderView()
this.likeBuilderView()
this.collectBuilderView()
this.commentBuilderView()
this.shareBuilderView()
}
// .backgroundColor(Color.Blue)
// .height('100%')
.width(58)
.position({ x: '100%', y: '100%' })
.markAnchor({ x: '100%', y: '100%' })
.padding({ bottom: 72, right: 10 })
.visibility(this.isOpenDetail || this.isDragging ? Visibility.None : Visibility.Visible)
}
/**
* 用户关注、号主页
*/
@Builder
userBuilderView() {
Stack() {
Image(this.getHeadUrl())
.width('100%')
.borderRadius(24)
.aspectRatio(1)
.border({ width: 1, color: Color.White, style: BorderStyle.Solid })
.alignRules({
top: { anchor: "__container__", align: VerticalAlign.Top },
left: { anchor: "__container__", align: HorizontalAlign.Start }
})
.id("row1")
.onClick(() => {
// 跳转到号主页
if (this.contentDetailData.rmhInfo?.cnMainControl === 1) {
// 号主页
const params: Params = {
creatorId: this.contentDetailData.rmhInfo.rmhId,
pageID: ''
}
WDRouterRule.jumpWithPage(WDRouterPage.peopleShipHomePage, params)
}
})
if (this.followStatus == '0') {
Image($r('app.media.ic_add'))
.width(24)
.borderRadius(12)
.alignRules({
left: { anchor: "__container__", align: HorizontalAlign.Center },
bottom: { anchor: "__container__", align: VerticalAlign.Bottom },
})
.margin({ left: -12 })
.id("row2")
.position({ x: '50%', y: '100%' })
.markAnchor({ x: '50%', y: '50%' })
.onClick(() => {
// 关注
// TODO:关注动画
this.handleAccention()
})
}
.height(48)
.width('100%')
.margin({ bottom: 30 })
.visibility(this.getHeadUrl() ? Visibility.Visible : Visibility.None)
}
/**
* 将点赞样式转换为icon
*/
transLikeStyle2Icon(): Resource {
if (this.likesStyle === 1) {
return this.newsStatusOfUser.likeStatus === '1' ? $r(`app.media.ic_like_check`) : $r(`app.media.ic_like_uncheck`)
} else if (this.likesStyle === 2) {
return this.newsStatusOfUser.likeStatus === '1' ? $r(`app.media.ic_thub_check`) : $r(`app.media.ic_thub_uncheck`)
} else if (this.likesStyle === 3) {
return this.newsStatusOfUser.likeStatus === '1' ? $r(`app.media.ic_candle_check`) : $r(`app.media.ic_candle_uncheck`)
}
return $r(`app.media.icon_like_ckeck`)
}
}.height(60)
transNum2String(name: 'likeNum' | 'collectNum' | 'commentNum') {
console.log(TAG, 'transNum2String', this.interactData.likeNum, this.interactData.collectNum, this.interactData.commentNum)
if (name === 'likeNum') {
return this.interactData.likeNum != 0 ? NumberFormatterUtils.formatNumberWithWan(this.interactData.likeNum || '') : ''
} else if (name === 'collectNum') {
return this.interactData.collectNum != 0 ? NumberFormatterUtils.formatNumberWithWan(this.interactData.collectNum || '') : ''
} else {
return this.interactData.commentNum != 0 ? NumberFormatterUtils.formatNumberWithWan(this.interactData.commentNum || '') : ''
}
}.margin({ bottom: 18 })
}
/**
* 点赞、默哀、祈福
*/
@Builder
buildOperationItem(item: OperationItem, index: number) {
likeBuilderView() {
Column() {
if (item.text === '赞') {
Image(this.newsStatusOfUser?.likeStatus == '1' ? item.icon_check : item.icon)
Image(this.transLikeStyle2Icon())
.width(32)
.aspectRatio(1)
.onClick(() => {
// TODO:点赞动画
this.toggleLikeStatus()
})
Text(this.interactData?.likeNum ? (this.interactData.likeNum + '') : item.text)
.width('100%')// .margin({ top: 4, left: 6, right: 6 })// .backgroundColor(Color.Brown)
Text(this.transNum2String('likeNum') || '赞')
.width('100%')
.fontWeight(500)
.textAlign(TextAlign.Center)
.fontSize(13)
.fontColor('#FFFFFF')
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
} else if (item.text === '收藏') {
Image(this.newsStatusOfUser?.collectStatus == 1 ? item.icon_check : item.icon)
}
.margin({ bottom: 20 })
.visibility(this.likesStyle !== 4 ? Visibility.Visible : Visibility.None)
}
/**
* 收藏、取消收藏、收藏文件夹
*/
@Builder
collectBuilderView() {
Column() {
Image(this.newsStatusOfUser.collectStatus == 1 ? $r(`app.media.ic_collect_check`) : $r(`app.media.ic_collect_uncheck`))
.width(32)
.aspectRatio(1)
.onClick(() => {
this.toggleCollectStatus()
})
Text(this.interactData?.collectNum ? (this.interactData.collectNum + '') : item.text)
.width('100%')// .margin({ top: 4, left: 6, right: 6 })// .backgroundColor(Color.Brown)
Text(this.transNum2String('collectNum') || '收藏')
.width('100%')
.fontWeight(500)
.textAlign(TextAlign.Center)
.fontSize(13)
.fontColor('#FFFFFF')
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
} else if (item.text === '抢首评') {
Image(item.icon)
}
.margin({ bottom: 20 })
}
/**
* 评论
*/
@Builder
commentBuilderView() {
Column() {
Image($r(`app.media.ic_comment`))
.width(32)
.aspectRatio(1)
.onClick((event: ClickEvent) => {
ToastUtils.showToast('评论为公共方法,待开发', 1000);
})
Text(this.interactData?.commentNum ? (this.interactData.commentNum + '') : item.text)
.width('100%')// .margin({ top: 4, left: 6, right: 6 })// .backgroundColor(Color.Brown)
Text(this.transNum2String('commentNum') || '抢首评')
.width('100%')
.fontWeight(500)
.textAlign(TextAlign.Center)
.fontSize(13)
.fontColor('#FFFFFF')
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
} else {
Image(item.icon)
}
.margin({ bottom: 20 })
}
/**
* 分享
*/
@Builder
shareBuilderView() {
Column() {
Image($r(`app.media.ic_share`))
.width(32)
.aspectRatio(1)
.onClick((event: ClickEvent) => {
ToastUtils.showToast('分享为公共方法,待开发', 1000);
})
Text(item.text)
.width('100%')// .margin({ top: 4, left: 6, right: 6 })// .backgroundColor(Color.Brown)
Text('分享')
.width('100%')
.fontWeight(500)
.textAlign(TextAlign.Center)
.fontSize(13)
... ... @@ -290,26 +327,6 @@ export struct PlayerRightView {
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
}
}
// .width(48)
.margin({ bottom: 20 })
.alignItems(HorizontalAlign.Center)
.hoverEffect(HoverEffect.Scale)
}
build() {
Column() {
this.buildUserComp()
ForEach(this.operationList, (item: OperationItem, index: number) => {
this.buildOperationItem(item, index)
}, (item: OperationItem, index: number) => JSON.stringify(item))
}
.width(48)
.position({ x: '100%', y: '100%' })
.markAnchor({ x: '100%', y: '100%' })
.padding({ bottom: 72 })
.visibility(this.isOpenDetail || this.isDragging ? Visibility.None : Visibility.Visible)
}
}
\ No newline at end of file
... ...