wangliang_wd

feat:优化评论界面,人民号号主页显示

@@ -2,7 +2,8 @@ import router from '@ohos.router' @@ -2,7 +2,8 @@ import router from '@ohos.router'
2 import { PeopleShipUserDetailData } from 'wdBean' 2 import { PeopleShipUserDetailData } from 'wdBean'
3 import { PeopleShipHomePageHeadComponent } from './PeopleShipHomePageHeadComponent' 3 import { PeopleShipHomePageHeadComponent } from './PeopleShipHomePageHeadComponent'
4 import { WDRouterPage, WDRouterRule } from 'wdRouter/Index' 4 import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'
5 -import { ToastUtils } from 'wdKit'; 5 +import { SPHelper, ToastUtils } from 'wdKit';
  6 +import { SpConstants } from 'wdConstant'
6 7
7 @Component 8 @Component
8 export struct PeopleShipHomePageNavComponent { 9 export struct PeopleShipHomePageNavComponent {
@@ -10,10 +11,16 @@ export struct PeopleShipHomePageNavComponent { @@ -10,10 +11,16 @@ export struct PeopleShipHomePageNavComponent {
10 @Consume isAttention: string 11 @Consume isAttention: string
11 @Consume isLoadingAttention: boolean 12 @Consume isLoadingAttention: boolean
12 @Prop attentionOpacity: boolean 13 @Prop attentionOpacity: boolean
  14 + @State userId:string = ''
13 15
14 // 页面详情数据 16 // 页面详情数据
15 @Prop detailModel: PeopleShipUserDetailData = {} as PeopleShipUserDetailData 17 @Prop detailModel: PeopleShipUserDetailData = {} as PeopleShipUserDetailData
16 18
  19 + aboutToAppear(): void {
  20 + this.userId = SPHelper.default.getSync(SpConstants.USER_ID, "") as string
  21 + }
  22 +
  23 +
17 build() { 24 build() {
18 RelativeContainer() { 25 RelativeContainer() {
19 Row() { 26 Row() {
@@ -67,52 +74,36 @@ export struct PeopleShipHomePageNavComponent { @@ -67,52 +74,36 @@ export struct PeopleShipHomePageNavComponent {
67 }) 74 })
68 .visibility((this.topOpacity > 0.5 ? Visibility.Visible : Visibility.Hidden)) 75 .visibility((this.topOpacity > 0.5 ? Visibility.Visible : Visibility.Hidden))
69 76
70 - if (this.isAttention == '0') {  
71 - // 关注  
72 - Button({ type: ButtonType.Normal, stateEffect: true }) {  
73 - Row(){  
74 - Image($r('app.media.people_ship_top_add'))  
75 - .objectFit(ImageFit.Auto)  
76 - .width('13vp')  
77 - .height('13pv')  
78 - .margin({  
79 - right: '3vp'  
80 - })  
81 - Text('关注')  
82 - .fontSize($r('app.float.vp_12'))  
83 - .fontColor(Color.White)  
84 - .height('100%') 77 + if (this.userId != this.detailModel.userId){
  78 + if (this.isAttention == '0') {
  79 + // 关注
  80 + Button({ type: ButtonType.Normal, stateEffect: true }) {
  81 + Row(){
  82 + Image($r('app.media.people_ship_top_add'))
  83 + .objectFit(ImageFit.Auto)
  84 + .width('13vp')
  85 + .height('13pv')
  86 + .margin({
  87 + right: '3vp'
  88 + })
  89 + Text('关注')
  90 + .fontSize($r('app.float.vp_12'))
  91 + .fontColor(Color.White)
  92 + .height('100%')
  93 + }
  94 + .alignSelf(ItemAlign.Center)
  95 + .justifyContent(FlexAlign.Center)
  96 + .width('100%')
  97 + .height('100%')
85 } 98 }
86 - .alignSelf(ItemAlign.Center)  
87 - .justifyContent(FlexAlign.Center)  
88 - .width('100%')  
89 - .height('100%')  
90 - }  
91 99
92 - .id("Button_Head")  
93 - .alignRules({  
94 - center: { anchor: "__container__", align: VerticalAlign.Center },  
95 - left: { anchor: "user_Head", align: HorizontalAlign.End }  
96 - })  
97 - .borderRadius(4)  
98 - .backgroundColor($r('app.color.color_ED2800'))  
99 - .width('54vp')  
100 - .height('24vp')  
101 - .onClick(() => {  
102 - if (this.isLoadingAttention){  
103 - return  
104 - }  
105 - this.isLoadingAttention = true  
106 - })  
107 - .margin({  
108 - left: '12vp',  
109 - })  
110 - .padding(0)  
111 - .visibility((this.attentionOpacity ? Visibility.Visible : Visibility.Hidden))  
112 - } else {  
113 - Button('已关注', { type: ButtonType.Normal, stateEffect: true }) 100 + .id("Button_Head")
  101 + .alignRules({
  102 + center: { anchor: "__container__", align: VerticalAlign.Center },
  103 + left: { anchor: "user_Head", align: HorizontalAlign.End }
  104 + })
114 .borderRadius(4) 105 .borderRadius(4)
115 - .backgroundColor($r('app.color.color_F5F5F5')) 106 + .backgroundColor($r('app.color.color_ED2800'))
116 .width('54vp') 107 .width('54vp')
117 .height('24vp') 108 .height('24vp')
118 .onClick(() => { 109 .onClick(() => {
@@ -124,15 +115,33 @@ export struct PeopleShipHomePageNavComponent { @@ -124,15 +115,33 @@ export struct PeopleShipHomePageNavComponent {
124 .margin({ 115 .margin({
125 left: '12vp', 116 left: '12vp',
126 }) 117 })
127 - .id("Button_Head")  
128 - .alignRules({  
129 - center: { anchor: "__container__", align: VerticalAlign.Center },  
130 - left: { anchor: "user_Head", align: HorizontalAlign.End }  
131 - })  
132 .padding(0) 118 .padding(0)
133 - .fontSize($r('app.float.vp_12'))  
134 - .fontColor($r('app.color.color_999999'))  
135 .visibility((this.attentionOpacity ? Visibility.Visible : Visibility.Hidden)) 119 .visibility((this.attentionOpacity ? Visibility.Visible : Visibility.Hidden))
  120 + } else {
  121 + Button('已关注', { type: ButtonType.Normal, stateEffect: true })
  122 + .borderRadius(4)
  123 + .backgroundColor($r('app.color.color_F5F5F5'))
  124 + .width('54vp')
  125 + .height('24vp')
  126 + .onClick(() => {
  127 + if (this.isLoadingAttention){
  128 + return
  129 + }
  130 + this.isLoadingAttention = true
  131 + })
  132 + .margin({
  133 + left: '12vp',
  134 + })
  135 + .id("Button_Head")
  136 + .alignRules({
  137 + center: { anchor: "__container__", align: VerticalAlign.Center },
  138 + left: { anchor: "user_Head", align: HorizontalAlign.End }
  139 + })
  140 + .padding(0)
  141 + .fontSize($r('app.float.vp_12'))
  142 + .fontColor($r('app.color.color_999999'))
  143 + .visibility((this.attentionOpacity ? Visibility.Visible : Visibility.Hidden))
  144 + }
136 } 145 }
137 } 146 }
138 .height('100%') 147 .height('100%')
1 import measure from '@ohos.measure' 1 import measure from '@ohos.measure'
2 -import { DisplayUtils, NumberFormatterUtils } from 'wdKit' 2 +import { DisplayUtils, NumberFormatterUtils, SPHelper } from 'wdKit'
3 import { PeopleShipHomePageHeadComponent } from './PeopleShipHomePageHeadComponent' 3 import { PeopleShipHomePageHeadComponent } from './PeopleShipHomePageHeadComponent'
4 import { PeopleShipHomePageAttestationComponent } from './PeopleShipHomePageAttestationComponent' 4 import { PeopleShipHomePageAttestationComponent } from './PeopleShipHomePageAttestationComponent'
5 import { Logger } from 'wdKit' 5 import { Logger } from 'wdKit'
@@ -8,6 +8,7 @@ import { InfluenceData, PeopleShipUserDetailData } from 'wdBean' @@ -8,6 +8,7 @@ import { InfluenceData, PeopleShipUserDetailData } from 'wdBean'
8 import { PeopleShipHomeAttentionComponent } from './PeopleShipHomeAttentionComponent' 8 import { PeopleShipHomeAttentionComponent } from './PeopleShipHomeAttentionComponent'
9 import { HWLocationUtils } from 'wdHwAbility' 9 import { HWLocationUtils } from 'wdHwAbility'
10 import { WDRouterPage, WDRouterRule } from 'wdRouter/Index' 10 import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'
  11 +import { SpConstants } from 'wdConstant'
11 12
12 13
13 @Component 14 @Component
@@ -32,6 +33,7 @@ export struct PeopleShipHomePageTopComponent { @@ -32,6 +33,7 @@ export struct PeopleShipHomePageTopComponent {
32 @State lineInNum: number = 1 33 @State lineInNum: number = 1
33 @Link topHeight: number 34 @Link topHeight: number
34 @State provinceName: string = '' 35 @State provinceName: string = ''
  36 + @State userId:string = ''
35 37
36 build() { 38 build() {
37 Column() { 39 Column() {
@@ -242,13 +244,15 @@ export struct PeopleShipHomePageTopComponent { @@ -242,13 +244,15 @@ export struct PeopleShipHomePageTopComponent {
242 top: '16vp' 244 top: '16vp'
243 }) 245 })
244 246
245 - // 分享-关注  
246 - PeopleShipHomeAttentionComponent()  
247 - .width(`calc(100% - ${32 + 'vp'})`)  
248 - .margin({  
249 - top: '10vp',  
250 - bottom: '16vp'  
251 - }) 247 + if (this.userId != this.detailModel.userId) {
  248 + // 分享-关注
  249 + PeopleShipHomeAttentionComponent()
  250 + .width(`calc(100% - ${32 + 'vp'})`)
  251 + .margin({
  252 + top: '10vp',
  253 + bottom: '16vp'
  254 + })
  255 + }
252 Row() 256 Row()
253 .backgroundColor($r('app.color.color_F5F5F5')) 257 .backgroundColor($r('app.color.color_F5F5F5'))
254 .width('100%') 258 .width('100%')
@@ -277,6 +281,7 @@ export struct PeopleShipHomePageTopComponent { @@ -277,6 +281,7 @@ export struct PeopleShipHomePageTopComponent {
277 this.onIntroductionUpdated() 281 this.onIntroductionUpdated()
278 } 282 }
279 283
  284 + this.userId = SPHelper.default.getSync(SpConstants.USER_ID, "") as string
280 } 285 }
281 286
282 // 不听减去2个字-一直到时3行 287 // 不听减去2个字-一直到时3行