陈剑华

Merge remote-tracking branch 'origin/main'

... ... @@ -9,4 +9,6 @@ export class InteractDataDTO {
likeNum: number | string = 0;
readNum: number = 0;
shareNum: number = 0;
}
\ No newline at end of file
... ...
import { InteractDataDTO } from '../content/InteractDataDTO';
import { FullColumnImgUrlDTO } from '../detail/FullColumnImgUrlDTO';
export interface slideShows {
fullColumnImgUrls: FullColumnImgUrlDTO[];
linkUrl?: string;
newsId: string;
newsTitle?: string;
newsTitleColor?: string;
objectLevel?: string;
objectType: string;
pageId?: string;
photoNum?: string;
publishTime: number;
relId: string;
source?: string;
timeBlurred?: string;
videoDuration?: string;
videoLandscape?: string;
videoUrl?: string;
voiceDuration?: string;
@Observed
export class slideShows {
fullColumnImgUrls?: FullColumnImgUrlDTO[];
linkUrl: string='';
newsId: string = '';
newsTitle: string='';
newsTitleColor: string='';
objectLevel: string='';
objectType: string ='';
pageId: string='';
photoNum: string='';
publishTime: number=0;
relId: string='';
source: string='';
timeBlurred: string='';
videoDuration: string='';
videoLandscape: string='';
videoUrl: string='';
voiceDuration: string='';
interactDataDto? :InteractDataDTO
}
\ No newline at end of file
... ...
... ... @@ -8,6 +8,7 @@ import router from '@ohos.router'
export struct CardSourceInfo {
@State contentDTO: ContentDTO = new ContentDTO();
@ObjectLink compDTO: CompDTO
isCompInnerSource: boolean = false
aboutToAppear(): void {
}
... ... @@ -21,6 +22,7 @@ export struct CardSourceInfo {
aboutToDisappear(): void {
}
handleTimeStr() {
return DateTimeUtils.getCommentTime(
this.contentDTO.publishTime.includes(' ')
... ... @@ -54,7 +56,6 @@ export struct CardSourceInfo {
return true
}
/**
* 全域数字显示规则
* 1、当数量为千位以內时,显示数字,不保留小数点,比如 4585
... ... @@ -64,17 +65,17 @@ export struct CardSourceInfo {
* 5、0 和空 不显示
*/
handlerNum(number: string) {
const num = number??'0';
const num = number ?? '0';
if (Number.parseInt(num) <= 9999) {
return Number.parseInt(num).toString()
} else if (Number.parseInt(num) > 9999 && Number.parseInt(num) <= 99999999) {
const num1: string = num.slice(0, -4); // 万
const num2: string = num.slice(-4, -3); // 千
return num2 === '0' ? num1 +'万' : num1 + '.' + num2 + '万'
return num2 === '0' ? num1 + '万' : num1 + '.' + num2 + '万'
} else if (Number.parseInt(num) > 99999999) {
const num1: string = num.slice(0, -8); // 亿
const num2: string = num.slice(-8, -7);
return num2 === '0' ? num1 +'亿' : num1 + '.' + num2 + '亿'
return num2 === '0' ? num1 + '亿' : num1 + '.' + num2 + '亿'
}
return num
}
... ... @@ -94,7 +95,7 @@ export struct CardSourceInfo {
.fontColor($r("app.color.color_ED2800"))
.margin({ right: 2 })
}
if(this.contentDTO.cornerMark){
if (this.contentDTO.cornerMark) {
Text(this.contentDTO.cornerMark)
.fontSize($r("app.float.font_size_11"))
.fontColor($r("app.color.color_ED2800"))
... ... @@ -113,59 +114,52 @@ export struct CardSourceInfo {
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
}
if (((this.contentDTO.rmhPlatform === 1 && this.contentDTO.rmhInfo?.rmhName && this.contentDTO.rmhInfo?.rmhName != '') || (this.contentDTO.source && this.contentDTO.source != '')) && (this.getContentDtoBean()?.interactData?.commentNum
// || DateTimeUtils.getCommentTime(Number.parseFloat(this.contentDTO.publishTime)) != ''
|| (this.contentDTO.isSearch || this.contentDTO.isCollection ||
!this.contentDTO.isSearch && DateTimeUtils.getCommentTime
(Number
.parseFloat(this
.contentDTO.publishTime))
.indexOf
('-') === -1)
)) {
if (((this.contentDTO.rmhPlatform === 1 && this.contentDTO.rmhInfo?.rmhName &&
this.contentDTO.rmhInfo?.rmhName != '') || (this.contentDTO.source && this.contentDTO.source != '')) &&
(this.getContentDtoBean()?.interactData?.commentNum
// || DateTimeUtils.getCommentTime(Number.parseFloat(this.contentDTO.publishTime)) != ''
|| (this.contentDTO.isSearch || this.contentDTO.isCollection ||
!this.contentDTO.isSearch && DateTimeUtils.getCommentTime
(Number
.parseFloat(this
.contentDTO.publishTime))
.indexOf
('-') === -1)
)) {
Image($r("app.media.point"))
.width(11)
.height(11)
}
// 新闻tab下的卡片,2天之前的不显示时间。但是如果是搜索情况下展示的卡片,显示时间
// if (this.contentDTO.isSearch || this.contentDTO.isCollection ||
// (!this.contentDTO.isSearch &&
// DateTimeUtils.getCommentTime(Number.parseFloat(this.contentDTO.publishTime)).indexOf('-') === -1)) {
//
// Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.contentDTO.publishTime)))
// .fontSize($r("app.float.font_size_11"))
// .fontColor($r("app.color.color_B0B0B0"))
// .flexShrink(0);
// }
// if (this.contentDTO.source && this.showTime()) {
// Text(this.handleTimeStr())
// .fontSize($r("app.float.font_size_11"))
// .fontColor($r("app.color.color_B0B0B0"))
// .flexShrink(0)
// .margin({right: 4})
// }
// 发布日期
if (this.showTime()) {
Text(this.handleTimeStr())
.fontSize($r("app.float.font_size_11"))
.fontColor($r("app.color.color_B0B0B0"))
.flexShrink(0)
.margin({right: 4})
.margin({ right: 4 })
}
if (Number(this.getContentDtoBean()?.interactData?.commentNum) > 0 && this.showCommentNum()) {
if (!this.isCompInnerSource && Number(this.getContentDtoBean()?.interactData?.commentNum) > 0 &&
this.showCommentNum()) {
Text(`${this.handlerNum(this.getContentDtoBean()?.interactData?.commentNum.toString())}评`)
.fontSize($r("app.float.font_size_11"))
.fontColor($r("app.color.color_B0B0B0"))
.flexShrink(0)
} else {
if (this.isCompInnerSource && this.contentDTO.interactData && this.contentDTO.interactData?.commentNum > 0) {
Text(`${this.handlerNum(this.contentDTO.interactData?.commentNum.toString())}评`)
.fontSize($r("app.float.font_size_11"))
.fontColor($r("app.color.color_B0B0B0"))
.flexShrink(0)
}
}
// if (this.getContentDtoBean()?.interactData?.commentNum && this.contentDTO.source) {
// Text(`${this.getContentDtoBean()?.interactData?.commentNum}评`)
// .fontSize($r("app.float.font_size_11"))
// .fontColor($r("app.color.color_B0B0B0"))
// .flexShrink(0)
// .visibility(Number(this.getContentDtoBean()?.interactData?.commentNum) === 0 ? Visibility.None :
// Visibility.Visible)
// }
}
.width(CommonConstants.FULL_WIDTH)
.margin({ top: 8 })
... ...
import { ContentDTO, slideShows, VideoInfoDTO, CompDTO } from 'wdBean';
import { ContentDTO, slideShows, VideoInfoDTO, CompDTO, InteractDataDTO } from 'wdBean';
import { CommonConstants } from 'wdConstant';
import { ProcessUtils } from 'wdRouter';
import { CardSourceInfo } from '../cardCommon/CardSourceInfo';
... ... @@ -8,6 +8,8 @@ import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
import { InfomationCardClick } from '../../utils/infomationCardClick'
import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed';
import router from '@ohos.router'
import { BasePageHelp } from '../page/template/BasePageHelp';
import { Logger } from 'wdKit/Index';
/**
* 大专题卡--CompStyle: 10
... ... @@ -25,11 +27,40 @@ export struct Card10Component {
@State titleMarked: boolean = false;
@State textArr: textItem[] = []
@State hideDetail: boolean = false;
basePageHelp: BasePageHelp = new BasePageHelp
// 稿件参与批查,需要对列表信息单独重绘
@State isBatchData : boolean= false
async aboutToAppear(): Promise<void> {
this.titleInit();
this.loadImg = await onlyWifiLoadImg();
this.initHideDetail();
if (!this.hideDetail) {
this.isBatchData = false
// 批查评论数据
let interactArray = this.basePageHelp.getCompInteractParams(this.contentDTO.slideShows)
if (interactArray.contentList != null && interactArray.contentList.length > 0) {
this.basePageHelp.requestCompInteractData(interactArray)
.then((result) => {
if (result != null && result.length > 0) {
this.isBatchData = true
this.contentDTO.slideShows.forEach((slideShowBean) => {
let newsId = slideShowBean.newsId
for (let interactBean of result) {
console.debug(TAG, JSON.stringify(interactBean))
if (newsId == interactBean.contentId) {
slideShowBean.interactDataDto = interactBean
break
}
}
})
}
})
}
}
}
initHideDetail() {
... ... @@ -40,7 +71,7 @@ export struct Card10Component {
}
titleInit() {
const titleInitRes:titleInitRes = SearchShowRed.titleInit(this.contentDTO.title);
const titleInitRes: titleInitRes = SearchShowRed.titleInit(this.contentDTO.title);
this.titleMarked = titleInitRes.titleMarked;
this.textArr = titleInitRes.textArr;
}
... ... @@ -63,16 +94,16 @@ export struct Card10Component {
Span(this.contentDTO.newsTitle)
}
}
.width(CommonConstants.FULL_WIDTH)
.fontSize($r('app.float.font_size_18'))
.fontWeight(600)
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.margin({ bottom: 19 })
.onClick((event: ClickEvent) => {
InfomationCardClick.track(this.compDTO, this.contentDTO, this.pageId, this.pageName)
ProcessUtils.processPage(this.contentDTO)
})
.width(CommonConstants.FULL_WIDTH)
.fontSize($r('app.float.font_size_18'))
.fontWeight(600)
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.margin({ bottom: 19 })
.onClick((event: ClickEvent) => {
InfomationCardClick.track(this.compDTO, this.contentDTO, this.pageId, this.pageName)
ProcessUtils.processPage(this.contentDTO)
})
}
// 大图
Stack() {
... ... @@ -94,17 +125,15 @@ export struct Card10Component {
// 专题列表--后端返回三个,
if (!this.hideDetail) {
Column() {
ForEach(this.contentDTO.slideShows, (item: slideShows, index: number) => {
this.timelineItem(item, index)
if (index < this.contentDTO.slideShows.length - 1) {
// 在不是最后一个元素的情况下添加分隔符
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 0, right: 0 });
}
})
if(this.isBatchData){
this.drawCompList()
}else {
this.drawCompList()
}
}
}
// 底部-查看更多。根据接口返回的isMore判断是否显示查看更多
if (this.contentDTO.hasMore == 1 && !this.hideDetail) {
... ... @@ -141,6 +170,21 @@ export struct Card10Component {
}
@Builder
drawCompList(){
Column() {
ForEach(this.contentDTO.slideShows, (item: slideShows, index: number) => {
this.timelineItem(item, index)
if (index < this.contentDTO.slideShows.length - 1) {
// 在不是最后一个元素的情况下添加分隔符
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 0, right: 0 });
}
})
}
}
@Builder
timelineItem(item: slideShows, index: number) {
Row() {
Column() {
... ... @@ -161,6 +205,7 @@ export struct Card10Component {
//bottom 评论等信息
CardSourceInfo(
{
isCompInnerSource:true,
compDTO: this.compDTO,
contentDTO: this.createContent(item)
}
... ... @@ -171,7 +216,7 @@ export struct Card10Component {
.alignItems(HorizontalAlign.Start)
// 右侧图片
if (item.fullColumnImgUrls[0] && item.fullColumnImgUrls[0].url) {
if (item.fullColumnImgUrls && item.fullColumnImgUrls[0] && item.fullColumnImgUrls[0].url) {
Stack() {
Image(this.loadImg ? item.fullColumnImgUrls[0].url : '')
.backgroundColor(0xf5f5f5)
... ... @@ -201,8 +246,9 @@ export struct Card10Component {
private createContent(item: slideShows): ContentDTO {
let contentDTO = new ContentDTO()
contentDTO.publishTime = item.publishTime.toString() || '';
contentDTO.publishTime = item.publishTime?.toString() || '';
contentDTO.source = item.source || '';
contentDTO.interactData = item.interactDataDto
return contentDTO;
}
... ... @@ -214,4 +260,6 @@ export struct Card10Component {
contentDTO.voiceInfo = { voiceDuration: Number(item.voiceDuration) as number };
return contentDTO;
}
}
\ No newline at end of file
... ...
... ... @@ -395,7 +395,7 @@ export struct PaperSingleColumn999CardView {
private item: ContentDTO = new ContentDTO();
private index: number = -1;
@State isRead: boolean = false;//已读状态
@State interactData: InteractDataDTO = {} as InteractDataDTO;
@State interactData: InteractDataDTO = new InteractDataDTO
@Consume @Watch('onChangeCommentList') commentList: InteractDataDTO[]
getPublishTime(): string {
... ...
import { CompDTO,
import {
CompDTO,
ContentBean,
ContentDTO,
InteractDataDTO,
InteractParam, LiveRoomDataBean, ReserveBean, ReserveItemBean } from 'wdBean/Index'
InteractParam,
LiveRoomDataBean,
ReserveBean,
ReserveItemBean,
slideShows
} from 'wdBean/Index'
import { BaseDTO } from 'wdBean/src/main/ets/bean/component/BaseDTO'
import { CollectionUtils, DateTimeUtils, LazyDataSource, Logger, StringUtils } from 'wdKit/Index'
import { HttpUtils, ResponseDTO } from 'wdNetwork/Index'
... ... @@ -22,7 +28,7 @@ export class BasePageHelp {
if (HttpUtils.getUserId()) {
let time = DateTimeUtils.getTimeStamp().toString()
Logger.debug(TAG, 'getAppointmentInfo-->'+time)
Logger.debug(TAG, 'getAppointmentInfo-->' + time)
const reserveBean = this.transformToLiveDetailsBeans(compList)
LiveModel.getAppointmentStatus(reserveBean).then((result) => {
Logger.debug(TAG, '是否预约数据:' + ` ${JSON.stringify(result)}`)
... ... @@ -116,11 +122,11 @@ export class BasePageHelp {
return idList.join(',')
}
/**
* 批查稿件的互动数据,如 评论人数等
* @param compList
* @returns
*/
/**
* 批查稿件的互动数据,如 评论人数等
* @param compList
* @returns
*/
async getInteractData(compList: CompDTO[]) {
let param: InteractParam = this.getInteractParams(compList);
const SIZE = 20;
... ... @@ -165,13 +171,17 @@ export class BasePageHelp {
allInteractDataList.push(...value);
}
})
// 批查全部完成,统一设置到comp里
// this.resetInteract(allInteractDataList, compList);
success(allInteractDataList);
})
})
}
/**
* 收集信息流页面,可参与批查稿件的业务信息
* @param compList
* @returns
*/
private getInteractParams(compList: CompDTO[]): InteractParam {
if (compList == null || compList.length == 0) {
return {} as InteractParam;
... ... @@ -204,6 +214,34 @@ export class BasePageHelp {
return param;
}
/**
* 获取组件中需要参与批查业务信息
* @param slideShowArray
* @returns
*/
public getCompInteractParams(slideShowArray: slideShows[]): InteractParam {
if (slideShowArray == null || slideShowArray.length == 0) {
return {} as InteractParam;
}
let param: InteractParam = {} as InteractParam;
param.contentList = new Array<ContentBean>();
slideShowArray.forEach((value) => {
let bean = {} as ContentBean;
bean.contentId = value.newsId;
bean.contentType = value.objectType;
param.contentList.push(bean);
})
return param
}
/**
* 查询互动相关数据,如收藏数、评论数等
* @param param
* @returns
*/
private createInteractDataPromise(param: InteractParam) {
return new Promise<InteractDataDTO[]>((success, error) => {
PageRepository.fetchInteractData(param).then((resDTO: ResponseDTO<InteractDataDTO[]>) => {
... ... @@ -221,12 +259,24 @@ export class BasePageHelp {
});
}
async requestCompInteractData(param: InteractParam): Promise<InteractDataDTO[]> {
return new Promise<InteractDataDTO[]>((success, error) => {
this.createInteractDataPromise(param).then((result) => {
if (!CollectionUtils.isArray(result)) {
success(new Array<InteractDataDTO>());
return;
}
success(result);
})
})
}
/**
* 刷新互动数据到compList
* @param interact 批查互动数据结果
* @param compList comp list
*/
resetInteract(interact: InteractDataDTO[], compList: BaseDTO[]) {
resetInteract(interact: InteractDataDTO[], compList: BaseDTO[]) {
if (interact == null || interact.length == 0) {
return
}
... ... @@ -252,6 +302,4 @@ export class BasePageHelp {
}
})
}
}
\ No newline at end of file
... ...
... ... @@ -59,7 +59,7 @@ export struct LiveOperRowListView {
@State needLike: boolean = true
@State styleType: number = -1
@State bgColor: ResourceColor = Color.White
@State interactData: InteractDataDTO = {} as InteractDataDTO
@State interactData: InteractDataDTO = new InteractDataDTO
@State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态
@State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0
@State dialogController: CustomDialogController | null = null;
... ...