yangchenggong1_wd

desc:注销sp 监听,个人中心 tab 吸顶调整

... ... @@ -25,6 +25,41 @@ export struct FollowListDetailUI {
curPageNum: number = 1;
preferences: dataPreferences.Preferences | null = null;
@State isGetRequest: boolean = false
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[1] == "0") {
this.data.getDataArray().forEach((element, index) => {
if (element.creatorId === arr[0]) {
this.data.deleteItem(index)
this.count = this.data.size()
}
});
} else {
if (!this.isLoading) {
this.isLoading = true
this.hasMore = true
this.curPageNum = 1
this.data.clear()
this.data.notifyDataReload()
this.getMyFollowListDetail()
}
}
}else{
let value = SPHelper.default.getSync(UserDataLocal.USER_FOLLOW_OPERATION, "") as string
let arr = value.split(',')
if (arr[1] == "0"){
this.data.getDataArray().forEach((element, index) => {
if (element.creatorId === arr[0]) {
this.data.getData(index).status = "0"
}
})
}
}
}
}
aboutToAppear() {
this.getNewPageData()
... ... @@ -76,42 +111,13 @@ export struct FollowListDetailUI {
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[1] == "0") {
this.data.getDataArray().forEach((element, index) => {
if (element.creatorId === arr[0]) {
this.data.deleteItem(index)
this.count = this.data.size()
}
});
} else {
if (!this.isLoading) {
this.isLoading = true
this.hasMore = true
this.curPageNum = 1
this.data.clear()
this.data.notifyDataReload()
this.getMyFollowListDetail()
}
}
}else{
let value = SPHelper.default.getSync(UserDataLocal.USER_FOLLOW_OPERATION, "") as string
let arr = value.split(',')
if (arr[1] == "0"){
this.data.getDataArray().forEach((element, index) => {
if (element.creatorId === arr[0]) {
this.data.getData(index).status = "0"
}
})
}
}
}
this.preferences.on('change', this.observer);
}
aboutToDisappear(): void {
if(this.preferences){
this.preferences.off('change', this.observer);
}
this.preferences.on('change', observer);
}
getMyFollowListDetail() {
... ...
... ... @@ -28,6 +28,29 @@ export struct HomePageBottomComponent{
@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()
... ... @@ -36,30 +59,13 @@ export struct HomePageBottomComponent{
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[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()
}
}
}
this.preferences.on('change', this.observer);
}
aboutToDisappear(): void {
if(this.preferences){
this.preferences.off('change', this.observer);
}
this.preferences.on('change', observer);
}
build(){
... ...
... ... @@ -24,6 +24,15 @@ export struct MinePageComponent {
@State moreData:MinePageMoreFunctionModel[] = []
scroller: Scroller = new Scroller()
preferences: dataPreferences.Preferences | null = null;
observer = (key: string) => {
if(key == SpConstants.USER_ID){
if(StringUtils.isEmpty(SPHelper.default.getSync(SpConstants.USER_ID,""))){
this.isLogin = false
}else {
this.isLogin = true
}
}
}
aboutToAppear(){
this.getUserLogin()
... ... @@ -33,16 +42,13 @@ export struct MinePageComponent {
async addLoginStatusObserver(){
this.preferences = await SPHelper.default.getPreferences();
let observer = (key: string) => {
if(key == SpConstants.USER_ID){
if(StringUtils.isEmpty(SPHelper.default.getSync(SpConstants.USER_ID,""))){
this.isLogin = false
}else {
this.isLogin = true
}
}
this.preferences.on('change', this.observer);
}
aboutToDisappear(): void {
if(this.preferences){
this.preferences.off('change', this.observer);
}
this.preferences.on('change', observer);
}
... ...
... ... @@ -182,20 +182,47 @@ struct MineHomePage {
Divider().width('100%').height('12lpx').color($r('app.color.color_F5F5F5')).strokeWidth('12lpx')
//tab 页面
Tabs({controller: this.controller}) {
TabContent() {
HomePageBottomComponent({style:0,commentNum:$commentNum})
}.tabBar(this.TabBuilder(0,"评论"))
TabContent() {
HomePageBottomComponent({style:1,commentNum:$commentNum})
}.tabBar(this.TabBuilder(1,"关注"))
Stack({ alignContent: Alignment.Top }){
Tabs({controller: this.controller}) {
TabContent() {
HomePageBottomComponent({style:0,commentNum:$commentNum})
}
TabContent() {
HomePageBottomComponent({style:1,commentNum:$commentNum})
}
}
.backgroundColor($r('app.color.white'))
.animationDuration(0)
.onChange((index: number) => {
this.currentIndex = index
})
.vertical(false)
.barHeight("77lpx")
Column() {
// 页签
Row({ space: 7 }) {
Scroll() {
Row() {
this.TabBuilder(0,"评论")
this.TabBuilder(1,"关注")
}
.justifyContent(FlexAlign.Start)
}
.align(Alignment.Start)
.scrollable(ScrollDirection.Horizontal)
.scrollBar(BarState.Off)
.width('100%')
.padding({left:'31lpx'})
}
.alignItems(VerticalAlign.Bottom)
.width('100%')
}
.backgroundColor($r('app.color.white'))
.alignItems(HorizontalAlign.Start)
.width('100%')
.height('77lpx')
}
.backgroundColor($r('app.color.white'))
.animationDuration(0)
.onChange((index: number) => {
this.currentIndex = index
})
.vertical(false)
}.width("100%")
}
.edgeEffect(EdgeEffect.None)
... ... @@ -341,9 +368,9 @@ struct MineHomePage {
this.currentIndex = index
this.controller.changeIndex(this.currentIndex)
})
.height('100%')
.width('100%')
.margin({right:'9lpx'})
.height('77lpx')
.width('70lpx')
.margin({right:'29lpx'})
}
/**
... ...
... ... @@ -176,20 +176,47 @@ struct OtherNormalUserHomePage {
Divider().width('100%').height('12lpx').color($r('app.color.color_F5F5F5')).strokeWidth('12lpx')
//tab 页面
Tabs({controller: this.controller}) {
TabContent() {
OtherHomePageBottomCommentComponent({curUserId:this.curUserId,levelHead:this.levelHead,commentNum:$commentNum})
}.tabBar(this.TabBuilder(0,"评论"))
TabContent() {
OtherHomePageBottomFollowComponent({curUserId:this.curUserId})
}.tabBar(this.TabBuilder(1,"关注"))
Stack({ alignContent: Alignment.Top }){
Tabs({controller: this.controller}) {
TabContent() {
OtherHomePageBottomCommentComponent({curUserId:this.curUserId,levelHead:this.levelHead,commentNum:$commentNum})
}
TabContent() {
OtherHomePageBottomFollowComponent({curUserId:this.curUserId})
}
}
.backgroundColor($r('app.color.white'))
.animationDuration(0)
.onChange((index: number) => {
this.currentIndex = index
})
.vertical(false)
.barHeight('77lpx')
Column() {
// 页签
Row({ space: 7 }) {
Scroll() {
Row() {
this.TabBuilder(0,"评论")
this.TabBuilder(1,"关注")
}
.justifyContent(FlexAlign.Start)
}
.align(Alignment.Start)
.scrollable(ScrollDirection.Horizontal)
.scrollBar(BarState.Off)
.width('90%')
.padding({left:'31lpx'})
}
.alignItems(VerticalAlign.Bottom)
.width('100%')
}
.backgroundColor($r('app.color.white'))
.alignItems(HorizontalAlign.Start)
.width('100%')
.height('77lpx')
}
.backgroundColor($r('app.color.white'))
.animationDuration(0)
.onChange((index: number) => {
this.currentIndex = index
})
.vertical(false)
}.width("100%")
}
.edgeEffect(EdgeEffect.None)
... ... @@ -300,9 +327,9 @@ struct OtherNormalUserHomePage {
this.currentIndex = index
this.controller.changeIndex(this.currentIndex)
})
.height('100%')
.width('100%')
.margin({right:'9lpx'})
.height('77lpx')
.width('70lpx')
.margin({right:'29lpx'})
}
... ...