wangliang_wd

feat:优化我的界面头像闪烁问题,优化关注列表刷新逻辑

... ... @@ -72,6 +72,11 @@ export class UserDataLocal {
SPHelper.default.save(UserDataLocal.USER_HEADER_URL, url)
}
public static setUser_name(url:string) {
UserDataLocal.userName = url
SPHelper.default.save(UserDataLocal.USER_NAME, url)
}
public static setUserType(type:string) {
SPHelper.default.save(UserDataLocal.USER_Type, type)
}
... ...
... ... @@ -26,11 +26,11 @@ export default struct MinePageUserSimpleInfoUI {
loginStateChange(){
if(this.isLogin){
///已登录状态,先获取本地数据
this.userName = SPHelper.default.getSync(SpConstants.USER_NAME,"") as string
this.headPhotoUrl = SPHelper.default.getSync(SpConstants.USER_HEAD_PHOTO_URL,"") as string
this.userName = UserDataLocal.getUserName()
this.headPhotoUrl = UserDataLocal.USER_HEADER_URL
///用户类型1普通用户
let userType = SPHelper.default.getSync(SpConstants.USER_Type,"") as string
let userType = UserDataLocal.getUserType()
if (userType && userType.length > 0) {
this.userType = userType
}
... ... @@ -43,7 +43,7 @@ export default struct MinePageUserSimpleInfoUI {
}
pageShowForUpdateData(){
let name = SPHelper.default.getSync(SpConstants.USER_NAME,"") as string
let name = UserDataLocal.getUserName()
if (name != this.userName) {
this.loginStateChange()
}
... ... @@ -182,6 +182,8 @@ export default struct MinePageUserSimpleInfoUI {
this.headPhotoUrl = value.headPhotoUrl
UserDataLocal.setUserHeaderUrl(value.headPhotoUrl)
UserDataLocal.setUser_name(value.userName)
this.userType = value.userType
UserDataLocal.setUserType(value.userType)
... ...
... ... @@ -199,7 +199,7 @@ export struct FollowListDetailUI {
this.getMyFollowListDetail()
} else {
if (this.hasMore) {
let object = new FollowListDetailRequestItem(this.creatorDirectoryId, 20, this.curPageNum)
let object = new FollowListDetailRequestItem(this.creatorDirectoryId, 10, this.curPageNum)
MinePageDatasModel.getFollowListDetailData(object, getContext(this)).then((value) => {
if (!this.data || value.list.length == 0) {
... ... @@ -250,30 +250,29 @@ export struct FollowListDetailUI {
}
})
})
data_temp.forEach((item) => {
let introduction = item.introduction
if(item.introduction.indexOf("\n") != -1){
let regex:RegExp = new RegExp('\n','g')
introduction = item.introduction.replace(regex,'')
}
this.data.push(new FollowListDetailItem(item.headPhotoUrl, item.cnUserName, item.cnFansNum, introduction, item.creatorId, item.status, item.attentionUserId, item.cnUserType, item.cnUserId, item.mainControl, item.banControl, item.authIcon))
})
if(StringUtils.isNotEmpty(userid)) {
this.getFollowStatus(data_temp, result.totalCount)
}else {
data_temp.forEach((item) => {
let introduction = item.introduction
if(item.introduction.indexOf("\n") != -1){
let regex:RegExp = new RegExp('\n','g')
introduction = item.introduction.replace(regex,'')
}
this.data.push(new FollowListDetailItem(item.headPhotoUrl, item.cnUserName, item.cnFansNum, introduction, item.creatorId, item.status, item.attentionUserId, item.cnUserType, item.cnUserId, item.mainControl, item.banControl, item.authIcon))
})
this.data.notifyDataReload()
this.data.notifyDataReload()
this.count = this.data.totalCount()
if (this.data.totalCount() < result.totalCount) {
this.curPageNum++
} else {
this.hasMore = false
}
this.count = this.data.totalCount()
if (this.data.totalCount() < result.totalCount) {
this.curPageNum++
} else {
this.hasMore = false
}
this.isLoading = false
this.isGetRequest = true
this.isLoading = false
this.isGetRequest = true
if(StringUtils.isNotEmpty(userid)) {
this.getFollowStatus(this.data, result.totalCount)
}
}else{
this.isGetRequest = true
... ... @@ -286,41 +285,20 @@ export struct FollowListDetailUI {
})
}
getFollowStatus(result: FollowListDetailItem[], totalCount: number) {
getFollowStatus(result: LazyDataSource<FollowListDetailItem>, totalCount: number) {
let status = new FollowListStatusRequestItem()
result.forEach((item) => {
result.getDataArray().forEach((item) => {
status.creatorIds.push(new QueryListIsFollowedItem(item.creatorId))
})
MinePageDatasModel.getFollowListStatusData(status, getContext(this)).then((newValue) => {
newValue.forEach((item) => {
result.forEach((list) => {
result.getDataArray().forEach((list) => {
if (item.creatorId == list.creatorId) {
list.status = item.status
}
})
})
result.forEach((item) => {
let introduction = item.introduction
if(item.introduction.indexOf("\n") != -1){
let regex:RegExp = new RegExp('\n','g')
introduction = item.introduction.replace(regex,'')
}
this.data.push(new FollowListDetailItem(item.headPhotoUrl, item.cnUserName, item.cnFansNum, introduction, item.creatorId, item.status, item.attentionUserId, item.cnUserType, item.cnUserId, item.mainControl, item.banControl, item.authIcon))
})
this.data.notifyDataReload()
this.count = this.data.totalCount()
if (this.data.totalCount() < totalCount) {
this.curPageNum++
} else {
this.hasMore = false
}
this.isLoading = false
this.isGetRequest = true
}).catch((err: Error) => {
// console.log(TAG, "请求失败")
this.isLoading = false
... ...
... ... @@ -12,7 +12,7 @@ import router from '@ohos.router';
import TrackingPageBrowseUtils from '../../utils/TrackingPageBrowseUtils'
import { TrackConstants } from 'wdTracking/Index';
import { SPHelper } from 'wdKit/Index';
import { SPHelper, UserDataLocal } from 'wdKit/Index';
import { SpConstants } from 'wdConstant/Index';
import { photoPickerUtils} from '../../utils/PhotoPickerUtils';
import { cameraPickerUtils } from '../../utils/CameraPickerUtils';
... ... @@ -138,6 +138,7 @@ struct EditUserInfoPage {
let userType = SPHelper.default.getSync(SpConstants.USER_Type,"") as string
if (userType && userType.length > 0) {
this.userType = userType
this.headerImg = UserDataLocal.getUserHeaderUrl()
}
this.getAccountOwnerInfo()
... ...
... ... @@ -4,7 +4,7 @@ import { editModel, editModelParams, WDEditDataModelType } from '../../model/Edi
import EditInfoViewModel from '../../viewmodel/EditInfoViewModel';
// import { encryptMessage } from '../../../utils/cryptoUtil'
import { encryptMessage } from 'wdLogin/src/main/ets/utils/cryptoUtil'
import { SPHelper } from 'wdKit';
import { SPHelper, UserDataLocal } from 'wdKit';
import { SpConstants } from 'wdConstant';
@Entry
... ... @@ -91,7 +91,8 @@ struct EditUserNikeNamePage {
}
goBack(){
SPHelper.default.saveSync(SpConstants.USER_NAME, this.nikeName)
UserDataLocal.setUser_name(this.nikeName)
let params: editModelParams = {
userName: this.nikeName
}
... ...