Showing
1 changed file
with
43 additions
and
16 deletions
| @@ -10,6 +10,7 @@ import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed | @@ -10,6 +10,7 @@ import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed | ||
| 10 | import router from '@ohos.router' | 10 | import router from '@ohos.router' |
| 11 | import { BasePageHelp } from '../page/template/BasePageHelp'; | 11 | import { BasePageHelp } from '../page/template/BasePageHelp'; |
| 12 | import { Logger } from 'wdKit/Index'; | 12 | import { Logger } from 'wdKit/Index'; |
| 13 | +import { hasClicked, persistentStorage } from '../../utils/persistentStorage'; | ||
| 13 | 14 | ||
| 14 | /** | 15 | /** |
| 15 | * 大专题卡--CompStyle: 10 | 16 | * 大专题卡--CompStyle: 10 |
| @@ -182,27 +183,44 @@ export struct Card10Component { | @@ -182,27 +183,44 @@ export struct Card10Component { | ||
| 182 | } | 183 | } |
| 183 | }) | 184 | }) |
| 184 | } | 185 | } |
| 185 | - | ||
| 186 | } | 186 | } |
| 187 | 187 | ||
| 188 | @Builder | 188 | @Builder |
| 189 | timelineItem(item: slideShows, index: number) { | 189 | timelineItem(item: slideShows, index: number) { |
| 190 | + Card10ComponentTimelineItem({ | ||
| 191 | + compDTO:this.compDTO, | ||
| 192 | + slideItem:item, | ||
| 193 | + contentDTO:this.contentDTO, | ||
| 194 | + loadImg:this.loadImg | ||
| 195 | + }) | ||
| 196 | + } | ||
| 197 | +} | ||
| 198 | + | ||
| 199 | +@Component | ||
| 200 | +export struct Card10ComponentTimelineItem { | ||
| 201 | + slideItem: slideShows = new slideShows; | ||
| 202 | + @State contentDTO: ContentDTO = new ContentDTO(); | ||
| 203 | + @ObjectLink compDTO: CompDTO | ||
| 204 | + @State loadImg: boolean = false; | ||
| 205 | + @State isRead: boolean = false;//已读状态 | ||
| 206 | + | ||
| 207 | + build() { | ||
| 190 | Row() { | 208 | Row() { |
| 191 | // 有图片资源的 | 209 | // 有图片资源的 |
| 192 | - if (item.fullColumnImgUrls && item.fullColumnImgUrls[0] && item.fullColumnImgUrls[0].url) { | 210 | + if (this.slideItem.fullColumnImgUrls && this.slideItem.fullColumnImgUrls[0] && this.slideItem.fullColumnImgUrls[0].url) { |
| 193 | 211 | ||
| 194 | Column() { | 212 | Column() { |
| 195 | Stack() { | 213 | Stack() { |
| 196 | - if (item.objectType == '5') { | 214 | + if (this.slideItem.objectType == '5') { |
| 197 | Notes({ objectType: 5 }) | 215 | Notes({ objectType: 5 }) |
| 198 | } | 216 | } |
| 199 | - Text(item.newsTitle) | 217 | + Text(this.slideItem.newsTitle) |
| 200 | .fontSize($r('app.float.font_size_17')) | 218 | .fontSize($r('app.float.font_size_17')) |
| 201 | .fontWeight(400) | 219 | .fontWeight(400) |
| 202 | - .fontColor($r('app.color.color_222222')) | 220 | + .fontColor(this.isRead ? 0x848484 : '#222222') |
| 203 | .maxLines(2) | 221 | .maxLines(2) |
| 204 | .textOverflow({ overflow: TextOverflow.Ellipsis }) | 222 | .textOverflow({ overflow: TextOverflow.Ellipsis }) |
| 205 | - .textIndent(item.objectType == '5' ? 38 : 0) | 223 | + .textIndent(this.slideItem.objectType == '5' ? 38 : 0) |
| 206 | }.alignContent(Alignment.TopStart) | 224 | }.alignContent(Alignment.TopStart) |
| 207 | 225 | ||
| 208 | Blank() | 226 | Blank() |
| @@ -211,7 +229,7 @@ export struct Card10Component { | @@ -211,7 +229,7 @@ export struct Card10Component { | ||
| 211 | { | 229 | { |
| 212 | isCompInnerSource: true, | 230 | isCompInnerSource: true, |
| 213 | compDTO: this.compDTO, | 231 | compDTO: this.compDTO, |
| 214 | - contentDTO: this.createContent(item) | 232 | + contentDTO: this.createContent(this.slideItem) |
| 215 | } | 233 | } |
| 216 | ) | 234 | ) |
| 217 | } | 235 | } |
| @@ -220,7 +238,7 @@ export struct Card10Component { | @@ -220,7 +238,7 @@ export struct Card10Component { | ||
| 220 | .alignItems(HorizontalAlign.Start) | 238 | .alignItems(HorizontalAlign.Start) |
| 221 | 239 | ||
| 222 | Stack() { | 240 | Stack() { |
| 223 | - Image(this.loadImg ? item.fullColumnImgUrls[0].url : '') | 241 | + Image(this.loadImg ? this.slideItem.fullColumnImgUrls[0].url : '') |
| 224 | .backgroundColor(0xf5f5f5) | 242 | .backgroundColor(0xf5f5f5) |
| 225 | .width(117) | 243 | .width(117) |
| 226 | .height(78) | 244 | .height(78) |
| @@ -228,7 +246,7 @@ export struct Card10Component { | @@ -228,7 +246,7 @@ export struct Card10Component { | ||
| 228 | .borderRadius($r('app.float.image_border_radius')) | 246 | .borderRadius($r('app.float.image_border_radius')) |
| 229 | .margin({ left: 12 }) | 247 | .margin({ left: 12 }) |
| 230 | CardMediaInfo({ | 248 | CardMediaInfo({ |
| 231 | - contentDTO: this.createMediaInfoContent(item) | 249 | + contentDTO: this.createMediaInfoContent(this.slideItem) |
| 232 | }) | 250 | }) |
| 233 | } | 251 | } |
| 234 | .alignContent(Alignment.BottomEnd) | 252 | .alignContent(Alignment.BottomEnd) |
| @@ -236,16 +254,16 @@ export struct Card10Component { | @@ -236,16 +254,16 @@ export struct Card10Component { | ||
| 236 | }else{ | 254 | }else{ |
| 237 | Column() { | 255 | Column() { |
| 238 | Stack() { | 256 | Stack() { |
| 239 | - if (item.objectType == '5') { | 257 | + if (this.slideItem.objectType == '5') { |
| 240 | Notes({ objectType: 5 }) | 258 | Notes({ objectType: 5 }) |
| 241 | } | 259 | } |
| 242 | - Text(item.newsTitle) | 260 | + Text(this.slideItem.newsTitle) |
| 243 | .fontSize($r('app.float.font_size_17')) | 261 | .fontSize($r('app.float.font_size_17')) |
| 244 | .fontWeight(400) | 262 | .fontWeight(400) |
| 245 | .fontColor($r('app.color.color_222222')) | 263 | .fontColor($r('app.color.color_222222')) |
| 246 | .maxLines(2) | 264 | .maxLines(2) |
| 247 | .textOverflow({ overflow: TextOverflow.Ellipsis }) | 265 | .textOverflow({ overflow: TextOverflow.Ellipsis }) |
| 248 | - .textIndent(item.objectType == '5' ? 38 : 0) | 266 | + .textIndent(this.slideItem.objectType == '5' ? 38 : 0) |
| 249 | }.alignContent(Alignment.TopStart) | 267 | }.alignContent(Alignment.TopStart) |
| 250 | 268 | ||
| 251 | //bottom 评论等信息 | 269 | //bottom 评论等信息 |
| @@ -253,7 +271,7 @@ export struct Card10Component { | @@ -253,7 +271,7 @@ export struct Card10Component { | ||
| 253 | { | 271 | { |
| 254 | isCompInnerSource: true, | 272 | isCompInnerSource: true, |
| 255 | compDTO: this.compDTO, | 273 | compDTO: this.compDTO, |
| 256 | - contentDTO: this.createContent(item) | 274 | + contentDTO: this.createContent(this.slideItem) |
| 257 | } | 275 | } |
| 258 | ) | 276 | ) |
| 259 | } | 277 | } |
| @@ -264,15 +282,24 @@ export struct Card10Component { | @@ -264,15 +282,24 @@ export struct Card10Component { | ||
| 264 | } | 282 | } |
| 265 | .padding({ top: 10, bottom: 10 }) | 283 | .padding({ top: 10, bottom: 10 }) |
| 266 | .onClick((event: ClickEvent) => { | 284 | .onClick((event: ClickEvent) => { |
| 285 | + this.isRead = true | ||
| 286 | + persistentStorage(this.slideItem.newsId); | ||
| 287 | + | ||
| 267 | const str: string = JSON.stringify(this.contentDTO); | 288 | const str: string = JSON.stringify(this.contentDTO); |
| 268 | const data: ContentDTO = JSON.parse(str) | 289 | const data: ContentDTO = JSON.parse(str) |
| 269 | - data.objectId = item.newsId | ||
| 270 | - data.relId = item.relId | ||
| 271 | - data.objectType = String(item.objectType) | 290 | + data.objectId = this.slideItem.newsId |
| 291 | + data.relId = this.slideItem.relId | ||
| 292 | + data.linkUrl = this.slideItem.linkUrl | ||
| 293 | + data.objectType = String(this.slideItem.objectType) | ||
| 272 | ProcessUtils.processPage(data) | 294 | ProcessUtils.processPage(data) |
| 273 | }) | 295 | }) |
| 274 | } | 296 | } |
| 275 | 297 | ||
| 298 | + aboutToAppear(): void { | ||
| 299 | + this.isRead = hasClicked(this.slideItem.newsId, '') | ||
| 300 | + } | ||
| 301 | + | ||
| 302 | + | ||
| 276 | private createContent(item: slideShows): ContentDTO { | 303 | private createContent(item: slideShows): ContentDTO { |
| 277 | let contentDTO = new ContentDTO() | 304 | let contentDTO = new ContentDTO() |
| 278 | contentDTO.publishTime = item.publishTime?.toString() || ''; | 305 | contentDTO.publishTime = item.publishTime?.toString() || ''; |
-
Please register or login to post a comment