yangchenggong1_wd

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

@@ -25,6 +25,41 @@ export struct FollowListDetailUI { @@ -25,6 +25,41 @@ export struct FollowListDetailUI {
25 curPageNum: number = 1; 25 curPageNum: number = 1;
26 preferences: dataPreferences.Preferences | null = null; 26 preferences: dataPreferences.Preferences | null = null;
27 @State isGetRequest: boolean = false 27 @State isGetRequest: boolean = false
  28 + observer = (key: string) => {
  29 + if (key == UserDataLocal.USER_FOLLOW_OPERATION) {
  30 + if (this.creatorDirectoryId === -1) {
  31 + let value = SPHelper.default.getSync(UserDataLocal.USER_FOLLOW_OPERATION, "") as string
  32 + let arr = value.split(',')
  33 + if (arr[1] == "0") {
  34 + this.data.getDataArray().forEach((element, index) => {
  35 + if (element.creatorId === arr[0]) {
  36 + this.data.deleteItem(index)
  37 + this.count = this.data.size()
  38 + }
  39 + });
  40 + } else {
  41 + if (!this.isLoading) {
  42 + this.isLoading = true
  43 + this.hasMore = true
  44 + this.curPageNum = 1
  45 + this.data.clear()
  46 + this.data.notifyDataReload()
  47 + this.getMyFollowListDetail()
  48 + }
  49 + }
  50 + }else{
  51 + let value = SPHelper.default.getSync(UserDataLocal.USER_FOLLOW_OPERATION, "") as string
  52 + let arr = value.split(',')
  53 + if (arr[1] == "0"){
  54 + this.data.getDataArray().forEach((element, index) => {
  55 + if (element.creatorId === arr[0]) {
  56 + this.data.getData(index).status = "0"
  57 + }
  58 + })
  59 + }
  60 + }
  61 + }
  62 + }
28 63
29 aboutToAppear() { 64 aboutToAppear() {
30 this.getNewPageData() 65 this.getNewPageData()
@@ -76,42 +111,13 @@ export struct FollowListDetailUI { @@ -76,42 +111,13 @@ export struct FollowListDetailUI {
76 111
77 async addFollowStatusObserver() { 112 async addFollowStatusObserver() {
78 this.preferences = await SPHelper.default.getPreferences(); 113 this.preferences = await SPHelper.default.getPreferences();
79 - let observer = (key: string) => {  
80 - if (key == UserDataLocal.USER_FOLLOW_OPERATION) {  
81 - if (this.creatorDirectoryId === -1) {  
82 - let value = SPHelper.default.getSync(UserDataLocal.USER_FOLLOW_OPERATION, "") as string  
83 - let arr = value.split(',')  
84 - if (arr[1] == "0") {  
85 - this.data.getDataArray().forEach((element, index) => {  
86 - if (element.creatorId === arr[0]) {  
87 - this.data.deleteItem(index)  
88 - this.count = this.data.size()  
89 - }  
90 - });  
91 - } else {  
92 - if (!this.isLoading) {  
93 - this.isLoading = true  
94 - this.hasMore = true  
95 - this.curPageNum = 1  
96 - this.data.clear()  
97 - this.data.notifyDataReload()  
98 - this.getMyFollowListDetail()  
99 - }  
100 - }  
101 - }else{  
102 - let value = SPHelper.default.getSync(UserDataLocal.USER_FOLLOW_OPERATION, "") as string  
103 - let arr = value.split(',')  
104 - if (arr[1] == "0"){  
105 - this.data.getDataArray().forEach((element, index) => {  
106 - if (element.creatorId === arr[0]) {  
107 - this.data.getData(index).status = "0"  
108 - }  
109 - })  
110 - }  
111 - }  
112 - } 114 + this.preferences.on('change', this.observer);
  115 + }
  116 +
  117 + aboutToDisappear(): void {
  118 + if(this.preferences){
  119 + this.preferences.off('change', this.observer);
113 } 120 }
114 - this.preferences.on('change', observer);  
115 } 121 }
116 122
117 getMyFollowListDetail() { 123 getMyFollowListDetail() {
@@ -28,6 +28,29 @@ export struct HomePageBottomComponent{ @@ -28,6 +28,29 @@ export struct HomePageBottomComponent{
28 @Link commentNum:number 28 @Link commentNum:number
29 preferences: dataPreferences.Preferences | null = null; 29 preferences: dataPreferences.Preferences | null = null;
30 @State isGetRequest:boolean = false 30 @State isGetRequest:boolean = false
  31 + observer = (key: string) => {
  32 + if (key == UserDataLocal.USER_FOLLOW_OPERATION) {
  33 + let value = SPHelper.default.getSync(UserDataLocal.USER_FOLLOW_OPERATION,"") as string
  34 + let arr = value.split(',')
  35 + if(arr[1] == "0"){
  36 + this.data_follow.getDataArray().forEach((element,index) => {
  37 + if (element.creatorId === arr[0]) {
  38 + this.data_follow.deleteItem(index)
  39 + this.count = this.data_follow.size()
  40 + }
  41 + });
  42 + }else{
  43 + if(!this.isLoading){
  44 + this.isLoading = true
  45 + this.hasMore = true
  46 + this.curPageNum = 1
  47 + this.data_follow.clear()
  48 + this.data_follow.notifyDataReload()
  49 + this.getMyFollowListDetail()
  50 + }
  51 + }
  52 + }
  53 + }
31 54
32 aboutToAppear(){ 55 aboutToAppear(){
33 this.getNewPageData() 56 this.getNewPageData()
@@ -36,30 +59,13 @@ export struct HomePageBottomComponent{ @@ -36,30 +59,13 @@ export struct HomePageBottomComponent{
36 59
37 async addFollowStatusObserver() { 60 async addFollowStatusObserver() {
38 this.preferences = await SPHelper.default.getPreferences(); 61 this.preferences = await SPHelper.default.getPreferences();
39 - let observer = (key: string) => {  
40 - if (key == UserDataLocal.USER_FOLLOW_OPERATION) {  
41 - let value = SPHelper.default.getSync(UserDataLocal.USER_FOLLOW_OPERATION,"") as string  
42 - let arr = value.split(',')  
43 - if(arr[1] == "0"){  
44 - this.data_follow.getDataArray().forEach((element,index) => {  
45 - if (element.creatorId === arr[0]) {  
46 - this.data_follow.deleteItem(index)  
47 - this.count = this.data_follow.size()  
48 - }  
49 - });  
50 - }else{  
51 - if(!this.isLoading){  
52 - this.isLoading = true  
53 - this.hasMore = true  
54 - this.curPageNum = 1  
55 - this.data_follow.clear()  
56 - this.data_follow.notifyDataReload()  
57 - this.getMyFollowListDetail()  
58 - }  
59 - }  
60 - } 62 + this.preferences.on('change', this.observer);
  63 + }
  64 +
  65 + aboutToDisappear(): void {
  66 + if(this.preferences){
  67 + this.preferences.off('change', this.observer);
61 } 68 }
62 - this.preferences.on('change', observer);  
63 } 69 }
64 70
65 build(){ 71 build(){
@@ -24,6 +24,15 @@ export struct MinePageComponent { @@ -24,6 +24,15 @@ export struct MinePageComponent {
24 @State moreData:MinePageMoreFunctionModel[] = [] 24 @State moreData:MinePageMoreFunctionModel[] = []
25 scroller: Scroller = new Scroller() 25 scroller: Scroller = new Scroller()
26 preferences: dataPreferences.Preferences | null = null; 26 preferences: dataPreferences.Preferences | null = null;
  27 + observer = (key: string) => {
  28 + if(key == SpConstants.USER_ID){
  29 + if(StringUtils.isEmpty(SPHelper.default.getSync(SpConstants.USER_ID,""))){
  30 + this.isLogin = false
  31 + }else {
  32 + this.isLogin = true
  33 + }
  34 + }
  35 + }
27 36
28 aboutToAppear(){ 37 aboutToAppear(){
29 this.getUserLogin() 38 this.getUserLogin()
@@ -33,16 +42,13 @@ export struct MinePageComponent { @@ -33,16 +42,13 @@ export struct MinePageComponent {
33 42
34 async addLoginStatusObserver(){ 43 async addLoginStatusObserver(){
35 this.preferences = await SPHelper.default.getPreferences(); 44 this.preferences = await SPHelper.default.getPreferences();
36 - let observer = (key: string) => {  
37 - if(key == SpConstants.USER_ID){  
38 - if(StringUtils.isEmpty(SPHelper.default.getSync(SpConstants.USER_ID,""))){  
39 - this.isLogin = false  
40 - }else {  
41 - this.isLogin = true  
42 - }  
43 - } 45 + this.preferences.on('change', this.observer);
  46 + }
  47 +
  48 + aboutToDisappear(): void {
  49 + if(this.preferences){
  50 + this.preferences.off('change', this.observer);
44 } 51 }
45 - this.preferences.on('change', observer);  
46 } 52 }
47 53
48 54
@@ -182,20 +182,47 @@ struct MineHomePage { @@ -182,20 +182,47 @@ struct MineHomePage {
182 Divider().width('100%').height('12lpx').color($r('app.color.color_F5F5F5')).strokeWidth('12lpx') 182 Divider().width('100%').height('12lpx').color($r('app.color.color_F5F5F5')).strokeWidth('12lpx')
183 183
184 //tab 页面 184 //tab 页面
185 - Tabs({controller: this.controller}) {  
186 - TabContent() {  
187 - HomePageBottomComponent({style:0,commentNum:$commentNum})  
188 - }.tabBar(this.TabBuilder(0,"评论"))  
189 - TabContent() {  
190 - HomePageBottomComponent({style:1,commentNum:$commentNum})  
191 - }.tabBar(this.TabBuilder(1,"关注")) 185 + Stack({ alignContent: Alignment.Top }){
  186 + Tabs({controller: this.controller}) {
  187 + TabContent() {
  188 + HomePageBottomComponent({style:0,commentNum:$commentNum})
  189 + }
  190 + TabContent() {
  191 + HomePageBottomComponent({style:1,commentNum:$commentNum})
  192 + }
  193 + }
  194 + .backgroundColor($r('app.color.white'))
  195 + .animationDuration(0)
  196 + .onChange((index: number) => {
  197 + this.currentIndex = index
  198 + })
  199 + .vertical(false)
  200 + .barHeight("77lpx")
  201 +
  202 + Column() {
  203 + // 页签
  204 + Row({ space: 7 }) {
  205 + Scroll() {
  206 + Row() {
  207 + this.TabBuilder(0,"评论")
  208 + this.TabBuilder(1,"关注")
  209 + }
  210 + .justifyContent(FlexAlign.Start)
  211 + }
  212 + .align(Alignment.Start)
  213 + .scrollable(ScrollDirection.Horizontal)
  214 + .scrollBar(BarState.Off)
  215 + .width('100%')
  216 + .padding({left:'31lpx'})
  217 + }
  218 + .alignItems(VerticalAlign.Bottom)
  219 + .width('100%')
  220 + }
  221 + .backgroundColor($r('app.color.white'))
  222 + .alignItems(HorizontalAlign.Start)
  223 + .width('100%')
  224 + .height('77lpx')
192 } 225 }
193 - .backgroundColor($r('app.color.white'))  
194 - .animationDuration(0)  
195 - .onChange((index: number) => {  
196 - this.currentIndex = index  
197 - })  
198 - .vertical(false)  
199 }.width("100%") 226 }.width("100%")
200 } 227 }
201 .edgeEffect(EdgeEffect.None) 228 .edgeEffect(EdgeEffect.None)
@@ -341,9 +368,9 @@ struct MineHomePage { @@ -341,9 +368,9 @@ struct MineHomePage {
341 this.currentIndex = index 368 this.currentIndex = index
342 this.controller.changeIndex(this.currentIndex) 369 this.controller.changeIndex(this.currentIndex)
343 }) 370 })
344 - .height('100%')  
345 - .width('100%')  
346 - .margin({right:'9lpx'}) 371 + .height('77lpx')
  372 + .width('70lpx')
  373 + .margin({right:'29lpx'})
347 } 374 }
348 375
349 /** 376 /**
@@ -176,20 +176,47 @@ struct OtherNormalUserHomePage { @@ -176,20 +176,47 @@ struct OtherNormalUserHomePage {
176 Divider().width('100%').height('12lpx').color($r('app.color.color_F5F5F5')).strokeWidth('12lpx') 176 Divider().width('100%').height('12lpx').color($r('app.color.color_F5F5F5')).strokeWidth('12lpx')
177 177
178 //tab 页面 178 //tab 页面
179 - Tabs({controller: this.controller}) {  
180 - TabContent() {  
181 - OtherHomePageBottomCommentComponent({curUserId:this.curUserId,levelHead:this.levelHead,commentNum:$commentNum})  
182 - }.tabBar(this.TabBuilder(0,"评论"))  
183 - TabContent() {  
184 - OtherHomePageBottomFollowComponent({curUserId:this.curUserId})  
185 - }.tabBar(this.TabBuilder(1,"关注")) 179 + Stack({ alignContent: Alignment.Top }){
  180 + Tabs({controller: this.controller}) {
  181 + TabContent() {
  182 + OtherHomePageBottomCommentComponent({curUserId:this.curUserId,levelHead:this.levelHead,commentNum:$commentNum})
  183 + }
  184 + TabContent() {
  185 + OtherHomePageBottomFollowComponent({curUserId:this.curUserId})
  186 + }
  187 + }
  188 + .backgroundColor($r('app.color.white'))
  189 + .animationDuration(0)
  190 + .onChange((index: number) => {
  191 + this.currentIndex = index
  192 + })
  193 + .vertical(false)
  194 + .barHeight('77lpx')
  195 +
  196 + Column() {
  197 + // 页签
  198 + Row({ space: 7 }) {
  199 + Scroll() {
  200 + Row() {
  201 + this.TabBuilder(0,"评论")
  202 + this.TabBuilder(1,"关注")
  203 + }
  204 + .justifyContent(FlexAlign.Start)
  205 + }
  206 + .align(Alignment.Start)
  207 + .scrollable(ScrollDirection.Horizontal)
  208 + .scrollBar(BarState.Off)
  209 + .width('90%')
  210 + .padding({left:'31lpx'})
  211 + }
  212 + .alignItems(VerticalAlign.Bottom)
  213 + .width('100%')
  214 + }
  215 + .backgroundColor($r('app.color.white'))
  216 + .alignItems(HorizontalAlign.Start)
  217 + .width('100%')
  218 + .height('77lpx')
186 } 219 }
187 - .backgroundColor($r('app.color.white'))  
188 - .animationDuration(0)  
189 - .onChange((index: number) => {  
190 - this.currentIndex = index  
191 - })  
192 - .vertical(false)  
193 }.width("100%") 220 }.width("100%")
194 } 221 }
195 .edgeEffect(EdgeEffect.None) 222 .edgeEffect(EdgeEffect.None)
@@ -300,9 +327,9 @@ struct OtherNormalUserHomePage { @@ -300,9 +327,9 @@ struct OtherNormalUserHomePage {
300 this.currentIndex = index 327 this.currentIndex = index
301 this.controller.changeIndex(this.currentIndex) 328 this.controller.changeIndex(this.currentIndex)
302 }) 329 })
303 - .height('100%')  
304 - .width('100%')  
305 - .margin({right:'9lpx'}) 330 + .height('77lpx')
  331 + .width('70lpx')
  332 + .margin({right:'29lpx'})
306 } 333 }
307 334
308 335