PeopleShipHomeAttentionComponent.ets 3.51 KB
import { ToastUtils } from 'wdKit';

@Component
export struct PeopleShipHomeAttentionComponent {
  @Consume isAttention: string
  @Consume isLoadingAttention: boolean
  build() {
    Flex({ alignItems: ItemAlign.Start, justifyContent: FlexAlign.Start }) {
      Button({type: ButtonType.Normal, stateEffect: false } ) {
        Stack() {
          Row()
            .width('100%')
            .height('100%')
            .backgroundColor(this.isAttention == '0'? $r('app.color.color_ED2800') : $r('app.color.color_F5F5F5'))
            .borderRadius("5lpx")
          Row() {
            if(this.isAttention == '0') {
              if(this.isLoadingAttention) {
                LoadingProgress()
                  .width(20)
                  .height(20)
                  .color($r('app.color.color_fff'))
              }else {
                Image($r('app.media.people_ship_top_add'))
                  .objectFit(ImageFit.Auto)
                  .width('16vp')
                  .height('16pv')
                  .margin({
                    right: '4vp'
                  })
                Text('关注')
                  .fontColor(Color.White)
                  .fontSize($r('app.float.vp_14'))
                  .fontWeight(500)
                  .margin({
                    right: '10vp'
                  })
              }
            }else {
              if(this.isLoadingAttention) {
                LoadingProgress()
                  .width(20)
                  .height(20)
                  .color( $r('app.color.color_CCCCCC'))
              }else {
                Text('已关注')
                  .fontSize($r('app.float.vp_14'))
                  .fontWeight(500)
                  .fontColor($r('app.color.color_CCCCCC'))
                  .margin({
                    right: '10vp'
                  })
              }
            }

          }
          .justifyContent(FlexAlign.Center)
          .alignItems(VerticalAlign.Center)
          .width('100%')
          .height('100%')
        }
        .width('100%')
        .height('100%')
      }
      .backgroundColor(Color.Transparent)
      .width(176)
      .height(36)
      .padding(0)
      .fontColor(Color.Black)
      .margin({
        right: '-5vp'
      })
      .onClick(() => {
        if(this.isLoadingAttention) {
          return
        }
        this.isLoadingAttention = true
      })

      Button({type: ButtonType.Normal, stateEffect: false}) {
        Stack() {
          Image($r('app.media.home_share_right_icon'))
            .width('100%')
            .height('100%')
            .objectFit(ImageFit.Cover)
          Row() {
            Image($r('app.media.QR_code_icon'))
              .width(16)
              .height(16)
              .objectFit(ImageFit.Cover)
              .margin({
                left: '10vp'
              })
            Text('分享名片')
              .fontSize($r('app.float.vp_14'))
              .fontColor($r('app.color.color_222222'))
              .fontWeight(500)
              .margin({ left: 5 })
          }
          .justifyContent(FlexAlign.Center)
          .alignItems(VerticalAlign.Center)
          .width('100%')
          .height('100%')
        }
        .width('100%')
        .height('100%')
      }
      .backgroundColor(Color.Transparent)
      .width(176)
      .height(36)
      .padding(0)
      .fontColor(Color.White)
      .margin({
        left: '-5vp'
      })
      .onClick(() => {
        ToastUtils.showToast('分享为公共方法,待开发', 1000);
      })
      .visibility(Visibility.Hidden)
    }

  }
}