Showing
8 changed files
with
95 additions
and
17 deletions
| @@ -171,6 +171,24 @@ export class LazyDataSource<T> extends BasicDataSource<T> { | @@ -171,6 +171,24 @@ export class LazyDataSource<T> extends BasicDataSource<T> { | ||
| 171 | } | 171 | } |
| 172 | } | 172 | } |
| 173 | 173 | ||
| 174 | + // 删除index指定索引位置的元素 | ||
| 175 | + public deleteItems(startIndex: number, count?: number): void { | ||
| 176 | + if (startIndex < 0) { | ||
| 177 | + return | ||
| 178 | + } | ||
| 179 | + this.dataArray.splice(startIndex, count || (this.dataArray.length - startIndex)); | ||
| 180 | + let to = 0 | ||
| 181 | + if (count == undefined) { | ||
| 182 | + to = this.dataArray.length - 1 | ||
| 183 | + } else { | ||
| 184 | + to = count + startIndex | ||
| 185 | + if (to >= this.dataArray.length) { | ||
| 186 | + to = this.dataArray.length - 1; | ||
| 187 | + } | ||
| 188 | + } | ||
| 189 | + this.notifyDataMove(startIndex, to); | ||
| 190 | + } | ||
| 191 | + | ||
| 174 | // 删除最后1个元素 | 192 | // 删除最后1个元素 |
| 175 | public pop(): void { | 193 | public pop(): void { |
| 176 | this.deleteItem() | 194 | this.deleteItem() |
| @@ -90,9 +90,6 @@ export struct SpacialTopicPageComponent { | @@ -90,9 +90,6 @@ export struct SpacialTopicPageComponent { | ||
| 90 | this.publishCommentModel.targetType = String(this.contentDetailData?.newsType || '') | 90 | this.publishCommentModel.targetType = String(this.contentDetailData?.newsType || '') |
| 91 | this.publishCommentModel.visitorComment = String(this.contentDetailData?.visitorComment || '') | 91 | this.publishCommentModel.visitorComment = String(this.contentDetailData?.visitorComment || '') |
| 92 | // } | 92 | // } |
| 93 | - if (this.contentDetailData[0]?.openComment) { | ||
| 94 | - this.operationButtonList = ['collect', 'share'] | ||
| 95 | - } | ||
| 96 | this.trySendData2H5() | 93 | this.trySendData2H5() |
| 97 | } | 94 | } |
| 98 | } | 95 | } |
| 1 | import { CompDTO } from 'wdBean/Index'; | 1 | import { CompDTO } from 'wdBean/Index'; |
| 2 | import { DateTimeUtils, Logger } from 'wdKit/Index'; | 2 | import { DateTimeUtils, Logger } from 'wdKit/Index'; |
| 3 | +import { PageHelper } from '../../viewmodel/PageHelper'; | ||
| 3 | import PageModel from '../../viewmodel/PageModel'; | 4 | import PageModel from '../../viewmodel/PageModel'; |
| 4 | 5 | ||
| 5 | /** | 6 | /** |
| @@ -61,6 +62,7 @@ export struct CardAdvBottom { | @@ -61,6 +62,7 @@ export struct CardAdvBottom { | ||
| 61 | } | 62 | } |
| 62 | if (currentIndex >= 0) { | 63 | if (currentIndex >= 0) { |
| 63 | this.pageModel.compList.deleteItem(currentIndex) | 64 | this.pageModel.compList.deleteItem(currentIndex) |
| 65 | + PageHelper.updateFirstPageEndIndex(this.pageModel, true, currentIndex) | ||
| 64 | } | 66 | } |
| 65 | } | 67 | } |
| 66 | } | 68 | } |
| 1 | import { CompDTO } from 'wdBean/Index'; | 1 | import { CompDTO } from 'wdBean/Index'; |
| 2 | import { DateTimeUtils, Logger } from 'wdKit/Index'; | 2 | import { DateTimeUtils, Logger } from 'wdKit/Index'; |
| 3 | +import {PageHelper} from '../../viewmodel/PageHelper'; | ||
| 3 | import PageModel from '../../viewmodel/PageModel'; | 4 | import PageModel from '../../viewmodel/PageModel'; |
| 4 | 5 | ||
| 5 | /** | 6 | /** |
| @@ -73,6 +74,7 @@ export struct CardAdvTop { | @@ -73,6 +74,7 @@ export struct CardAdvTop { | ||
| 73 | } | 74 | } |
| 74 | if (currentIndex >= 0) { | 75 | if (currentIndex >= 0) { |
| 75 | this.pageModel.compList.deleteItem(currentIndex) | 76 | this.pageModel.compList.deleteItem(currentIndex) |
| 77 | + PageHelper.updateFirstPageEndIndex(this.pageModel, true, currentIndex) | ||
| 76 | } | 78 | } |
| 77 | } | 79 | } |
| 78 | } | 80 | } |
| @@ -99,6 +99,7 @@ export struct CommentTabComponent { | @@ -99,6 +99,7 @@ export struct CommentTabComponent { | ||
| 99 | bottom: { anchor: "__container__", align: VerticalAlign.Bottom }, | 99 | bottom: { anchor: "__container__", align: VerticalAlign.Bottom }, |
| 100 | }) | 100 | }) |
| 101 | .id("Image") | 101 | .id("Image") |
| 102 | + .visibility(this.contentDetail.appstyle !== 9 ? Visibility.Visible : Visibility.Hidden) | ||
| 102 | } | 103 | } |
| 103 | Text(this.placeHolder) | 104 | Text(this.placeHolder) |
| 104 | .fontSize(12) | 105 | .fontSize(12) |
| @@ -110,6 +111,7 @@ export struct CommentTabComponent { | @@ -110,6 +111,7 @@ export struct CommentTabComponent { | ||
| 110 | bottom: { anchor: "__container__", align: VerticalAlign.Bottom }, | 111 | bottom: { anchor: "__container__", align: VerticalAlign.Bottom }, |
| 111 | }) | 112 | }) |
| 112 | .id("Text") | 113 | .id("Text") |
| 114 | + .visibility(this.contentDetail.appstyle !== 9 ? Visibility.Visible : Visibility.Hidden) | ||
| 113 | } | 115 | } |
| 114 | } | 116 | } |
| 115 | } | 117 | } |
| @@ -134,6 +136,7 @@ export struct CommentIconComponent { | @@ -134,6 +136,7 @@ export struct CommentIconComponent { | ||
| 134 | @ObjectLink publishCommentModel: publishCommentModel | 136 | @ObjectLink publishCommentModel: publishCommentModel |
| 135 | /*展示类型*/ | 137 | /*展示类型*/ |
| 136 | @State type: number = 1 | 138 | @State type: number = 1 |
| 139 | + @Prop contentDetail: ContentDetailDTO | ||
| 137 | styleType: number = 1 //1: 白色背景(图文底部栏) 2: 黑色背景(图集底部栏) | 140 | styleType: number = 1 //1: 白色背景(图文底部栏) 2: 黑色背景(图集底部栏) |
| 138 | // aboutToAppear(): void { | 141 | // aboutToAppear(): void { |
| 139 | // setTimeout(() => { | 142 | // setTimeout(() => { |
| @@ -206,7 +209,10 @@ export struct CommentIconComponent { | @@ -206,7 +209,10 @@ export struct CommentIconComponent { | ||
| 206 | 209 | ||
| 207 | } | 210 | } |
| 208 | } | 211 | } |
| 209 | - }.width(24).height(24) | 212 | + } |
| 213 | + .width(24) | ||
| 214 | + .height(24) | ||
| 215 | + .visibility(this.contentDetail.appstyle !== 9 ? Visibility.Visible : Visibility.Hidden) | ||
| 210 | 216 | ||
| 211 | // .backgroundColor(Color.Blue) | 217 | // .backgroundColor(Color.Blue) |
| 212 | } | 218 | } |
| @@ -233,7 +233,11 @@ export struct OperRowListView { | @@ -233,7 +233,11 @@ export struct OperRowListView { | ||
| 233 | if (this.showCommentIcon) { | 233 | if (this.showCommentIcon) { |
| 234 | Column() { | 234 | Column() { |
| 235 | if (this.publishCommentModel?.targetId) { | 235 | if (this.publishCommentModel?.targetId) { |
| 236 | - CommentIconComponent({ publishCommentModel: this.publishCommentModel, styleType: this.styleType }) | 236 | + CommentIconComponent({ |
| 237 | + publishCommentModel: this.publishCommentModel, | ||
| 238 | + styleType: this.styleType, | ||
| 239 | + contentDetail: this.contentDetailData | ||
| 240 | + }) | ||
| 237 | .onClick(() => { | 241 | .onClick(() => { |
| 238 | this.onCommentIconClick() | 242 | this.onCommentIconClick() |
| 239 | 243 |
| @@ -80,7 +80,7 @@ export class PageHelper { | @@ -80,7 +80,7 @@ export class PageHelper { | ||
| 80 | return; | 80 | return; |
| 81 | } | 81 | } |
| 82 | pageModel.pageInfo = pageInfo; | 82 | pageModel.pageInfo = pageInfo; |
| 83 | - pageModel.cachePageInfoMd5 = pageInfo.md5 | 83 | + pageModel.displayPageInfoMd5 = pageInfo.md5 |
| 84 | //解析页面挂角广告资源 | 84 | //解析页面挂角广告资源 |
| 85 | pageAdvModel.analysisAdvSource(pageInfo); | 85 | pageAdvModel.analysisAdvSource(pageInfo); |
| 86 | this.parseGroup(pageModel, true) | 86 | this.parseGroup(pageModel, true) |
| @@ -129,7 +129,7 @@ export class PageHelper { | @@ -129,7 +129,7 @@ export class PageHelper { | ||
| 129 | return; | 129 | return; |
| 130 | } | 130 | } |
| 131 | pageModel.pageInfo = pageInfo; | 131 | pageModel.pageInfo = pageInfo; |
| 132 | - if (pageInfo.md5 == pageModel.cachePageInfoMd5) { | 132 | + if (pageInfo.md5 == pageModel.displayPageInfoMd5) { |
| 133 | // 缓存一致,不解析 | 133 | // 缓存一致,不解析 |
| 134 | Logger.debug(TAG, 'getPageInfo 与缓存一致,不解析广告。。。') | 134 | Logger.debug(TAG, 'getPageInfo 与缓存一致,不解析广告。。。') |
| 135 | } else { | 135 | } else { |
| @@ -138,6 +138,7 @@ export class PageHelper { | @@ -138,6 +138,7 @@ export class PageHelper { | ||
| 138 | // 保存缓存 | 138 | // 保存缓存 |
| 139 | CacheData.saveCacheData(CacheData.comPageInfoCacheKey + pageModel.pageId, pageInfo, pageInfo.md5) | 139 | CacheData.saveCacheData(CacheData.comPageInfoCacheKey + pageModel.pageId, pageInfo, pageInfo.md5) |
| 140 | } | 140 | } |
| 141 | + pageModel.displayPageInfoMd5 = pageInfo.md5 | ||
| 141 | //解析页面挂角广告资源 | 142 | //解析页面挂角广告资源 |
| 142 | pageAdvModel.analysisAdvSource(pageInfo); | 143 | pageAdvModel.analysisAdvSource(pageInfo); |
| 143 | } | 144 | } |
| @@ -185,15 +186,25 @@ export class PageHelper { | @@ -185,15 +186,25 @@ export class PageHelper { | ||
| 185 | Logger.debug(TAG, 'parseGroup isCache: ' + isCache) | 186 | Logger.debug(TAG, 'parseGroup isCache: ' + isCache) |
| 186 | if (isCache) { | 187 | if (isCache) { |
| 187 | pageDto = await PageViewModel.getPageGroupCacheData(pageModel.bizCopy()) as PageDTO | 188 | pageDto = await PageViewModel.getPageGroupCacheData(pageModel.bizCopy()) as PageDTO |
| 188 | - pageModel.cacheGroupInfoMd5 = pageDto.md5 | 189 | + pageModel.displayGroupInfoMd5 = pageDto.md5 |
| 189 | } else { | 190 | } else { |
| 190 | pageDto = await PageViewModel.getPageGroupCompData(pageModel.bizCopy()) as PageDTO | 191 | pageDto = await PageViewModel.getPageGroupCompData(pageModel.bizCopy()) as PageDTO |
| 191 | - if (pageDto.md5 == pageModel.cacheGroupInfoMd5) { | 192 | + if (pageDto.md5 == pageModel.displayGroupInfoMd5) { |
| 192 | Logger.debug(TAG, 'parseGroup cache load, return: ' + pageDto.md5) | 193 | Logger.debug(TAG, 'parseGroup cache load, return: ' + pageDto.md5) |
| 193 | - // 缓存数据一致,不再刷新 | 194 | + // 下拉刷新场景,数据没变,拦截刷新UI,重置相关参数 |
| 195 | + if (pageModel.loadStrategy === 2) { | ||
| 196 | + // 缓存数据一致,不再刷新 | ||
| 197 | + this.refreshUIEnd(pageModel, true) | ||
| 198 | + // 第一页不刷新,分页数据清除 | ||
| 199 | + pageModel.hasMore = true | ||
| 200 | + this.deleteMorePage(pageModel) | ||
| 201 | + pageModel.pageTotalCompSize = pageModel.compList.size() | ||
| 202 | + } | ||
| 203 | + pageModel.currentPage++ | ||
| 194 | return | 204 | return |
| 195 | } | 205 | } |
| 196 | - Logger.debug(TAG, 'parseGroup cache load, save: ') | 206 | + pageModel.displayGroupInfoMd5 = pageDto.md5 |
| 207 | + Logger.debug(TAG, 'parseGroup cache load, save: ' + pageDto.md5) | ||
| 197 | // 保存缓存 | 208 | // 保存缓存 |
| 198 | CacheData.saveCacheData(CacheData.compGroupInfoDataCacheKey + pageModel.pageId + pageModel.groupId, pageDto, | 209 | CacheData.saveCacheData(CacheData.compGroupInfoDataCacheKey + pageModel.pageId + pageModel.groupId, pageDto, |
| 199 | pageDto.md5) | 210 | pageDto.md5) |
| @@ -238,9 +249,11 @@ export class PageHelper { | @@ -238,9 +249,11 @@ export class PageHelper { | ||
| 238 | 249 | ||
| 239 | // 批查互动数据 | 250 | // 批查互动数据 |
| 240 | this.allCompBatchRequest(pageInfo.oneRequestPageGroupCompList.convertToArray(), pageModel) | 251 | this.allCompBatchRequest(pageInfo.oneRequestPageGroupCompList.convertToArray(), pageModel) |
| 241 | - | ||
| 242 | - // | ||
| 243 | - pageModel.currentPage++ | 252 | + // 记录第一页数量 |
| 253 | + this.saveFirstPageEndIndex(pageModel) | ||
| 254 | + if (!isCache) { | ||
| 255 | + pageModel.currentPage++ | ||
| 256 | + } | ||
| 244 | pageModel.viewType = ViewType.LOADED | 257 | pageModel.viewType = ViewType.LOADED |
| 245 | this.refreshUIEnd(pageModel, true) | 258 | this.refreshUIEnd(pageModel, true) |
| 246 | 259 | ||
| @@ -754,6 +767,40 @@ export class PageHelper { | @@ -754,6 +767,40 @@ export class PageHelper { | ||
| 754 | } | 767 | } |
| 755 | 768 | ||
| 756 | } | 769 | } |
| 770 | + | ||
| 771 | + saveFirstPageEndIndex(pageModel: PageModel) { | ||
| 772 | + pageModel.firstPageEndIndex = pageModel.compList.size() - 1 | ||
| 773 | + } | ||
| 774 | + | ||
| 775 | + static updateFirstPageEndIndex(pageModel: PageModel, isDel: boolean, index: number) { | ||
| 776 | + if (index > pageModel.firstPageEndIndex) { | ||
| 777 | + return | ||
| 778 | + } | ||
| 779 | + // 这里默认删除、添加都是一条一条处理 | ||
| 780 | + let count = 1 | ||
| 781 | + let endIndex = pageModel.firstPageEndIndex | ||
| 782 | + if (isDel) { | ||
| 783 | + // 第一页里删除 | ||
| 784 | + let offset = Math.min(endIndex - index, count) | ||
| 785 | + endIndex = endIndex - offset | ||
| 786 | + } else { | ||
| 787 | + // 第一页里添加 | ||
| 788 | + endIndex = endIndex + count | ||
| 789 | + } | ||
| 790 | + pageModel.firstPageEndIndex = endIndex | ||
| 791 | + } | ||
| 792 | + | ||
| 793 | + /** | ||
| 794 | + * 删除分页数据,保留第一页的数据。(下拉刷新场景用到) | ||
| 795 | + */ | ||
| 796 | + deleteMorePage(pageModel: PageModel) { | ||
| 797 | + Logger.debug(TAG, 'deleteMorePage endindex: ' + pageModel.firstPageEndIndex) | ||
| 798 | + if (pageModel.firstPageEndIndex < 0) { | ||
| 799 | + return | ||
| 800 | + } | ||
| 801 | + // 从第二页开始删 | ||
| 802 | + pageModel.compList.deleteItems(pageModel.firstPageEndIndex + 1) | ||
| 803 | + } | ||
| 757 | } | 804 | } |
| 758 | 805 | ||
| 759 | 806 |
| @@ -63,9 +63,11 @@ export default class PageModel { | @@ -63,9 +63,11 @@ export default class PageModel { | ||
| 63 | pageType: number = 0; | 63 | pageType: number = 0; |
| 64 | 64 | ||
| 65 | extra: string = '' | 65 | extra: string = '' |
| 66 | - // 缓存数据相关 | ||
| 67 | - cachePageInfoMd5: string = '' | ||
| 68 | - cacheGroupInfoMd5: string = '' | 66 | + // 页面加载,md5数据相关(初始缓存、下拉刷新用到) |
| 67 | + displayPageInfoMd5: string = '' | ||
| 68 | + displayGroupInfoMd5: string = '' | ||
| 69 | + // 第一页,最后一个comp下标,用于区分分页加载(下拉刷新,清除分页数据) | ||
| 70 | + firstPageEndIndex = -1 | ||
| 69 | 71 | ||
| 70 | /** | 72 | /** |
| 71 | * 简单复制业务数据 | 73 | * 简单复制业务数据 |
-
Please register or login to post a comment