yangchenggong1_wd

desc:个人中心 我的模块 tab 评论 和关注 分离,降低耦合

import { DateTimeUtils, LazyDataSource, UserDataLocal } from 'wdKit';
import MinePageDatasModel from '../../../model/MinePageDatasModel';
import { CommentListItem } from '../../../viewmodel/CommentListItem';
import { FollowListDetailRequestItem } from '../../../viewmodel/FollowListDetailRequestItem';
import { ListHasNoMoreDataUI } from '../../reusable/ListHasNoMoreDataUI';
import { EmptyComponent } from '../../view/EmptyComponent';
import { ChildCommentComponent } from './ChildCommentComponent';
import { MineCommentListDetailItem } from '../../../viewmodel/MineCommentListDetailItem';
import { OtherUserCommentLikeStatusRequestItem } from '../../../viewmodel/OtherUserCommentLikeStatusRequestItem';
const TAG = "HomePageBottomCommentComponent"
/**
* 我的主页 评论tab
*/
@Component
export struct HomePageBottomCommentComponent {
@State data_comment: LazyDataSource<CommentListItem> = new LazyDataSource();
@State isLoading: boolean = false
@State hasMore: boolean = true
curPageNum: number = 1;
@State count: number = 0;
@Link commentNum: number
@State isGetRequest: boolean = false
aboutToAppear() {
this.getNewPageData()
}
build() {
Column() {
if (this.isGetRequest == true) {
Divider().width('100%')
.height('2lpx')
.strokeWidth('1lpx')
.backgroundColor($r('app.color.color_EDEDED'))
}
if (this.count === 0) {
if (this.isGetRequest == true) {
EmptyComponent({ emptyType: 11 })
.layoutWeight(1)
.width('100%')
.offset({ y: "-200lpx" })
}
} else {
List({ space: 3 }) {
LazyForEach(this.data_comment, (item: CommentListItem, index: number = 0) => {
ListItem() {
ChildCommentComponent({
data: item,
levelHead: UserDataLocal.getUserLevelHeaderUrl(),
isLastItem: index === this.data_comment.totalCount() - 1
})
}
}, (item: CommentListItem, index: number) => index.toString())
//没有更多数据 显示提示
if (!this.hasMore) {
ListItem() {
ListHasNoMoreDataUI()
}
}
}
.cachedCount(15)
.layoutWeight(1)
.scrollBar(BarState.Off)
.edgeEffect(EdgeEffect.None)
.nestedScroll({
scrollForward: NestedScrollMode.PARENT_FIRST,
scrollBackward: NestedScrollMode.SELF_FIRST
})
.onReachEnd(() => {
console.log(TAG, "触底了");
if (!this.isLoading) {
this.isLoading = true
//加载分页数据
this.getNewPageData()
}
})
}
}.layoutWeight(1)
.justifyContent(FlexAlign.Start)
.width('100%')
}
getNewPageData() {
this.isLoading = true
if (this.hasMore) {
let time = encodeURI(DateTimeUtils.getCurDate(DateTimeUtils.PATTERN_DATE_TIME_HYPHEN))
let object = new FollowListDetailRequestItem(-1, 20, this.curPageNum)
MinePageDatasModel.getMineCommentListData(time, object, getContext(this)).then((value) => {
if (!this.data_comment || value.list.length == 0) {
this.hasMore = false
this.isLoading = false
this.isGetRequest = true
} else {
this.getCommentListStatus(value)
}
}).catch((err: Error) => {
console.log(TAG, "请求失败")
this.isLoading = false
this.isGetRequest = true
})
} else {
this.isLoading = false
this.isGetRequest = true
}
}
getCommentListStatus(value: MineCommentListDetailItem) {
let status = new OtherUserCommentLikeStatusRequestItem()
let data: CommentListItem[] = []
value.list.forEach((item) => {
if (item.checkStatus === 2) {
status.commentIdList.push(item.id)
}
let commentContent = item.commentContent
if (item.sensitiveShow === 0 && item.sensitiveExist === 1) {
commentContent = item.commentContentSensitive
}
let parentCommentContent = ""
if (item.parentCommentVo != null) {
parentCommentContent = item.parentCommentVo.commentContent
}
let parentCommentUserName = ""
if (item.parentCommentVo != null) {
parentCommentUserName = item.parentCommentVo.fromUserName
}
data.push(new CommentListItem(item.fromUserHeader, item.fromUserName, item.targetTitle, item.createTime,
commentContent, item.likeNum, 0, item.id, item.targetId, item.targetType, item.targetRelId,
item.targetRelObjectId, item.targetRelType, item.targetStatus, item.checkStatus, parentCommentContent,
parentCommentUserName))
})
if (status.commentIdList.length === 0) {
data.forEach((item) => {
let publishTime =
DateTimeUtils.getCommentTime(DateTimeUtils.parseDate(item.createTime, DateTimeUtils.PATTERN_DATE_TIME_HYPHEN))
this.data_comment.push(new CommentListItem(item.fromUserHeader, item.fromUserName, item.targetTitle,
publishTime, item.commentContent, item.likeNum, item.like_status, item.id, item.targetId, item.targetType,
item.targetRelId, item.targetRelObjectId, item.targetRelType, item.targetStatus, item.checkStatus,
item.parentCommentContent, item.parentCommentUserName))
})
this.data_comment.notifyDataReload()
this.count = this.data_comment.totalCount()
this.commentNum = value.totalCount
if (this.data_comment.totalCount() < value.totalCount) {
this.curPageNum++
} else {
this.hasMore = false
}
this.isLoading = false
this.isGetRequest = true
return
}
MinePageDatasModel.getOtherUserCommentLikeStatusData(status, getContext(this)).then((newValue) => {
newValue.forEach((item) => {
data.forEach((list) => {
if (item.commentId == list.id) {
list.like_status = item.status
}
})
})
data.forEach((item) => {
let publishTime =
DateTimeUtils.getCommentTime(DateTimeUtils.parseDate(item.createTime, DateTimeUtils.PATTERN_DATE_TIME_HYPHEN))
this.data_comment.push(new CommentListItem(item.fromUserHeader, item.fromUserName, item.targetTitle,
publishTime, item.commentContent, item.likeNum, item.like_status, item.id, item.targetId, item.targetType,
item.targetRelId, item.targetRelObjectId, item.targetRelType, item.targetStatus, item.checkStatus,
item.parentCommentContent, item.parentCommentUserName))
})
this.data_comment.notifyDataReload()
this.count = this.data_comment.totalCount()
this.commentNum = value.totalCount
if (this.data_comment.totalCount() < value.totalCount) {
this.curPageNum++
} else {
this.hasMore = false
}
this.isLoading = false
this.isGetRequest = true
}).catch((err: Error) => {
console.log(TAG, "请求失败")
this.isLoading = false
this.isGetRequest = true
})
}
}
\ No newline at end of file
... ...
import { DateTimeUtils, LazyDataSource, SPHelper,UserDataLocal } from 'wdKit';
import { WDRouterPage, WDRouterRule } from 'wdRouter';
import MinePageDatasModel from '../../../model/MinePageDatasModel';
import { CommentListItem } from '../../../viewmodel/CommentListItem';
import { FollowListDetailItem } from '../../../viewmodel/FollowListDetailItem';
import { FollowListDetailRequestItem } from '../../../viewmodel/FollowListDetailRequestItem';
import { ListHasNoMoreDataUI } from '../../reusable/ListHasNoMoreDataUI';
import { FollowChildComponent } from '../follow/FollowChildComponent';
import dataPreferences from '@ohos.data.preferences';
import { EmptyComponent } from '../../view/EmptyComponent';
import { ChildCommentComponent } from './ChildCommentComponent';
import { MineCommentListDetailItem } from '../../../viewmodel/MineCommentListDetailItem';
import { OtherUserCommentLikeStatusRequestItem } from '../../../viewmodel/OtherUserCommentLikeStatusRequestItem';
const TAG = "HomePageBottomComponent"
@Component
export struct HomePageBottomComponent{
@State style:number = 0; //0 评论 ,1 关注
@State data_follow: LazyDataSource<FollowListDetailItem> = new LazyDataSource();
@State data_comment: LazyDataSource<CommentListItem> = new LazyDataSource();
@State isLoading:boolean = false
@State hasMore:boolean = true
curPageNum:number = 1;
@State count:number = 0;
@State isMineAccount:boolean = true;
@State userId:string = "";
@Link commentNum:number
preferences: dataPreferences.Preferences | null = null;
@State isGetRequest:boolean = false
observer = (key: string) => {
if (key == UserDataLocal.USER_FOLLOW_OPERATION) {
let value = SPHelper.default.getSync(UserDataLocal.USER_FOLLOW_OPERATION,"") as string
let arr = value.split(',')
if(arr[1] == "0"){
this.data_follow.getDataArray().forEach((element,index) => {
if (element.creatorId === arr[0]) {
this.data_follow.deleteItem(index)
this.count = this.data_follow.size()
}
});
}else{
if(!this.isLoading){
this.isLoading = true
this.hasMore = true
this.curPageNum = 1
this.data_follow.clear()
this.data_follow.notifyDataReload()
this.getMyFollowListDetail()
}
}
}
}
aboutToAppear(){
this.getNewPageData()
this.addFollowStatusObserver()
}
async addFollowStatusObserver() {
this.preferences = await SPHelper.default.getPreferences();
this.preferences.on('change', this.observer);
}
aboutToDisappear(): void {
if(this.preferences){
this.preferences.off('change', this.observer);
}
}
build(){
Column(){
if(this.isGetRequest == true){
Divider().width('100%')
.height('2lpx')
.strokeWidth('1lpx')
.backgroundColor($r('app.color.color_EDEDED'))
}
if(this.count === 0 ){
if(this.style === 1){
Column(){
Row(){
Text("关注更多人民号")
.fontWeight('400lpx')
.fontColor($r('app.color.color_222222'))
.lineHeight('38lpx')
.fontSize('27lpx')
.textAlign(TextAlign.Center)
.margin({right:'4lpx'})
Image($r('app.media.arrow_icon_right'))
.objectFit(ImageFit.Auto)
.width('27lpx')
.height('27lpx')
}.height('69lpx')
.width('659lpx')
.alignItems(VerticalAlign.Center)
.justifyContent(FlexAlign.Center)
.backgroundColor($r('app.color.color_F5F5F5'))
.margin({top:'31lpx',bottom:'4lpx'})
.onClick(()=>{
let params = {'index': "1"} as Record<string, string>
WDRouterRule.jumpWithPage(WDRouterPage.followListPage,params)
})
if(this.isGetRequest == true){
EmptyComponent({emptyType:14})
.layoutWeight(1)
.width('100%')
.offset({y:"-200lpx"})
}
}.layoutWeight(1)
.justifyContent(FlexAlign.Start)
}else{
if(this.isGetRequest == true){
EmptyComponent({emptyType:11})
.layoutWeight(1)
.width('100%')
.offset({y:"-200lpx"})
}
}
}else{
if(this.style === 1){
List({ space: 3 }) {
ListItem() {
Row(){
Text("关注更多人民号")
.fontWeight('400lpx')
.fontColor($r('app.color.color_222222'))
.lineHeight('38lpx')
.fontSize('27lpx')
.textAlign(TextAlign.Center)
.margin({right:'4lpx'})
Image($r('app.media.arrow_icon_right'))
.objectFit(ImageFit.Auto)
.width('27lpx')
.height('27lpx')
}.height('69lpx')
.width('659lpx')
.alignItems(VerticalAlign.Center)
.justifyContent(FlexAlign.Center)
.backgroundColor($r('app.color.color_F5F5F5'))
.margin({top:'31lpx',bottom:'4lpx'})
}.onClick(()=>{
let params = {'index': "1"} as Record<string, string>
WDRouterRule.jumpWithPage(WDRouterPage.followListPage,params)
})
LazyForEach(this.data_follow, (item: FollowListDetailItem, index: number = 0) => {
ListItem() {
FollowChildComponent({data: item,type:2})
}
.onClick(() => {
})
}, (item: FollowListDetailItem, index: number) => index.toString())
//没有更多数据 显示提示
if(!this.hasMore){
ListItem(){
ListHasNoMoreDataUI()
}
}
}.cachedCount(15)
.padding({left:'31lpx',right:'31lpx'})
.layoutWeight(1)
.scrollBar(BarState.Off)
.edgeEffect(EdgeEffect.None)
.nestedScroll({
scrollForward: NestedScrollMode.PARENT_FIRST,
scrollBackward: NestedScrollMode.SELF_FIRST
})
.onReachEnd(()=>{
console.log(TAG,"触底了");
if(!this.isLoading){
this.isLoading = true
//加载分页数据
this.getNewPageData()
}
})
}else if(this.style === 0){
List({ space: 3 }) {
LazyForEach(this.data_comment, (item: CommentListItem, index: number = 0) => {
ListItem() {
ChildCommentComponent({data: item,levelHead:UserDataLocal.getUserLevelHeaderUrl(),isLastItem:index===this.data_comment.totalCount()-1})
}
.onClick(() => {
})
}, (item: CommentListItem, index: number) => index.toString())
//没有更多数据 显示提示
if(!this.hasMore){
ListItem(){
ListHasNoMoreDataUI()
}
}
}.cachedCount(15)
.layoutWeight(1)
.scrollBar(BarState.Off)
.edgeEffect(EdgeEffect.None)
.nestedScroll({
scrollForward: NestedScrollMode.PARENT_FIRST,
scrollBackward: NestedScrollMode.SELF_FIRST
})
.onReachEnd(()=>{
console.log(TAG,"触底了");
if(!this.isLoading){
this.isLoading = true
//加载分页数据
this.getNewPageData()
}
})
}
}
}.layoutWeight(1)
.justifyContent(FlexAlign.Start)
.width('100%')
}
@Styles
listStyle() {
.backgroundColor(Color.White)
.height(72)
.width("100%")
.borderRadius(12)
}
getMyFollowListDetail(){
if(this.hasMore){
let object = new FollowListDetailRequestItem(-1,20,this.curPageNum)
MinePageDatasModel.getMineFollowListData(object,getContext(this)).then((value)=>{
if (!this.data_follow || value.list.length == 0){
this.hasMore = false
}else{
value.list.forEach((value)=>{
let fansNum:number = value.fansNum
let fansNumString = ""
if (fansNum > 10000) {
let temp = (fansNum / 10000) + ""
let index = temp.indexOf('.')
if (index != -1) {
temp = temp.substring(0, index + 2)
} else {
temp = temp
}
fansNumString = temp + "万"
} else {
fansNumString = fansNum + ""
}
this.data_follow.push(new FollowListDetailItem(value.attentionHeadPhotoUrl,value.attentionUserName,fansNumString,value.introduction,value.attentionCreatorId,"1",value.attentionUserId,value.attentionUserType,value.attentionUserId,value.mainControl,value.banControl,value.authIcon))
})
this.data_follow.notifyDataReload()
this.count = this.data_follow.totalCount()
if (this.data_follow.totalCount() < value.totalCount) {
this.curPageNum++
}else {
this.hasMore = false
}
}
this.isLoading = false
this.isGetRequest = true
}).catch((err:Error)=>{
console.log(TAG,"请求失败")
this.isLoading = false
this.isGetRequest = true
})
}else{
this.isLoading = false
this.isGetRequest = true
}
}
getNewPageData(){
this.isLoading = true
//我的关注列表
if (this.style === 1){
this.getMyFollowListDetail()
}else if(this.style === 0){
if(this.hasMore){
let time = encodeURI(DateTimeUtils.getCurDate(DateTimeUtils.PATTERN_DATE_TIME_HYPHEN))
let object = new FollowListDetailRequestItem(-1,20,this.curPageNum)
MinePageDatasModel.getMineCommentListData(time,object,getContext(this)).then((value)=>{
if (!this.data_comment || value.list.length == 0){
this.hasMore = false
this.isLoading = false
this.isGetRequest = true
}else{
this.getCommentListStatus(value)
}
}).catch((err:Error)=>{
console.log(TAG,"请求失败")
this.isLoading = false
this.isGetRequest = true
})
}else{
this.isLoading = false
this.isGetRequest = true
}
}
}
getCommentListStatus(value:MineCommentListDetailItem){
let status = new OtherUserCommentLikeStatusRequestItem()
let data : CommentListItem[] = []
value.list.forEach((item)=>{
if(item.checkStatus === 2){
status.commentIdList.push(item.id)
}
let commentContent = item.commentContent
if(item.sensitiveShow === 0 && item.sensitiveExist === 1){
commentContent = item.commentContentSensitive
}
let parentCommentContent = ""
if(item.parentCommentVo!=null ){
parentCommentContent = item.parentCommentVo.commentContent
}
let parentCommentUserName = ""
if(item.parentCommentVo!=null ){
parentCommentUserName = item.parentCommentVo.fromUserName
}
data.push(new CommentListItem(item.fromUserHeader,item.fromUserName,item.targetTitle,item.createTime,commentContent,item.likeNum,0,item.id,item.targetId,item.targetType,item.targetRelId,item.targetRelObjectId,item.targetRelType,item.targetStatus,item.checkStatus,parentCommentContent,parentCommentUserName))
})
if(status.commentIdList.length === 0){
data.forEach((item)=>{
let publishTime = DateTimeUtils.getCommentTime(DateTimeUtils.parseDate(item.createTime,DateTimeUtils.PATTERN_DATE_TIME_HYPHEN))
this.data_comment.push(new CommentListItem(item.fromUserHeader,item.fromUserName,item.targetTitle,publishTime,item.commentContent,item.likeNum,item.like_status,item.id,item.targetId,item.targetType,item.targetRelId,item.targetRelObjectId,item.targetRelType,item.targetStatus,item.checkStatus,item.parentCommentContent,item.parentCommentUserName))
})
this.data_comment.notifyDataReload()
this.count = this.data_comment.totalCount()
this.commentNum = value.totalCount
if (this.data_comment.totalCount() < value.totalCount) {
this.curPageNum++
}else {
this.hasMore = false
}
this.isLoading = false
this.isGetRequest = true
return
}
MinePageDatasModel.getOtherUserCommentLikeStatusData(status,getContext(this)).then((newValue)=>{
newValue.forEach((item)=>{
data.forEach((list)=>{
if (item.commentId == list.id) {
list.like_status = item.status
}
})
})
data.forEach((item)=>{
let publishTime = DateTimeUtils.getCommentTime(DateTimeUtils.parseDate(item.createTime,DateTimeUtils.PATTERN_DATE_TIME_HYPHEN))
this.data_comment.push(new CommentListItem(item.fromUserHeader,item.fromUserName,item.targetTitle,publishTime,item.commentContent,item.likeNum,item.like_status,item.id,item.targetId,item.targetType,item.targetRelId,item.targetRelObjectId,item.targetRelType,item.targetStatus,item.checkStatus,item.parentCommentContent,item.parentCommentUserName))
})
this.data_comment.notifyDataReload()
this.count = this.data_comment.totalCount()
this.commentNum = value.totalCount
if (this.data_comment.totalCount() < value.totalCount) {
this.curPageNum++
}else {
this.hasMore = false
}
this.isLoading = false
this.isGetRequest = true
}).catch((err:Error)=>{
console.log(TAG,"请求失败")
this.isLoading = false
this.isGetRequest = true
})
}
}
\ No newline at end of file
import { LazyDataSource, SPHelper, UserDataLocal } from 'wdKit';
import { WDRouterPage, WDRouterRule } from 'wdRouter';
import MinePageDatasModel from '../../../model/MinePageDatasModel';
import { FollowListDetailItem } from '../../../viewmodel/FollowListDetailItem';
import { FollowListDetailRequestItem } from '../../../viewmodel/FollowListDetailRequestItem';
import { ListHasNoMoreDataUI } from '../../reusable/ListHasNoMoreDataUI';
import { FollowChildComponent } from '../follow/FollowChildComponent';
import dataPreferences from '@ohos.data.preferences';
import { EmptyComponent } from '../../view/EmptyComponent';
const TAG = "HomePageBottomFollowComponent"
/**
* 我的主页 关注 tab
*/
@Component
export struct HomePageBottomFollowComponent {
@State data_follow: LazyDataSource<FollowListDetailItem> = new LazyDataSource();
@State isLoading: boolean = false
@State hasMore: boolean = true
curPageNum: number = 1;
@State count: number = 0;
preferences: dataPreferences.Preferences | null = null;
@State isGetRequest: boolean = false
observer = (key: string) => {
if (key == UserDataLocal.USER_FOLLOW_OPERATION) {
let value = SPHelper.default.getSync(UserDataLocal.USER_FOLLOW_OPERATION, "") as string
let arr = value.split(',')
if (arr[1] == "0") {
this.data_follow.getDataArray().forEach((element, index) => {
if (element.creatorId === arr[0]) {
this.data_follow.deleteItem(index)
this.count = this.data_follow.size()
}
});
} else {
if (!this.isLoading) {
this.isLoading = true
this.hasMore = true
this.curPageNum = 1
this.data_follow.clear()
this.data_follow.notifyDataReload()
this.getMyFollowListDetail()
}
}
}
}
aboutToAppear() {
this.getNewPageData()
this.addFollowStatusObserver()
}
async addFollowStatusObserver() {
this.preferences = await SPHelper.default.getPreferences();
this.preferences.on('change', this.observer);
}
aboutToDisappear(): void {
if (this.preferences) {
this.preferences.off('change', this.observer);
}
}
build() {
Column() {
if (this.isGetRequest == true) {
Divider().width('100%')
.height('2lpx')
.strokeWidth('1lpx')
.backgroundColor($r('app.color.color_EDEDED'))
}
if (this.count === 0) {
Stack({ alignContent: Alignment.Top }) {
if (this.isGetRequest == true) {
EmptyComponent({ emptyType: 14 })
.layoutWeight(1)
.width('100%')
.offset({ y: "-200lpx" })
}
Row() {
Text("关注更多人民号")
.fontWeight('400lpx')
.fontColor($r('app.color.color_222222'))
.lineHeight('38lpx')
.fontSize('27lpx')
.textAlign(TextAlign.Center)
.margin({ right: '4lpx' })
Image($r('app.media.arrow_icon_right'))
.objectFit(ImageFit.Auto)
.width('27lpx')
.height('27lpx')
}
.height('69lpx')
.width('659lpx')
.alignItems(VerticalAlign.Center)
.justifyContent(FlexAlign.Center)
.backgroundColor($r('app.color.color_F5F5F5'))
.margin({ top: '31lpx', bottom: '4lpx' })
.onClick(() => {
let params = { 'index': "1" } as Record<string, string>
WDRouterRule.jumpWithPage(WDRouterPage.followListPage, params)
})
}.layoutWeight(1)
} else {
List({ space: 3 }) {
ListItem() {
Row() {
Text("关注更多人民号")
.fontWeight('400lpx')
.fontColor($r('app.color.color_222222'))
.lineHeight('38lpx')
.fontSize('27lpx')
.textAlign(TextAlign.Center)
.margin({ right: '4lpx' })
Image($r('app.media.arrow_icon_right'))
.objectFit(ImageFit.Auto)
.width('27lpx')
.height('27lpx')
}
.height('69lpx')
.width('659lpx')
.alignItems(VerticalAlign.Center)
.justifyContent(FlexAlign.Center)
.backgroundColor($r('app.color.color_F5F5F5'))
.margin({ top: '31lpx', bottom: '4lpx' })
}.onClick(() => {
let params = { 'index': "1" } as Record<string, string>
WDRouterRule.jumpWithPage(WDRouterPage.followListPage, params)
})
LazyForEach(this.data_follow, (item: FollowListDetailItem, index: number = 0) => {
ListItem() {
FollowChildComponent({ data: item, type: 2 })
}
}, (item: FollowListDetailItem, index: number) => index.toString())
//没有更多数据 显示提示
if (!this.hasMore) {
ListItem() {
ListHasNoMoreDataUI()
}
}
}
.cachedCount(15)
.padding({ left: '31lpx', right: '31lpx' })
.layoutWeight(1)
.scrollBar(BarState.Off)
.edgeEffect(EdgeEffect.None)
.nestedScroll({
scrollForward: NestedScrollMode.PARENT_FIRST,
scrollBackward: NestedScrollMode.SELF_FIRST
})
.onReachEnd(() => {
console.log(TAG, "触底了");
if (!this.isLoading) {
this.isLoading = true
//加载分页数据
this.getNewPageData()
}
})
}
}.layoutWeight(1)
.justifyContent(FlexAlign.Start)
.width('100%')
}
@Styles
listStyle() {
.backgroundColor(Color.White)
.height(72)
.width("100%")
.borderRadius(12)
}
getMyFollowListDetail() {
if (this.hasMore) {
let object = new FollowListDetailRequestItem(-1, 20, this.curPageNum)
MinePageDatasModel.getMineFollowListData(object, getContext(this)).then((value) => {
if (!this.data_follow || value.list.length == 0) {
this.hasMore = false
} else {
value.list.forEach((value) => {
let fansNum: number = value.fansNum
let fansNumString = ""
if (fansNum > 10000) {
let temp = (fansNum / 10000) + ""
let index = temp.indexOf('.')
if (index != -1) {
temp = temp.substring(0, index + 2)
} else {
temp = temp
}
fansNumString = temp + "万"
} else {
fansNumString = fansNum + ""
}
this.data_follow.push(new FollowListDetailItem(value.attentionHeadPhotoUrl, value.attentionUserName,
fansNumString, value.introduction, value.attentionCreatorId, "1", value.attentionUserId,
value.attentionUserType, value.attentionUserId, value.mainControl, value.banControl, value.authIcon))
})
this.data_follow.notifyDataReload()
this.count = this.data_follow.totalCount()
if (this.data_follow.totalCount() < value.totalCount) {
this.curPageNum++
} else {
this.hasMore = false
}
}
this.isLoading = false
this.isGetRequest = true
}).catch((err: Error) => {
console.log(TAG, "请求失败")
this.isLoading = false
this.isGetRequest = true
})
} else {
this.isLoading = false
this.isGetRequest = true
}
}
getNewPageData() {
this.isLoading = true
//我的关注列表
this.getMyFollowListDetail()
}
}
\ No newline at end of file
... ...
... ... @@ -9,7 +9,9 @@ import { ChildCommentComponent } from './ChildCommentComponent';
import { EmptyComponent } from '../../view/EmptyComponent';
const TAG = "HomePageBottomComponent"
/**
* 普通用户的主页 评论 tab
*/
@Component
export struct OtherHomePageBottomCommentComponent {
@Prop curUserId: string
... ...
... ... @@ -9,6 +9,10 @@ import { EmptyComponent } from '../../view/EmptyComponent';
import { FollowChildComponent } from '../follow/FollowChildComponent';
const TAG = "HomePageBottomComponent"
/**
* 普通用户的主页 关注 tab
*/
@Component
export struct OtherHomePageBottomFollowComponent{
@State data_follow: LazyDataSource<FollowListDetailItem> = new LazyDataSource();
... ...
import router from '@ohos.router'
import { Params } from 'wdBean';
import { StringUtils } from 'wdKit';
import { WDRouterPage, WDRouterRule } from 'wdRouter';
import { HomePageBottomComponent } from '../components/mine/home/HomePageBottomComponent';
import { HomePageBottomCommentComponent } from '../components/mine/home/HomePageBottomCommentComponent';
import { HomePageBottomFollowComponent } from '../components/mine/home/HomePageBottomFollowComponent';
import MinePageDatasModel from '../model/MinePageDatasModel';
const TAG = "MineHomePage"
... ... @@ -185,10 +185,10 @@ struct MineHomePage {
Stack({ alignContent: Alignment.Top }){
Tabs({controller: this.controller}) {
TabContent() {
HomePageBottomComponent({style:0,commentNum:$commentNum})
HomePageBottomCommentComponent({commentNum:$commentNum})
}
TabContent() {
HomePageBottomComponent({style:1,commentNum:$commentNum})
HomePageBottomFollowComponent()
}
}
.backgroundColor($r('app.color.white'))
... ...