payment_success_page.dart 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. import 'package:cpt_payment/modules/payment_success/payment_success_state.dart';
  2. import 'package:cs_resources/generated/assets.dart';
  3. import 'package:cs_resources/generated/l10n.dart';
  4. import 'package:cs_resources/theme/app_colors_theme.dart';
  5. import 'package:flutter/material.dart';
  6. import 'package:auto_route/auto_route.dart';
  7. import 'package:flutter_hooks/flutter_hooks.dart';
  8. import 'package:hooks_riverpod/hooks_riverpod.dart';
  9. import 'package:router/ext/auto_router_extensions.dart';
  10. import 'package:widgets/ext/ex_widget.dart';
  11. import 'package:widgets/my_appbar.dart';
  12. import 'package:widgets/my_load_image.dart';
  13. import 'package:widgets/my_text_view.dart';
  14. import 'package:widgets/utils/dark_theme_util.dart';
  15. import '../../router/page/payment_page_router.dart';
  16. import 'payment_success_view_model.dart';
  17. @RoutePage()
  18. class PaymentSuccessPage extends HookConsumerWidget {
  19. final String? orderId;
  20. const PaymentSuccessPage({
  21. Key? key,
  22. @PathParam() required this.orderId,
  23. }) : super(key: key);
  24. //启动并关闭其他栈
  25. static void startWithPop({required String? orderId}) {
  26. appRouter.pushAndPopUntil(
  27. PaymentSuccessPageRoute(orderId: orderId),
  28. predicate: (route) {
  29. return route.settings.name == 'PaymentPageRoute';
  30. },
  31. );
  32. }
  33. @override
  34. Widget build(BuildContext context, WidgetRef ref) {
  35. final viewModel = ref.read(paymentSuccessViewModelProvider.notifier);
  36. final PaymentSuccessState state = ref.watch(paymentSuccessViewModelProvider);
  37. useEffect(() {
  38. // 组件挂载时执行 - 执行接口请求
  39. Future.microtask(() {
  40. viewModel.fetchFormDetail(orderId);
  41. });
  42. return () {
  43. // 组件卸载时执行
  44. };
  45. }, []);
  46. return Scaffold(
  47. appBar: MyAppBar.appBar(context, state?.paymentDetail?.title ?? "Payment Detail"),
  48. backgroundColor: context.appColors.backgroundWhite,
  49. body: SizedBox(
  50. width: double.infinity,
  51. child: Column(
  52. children: [
  53. //成功图片
  54. MyAssetImage(
  55. Assets.facilityPaymentSuccessIcon,
  56. width: 54,
  57. height: 54,
  58. color: DarkThemeUtil.multiColors(context, AppColorsTheme.colorPrimary, darkColor: Colors.white),
  59. ).marginOnly(top: 11, bottom: 13),
  60. //支付成功
  61. MyTextView(
  62. S.current.payment_successful,
  63. fontSize: 18,
  64. marginBottom: 3,
  65. isFontMedium: true,
  66. textColor: context.appColors.textPrimary,
  67. ),
  68. //支付金额
  69. MyTextView(
  70. S.current.fee_paid,
  71. marginTop: 40,
  72. fontSize: 15,
  73. isFontRegular: true,
  74. textColor: context.appColors.textBlack,
  75. ),
  76. MyTextView(
  77. "\$${state.paymentDetail?.totalAmount ?? ""}",
  78. fontSize: 15,
  79. isFontRegular: true,
  80. textColor: context.appColors.textPrimary,
  81. ),
  82. // //付款类型与时间
  83. // Row(
  84. // mainAxisSize: MainAxisSize.min,
  85. // children: [
  86. // MyTextView(
  87. // "Master card ending",
  88. // fontSize: 15,
  89. // isFontRegular: true,
  90. // textColor: context.appColors.textBlack,
  91. // ),
  92. // MyTextView(
  93. // "9423",
  94. // fontSize: 15,
  95. // isFontMedium: true,
  96. // textColor: context.appColors.textBlack,
  97. // ),
  98. // ],
  99. // ).marginOnly(top: 12),
  100. Row(
  101. mainAxisSize: MainAxisSize.min,
  102. children: [
  103. MyTextView(
  104. S.current.paid_on,
  105. fontSize: 15,
  106. isFontRegular: true,
  107. textColor: context.appColors.textBlack,
  108. ),
  109. MyTextView(
  110. state.paymentDetail?.paidAt ?? "",
  111. fontSize: 15,
  112. isFontMedium: true,
  113. textColor: context.appColors.textBlack,
  114. ),
  115. ],
  116. ).marginOnly(top: 5),
  117. const SizedBox(height: 23),
  118. ],
  119. ),
  120. ),
  121. );
  122. }
  123. }