PeopleShipHomeNavComponent.ets 5.95 KB
import router from '@ohos.router'
import { PeopleShipUserDetailData } from 'wdBean'
import { PeopleShipHomePageHeadComponent } from './PeopleShipHomePageHeadComponent'
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'
import { ToastUtils } from 'wdKit';

@Component
export struct PeopleShipHomePageNavComponent {
  @Prop topOpacity: number
  @Consume isAttention: string
  @Consume isLoadingAttention: boolean
  @Prop attentionOpacity: boolean

  // 页面详情数据
  @Prop detailModel: PeopleShipUserDetailData = {} as PeopleShipUserDetailData

  build() {
    RelativeContainer() {
      Row() {
        // 返回
        Image((this.topOpacity > 0.5 ? $r('app.media.icon_arrow_left') : $r('app.media.icon_arrow_left_white')))
          .width('24vp')
          .height('24vp')
          .objectFit(ImageFit.Auto)
          .id("back_icon")
          .alignRules({
            center: { anchor: "__container__", align: VerticalAlign.Center },
            left: { anchor: "__container__", align: HorizontalAlign.Start }
          })
          .margin({ left: 18 })
          .onClick(() => {
            router.back()
          })
        // 头像
        PeopleShipHomePageHeadComponent({
          diameter: 30,
          iconDiameter: 10,
          headPhotoUrl: (this.detailModel.headPhotoUrl && this.detailModel.headPhotoUrl.length > 0 ) ? this.detailModel.headPhotoUrl : $r('app.media.WDAccountOwnerHedaerDefaultIcon'),
          authIcon: this.detailModel.authIcon
        }).onClick(()=>{
          let params = {
            'headPhotoUrl': this.detailModel.headPhotoUrl,
          } as Record<string, string>;
          WDRouterRule.jumpWithPage(WDRouterPage.showHomePageHeaderPage,params)
        }).margin({
          left: '10vp',
        })
          .id("Page_Head")
          .alignRules({
            center: { anchor: "__container__", align: VerticalAlign.Center },
            left: { anchor: "back_icon", align: HorizontalAlign.End }
          })
          .visibility((this.topOpacity > 0.5 ? Visibility.Visible : Visibility.Hidden))

        // 文字
        Text(this.detailModel.userName)
          .height('46vp')
          .fontSize($r('app.float.vp_14'))
          .fontColor($r('app.color.color_222222'))
          .margin({
            left: '6vp'
          })
          .id("user_Head")
          .alignRules({
            center: { anchor: "__container__", align: VerticalAlign.Center },
            left: { anchor: "Page_Head", align: HorizontalAlign.End }
          })
          .visibility((this.topOpacity > 0.5 ? Visibility.Visible : Visibility.Hidden))

        if (this.isAttention == '0') {
          // 关注
          Button({ type: ButtonType.Normal, stateEffect: true }) {
            Row(){
              Image($r('app.media.people_ship_top_add'))
                .objectFit(ImageFit.Auto)
                .width('13vp')
                .height('13pv')
                .margin({
                  right: '3vp'
                })
              Text('关注')
                .fontSize($r('app.float.vp_12'))
                .fontColor(Color.White)
                .height('100%')
            }
            .alignSelf(ItemAlign.Center)
            .justifyContent(FlexAlign.Center)
            .width('100%')
            .height('100%')
          }

          .id("Button_Head")
          .alignRules({
            center: { anchor: "__container__", align: VerticalAlign.Center },
            left: { anchor: "user_Head", align: HorizontalAlign.End }
          })
          .borderRadius(4)
          .backgroundColor($r('app.color.color_ED2800'))
          .width('54vp')
          .height('24vp')
          .onClick(() => {
            if (this.isLoadingAttention){
              return
            }
            this.isLoadingAttention = true
          })
          .margin({
            left: '12vp',
          })
          .padding(0)
          .visibility((this.attentionOpacity ? Visibility.Visible : Visibility.Hidden))
        } else {
          Button('已关注', { type: ButtonType.Normal, stateEffect: true })
            .borderRadius(4)
            .backgroundColor($r('app.color.color_F5F5F5'))
            .width('54vp')
            .height('24vp')
            .onClick(() => {
              if (this.isLoadingAttention){
                return
              }
              this.isLoadingAttention = true
            })
            .margin({
              left: '12vp',
            })
            .id("Button_Head")
            .alignRules({
              center: { anchor: "__container__", align: VerticalAlign.Center },
              left: { anchor: "user_Head", align: HorizontalAlign.End }
            })
            .padding(0)
            .fontSize($r('app.float.vp_12'))
            .fontColor($r('app.color.color_999999'))
            .visibility((this.attentionOpacity ? Visibility.Visible : Visibility.Hidden))
        }
      }
      .height('100%')
    }
    .height(44)
    .width('100%')
    .backgroundColor($r('app.color.white'))
    .visibility(this.topOpacity > 0 ? 0 : 1)
    .opacity(this.topOpacity )

    // Row() {
    //   Stack({ alignContent: Alignment.TopStart }) {
    //     Row()
    //       .width('100%')
    //       .height('100%')
    //       .backgroundColor($r('app.color.white'))
    //       .opacity(this.topOpacity)
    //     Row() {
    //
    //       Blank()
    //       // 分享  分享暂不展示
    //       // Image((this.topOpacity > 0.5 ? $r('app.media.icon_forward') : $r('app.media.icon_share')))
    //       //   .width('24vp')
    //       //   .height('24vp')
    //       //   .objectFit(ImageFit.Auto)
    //       //   .margin({ right: '10vp' })
    //       //   .onClick(() => {
    //       //     ToastUtils.showToast('分享为公共方法,待开发', 1000);
    //       //   })
    //     }
    //     .width('100%')
    //     .height('100%')
    //     .alignItems(VerticalAlign.Center)
    //     .justifyContent(FlexAlign.SpaceBetween)
    //   }
    //   .zIndex(1000)
    //   .width('100%')
    //   .height('100%')
    // }
  }
}