Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
yangchenggong1_wd
2024-04-22 14:53:43 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5b9dc9fbaf8f3d3f0eaae276f65e9106201528d3
5b9dc9fb
1 parent
665cdd61
desc:关注更新
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
240 additions
and
120 deletions
sight_harmony/commons/wdKit/src/main/ets/utils/UserDataLocal.ets
sight_harmony/features/wdComponent/src/main/ets/components/mine/follow/FollowChildComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/mine/follow/FollowListDetailUI.ets
sight_harmony/features/wdComponent/src/main/ets/components/mine/home/HomePageBottomComponent.ets
sight_harmony/commons/wdKit/src/main/ets/utils/UserDataLocal.ets
View file @
5b9dc9f
...
...
@@ -24,6 +24,7 @@ export class UserDataLocal {
static USER_HEADER_URL="userHeaderUrl"
static USER_LEVEL="userLevel"
static USER_LEVEL_HEADER_URL="userLevelHeaderUrl"
static USER_FOLLOW_OPERATION="user_follow_operation"
//刷新token 用到
static USER_REFRESH_TOKEN="refreshToken"
...
...
@@ -89,6 +90,10 @@ export class UserDataLocal {
SPHelper.default.save(UserDataLocal.USER_HEADER_URL, url)
}
public static setUserFollowOperation(timestamp:string) {
SPHelper.default.saveSync(UserDataLocal.USER_FOLLOW_OPERATION, timestamp)
}
public static getUserLevel() {
if(UserDataLocal.userLevel != -1){
...
...
sight_harmony/features/wdComponent/src/main/ets/components/mine/follow/FollowChildComponent.ets
View file @
5b9dc9f
import {
StringUtils, ToastUtils
} from 'wdKit/Index'
import {
DateTimeUtils, StringUtils, ToastUtils, UserDataLocal
} from 'wdKit/Index'
import { HttpUrlUtils } from 'wdNetwork/Index'
import { WDRouterRule, WDRouterPage } from 'wdRouter/Index'
import MinePageDatasModel from '../../../model/MinePageDatasModel'
...
...
@@ -133,14 +133,17 @@ export struct FollowChildComponent{
.maxLines(1)
.margin({bottom:'12lpx'})
Row(){
Text(`粉丝${this.data.cnFansNum}`)
.fontColor($r('app.color.color_B0B0B0'))
.fontSize('23lpx')
Image($r("app.media.point"))
.width('31lpx')
.height('31lpx')
.objectFit(ImageFit.Auto)
if(this.data.cnFansNum!="0"){
Text(`粉丝${this.data.cnFansNum}`)
.fontColor($r('app.color.color_B0B0B0'))
.fontSize('23lpx')
}
if(this.data.cnFansNum!="0" && StringUtils.isNotEmpty(this.data.introduction)){
Image($r("app.media.point"))
.width('31lpx')
.height('31lpx')
.objectFit(ImageFit.Auto)
}
Text(`${this.data.introduction}`)
.fontColor($r('app.color.color_B0B0B0'))
...
...
@@ -222,6 +225,12 @@ export struct FollowChildComponent{
if(value!=null){
if (value.code === 0 || value.code.toString() === "0") {
this.data.status = this.data.status ==="0"?"1":"0"
if(this.data.status === "1"){
UserDataLocal.setUserFollowOperation(DateTimeUtils.getTimeStamp()+"")
}else{
UserDataLocal.setUserFollowOperation(DateTimeUtils.getTimeStamp()+","+this.data.creatorId)
}
}
}
})
...
...
sight_harmony/features/wdComponent/src/main/ets/components/mine/follow/FollowListDetailUI.ets
View file @
5b9dc9f
import { LazyDataSource } from 'wdKit';
import { LazyDataSource
, SPHelper, UserDataLocal
} from 'wdKit';
import MinePageDatasModel from '../../../model/MinePageDatasModel';
import SearcherAboutDataModel from '../../../model/SearcherAboutDataModel';
import { CreatorDetailRequestItem } from '../../../viewmodel/CreatorDetailRequestItem';
...
...
@@ -9,50 +9,55 @@ import { MineFollowListDetailItem } from '../../../viewmodel/MineFollowListDetai
import { QueryListIsFollowedItem } from '../../../viewmodel/QueryListIsFollowedItem';
import { ListHasNoMoreDataUI } from '../../reusable/ListHasNoMoreDataUI';
import { FollowChildComponent } from './FollowChildComponent';
import dataPreferences from '@ohos.data.preferences';
const TAG = "FollowListDetailUI"
@Component
export struct FollowListDetailUI{
@State creatorDirectoryId:number = -1;
@State type:number = 0
export struct FollowListDetailUI {
@State creatorDirectoryId: number = -1;
@State type: number = 0
@State data: LazyDataSource<FollowListDetailItem> = new LazyDataSource();
@State count:number = 0;
@State isLoading:boolean = false
@State hasMore:boolean = true
curPageNum:number = 1;
@State count: number = 0;
@State isLoading: boolean = false
@State hasMore: boolean = true
curPageNum: number = 1;
preferences: dataPreferences.Preferences | null = null;
aboutToAppear(){
aboutToAppear()
{
this.getNewPageData()
this.addFollowStatusObserver()
}
build(){
Column(){
if(this.count === 0){
ListHasNoMoreDataUI({style:2})
build() {
Column() {
if (this.count === 0) {
ListHasNoMoreDataUI({ style: 2 })
.height('100%')
}
else
{
}
else
{
List({ space: 3 }) {
LazyForEach(this.data, (item: FollowListDetailItem, index: number = 0) => {
ListItem() {
FollowChildComponent({
data: item,type:this.type
})
FollowChildComponent({
data: item, type: this.type
})
}
.onClick(() => {
})
}, (item: FollowListDetailItem
, index: number) => index.toString()
)
}, (item: FollowListDetailItem
) => item.creatorId
)
//没有更多数据 显示提示
if(!this.hasMore){
ListItem(){
if (!this.hasMore) {
ListItem() {
ListHasNoMoreDataUI()
}
}
}.cachedCount(10)
.padding({left:'31lpx',right:'31lpx'})
}
.cachedCount(10)
.padding({ left: '31lpx', right: '31lpx' })
.layoutWeight(1)
.scrollBar(BarState.Off)
.onReachEnd(()=>{
console.log(TAG,"触底了");
if(!this.isLoading){
.onReachEnd(() => {
console.log(TAG, "触底了");
if (!this.isLoading) {
this.isLoading = true
//加载分页数据
this.getNewPageData()
...
...
@@ -63,79 +68,128 @@ export struct FollowListDetailUI{
.width('100%')
}
getNewPageData(){
this.isLoading = true
//我的关注列表
if (this.creatorDirectoryId === -1){
if(this.hasMore){
let object = new FollowListDetailRequestItem(-1,20,this.curPageNum)
MinePageDatasModel.getMineFollowListData(object,getContext(this)).then((value)=>{
if (!this.data || value.list.length == 0){
this.hasMore = false
async addFollowStatusObserver() {
this.preferences = await SPHelper.default.getPreferences();
let observer = (key: string) => {
if (key == UserDataLocal.USER_FOLLOW_OPERATION) {
if (this.creatorDirectoryId === -1) {
let value = SPHelper.default.getSync(UserDataLocal.USER_FOLLOW_OPERATION,"") as string
let arr = value.split(',')
if(arr!=null && arr.length === 2){
this.data.getDataArray().forEach((element,index) => {
if (element.creatorId === arr[1]) {
this.data.deleteItem(index)
}
});
}else{
value.list.forEach((value)=>{
this.data.push(new FollowListDetailItem(value.attentionHeadPhotoUrl,value.attentionUserName,value.fansNum+"",value.introduction,value.attentionCreatorId,"1",value.attentionUserId,value.attentionUserType,value.attentionUserId,value.mainControl,value.banControl))
})
this.data.notifyDataReload()
this.count = this.data.totalCount()
if (this.data.totalCount() < value.totalCount) {
this.curPageNum++
}else {
this.hasMore = false
if(!this.isLoading){
this.isLoading = true
this.hasMore = true
this.curPageNum = 1
this.data.clear()
this.data.notifyDataReload()
this.getMyFollowListDetail()
}
}
this.isLoading = false
}).catch((err:Error)=>{
console.log(TAG,"请求失败")
this.isLoading = false
})
}
}
}else{
if(this.hasMore){
let object = new FollowListDetailRequestItem(this.creatorDirectoryId,20,this.curPageNum)
}
this.preferences.on('change', observer);
}
getMyFollowListDetail() {
if (this.hasMore) {
let object = new FollowListDetailRequestItem(-1, 20, this.curPageNum)
MinePageDatasModel.getFollowListDetailData(object,getContext(this)).then((value)=>{
if (!this.data || value.list.length == 0){
MinePageDatasModel.getMineFollowListData(object, getContext(this)).then((value) => {
if (!this.data || value.list.length == 0) {
this.hasMore = false
this.isLoading = 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.push(new FollowListDetailItem(value.attentionHeadPhotoUrl, value.attentionUserName, fansNumString, value.introduction, value.attentionCreatorId, "1", value.attentionUserId, value.attentionUserType, value.attentionUserId, value.mainControl, value.banControl))
})
this.data.notifyDataReload()
this.count = this.data.totalCount()
if (this.data.totalCount() < value.totalCount) {
this.curPageNum++
} else {
this.hasMore = false
}
}
this.isLoading = false
}).catch((err: Error) => {
console.log(TAG, "请求失败")
this.isLoading = false
})
}else {
this.isLoading = false
}
}
getNewPageData() {
//我的关注列表
if (this.creatorDirectoryId === -1) {
this.getMyFollowListDetail()
} else {
if (this.hasMore) {
let object = new FollowListDetailRequestItem(this.creatorDirectoryId, 20, this.curPageNum)
MinePageDatasModel.getFollowListDetailData(object, getContext(this)).then((value) => {
if (!this.data || value.list.length == 0) {
this.hasMore = false
this.isLoading = false
}
else
{
}
else
{
this.getFollowListStatus(value)
}
}).catch((err:Error)=>{
console.log(TAG,"请求失败")
}).catch((err: Error) => {
console.log(TAG, "请求失败")
this.isLoading = false
})
}
}
}
getFollowListStatus(result:MineFollowListDetailItem){
let data_temp : FollowListDetailItem[] = []
result.list.forEach((item)=>{
data_temp.push(new FollowListDetailItem(item.headPhotoUrl,item.cnUserName,item.cnFansNum,item.introduction,item.creatorId,"0",item.attentionUserId,item.cnUserType,item.cnUserId,item.cnMainControl,-1))
getFollowListStatus(result: MineFollowListDetailItem) {
let data_temp: FollowListDetailItem[] = []
result.list.forEach((item) => {
data_temp.push(new FollowListDetailItem(item.headPhotoUrl, item.cnUserName, item.cnFansNum, item.introduction, item.creatorId, "0", item.attentionUserId, item.cnUserType, item.cnUserId, item.cnMainControl, -1))
})
let request = new CreatorDetailRequestItem()
data_temp.forEach((data)
=>
{
data_temp.forEach((data)
=>
{
request.creatorIdList.push(data.creatorId)
})
SearcherAboutDataModel.getCreatorDetailListData(request).then((value)=>{
if(value!=null && value.length>0){
data_temp.forEach((data)=>{
value.forEach((item)=>{
if(data.creatorId == item.creatorId){
SearcherAboutDataModel.getCreatorDetailListData(request).then((value) => {
if (value != null && value.length > 0) {
data_temp.forEach((data) => {
value.forEach((item) => {
if (data.creatorId == item.creatorId) {
data.headPhotoUrl = item.headPhotoUrl
if(item.fansNum>10000){
let temp = (item.fansNum/10000)+""
if (item.fansNum > 10000) {
let temp = (item.fansNum / 10000) + ""
let index = temp.indexOf('.')
if(index != -1){
temp = temp.substring(0,index+2)
}else{
if (index != -1) {
temp = temp.substring(0, index + 2)
} else {
temp = temp
}
data.cnFansNum = temp + "万"
}
else
{
}
else
{
data.cnFansNum = item.fansNum + ""
}
data.introduction = item.introduction
...
...
@@ -144,32 +198,32 @@ export struct FollowListDetailUI{
}
})
})
this.getFollowStatus(data_temp,result.totalCount)
this.getFollowStatus(data_temp,
result.totalCount)
}
}).catch((err:Error)=>{
console.log(TAG,JSON.stringify(err))
}).catch((err: Error) => {
console.log(TAG, JSON.stringify(err))
this.isLoading = false
this.count = this.count
===-1?0:
this.count
this.count = this.count
=== -1 ? 0 :
this.count
})
}
getFollowStatus(result
: FollowListDetailItem[],totalCount:number)
{
getFollowStatus(result
: FollowListDetailItem[], totalCount: number)
{
let status = new FollowListStatusRequestItem()
result.forEach((item)
=>
{
result.forEach((item)
=>
{
status.creatorIds.push(new QueryListIsFollowedItem(item.creatorId))
})
MinePageDatasModel.getFollowListStatusData(status,getContext(this)).then((newValue)=>{
newValue.forEach((item)=>{
result.forEach((list)=>{
MinePageDatasModel.getFollowListStatusData(status, getContext(this)).then((newValue) => {
newValue.forEach((item) => {
result.forEach((list) => {
if (item.creatorId == list.creatorId) {
list.status = item.status
}
})
})
result.forEach((item)=>{
this.data.push(new FollowListDetailItem(item.headPhotoUrl,item.cnUserName,item.cnFansNum,item.introduction,item.creatorId,item.status,item.attentionUserId,item.cnUserType,item.cnUserId,item.mainControl,item.banControl))
result.forEach((item) => {
this.data.push(new FollowListDetailItem(item.headPhotoUrl, item.cnUserName, item.cnFansNum, item.introduction, item.creatorId, item.status, item.attentionUserId, item.cnUserType, item.cnUserId, item.mainControl, item.banControl))
})
this.data.notifyDataReload()
...
...
@@ -177,15 +231,14 @@ export struct FollowListDetailUI{
this.count = this.data.totalCount()
if (this.data.totalCount() < totalCount) {
this.curPageNum++
}else {
}
else {
this.hasMore = false
}
this.isLoading = false
}).catch((err:Error)=>{
console.log(TAG,"请求失败")
}).catch((err: Error) => {
console.log(TAG, "请求失败")
this.isLoading = false
})
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdComponent/src/main/ets/components/mine/home/HomePageBottomComponent.ets
View file @
5b9dc9f
import { Params } from 'wdBean';
import { DateTimeUtils, LazyDataSource,UserDataLocal } from 'wdKit';
import { DateTimeUtils, LazyDataSource,
SPHelper,
UserDataLocal } from 'wdKit';
import { WDRouterPage, WDRouterRule } from 'wdRouter';
import MinePageDatasModel from '../../../model/MinePageDatasModel';
import { CommentListItem } from '../../../viewmodel/CommentListItem';
...
...
@@ -7,6 +7,7 @@ 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';
const TAG = "HomePageBottomComponent"
@Component
...
...
@@ -21,9 +22,38 @@ export struct HomePageBottomComponent{
@State isMineAccount:boolean = true;
@State userId:string = "";
@Link commentNum:number
preferences: dataPreferences.Preferences | null = null;
aboutToAppear(){
this.getNewPageData()
this.addFollowStatusObserver()
}
async addFollowStatusObserver() {
this.preferences = await SPHelper.default.getPreferences();
let 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!=null && arr.length === 2){
this.data_follow.getDataArray().forEach((element,index) => {
if (element.creatorId === arr[1]) {
this.data_follow.deleteItem(index)
}
});
}else{
if(!this.isLoading){
this.isLoading = true
this.hasMore = true
this.curPageNum = 1
this.data_follow.clear()
this.data_follow.notifyDataReload()
this.getMyFollowListDetail()
}
}
}
}
this.preferences.on('change', observer);
}
build(){
...
...
@@ -175,34 +205,55 @@ export struct HomePageBottomComponent{
.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))
})
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
}).catch((err:Error)=>{
console.log(TAG,"请求失败")
this.isLoading = false
})
}else{
this.isLoading = false
}
}
getNewPageData(){
this.isLoading = true
//我的关注列表
if (this.style === 1){
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)=>{
this.data_follow.push(new FollowListDetailItem(value.attentionHeadPhotoUrl,value.attentionUserName,value.fansNum+"",value.introduction,value.attentionCreatorId,"1",value.attentionUserId,value.attentionUserType,value.attentionUserId,value.mainControl,value.banControl))
})
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
}).catch((err:Error)=>{
console.log(TAG,"请求失败")
this.isLoading = false
})
}
this.getMyFollowListDetail()
}else if(this.style === 0){
if(this.hasMore){
let time = encodeURI(DateTimeUtils.getCurDate(DateTimeUtils.PATTERN_DATE_TIME_HYPHEN))
...
...
@@ -230,6 +281,8 @@ export struct HomePageBottomComponent{
console.log(TAG,"请求失败")
this.isLoading = false
})
}else{
this.isLoading = false
}
}
}
...
...
Please
register
or
login
to post a comment