Showing
4 changed files
with
57 additions
and
25 deletions
| @@ -195,6 +195,7 @@ export struct ENewspaperPageComponent { | @@ -195,6 +195,7 @@ export struct ENewspaperPageComponent { | ||
| 195 | top: { anchor: "e_newspaper_top", align: VerticalAlign.Bottom }, | 195 | top: { anchor: "e_newspaper_top", align: VerticalAlign.Bottom }, |
| 196 | middle: { anchor: "__container__", align: HorizontalAlign.Center } | 196 | middle: { anchor: "__container__", align: HorizontalAlign.Center } |
| 197 | }) | 197 | }) |
| 198 | + .effectMode(EdgeEffect.None) | ||
| 198 | .onChange((index: number) => { | 199 | .onChange((index: number) => { |
| 199 | this.currentPageNum = this.newspaperListBean?.list[index]?.pageNum | 200 | this.currentPageNum = this.newspaperListBean?.list[index]?.pageNum |
| 200 | this.swiperIndex = index | 201 | this.swiperIndex = index |
| @@ -202,12 +203,12 @@ export struct ENewspaperPageComponent { | @@ -202,12 +203,12 @@ export struct ENewspaperPageComponent { | ||
| 202 | 203 | ||
| 203 | Image($r('app.media.newspaper_shadow')) | 204 | Image($r('app.media.newspaper_shadow')) |
| 204 | .height($r('app.float.vp_12')) | 205 | .height($r('app.float.vp_12')) |
| 205 | - .margin({ left: 20, right: 20, top: -1 }) | 206 | + .margin({ left: 10, right: 10, top: -1 }) |
| 206 | .objectFit(ImageFit.Contain) | 207 | .objectFit(ImageFit.Contain) |
| 207 | .alignRules({ | 208 | .alignRules({ |
| 208 | top: { anchor: "e_newspaper_content", align: VerticalAlign.Bottom }, | 209 | top: { anchor: "e_newspaper_content", align: VerticalAlign.Bottom }, |
| 209 | - left: { anchor: 'e_newspaper_content', align: HorizontalAlign.Start }, | ||
| 210 | - right: { anchor: 'e_newspaper_content', align: HorizontalAlign.End } | 210 | + // left: { anchor: 'e_newspaper_content', align: HorizontalAlign.Start }, |
| 211 | + // right: { anchor: 'e_newspaper_content', align: HorizontalAlign.End } | ||
| 211 | }) | 212 | }) |
| 212 | .id('e_newspaper_shadow') | 213 | .id('e_newspaper_shadow') |
| 213 | 214 |
| @@ -61,6 +61,7 @@ export struct ChildCommentComponent { | @@ -61,6 +61,7 @@ export struct ChildCommentComponent { | ||
| 61 | .lineHeight("31lpx") | 61 | .lineHeight("31lpx") |
| 62 | .fontColor(this.data.like_status === 0 ? $r('app.color.color_666666') : $r('app.color.color_ED2800')) | 62 | .fontColor(this.data.like_status === 0 ? $r('app.color.color_666666') : $r('app.color.color_ED2800')) |
| 63 | .margin({ right: '8lpx' }) | 63 | .margin({ right: '8lpx' }) |
| 64 | + .visibility(this.data.likeNum <= 0||StringUtils.isEmpty(this.data.likeNum.toString()) ? Visibility.Hidden : Visibility.Visible) | ||
| 64 | Image(this.data.like_status === 0 ? $r('app.media.like_default_status') : $r('app.media.liked_status')) | 65 | Image(this.data.like_status === 0 ? $r('app.media.like_default_status') : $r('app.media.liked_status')) |
| 65 | .width('31lpx') | 66 | .width('31lpx') |
| 66 | .height('31lpx') | 67 | .height('31lpx') |
| 1 | -import { CompDTO, ContentDTO, PageDTO, PageInfoDTO } from 'wdBean'; | 1 | +import { CompDTO, ContentDTO, InteractDataDTO, PageDTO, PageInfoDTO } from 'wdBean'; |
| 2 | import { CompStyle, ViewType } from 'wdConstant/Index'; | 2 | import { CompStyle, ViewType } from 'wdConstant/Index'; |
| 3 | -import { CollectionUtils, DateTimeUtils, Logger, NetworkUtil, StringUtils } from 'wdKit'; | 3 | +import { CollectionUtils, DateTimeUtils, LazyDataSource, Logger, NetworkUtil, StringUtils } from 'wdKit'; |
| 4 | import { closeRefresh } from '../utils/PullDownRefresh'; | 4 | import { closeRefresh } from '../utils/PullDownRefresh'; |
| 5 | import PageModel from './PageModel'; | 5 | import PageModel from './PageModel'; |
| 6 | import PageViewModel from './PageViewModel'; | 6 | import PageViewModel from './PageViewModel'; |
| @@ -10,6 +10,7 @@ import PageAdModel from './PageAdvModel'; | @@ -10,6 +10,7 @@ import PageAdModel from './PageAdvModel'; | ||
| 10 | import { ArrayList } from '@kit.ArkTS'; | 10 | import { ArrayList } from '@kit.ArkTS'; |
| 11 | import { WDViewDefaultType } from '../components/view/EmptyComponent'; | 11 | import { WDViewDefaultType } from '../components/view/EmptyComponent'; |
| 12 | import { CompAdvMatInfoBean } from 'wdBean/src/main/ets/bean/adv/CompAdvInfoBean'; | 12 | import { CompAdvMatInfoBean } from 'wdBean/src/main/ets/bean/adv/CompAdvInfoBean'; |
| 13 | +import { BaseDTO } from 'wdBean/src/main/ets/bean/component/BaseDTO'; | ||
| 13 | 14 | ||
| 14 | const TAG = 'PageHelper'; | 15 | const TAG = 'PageHelper'; |
| 15 | 16 | ||
| @@ -121,7 +122,6 @@ export class PageHelper { | @@ -121,7 +122,6 @@ export class PageHelper { | ||
| 121 | pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() | 122 | pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() |
| 122 | if (pageDto && pageDto.compList && pageDto.compList.length > 0) { | 123 | if (pageDto && pageDto.compList && pageDto.compList.length > 0) { |
| 123 | pageModel.viewType = ViewType.LOADED; | 124 | pageModel.viewType = ViewType.LOADED; |
| 124 | - let sizeBefore: number = pageModel.compList.size(); | ||
| 125 | if (isLastGroup) { | 125 | if (isLastGroup) { |
| 126 | // 认为分页只会在最后一个group里 | 126 | // 认为分页只会在最后一个group里 |
| 127 | pageModel.currentPage++; | 127 | pageModel.currentPage++; |
| @@ -132,17 +132,15 @@ export class PageHelper { | @@ -132,17 +132,15 @@ export class PageHelper { | ||
| 132 | //移除音频 和 活动 | 132 | //移除音频 和 活动 |
| 133 | this.collectPageComp(pageModel, pageDto) | 133 | this.collectPageComp(pageModel, pageDto) |
| 134 | 134 | ||
| 135 | - // pageModel.compList.push(...pageDto.compList) | ||
| 136 | - | ||
| 137 | // TODO 暂时去掉互动数据,待优化。(主要是互动数据返回,如何渲染到ui上) | 135 | // TODO 暂时去掉互动数据,待优化。(主要是互动数据返回,如何渲染到ui上) |
| 138 | // TODO updateItems(sizeBefore, data),这里可能有时序问题,导致覆盖别的group数据,需要优化,考虑精准替换 | 136 | // TODO updateItems(sizeBefore, data),这里可能有时序问题,导致覆盖别的group数据,需要优化,考虑精准替换 |
| 139 | // 二次请求,批查互动数据 | 137 | // 二次请求,批查互动数据 |
| 140 | - // PageViewModel.getInteractData(pageDto.compList).then((data: CompDTO[]) => { | ||
| 141 | - // // 刷新,替换所有数据 | ||
| 142 | - // // pageModel.compList.replaceAll(...data) | ||
| 143 | - // pageModel.compList.updateItems(sizeBefore, data) | ||
| 144 | - // pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 145 | - // }) | 138 | + PageViewModel.getInteractData(pageDto.compList).then((data: InteractDataDTO[]) => { |
| 139 | + // 刷新,替换所有数据 | ||
| 140 | + this.resetInteract(data, pageModel.compList) | ||
| 141 | + pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 142 | + pageModel.compList.reloadData() | ||
| 143 | + }) | ||
| 146 | // content级别的展现加载丢给comp自己,这里只需要处理屏蔽分页加载,pageModel.pageScroll | 144 | // content级别的展现加载丢给comp自己,这里只需要处理屏蔽分页加载,pageModel.pageScroll |
| 147 | if (isLastGroup) { | 145 | if (isLastGroup) { |
| 148 | closeRefresh(pageModel, true); | 146 | closeRefresh(pageModel, true); |
| @@ -335,18 +333,17 @@ export class PageHelper { | @@ -335,18 +333,17 @@ export class PageHelper { | ||
| 335 | // 直接认为有分页,一直加载分页。直到没有数据,再停止 | 333 | // 直接认为有分页,一直加载分页。直到没有数据,再停止 |
| 336 | pageModel.currentPage++; | 334 | pageModel.currentPage++; |
| 337 | pageModel.hasMore = true; | 335 | pageModel.hasMore = true; |
| 338 | - let sizeBefore: number = pageModel.compList.size(); | ||
| 339 | 336 | ||
| 340 | //移除音频 和 活动 | 337 | //移除音频 和 活动 |
| 341 | this.collectPageComp(pageModel, data) | 338 | this.collectPageComp(pageModel, data) |
| 342 | 339 | ||
| 343 | - // pageModel.compList.push(...data.compList) | ||
| 344 | // TODO 暂时屏蔽,此处代码会造成 广告逻辑错乱,只有第一页有广告数据,随着加载更多,第二页也会出现广告数据 | 340 | // TODO 暂时屏蔽,此处代码会造成 广告逻辑错乱,只有第一页有广告数据,随着加载更多,第二页也会出现广告数据 |
| 345 | - // PageViewModel.getInteractData(data.compList).then((data: CompDTO[]) => { | ||
| 346 | - // // 刷新,替换所有数据 | ||
| 347 | - // pageModel.compList.updateItems(sizeBefore, data) | ||
| 348 | - // pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 349 | - // }) | 341 | + PageViewModel.getInteractData(data.compList).then((data: InteractDataDTO[]) => { |
| 342 | + // 刷新,替换所有数据 | ||
| 343 | + this.resetInteract(data, pageModel.compList) | ||
| 344 | + pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 345 | + pageModel.compList.reloadData() | ||
| 346 | + }) | ||
| 350 | } | 347 | } |
| 351 | }).catch((err: string | Resource) => { | 348 | }).catch((err: string | Resource) => { |
| 352 | promptAction.showToast({ message: err }); | 349 | promptAction.showToast({ message: err }); |
| @@ -394,6 +391,36 @@ export class PageHelper { | @@ -394,6 +391,36 @@ export class PageHelper { | ||
| 394 | 391 | ||
| 395 | 392 | ||
| 396 | } | 393 | } |
| 394 | + | ||
| 395 | + /** | ||
| 396 | + * 刷新互动数据到compList | ||
| 397 | + * @param interact 批查互动数据结果 | ||
| 398 | + * @param compList comp list | ||
| 399 | + */ | ||
| 400 | + private resetInteract(interact: InteractDataDTO[], compList: LazyDataSource<BaseDTO>) { | ||
| 401 | + if (interact == null || interact.length == 0) { | ||
| 402 | + return | ||
| 403 | + } | ||
| 404 | + interact.forEach((interactData) => { | ||
| 405 | + let id = interactData.contentId; | ||
| 406 | + outer: for (let i = 0; i < compList.totalCount(); i++) { | ||
| 407 | + let comp = compList.getData(i) as CompDTO; | ||
| 408 | + if (comp == null || comp.operDataList == null || comp.operDataList.length == 0) { | ||
| 409 | + continue; | ||
| 410 | + } | ||
| 411 | + for (let j = 0; j < comp.operDataList.length; j++) { | ||
| 412 | + let content = comp.operDataList[j]; | ||
| 413 | + if (content == null) { | ||
| 414 | + continue; | ||
| 415 | + } | ||
| 416 | + if (id == content.objectId) { | ||
| 417 | + content.interactData = interactData; | ||
| 418 | + break outer; | ||
| 419 | + } | ||
| 420 | + } | ||
| 421 | + } | ||
| 422 | + }) | ||
| 423 | + } | ||
| 397 | } | 424 | } |
| 398 | 425 | ||
| 399 | 426 |
| @@ -232,10 +232,10 @@ export class PageViewModel extends BaseViewModel { | @@ -232,10 +232,10 @@ export class PageViewModel extends BaseViewModel { | ||
| 232 | } | 232 | } |
| 233 | } | 233 | } |
| 234 | 234 | ||
| 235 | - return new Promise<CompDTO[]>((success, error) => { | 235 | + return new Promise<InteractDataDTO[]>((success, error) => { |
| 236 | Promise.all(promises).then((result) => { | 236 | Promise.all(promises).then((result) => { |
| 237 | if (!CollectionUtils.isArray(result)) { | 237 | if (!CollectionUtils.isArray(result)) { |
| 238 | - success(compList); | 238 | + success(new Array<InteractDataDTO>()); |
| 239 | return; | 239 | return; |
| 240 | } | 240 | } |
| 241 | 241 | ||
| @@ -246,8 +246,8 @@ export class PageViewModel extends BaseViewModel { | @@ -246,8 +246,8 @@ export class PageViewModel extends BaseViewModel { | ||
| 246 | } | 246 | } |
| 247 | }) | 247 | }) |
| 248 | // 批查全部完成,统一设置到comp里 | 248 | // 批查全部完成,统一设置到comp里 |
| 249 | - this.resetInteract(allInteractDataList, compList); | ||
| 250 | - success(compList); | 249 | + // this.resetInteract(allInteractDataList, compList); |
| 250 | + success(allInteractDataList); | ||
| 251 | }) | 251 | }) |
| 252 | }) | 252 | }) |
| 253 | } | 253 | } |
| @@ -269,6 +269,9 @@ export class PageViewModel extends BaseViewModel { | @@ -269,6 +269,9 @@ export class PageViewModel extends BaseViewModel { | ||
| 269 | }); | 269 | }); |
| 270 | } | 270 | } |
| 271 | 271 | ||
| 272 | + /** | ||
| 273 | + * @deprecated | ||
| 274 | + */ | ||
| 272 | private resetInteract(interact: InteractDataDTO[], compList: CompDTO[]) { | 275 | private resetInteract(interact: InteractDataDTO[], compList: CompDTO[]) { |
| 273 | if (interact == null || interact.length == 0) { | 276 | if (interact == null || interact.length == 0) { |
| 274 | return | 277 | return |
-
Please register or login to post a comment