liyubing

feat:

1)人民号--关注频道,稿件线,和删除冗余调用冗余接口
@@ -25,6 +25,7 @@ import { TrackConstants, TrackingPageBrowse } from 'wdTracking/Index'; @@ -25,6 +25,7 @@ import { TrackConstants, TrackingPageBrowse } from 'wdTracking/Index';
25 */ 25 */
26 @Component 26 @Component
27 export struct CardParser { 27 export struct CardParser {
  28 +
28 @State pageId: string = ''; 29 @State pageId: string = '';
29 @State pageName: string = ''; 30 @State pageName: string = '';
30 @State contentDTO: ContentDTO = new ContentDTO(); 31 @State contentDTO: ContentDTO = new ContentDTO();
1 import { PeopleShipRecommendComponent } from './PeopleShipRecommendComponent'; 1 import { PeopleShipRecommendComponent } from './PeopleShipRecommendComponent';
2 import { PeopleShipMainViewModel } from '../../viewmodel/PeopleShipMainViewModel'; 2 import { PeopleShipMainViewModel } from '../../viewmodel/PeopleShipMainViewModel';
3 -import { HttpUtils } from 'wdNetwork/Index'; 3 +import { HttpUtils } from 'wdNetwork/Index';
4 import { Logger, DateTimeUtils, EmitterEventId, EmitterUtils } from 'wdKit'; 4 import { Logger, DateTimeUtils, EmitterEventId, EmitterUtils } from 'wdKit';
5 import { 5 import {
6 RmhRecommendDTO, 6 RmhRecommendDTO,
@@ -21,27 +21,27 @@ import { FollowListDetailItem } from '../../viewmodel/FollowListDetailItem'; @@ -21,27 +21,27 @@ import { FollowListDetailItem } from '../../viewmodel/FollowListDetailItem';
21 import { CustomPullToRefresh } from '../reusable/CustomPullToRefresh'; 21 import { CustomPullToRefresh } from '../reusable/CustomPullToRefresh';
22 import PageModel from '../../viewmodel/PageModel'; 22 import PageModel from '../../viewmodel/PageModel';
23 import PageAdModel from '../../viewmodel/PageAdvModel'; 23 import PageAdModel from '../../viewmodel/PageAdvModel';
24 -import PageHelper from '../../viewmodel/PageHelper';  
25 import { PeopleShipAttentionContentListTopComponent } from './PeopleShipAttentionContentListTopComponent' 24 import { PeopleShipAttentionContentListTopComponent } from './PeopleShipAttentionContentListTopComponent'
26 import { CardParser } from '../CardParser' 25 import { CardParser } from '../CardParser'
27 import { PeopleShipNoMoreData } from '../reusable/PeopleShipNoMoreData'; 26 import { PeopleShipNoMoreData } from '../reusable/PeopleShipNoMoreData';
  27 +import PageFollowHelper from '../../viewmodel/PageFollowHelper';
  28 +
28 const TAG = 'PeopleShipMainComponent'; 29 const TAG = 'PeopleShipMainComponent';
  30 +
29 /** 31 /**
30 * 人民号 --- 关注 32 * 人民号 --- 关注
31 */ 33 */
32 @Component 34 @Component
33 export struct PeopleShipMainComponent { 35 export struct PeopleShipMainComponent {
34 @State private pageModel: PageModel = new PageModel(); 36 @State private pageModel: PageModel = new PageModel();
35 - @State private pageAdvModel: PageAdModel = new PageAdModel();  
36 // 自动刷新通知 37 // 自动刷新通知
37 @Prop @Watch('onAutoRefresh') autoRefresh: number = 0 38 @Prop @Watch('onAutoRefresh') autoRefresh: number = 0
38 navIndex: number = 0; 39 navIndex: number = 0;
39 pageId: string = ""; 40 pageId: string = "";
40 channelId: string = ""; 41 channelId: string = "";
41 @Link @Watch('onChange') currentTopNavSelectedIndex: number 42 @Link @Watch('onChange') currentTopNavSelectedIndex: number
42 - // private scroller: Scroller = new Scroller() 43 + // private scroller: Scroller = new Scroller()
43 private listScroller: Scroller = new Scroller() 44 private listScroller: Scroller = new Scroller()
44 -  
45 @State rmhList: RmhRecommendDTO[] = [] 45 @State rmhList: RmhRecommendDTO[] = []
46 @Provide rmhSelectedList: string[] = [] 46 @Provide rmhSelectedList: string[] = []
47 @State viewType: ViewType = ViewType.LOADING 47 @State viewType: ViewType = ViewType.LOADING
@@ -56,7 +56,6 @@ export struct PeopleShipMainComponent { @@ -56,7 +56,6 @@ export struct PeopleShipMainComponent {
56 @State private currentPage: number = 1 56 @State private currentPage: number = 1
57 @State private isLoading: boolean = false 57 @State private isLoading: boolean = false
58 @State private loadTime: string = '' 58 @State private loadTime: string = ''
59 -  
60 // 页面展示监听 59 // 页面展示监听
61 @Consume @Watch('onPageShowChange') pageShow: number 60 @Consume @Watch('onPageShowChange') pageShow: number
62 @State private pageAttentionChange: boolean = false 61 @State private pageAttentionChange: boolean = false
@@ -96,7 +95,7 @@ export struct PeopleShipMainComponent { @@ -96,7 +95,7 @@ export struct PeopleShipMainComponent {
96 this.getData(resolve) 95 this.getData(resolve)
97 }, 96 },
98 }) 97 })
99 - }else { 98 + } else {
100 CustomPullToRefresh({ 99 CustomPullToRefresh({
101 alldata: this.attentionList, 100 alldata: this.attentionList,
102 scroller: this.listScroller, 101 scroller: this.listScroller,
@@ -108,19 +107,19 @@ export struct PeopleShipMainComponent { @@ -108,19 +107,19 @@ export struct PeopleShipMainComponent {
108 this.currentPage = 1 107 this.currentPage = 1
109 this.getData(resolve) 108 this.getData(resolve)
110 }, 109 },
111 - onLoadMore:(resolve)=> { 110 + onLoadMore: (resolve) => {
112 if (this.hasMore === false) { 111 if (this.hasMore === false) {
113 - if(resolve) { 112 + if (resolve) {
114 resolve('') 113 resolve('')
115 } 114 }
116 return 115 return
117 } 116 }
118 - if(!this.isLoading && this.hasMore){ 117 + if (!this.isLoading && this.hasMore) {
119 //加载分页数据 118 //加载分页数据
120 this.currentPage++; 119 this.currentPage++;
121 this.getAttentionContentListData(resolve) 120 this.getAttentionContentListData(resolve)
122 - }else {  
123 - if(resolve) { 121 + } else {
  122 + if (resolve) {
124 resolve('') 123 resolve('')
125 } 124 }
126 } 125 }
@@ -138,9 +137,9 @@ export struct PeopleShipMainComponent { @@ -138,9 +137,9 @@ export struct PeopleShipMainComponent {
138 @Builder 137 @Builder
139 ListLayout() { 138 ListLayout() {
140 139
141 - List({scroller: this.listScroller}){ 140 + List({ scroller: this.listScroller }) {
142 // 头部关注列表 141 // 头部关注列表
143 - ListItem(){ 142 + ListItem() {
144 PeopleShipRecommendComponent({ 143 PeopleShipRecommendComponent({
145 rmhList: this.rmhList, 144 rmhList: this.rmhList,
146 oneKeyFollow: this.oneKeyFollow, 145 oneKeyFollow: this.oneKeyFollow,
@@ -156,20 +155,25 @@ export struct PeopleShipMainComponent { @@ -156,20 +155,25 @@ export struct PeopleShipMainComponent {
156 155
157 @Builder 156 @Builder
158 ListAttentionLayout() { 157 ListAttentionLayout() {
159 - List({scroller: this.listScroller}){ 158 + List({ scroller: this.listScroller }) {
160 // 头部关注列表 159 // 头部关注列表
161 - ListItem(){ 160 + ListItem() {
162 PeopleShipAttentionContentListTopComponent({ 161 PeopleShipAttentionContentListTopComponent({
163 followList: this.followList 162 followList: this.followList
164 }) 163 })
165 } 164 }
  165 +
166 ForEach(this.attentionList, (item: ContentDTO) => { 166 ForEach(this.attentionList, (item: ContentDTO) => {
167 ListItem() { 167 ListItem() {
168 - CardParser({compDTO:new CompDTO, contentDTO: item }) 168 + Column(){
  169 + CardParser({ compDTO: new CompDTO, contentDTO: item })
  170 + Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
  171 + }.width('100%')
  172 +
169 }.width("100%") 173 }.width("100%")
170 .backgroundColor(Color.Transparent) 174 .backgroundColor(Color.Transparent)
171 175
172 - }, (item: ContentDTO, index: number) => item.objectId + index.toString()) 176 + }, (item: ContentDTO, index: number) => item.objectId + index.toString())
173 177
174 // 加载更多 178 // 加载更多
175 ListItem() { 179 ListItem() {
@@ -196,7 +200,8 @@ export struct PeopleShipMainComponent { @@ -196,7 +200,8 @@ export struct PeopleShipMainComponent {
196 } 200 }
197 201
198 onChange() { 202 onChange() {
199 - if (this.navIndex === this.currentTopNavSelectedIndex && (this.viewType == ViewType.LOADING || this.pageAttentionChange)) { 203 + if (this.navIndex === this.currentTopNavSelectedIndex &&
  204 + (this.viewType == ViewType.LOADING || this.pageAttentionChange)) {
200 this.getData(); 205 this.getData();
201 } 206 }
202 } 207 }
@@ -224,7 +229,6 @@ export struct PeopleShipMainComponent { @@ -224,7 +229,6 @@ export struct PeopleShipMainComponent {
224 this.getRmhRecommendInfo(resolve) 229 this.getRmhRecommendInfo(resolve)
225 } else { 230 } else {
226 this.followList = [] 231 this.followList = []
227 - // this.followList = followInfo.list  
228 this.followList.push(...followInfo.list) 232 this.followList.push(...followInfo.list)
229 this.attentionList = [] 233 this.attentionList = []
230 this.currentPage = 1 234 this.currentPage = 1
@@ -292,7 +296,7 @@ export struct PeopleShipMainComponent { @@ -292,7 +296,7 @@ export struct PeopleShipMainComponent {
292 } 296 }
293 //批量查询各类型内容动态数据接口 297 //批量查询各类型内容动态数据接口
294 this.checkContentInteractData(listData.list, resolve) 298 this.checkContentInteractData(listData.list, resolve)
295 - } else { 299 + } else {
296 this.hasMore = false; 300 this.hasMore = false;
297 this.resolveEnd(true, resolve) 301 this.resolveEnd(true, resolve)
298 } 302 }
@@ -322,7 +326,7 @@ export struct PeopleShipMainComponent { @@ -322,7 +326,7 @@ export struct PeopleShipMainComponent {
322 this.resolveEnd(true, resolve) 326 this.resolveEnd(true, resolve)
323 list.forEach((element: ContentDTO) => { 327 list.forEach((element: ContentDTO) => {
324 // 获取 interactData 数据 328 // 获取 interactData 数据
325 - if (listData && listData.length > 0) { 329 + if (listData && listData.length > 0) {
326 const objc = listData.find((interactModel: InteractDataDTO) => { 330 const objc = listData.find((interactModel: InteractDataDTO) => {
327 return element.objectId == interactModel.contentId 331 return element.objectId == interactModel.contentId
328 }) 332 })
@@ -346,7 +350,7 @@ export struct PeopleShipMainComponent { @@ -346,7 +350,7 @@ export struct PeopleShipMainComponent {
346 if (resolve) { 350 if (resolve) {
347 if (this.currentPage == 1 && isTop) { 351 if (this.currentPage == 1 && isTop) {
348 resolve('已更新至最新') 352 resolve('已更新至最新')
349 - }else { 353 + } else {
350 resolve('') 354 resolve('')
351 } 355 }
352 } 356 }
@@ -360,12 +364,13 @@ export struct PeopleShipMainComponent { @@ -360,12 +364,13 @@ export struct PeopleShipMainComponent {
360 364
361 // 说是首页必须要调用 365 // 说是首页必须要调用
362 async getInitData() { 366 async getInitData() {
363 - Logger.debug('PeopleShipMainComponent', `getData id: ${this.pageId} , ${this.channelId} , navIndex: ${this.currentTopNavSelectedIndex}`); 367 + Logger.debug('PeopleShipMainComponent',
  368 + `getData id: ${this.pageId} , ${this.channelId} , navIndex: ${this.currentTopNavSelectedIndex}`);
364 this.pageModel.pageId = this.pageId; 369 this.pageModel.pageId = this.pageId;
365 this.pageModel.groupId = this.pageId; 370 this.pageModel.groupId = this.pageId;
366 this.pageModel.channelId = this.channelId; 371 this.pageModel.channelId = this.channelId;
367 this.pageModel.currentPage = 1; 372 this.pageModel.currentPage = 1;
368 - PageHelper.getInitData(this.pageModel, this.pageAdvModel) 373 + PageFollowHelper.getInitData(this.pageModel)
369 } 374 }
370 375
371 // 点击一键关注 376 // 点击一键关注
@@ -391,7 +396,7 @@ export struct PeopleShipMainComponent { @@ -391,7 +396,7 @@ export struct PeopleShipMainComponent {
391 // 获取列表数据 396 // 获取列表数据
392 let objects = new AttentionBatchDTO() 397 let objects = new AttentionBatchDTO()
393 this.rmhList.forEach((element: RmhRecommendDTO) => { 398 this.rmhList.forEach((element: RmhRecommendDTO) => {
394 - if ( this.rmhSelectedList.indexOf(element.creatorId) != -1) { 399 + if (this.rmhSelectedList.indexOf(element.creatorId) != -1) {
395 const creator = new CreatorDTO(element.userType, element.userId, element.creatorId) 400 const creator = new CreatorDTO(element.userType, element.userId, element.creatorId)
396 objects.creators.push(creator) 401 objects.creators.push(creator)
397 } 402 }
@@ -416,7 +421,7 @@ export struct PeopleShipMainComponent { @@ -416,7 +421,7 @@ export struct PeopleShipMainComponent {
416 421
417 // 页面展示监听 422 // 页面展示监听
418 onPageShowChange() { 423 onPageShowChange() {
419 - if (this.navIndex === this.currentTopNavSelectedIndex && this.pageAttentionChange ) { 424 + if (this.navIndex === this.currentTopNavSelectedIndex && this.pageAttentionChange) {
420 this.getData() 425 this.getData()
421 } 426 }
422 } 427 }
@@ -294,11 +294,12 @@ export struct SearchResultContentComponent { @@ -294,11 +294,12 @@ export struct SearchResultContentComponent {
294 CardParser({compDTO:new CompDTO, contentDTO: item }) 294 CardParser({compDTO:new CompDTO, contentDTO: item })
295 } 295 }
296 if (index != this.data.totalCount() - 1) { 296 if (index != this.data.totalCount() - 1) {
297 - Divider()  
298 - .width('100%')  
299 - .height('1lpx')  
300 - .color($r('app.color.color_F5F5F5'))  
301 - .strokeWidth('1lpx') 297 + Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
  298 + // Divider()
  299 + // .width('100%')
  300 + // .height('1lpx')
  301 + // .color($r('app.color.color_F5F5F5'))
  302 + // .strokeWidth('1lpx')
302 } 303 }
303 } 304 }
304 } 305 }
  1 +import { CompDTO, ContentDTO, InteractDataDTO, LiveReviewDTO, LiveRoomDataBean, PageDTO, PageInfoDTO } from 'wdBean';
  2 +import { CompStyle, ViewType } from 'wdConstant/Index';
  3 +import { CollectionUtils, DateTimeUtils, LazyDataSource, Logger, NetworkUtil, StringUtils, ToastUtils } from 'wdKit';
  4 +import { closeRefresh } from '../utils/PullDownRefresh';
  5 +import PageModel from './PageModel';
  6 +import PageViewModel from './PageViewModel';
  7 +import { promptAction } from '@kit.ArkUI';
  8 +import { CompAdvBean } from 'wdBean/src/main/ets/bean/adv/AdvsRuleBean';
  9 +import PageAdModel from './PageAdvModel';
  10 +import { ArrayList } from '@kit.ArkTS';
  11 +import { WDViewDefaultType } from '../components/view/EmptyComponent';
  12 +import { CompAdvMatInfoBean } from 'wdBean/src/main/ets/bean/adv/CompAdvInfoBean';
  13 +import { BaseDTO } from 'wdBean/src/main/ets/bean/component/BaseDTO';
  14 +import { viewBlogInsightIntentShare, ActionMode } from '../utils/InsightIntentShare'
  15 +import { common } from '@kit.AbilityKit';
  16 +import { CacheData } from 'wdNetwork/Index';
  17 +import { closeLoadMore } from '../utils/PullUpLoadMore';
  18 +
  19 +const TAG = 'PageHelper';
  20 +
  21 +
  22 +/**
  23 + * 处理返回后的数据
  24 + */
  25 +export class PageFollowHelper {
  26 + private refreshUIEnd(pageModel: PageModel, isRefreshSuccess: boolean) {
  27 + if (pageModel.loadStrategy != 2) {
  28 + return
  29 + }
  30 + closeRefresh(pageModel, isRefreshSuccess)
  31 + }
  32 +
  33 +
  34 +
  35 + /**
  36 + * 进页面请求数据
  37 + */
  38 + async getInitData(pageModel: PageModel) {
  39 + pageModel.loadStrategy = 1
  40 + let netStatus = NetworkUtil.isNetConnected()
  41 + if (netStatus) {
  42 + this.getPageInfo(pageModel)
  43 + } else if (pageModel.compList.size() > 0) {
  44 + // 加载缓存数据了,不用无网络提示
  45 + } else {
  46 + pageModel.viewType = ViewType.EMPTY;
  47 + pageModel.emptyType = WDViewDefaultType.WDViewDefaultType_NoNetwork;
  48 + }
  49 + }
  50 +
  51 + getPageInfo(pageModel: PageModel) {
  52 + pageModel.currentPage = 1;
  53 + Logger.debug(TAG, 'getPageInfo')
  54 + PageViewModel.getPageInfo(pageModel.pageId).then(pageInfo => {
  55 + Logger.debug(TAG, 'getPageInfo back: ' + JSON.stringify(pageInfo))
  56 + if (pageInfo == null) {
  57 + pageModel.viewType = ViewType.EMPTY;
  58 + pageModel.emptyType = WDViewDefaultType.WDViewDefaultType_NoContent1;
  59 + return;
  60 + }
  61 + pageModel.pageInfo = pageInfo;
  62 +
  63 + Logger.debug(TAG, 'getPageInfo go on')
  64 + }).catch(() => {
  65 + this.refreshUIEnd(pageModel, false)
  66 + if (this.isPageLoaded(pageModel)) {
  67 + return
  68 + }
  69 + pageModel.viewType = ViewType.EMPTY;
  70 + pageModel.emptyType = WDViewDefaultType.WDViewDefaultType_ContentFailed;
  71 + })
  72 + }
  73 +
  74 + private isPageLoaded(pageModel: PageModel) {
  75 + if (pageModel.compList.size() > 0) {
  76 + return true
  77 + }
  78 + return false
  79 + }
  80 +}
  81 +
  82 +
  83 +
  84 +
  85 +let pageHelper = new PageFollowHelper();
  86 +
  87 +export default pageHelper as PageFollowHelper;