1 个回答

参考demo:

// xxx.ets
@Entry
@Component
struct ShapeExample {
  private borderWdth: number = 2;
  private radiusWdthSmall: number = 8
  private radiusWdthBig: number = 10
  build() {
    Column({ space: 10 }) {
      Row(){
        Column(){
          Stack(){
            Column(){
              Text('618')
                .fontSize(10)
                .fontColor('#fff')
            }
            .position({
              x: 0,
              y: 0,
            })
            .width(40)
            .backgroundColor('rgba(255,255,255,0.3)')
            .borderRadius({
              topLeft: this.radiusWdthBig,
              bottomRight: this.radiusWdthBig,
            })
            Column(){
              Text(){
                Span('¥')
                  .fontSize(16)
                  .fontColor('#fff')
                Span('20')
                  .fontSize(20)

              }
              .fontColor('#fff')
              .fontWeight(FontWeight.Bold)
              Text(){
                Span('无门槛使用')
                  .fontSize(10)
                  .fontColor('#fff')
              }
            }

          }
          .width('100%')
          .height('100%')
        }
        .width(80)
        .height(80)
        .border({
          width: { left: this.borderWdth, right: 0, top: this.borderWdth, bottom: this.borderWdth },
          color: '#f00',
        })
        .borderRadius({
          topLeft: this.radiusWdthBig,
          bottomLeft: this.radiusWdthBig,
        })
        Column(){
          Row()
            .width(this.radiusWdthSmall)
            .height(this.radiusWdthSmall)
            .backgroundColor('#fff')
            .borderRadius({
              bottomLeft: this.radiusWdthSmall
            })
            .border({
              width: { left: this.borderWdth, right: 0, top: 0, bottom: this.borderWdth },
              color: '#f00',
            })
          Row()
            .width(this.radiusWdthSmall)
            .height(`calc(100% - ${2 * this.radiusWdthSmall}vp)`)
            .border({
              color: '#ccc',
              width: { left: 0, right: 1, top: 0, bottom: 0 },
              style: {
                right: BorderStyle.Dotted
              }
            })
          Row()
            .width(this.radiusWdthSmall)
            .height(this.radiusWdthSmall)
            .backgroundColor('#fff')
            .borderRadius({
              topLeft: this.radiusWdthSmall
            })
            .border({
              width: { left: this.borderWdth, right: 0, top: this.borderWdth, bottom: 0 },
              color: '#f00'
            })
        }
        .height('100%')
        .justifyContent(FlexAlign.SpaceBetween)
        Column(){
          Column()
            .width(this.radiusWdthSmall)
            .height(this.radiusWdthSmall)
            .backgroundColor('#fff')
            .borderRadius({
              bottomRight: this.radiusWdthSmall
            })
            .border({
              width: { left: 0, right: this.borderWdth, top: 0, bottom: this.borderWdth },
              color: '#f00',
            })
          Column()
            .width(this.radiusWdthSmall)
            .height(this.radiusWdthSmall)
            .backgroundColor('#fff')
            .borderRadius({
              topRight: this.radiusWdthSmall
            })
            .border({
              width: { left: 0, right: this.borderWdth, top: this.borderWdth, bottom: 0 },
              color: '#f00',
            })
        }
        .height('100%')
        .justifyContent(FlexAlign.SpaceBetween)
        Column(){
          Row(){
            Column(){
              Text(){
                Span('新客专享券')
                  .fontSize(12)

              }
              .fontColor('#fff')
              .margin({
                bottom: 6
              })
              Text(){
                Span('有效期至2024-8-30')
                  .fontSize(10)
                  .fontColor('#ddd')
              }
            }
            Stack(){
              Button('领取')
                .backgroundColor('#f00')
                .height(20)
                .fontSize(12)
                .margin(10)
            }
            .height('100%')
          }
          .width('100%')
          .justifyContent(FlexAlign.SpaceBetween)
        }
        .height('100%')
        .width(`calc(100% - ${80 + 2 * this.radiusWdthSmall}vp)`)
        .border({
          width: { left: 0, right: this.borderWdth, top: this.borderWdth, bottom: this.borderWdth },
          color: '#f00',
        })
        .borderRadius({
          topRight: this.radiusWdthBig,
          bottomRight: this.radiusWdthBig,
        })
      }
      .width(300)
      .height(80)
      // .backgroundColor('#f00')
      .linearGradient({
        angle: 90,
        colors: [['rgba(255,0,0,0.7)', 0.0], ['rgba(255,0,0,0.3)', 1]]
      })
      .borderRadius(this.radiusWdthBig)
    }.width('100%').margin({ top: 15 })
  }
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进