wangliang_wd

feat:优化专题卡跳转问题,增加已读状态

... ... @@ -10,6 +10,7 @@ import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed
import router from '@ohos.router'
import { BasePageHelp } from '../page/template/BasePageHelp';
import { Logger } from 'wdKit/Index';
import { hasClicked, persistentStorage } from '../../utils/persistentStorage';
/**
* 大专题卡--CompStyle: 10
... ... @@ -182,27 +183,44 @@ export struct Card10Component {
}
})
}
}
@Builder
timelineItem(item: slideShows, index: number) {
Card10ComponentTimelineItem({
compDTO:this.compDTO,
slideItem:item,
contentDTO:this.contentDTO,
loadImg:this.loadImg
})
}
}
@Component
export struct Card10ComponentTimelineItem {
slideItem: slideShows = new slideShows;
@State contentDTO: ContentDTO = new ContentDTO();
@ObjectLink compDTO: CompDTO
@State loadImg: boolean = false;
@State isRead: boolean = false;//已读状态
build() {
Row() {
// 有图片资源的
if (item.fullColumnImgUrls && item.fullColumnImgUrls[0] && item.fullColumnImgUrls[0].url) {
if (this.slideItem.fullColumnImgUrls && this.slideItem.fullColumnImgUrls[0] && this.slideItem.fullColumnImgUrls[0].url) {
Column() {
Stack() {
if (item.objectType == '5') {
if (this.slideItem.objectType == '5') {
Notes({ objectType: 5 })
}
Text(item.newsTitle)
Text(this.slideItem.newsTitle)
.fontSize($r('app.float.font_size_17'))
.fontWeight(400)
.fontColor($r('app.color.color_222222'))
.fontColor(this.isRead ? 0x848484 : '#222222')
.maxLines(2)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.textIndent(item.objectType == '5' ? 38 : 0)
.textIndent(this.slideItem.objectType == '5' ? 38 : 0)
}.alignContent(Alignment.TopStart)
Blank()
... ... @@ -211,7 +229,7 @@ export struct Card10Component {
{
isCompInnerSource: true,
compDTO: this.compDTO,
contentDTO: this.createContent(item)
contentDTO: this.createContent(this.slideItem)
}
)
}
... ... @@ -220,7 +238,7 @@ export struct Card10Component {
.alignItems(HorizontalAlign.Start)
Stack() {
Image(this.loadImg ? item.fullColumnImgUrls[0].url : '')
Image(this.loadImg ? this.slideItem.fullColumnImgUrls[0].url : '')
.backgroundColor(0xf5f5f5)
.width(117)
.height(78)
... ... @@ -228,7 +246,7 @@ export struct Card10Component {
.borderRadius($r('app.float.image_border_radius'))
.margin({ left: 12 })
CardMediaInfo({
contentDTO: this.createMediaInfoContent(item)
contentDTO: this.createMediaInfoContent(this.slideItem)
})
}
.alignContent(Alignment.BottomEnd)
... ... @@ -236,16 +254,16 @@ export struct Card10Component {
}else{
Column() {
Stack() {
if (item.objectType == '5') {
if (this.slideItem.objectType == '5') {
Notes({ objectType: 5 })
}
Text(item.newsTitle)
Text(this.slideItem.newsTitle)
.fontSize($r('app.float.font_size_17'))
.fontWeight(400)
.fontColor($r('app.color.color_222222'))
.maxLines(2)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.textIndent(item.objectType == '5' ? 38 : 0)
.textIndent(this.slideItem.objectType == '5' ? 38 : 0)
}.alignContent(Alignment.TopStart)
//bottom 评论等信息
... ... @@ -253,7 +271,7 @@ export struct Card10Component {
{
isCompInnerSource: true,
compDTO: this.compDTO,
contentDTO: this.createContent(item)
contentDTO: this.createContent(this.slideItem)
}
)
}
... ... @@ -264,15 +282,24 @@ export struct Card10Component {
}
.padding({ top: 10, bottom: 10 })
.onClick((event: ClickEvent) => {
this.isRead = true
persistentStorage(this.slideItem.newsId);
const str: string = JSON.stringify(this.contentDTO);
const data: ContentDTO = JSON.parse(str)
data.objectId = item.newsId
data.relId = item.relId
data.objectType = String(item.objectType)
data.objectId = this.slideItem.newsId
data.relId = this.slideItem.relId
data.linkUrl = this.slideItem.linkUrl
data.objectType = String(this.slideItem.objectType)
ProcessUtils.processPage(data)
})
}
aboutToAppear(): void {
this.isRead = hasClicked(this.slideItem.newsId, '')
}
private createContent(item: slideShows): ContentDTO {
let contentDTO = new ContentDTO()
contentDTO.publishTime = item.publishTime?.toString() || '';
... ...