王士厅

fix: 人民号关注页面无内容时toast显示‘加载失败,请稍后重试’

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, ToastUtils } from 'wdKit';
5 import { autoRefresh, onActionEnd, onActionStart, onActionUpdate,closeRefresh } from '../../utils/NewPullDownRefresh'; 5 import { autoRefresh, onActionEnd, onActionStart, onActionUpdate,closeRefresh } from '../../utils/NewPullDownRefresh';
6 6
7 import { 7 import {
@@ -88,27 +88,31 @@ export struct PeopleShipMainComponent { @@ -88,27 +88,31 @@ export struct PeopleShipMainComponent {
88 Column(){ 88 Column(){
89 if (this.viewType == ViewType.LOADING) { 89 if (this.viewType == ViewType.LOADING) {
90 this.LoadingLayout() 90 this.LoadingLayout()
91 - } else if (this.viewType == ViewType.ERROR) {  
92 - //缺省页  
93 - EmptyComponent({  
94 - emptyType: this.pageModel.emptyType,  
95 - emptyButton: true,  
96 - retry: () => {  
97 - this.getData()  
98 - }  
99 - })  
100 - .grayscale(this.GrayManage.get().isRmhMourning(`${this.channelId}`) ? 1 : 0)  
101 - } else if (this.viewType == ViewType.EMPTY) {  
102 - //缺省页  
103 - EmptyComponent({  
104 - emptyType: this.pageModel.emptyType,  
105 - emptyButton: true,  
106 - retry: () => {  
107 - this.getData()  
108 - }  
109 - })  
110 - .grayscale(this.GrayManage.get().isRmhMourning(`${this.channelId}`) ? 1 : 0)  
111 - }else { 91 + }
  92 + // else if (this.viewType == ViewType.ERROR) {
  93 + // //缺省页
  94 + // // EmptyComponent({
  95 + // // emptyType: this.pageModel.emptyType,
  96 + // // emptyButton: true,
  97 + // // retry: () => {
  98 + // // this.getData()
  99 + // // }
  100 + // // })
  101 + // // .grayscale(this.GrayManage.get().isRmhMourning(`${this.channelId}`) ? 1 : 0)
  102 + //
  103 + // } else if (this.viewType == ViewType.EMPTY) {
  104 + // // //缺省页
  105 + // // EmptyComponent({
  106 + // // emptyType: this.pageModel.emptyType,
  107 + // // emptyButton: true,
  108 + // // retry: () => {
  109 + // // this.getData()
  110 + // // }
  111 + // // })
  112 + // // .grayscale(this.GrayManage.get().isRmhMourning(`${this.channelId}`) ? 1 : 0)
  113 + //
  114 + // }
  115 + else {
112 if (this.followList.length == 0) { 116 if (this.followList.length == 0) {
113 this.ListLayout() 117 this.ListLayout()
114 } else { 118 } else {
@@ -328,7 +332,7 @@ export struct PeopleShipMainComponent { @@ -328,7 +332,7 @@ export struct PeopleShipMainComponent {
328 // 获取用户关注人数 332 // 获取用户关注人数
329 let object = new FollowListDetailRequestItem(-1, 20, 1) 333 let object = new FollowListDetailRequestItem(-1, 20, 1)
330 let followInfo = await MinePageDatasModel.getMineFollowListData(object, getContext(this)) 334 let followInfo = await MinePageDatasModel.getMineFollowListData(object, getContext(this))
331 - Logger.debug('PeopleShipMainComponent', '获取页面信息' + `${JSON.stringify(followInfo)}`) 335 + // Logger.debug('PeopleShipMainComponent', '获取页面信息' + `${JSON.stringify(followInfo)}`)
332 336
333 if (followInfo.list.length == 0) { 337 if (followInfo.list.length == 0) {
334 this.followList = [] 338 this.followList = []
@@ -347,6 +351,7 @@ export struct PeopleShipMainComponent { @@ -347,6 +351,7 @@ export struct PeopleShipMainComponent {
347 } catch (exception) { 351 } catch (exception) {
348 this.viewType = ViewType.ERROR 352 this.viewType = ViewType.ERROR
349 this.isLoading = false 353 this.isLoading = false
  354 + ToastUtils.shortToast('加载失败,请稍后重试')
350 } 355 }
351 } 356 }
352 357
@@ -362,11 +367,14 @@ export struct PeopleShipMainComponent { @@ -362,11 +367,14 @@ export struct PeopleShipMainComponent {
362 this.viewType = ViewType.LOADED 367 this.viewType = ViewType.LOADED
363 this.changeButton = false 368 this.changeButton = false
364 this.isLoading = false 369 this.isLoading = false
365 - Logger.debug('PeopleShipMainComponent', 'getRmhRecommendInfo' + `${JSON.stringify(this.rmhList)}`) 370 + // Logger.debug('PeopleShipMainComponent', 'getRmhRecommendInfo' + `${JSON.stringify(this.rmhList)}`)
366 if (resolve) { 371 if (resolve) {
367 resolve('已更新至最新') 372 resolve('已更新至最新')
368 } 373 }
369 this.closeRefresh(true) 374 this.closeRefresh(true)
  375 + if(this.rmhList?.length! === 0) {
  376 + ToastUtils.shortToast('加载失败,请稍后重试')
  377 + }
370 } catch (exception) { 378 } catch (exception) {
371 if (resolve) { 379 if (resolve) {
372 resolve('') 380 resolve('')
@@ -375,6 +383,7 @@ export struct PeopleShipMainComponent { @@ -375,6 +383,7 @@ export struct PeopleShipMainComponent {
375 this.viewType = ViewType.ERROR 383 this.viewType = ViewType.ERROR
376 this.changeButton = false 384 this.changeButton = false
377 this.isLoading = false 385 this.isLoading = false
  386 + ToastUtils.shortToast('加载失败,请稍后重试')
378 } 387 }
379 } 388 }
380 389
@@ -390,7 +399,7 @@ export struct PeopleShipMainComponent { @@ -390,7 +399,7 @@ export struct PeopleShipMainComponent {
390 try { 399 try {
391 // 获取列表数据 400 // 获取列表数据
392 let listData = await PeopleShipMainViewModel.getAttentionContentListInfo(this.currentPage, 20, this.loadTime) 401 let listData = await PeopleShipMainViewModel.getAttentionContentListInfo(this.currentPage, 20, this.loadTime)
393 - Logger.debug('PeopleShipMainComponent', '获取页面信息' + `${JSON.stringify(listData)}`) 402 + // Logger.debug('PeopleShipMainComponent', '获取页面信息' + `${JSON.stringify(listData)}`)
394 if (listData && listData.list && listData.list.length > 0) { 403 if (listData && listData.list && listData.list.length > 0) {
395 if (listData.list.length === 20) { 404 if (listData.list.length === 20) {
396 this.hasMore = true; 405 this.hasMore = true;
@@ -429,7 +438,7 @@ export struct PeopleShipMainComponent { @@ -429,7 +438,7 @@ export struct PeopleShipMainComponent {
429 }) 438 })
430 439
431 let listData = await PeopleShipMainViewModel.getContentInteractInfo(params) 440 let listData = await PeopleShipMainViewModel.getContentInteractInfo(params)
432 - Logger.debug('PeopleShipMainComponent', '获取页面信息' + `${JSON.stringify(listData)}`) 441 + // Logger.debug('PeopleShipMainComponent', '获取页面信息' + `${JSON.stringify(listData)}`)
433 this.resolveEnd(true, resolve) 442 this.resolveEnd(true, resolve)
434 443
435 if (this.currentPage == 1) { 444 if (this.currentPage == 1) {
@@ -481,6 +490,7 @@ export struct PeopleShipMainComponent { @@ -481,6 +490,7 @@ export struct PeopleShipMainComponent {
481 } 490 }
482 if (this.currentPage == 1 && !isTop) { 491 if (this.currentPage == 1 && !isTop) {
483 this.viewType = ViewType.ERROR 492 this.viewType = ViewType.ERROR
  493 + ToastUtils.shortToast('加载失败,请稍后重试')
484 } else { 494 } else {
485 this.viewType = ViewType.LOADED 495 this.viewType = ViewType.LOADED
486 } 496 }
@@ -489,8 +499,8 @@ export struct PeopleShipMainComponent { @@ -489,8 +499,8 @@ export struct PeopleShipMainComponent {
489 499
490 // 说是首页必须要调用 500 // 说是首页必须要调用
491 async getInitData() { 501 async getInitData() {
492 - Logger.debug('PeopleShipMainComponent',  
493 - `getData id: ${this.pageId} , ${this.channelId} , navIndex: ${this.currentTopNavSelectedIndex}`); 502 + // Logger.debug('PeopleShipMainComponent',
  503 + // `getData id: ${this.pageId} , ${this.channelId} , navIndex: ${this.currentTopNavSelectedIndex}`);
494 this.pageModel.pageId = this.pageId; 504 this.pageModel.pageId = this.pageId;
495 this.pageModel.groupId = this.pageId; 505 this.pageModel.groupId = this.pageId;
496 this.pageModel.channelId = this.channelId; 506 this.pageModel.channelId = this.channelId;
@@ -526,7 +536,7 @@ export struct PeopleShipMainComponent { @@ -526,7 +536,7 @@ export struct PeopleShipMainComponent {
526 objects.creators.push(creator) 536 objects.creators.push(creator)
527 } 537 }
528 }) 538 })
529 - Logger.debug('PeopleShipMainComponent', `一键关注接口参数: ${JSON.stringify(objects)}`); 539 + // Logger.debug('PeopleShipMainComponent', `一键关注接口参数: ${JSON.stringify(objects)}`);
530 let batchInfo = await PeopleShipMainViewModel.getAttentionBatchInfo(objects) 540 let batchInfo = await PeopleShipMainViewModel.getAttentionBatchInfo(objects)
531 this.oneKeyFollow = false 541 this.oneKeyFollow = false
532 if (batchInfo.code === 0 || batchInfo.code.toString() === "0") { 542 if (batchInfo.code === 0 || batchInfo.code.toString() === "0") {
@@ -556,7 +566,7 @@ export struct PeopleShipMainComponent { @@ -556,7 +566,7 @@ export struct PeopleShipMainComponent {
556 return 566 return
557 } 567 }
558 // 当前页面,自动刷新数据 568 // 当前页面,自动刷新数据
559 - Logger.debug(TAG, 'page onAutoRefresh ' + this.autoRefresh) 569 + // Logger.debug(TAG, 'page onAutoRefresh ' + this.autoRefresh)
560 this.listScroller.scrollToIndex(0) 570 this.listScroller.scrollToIndex(0)
561 autoRefresh(this.pageModel,this.onRefresh) 571 autoRefresh(this.pageModel,this.onRefresh)
562 } 572 }