优化:三方支付显示赠送比例优化

This commit is contained in:
ivan 2026-04-23 16:37:44 +08:00
parent faed1ab448
commit fef2606e66
2 changed files with 56 additions and 54 deletions

View File

@ -10,8 +10,8 @@ const double _paymentSheetIconScale = 1.5;
/// 与 `funymee_home.pen` **zL8hY / p7kQm** 对齐的第三方支付底部表单。 /// 与 `funymee_home.pen` **zL8hY / p7kQm** 对齐的第三方支付底部表单。
/// 先点选支付方式,再点底部 **Pay** 确认(与画板 `btnPayPrimary` 一致)。 /// 先点选支付方式,再点底部 **Pay** 确认(与画板 `btnPayPrimary` 一致)。
/// ///
/// [summaryTierCredits] / [summaryTierBonus] 与购买页档位一致(原始档位积分 + 原始档位赠送); /// [summaryTierCredits] / [summaryTierBonus] 与购买页摘要一致(档位积分 + 档位赠送);
/// 均为 `null` 时从 [product] 读取。 /// 均为 `null` 时从 [product] 读取。各支付方式副标题的赠送比例仅读接口 [PaymentMethodItem.bonusRatio],不作本地推算。
Future<PaymentMethodItem?> showThirdPartyPaymentMethodSheet( Future<PaymentMethodItem?> showThirdPartyPaymentMethodSheet(
BuildContext context, { BuildContext context, {
required List<PaymentMethodItem> methods, required List<PaymentMethodItem> methods,
@ -181,10 +181,6 @@ class _ThirdPartyPaymentSheetBodyState
if (i > 0) const SizedBox(height: 12), if (i > 0) const SizedBox(height: 12),
_PaymentMethodOptionCard( _PaymentMethodOptionCard(
method: widget.methods[i], method: widget.methods[i],
tierCreditsForChannelPercent:
widget.summaryTierCredits ??
widget.product.credits ??
0,
selected: _selectedIndex == i, selected: _selectedIndex == i,
iconColor: _iconAccent(widget.methods[i]), iconColor: _iconAccent(widget.methods[i]),
onSelect: () => setState(() => _selectedIndex = i), onSelect: () => setState(() => _selectedIndex = i),
@ -225,16 +221,19 @@ String _formatProductPrice(PaymentProductItem p) {
return '\$$a'; return '\$$a';
} }
/// 支付渠道赠送:仅用 [PaymentMethodItem.bonusCredits],相对档位原始积分 [tierCredits] 换算为 `+N% More Credits`(过小为 `+<1% More Credits`)。 /// 第三方支付方式副标题:赠送**比例**仅用服务端 [PaymentMethodItem.bonusRatio](与框架解析一致:`≤1` 为小数比例,否则为百分数),
String? _channelBonusCreditsPercentLine( /// 不用 `bonusCredits / 档位积分` 推算;无 `bonusRatio` 时再展示 [PaymentMethodItem.bonusCredits] 的绝对赠送文案。
int tierCredits, String? _thirdPartyChannelBonusSubtitle(PaymentMethodItem method) {
int? channelBonusCredits, final br = method.bonusRatio;
) { if (br != null && br > 0) {
if (channelBonusCredits == null || channelBonusCredits <= 0) return null; final pct = br <= 1 ? (br * 100).round() : br.round();
if (tierCredits <= 0) return null; return '+$pct% More Credits';
final rounded = ((channelBonusCredits * 100.0) / tierCredits).round(); }
if (rounded > 0) return '+$rounded% More Credits'; final bc = method.bonusCredits;
return '+<1% More Credits'; if (bc != null && bc > 0) {
return '+$bc More Credits';
}
return null;
} }
class _PaymentSummaryCard extends StatelessWidget { class _PaymentSummaryCard extends StatelessWidget {
@ -360,16 +359,12 @@ class _PayCtaButton extends StatelessWidget {
class _PaymentMethodOptionCard extends StatelessWidget { class _PaymentMethodOptionCard extends StatelessWidget {
const _PaymentMethodOptionCard({ const _PaymentMethodOptionCard({
required this.method, required this.method,
required this.tierCreditsForChannelPercent,
required this.selected, required this.selected,
required this.iconColor, required this.iconColor,
required this.onSelect, required this.onSelect,
}); });
final PaymentMethodItem method; final PaymentMethodItem method;
/// 渠道赠送占比分母:与摘要一致的档位原始积分(非赠送)。
final int tierCreditsForChannelPercent;
final bool selected; final bool selected;
final Color iconColor; final Color iconColor;
final VoidCallback onSelect; final VoidCallback onSelect;
@ -382,10 +377,7 @@ class _PaymentMethodOptionCard extends StatelessWidget {
final title = method.displayName.isNotEmpty final title = method.displayName.isNotEmpty
? method.displayName ? method.displayName
: (method.paymentMethod ?? 'Payment'); : (method.paymentMethod ?? 'Payment');
final channelBonusLine = _channelBonusCreditsPercentLine( final channelBonusLine = _thirdPartyChannelBonusSubtitle(method);
tierCreditsForChannelPercent,
method.bonusCredits,
);
return Material( return Material(
color: Colors.white, color: Colors.white,
@ -464,15 +456,44 @@ class _PaymentMethodOptionCard extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
Text( Row(
title, crossAxisAlignment: CrossAxisAlignment.center,
style: GoogleFonts.inter( children: [
fontSize: 16, Expanded(
fontWeight: FontWeight.w700, child: Text(
color: PencilTheme.stone900, title,
), style: GoogleFonts.inter(
maxLines: 2, fontSize: 16,
overflow: TextOverflow.ellipsis, fontWeight: FontWeight.w700,
color: PencilTheme.stone900,
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
),
if (method.recommend == true) ...[
const SizedBox(width: 6),
Container(
padding: const EdgeInsets.symmetric(
horizontal: 6,
vertical: 2,
),
decoration: BoxDecoration(
color: PencilTheme.cardThumbBg,
borderRadius: BorderRadius.circular(6),
),
child: Text(
'Recommend',
style: GoogleFonts.inter(
fontSize: 9,
fontWeight: FontWeight.w600,
height: 1.1,
color: PencilTheme.stone700,
),
),
),
],
],
), ),
if (channelBonusLine != null) ...[ if (channelBonusLine != null) ...[
const SizedBox(height: 4), const SizedBox(height: 4),
@ -483,32 +504,13 @@ class _PaymentMethodOptionCard extends StatelessWidget {
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
color: PencilTheme.profileCredits, color: PencilTheme.profileCredits,
), ),
maxLines: 2, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),
], ],
], ],
), ),
), ),
if (method.recommend == true)
Container(
padding: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 5,
),
decoration: BoxDecoration(
color: PencilTheme.cardThumbBg,
borderRadius: BorderRadius.circular(8),
),
child: Text(
'Recommend',
style: GoogleFonts.inter(
fontSize: 11,
fontWeight: FontWeight.w600,
color: PencilTheme.stone700,
),
),
),
], ],
), ),
), ),

View File

@ -2,7 +2,7 @@ name: funymee_ai
description: "FunyMee AI Application." description: "FunyMee AI Application."
publish_to: 'none' publish_to: 'none'
version: 1.0.18+18 version: 1.0.19+19
environment: environment:
sdk: ^3.11.1 sdk: ^3.11.1