/** * QuotaCardView(F1)—— 配额卡片:剩余数大字 + 进度条 + 周期文案。 * * 数据契约(对齐后端 GET /api/v1/quota): * used / (limit_value + bonus_granted) 为进度;remaining 为剩余额度。 * 周期文案由父层根据 quota_key + reset_at 算好传入(日=明日恢复/终身=一次性)。 */ import { COLOR_PRIMARY } from '../../core/Theme' @Component export struct QuotaCardView { @Prop title: string = '' @Prop remaining: number = 0 @Prop used: number = 0 @Prop total: number = 0 @Prop resetText: string = '' @Prop loaded: boolean = false @Prop errorText: string = '' @Prop accent: string = COLOR_PRIMARY build() { Column({ space: 6 }) { Text(this.title) .fontSize(13) .fontColor('#8A8A8A') .maxLines(1) .textOverflow({ overflow: TextOverflow.Ellipsis }) if (!this.loaded) { LoadingProgress() .width(28) .height(28) .color('#CCCCCC') .margin({ top: 10, bottom: 14 }) } else if (this.errorText !== '') { Text(this.errorText) .fontSize(13) .fontColor('#C0392B') .maxLines(2) .margin({ top: 6, bottom: 8 }) .textAlign(TextAlign.Center) } else { Text(`${this.remaining}`) .fontSize(34) .fontWeight(FontWeight.Bold) .fontColor(this.accent) Text('剩余次数') .fontSize(11) .fontColor('#AAAAAA') Progress({ value: this.used, total: Math.max(this.total, 1), type: ProgressType.Linear }) .width('100%') .height(6) .borderRadius(3) .color(this.accent) .backgroundColor('#F1E7EB') .margin({ top: 4 }) Text(`已用 ${this.used}/${this.total}`) .fontSize(11) .fontColor('#999999') Text(this.resetText) .fontSize(10) .fontColor('#B3B3B3') .maxLines(1) } } .width('100%') .padding(12) .borderRadius(16) .backgroundColor('#FFFFFF') .alignItems(HorizontalAlign.Center) } }