rewards_transaction_page.dart 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. import 'package:cs_resources/generated/l10n.dart';
  2. import 'package:cs_resources/theme/app_colors_theme.dart';
  3. import 'package:domain/entity/rewards_detail_entity.dart';
  4. import 'package:domain/entity/rewards_my_detail_entity.dart';
  5. import 'package:flutter/cupertino.dart';
  6. import 'package:flutter/material.dart';
  7. import 'package:auto_route/auto_route.dart';
  8. import 'package:flutter_hooks/flutter_hooks.dart';
  9. import 'package:hooks_riverpod/hooks_riverpod.dart';
  10. import 'package:router/ext/auto_router_extensions.dart';
  11. import 'package:shared/utils/log_utils.dart';
  12. import 'package:shared/utils/color_utils.dart';
  13. import 'package:widgets/ext/ex_widget.dart';
  14. import 'package:widgets/my_appbar.dart';
  15. import 'package:widgets/my_load_image.dart';
  16. import 'package:widgets/my_text_view.dart';
  17. import 'package:widgets/shatter/picker_container.dart';
  18. import 'package:widgets/utils/dark_theme_util.dart';
  19. import 'package:widgets/widget_export.dart';
  20. import 'package:cs_resources/generated/assets.dart';
  21. import '../../../router/page/rewards_page_router.dart';
  22. import './rewards_transaction_vm.dart';
  23. @RoutePage()
  24. class RewardsTransactionPage extends HookConsumerWidget {
  25. final int? id;
  26. final String? type;
  27. const RewardsTransactionPage({Key? key, @PathParam('id') required this.id, @PathParam('type') required this.type}) : super(key: key);
  28. //启动当前页面
  29. static void startInstance({BuildContext? context, int? id, String? type = ''}) {
  30. if (context != null) {
  31. context.router.push(RewardsTransactionPageRoute(id: id, type: type));
  32. } else {
  33. appRouter.push(RewardsTransactionPageRoute(id: id, type: type));
  34. }
  35. }
  36. // listitem
  37. Widget _buildSaleItem(BuildContext context, WidgetRef ref, _vm, detailInfo) {
  38. String title = detailInfo!.reward.title ?? "";
  39. List? resources = detailInfo!.reward.resources ?? [];
  40. int point = detailInfo.reward.point ?? 0;
  41. int originalPoint = detailInfo.reward.originalPoint ?? 0;
  42. return Column(
  43. children: [
  44. Container(
  45. decoration: BoxDecoration(
  46. color: context.appColors.whiteBG,
  47. borderRadius: const BorderRadius.all(Radius.circular(6.0)),
  48. boxShadow: const [BoxShadow(color: Color.fromRGBO(184, 191, 217, 0.3), blurRadius: 6)],
  49. ),
  50. width: MediaQuery.of(context).size.width - 30,
  51. // height: 420,
  52. // margin: const EdgeInsets.only(left: 15, right: 15, top: 12.5),
  53. child: Column(
  54. crossAxisAlignment: CrossAxisAlignment.start,
  55. mainAxisAlignment: MainAxisAlignment.start,
  56. children: [
  57. resources!.length > 0
  58. ? MyLoadImage(
  59. resources[0] ?? '',
  60. width: MediaQuery.of(context).size.width,
  61. height: 150,
  62. )
  63. : Container(),
  64. Column(
  65. crossAxisAlignment: CrossAxisAlignment.start,
  66. mainAxisAlignment: MainAxisAlignment.start,
  67. children: [
  68. Text(
  69. maxLines: 1, // 设置最大行数为2
  70. overflow: TextOverflow.ellipsis, // 超出部分用省略号表示
  71. title,
  72. style: TextStyle(fontSize: 17.0, color: context.appColors.textBlack, fontWeight: FontWeight.w500),
  73. ).marginOnly(bottom: 5),
  74. Row(
  75. children: [
  76. Text(
  77. '$point',
  78. style: TextStyle(fontSize: 19.0, color: context.appColors.textBlack, fontWeight: FontWeight.w500),
  79. ),
  80. Text(
  81. '$originalPoint',
  82. style: TextStyle(
  83. decoration: TextDecoration.lineThrough,
  84. decorationColor: ColorUtils.string2Color('#808DAF'),
  85. decorationStyle: TextDecorationStyle.solid,
  86. fontSize: 12.0,
  87. color: ColorUtils.string2Color('#808DAF'),
  88. fontWeight: FontWeight.w400),
  89. ).marginOnly(left: 5, right: 5),
  90. Text(
  91. S.current.points,
  92. style: TextStyle(fontSize: 13.0, color: context.appColors.textBlack, fontWeight: FontWeight.w400),
  93. ),
  94. ],
  95. ),
  96. ],
  97. ).paddingOnly(left: 15, right: 15, top: 10, bottom: 20),
  98. ],
  99. )),
  100. ],
  101. ).marginOnly(left: 15, bottom: 15, right: 15);
  102. }
  103. Widget _buildDeal(BuildContext context, WidgetRef ref, _vm, detailInfo) {
  104. String redeemedStart = detailInfo.reward.redeemedStart ?? "";
  105. String redeemedEnd = detailInfo.reward.redeemedEnd ?? "";
  106. String redeemedDate = '$redeemedStart until $redeemedEnd';
  107. int code = detailInfo.redemptionCode ?? 0;
  108. return Column(
  109. children: [
  110. Container(
  111. decoration: BoxDecoration(
  112. color: context.appColors.whiteBG,
  113. borderRadius: const BorderRadius.all(Radius.circular(6.0)),
  114. boxShadow: const [BoxShadow(color: Color.fromRGBO(184, 191, 217, 0.3), blurRadius: 6)],
  115. ),
  116. width: MediaQuery.of(context).size.width - 30,
  117. child: Column(
  118. crossAxisAlignment: CrossAxisAlignment.start,
  119. children: [
  120. Row(
  121. mainAxisSize: MainAxisSize.min,
  122. mainAxisAlignment: MainAxisAlignment.start,
  123. crossAxisAlignment: CrossAxisAlignment.center,
  124. children: [
  125. const MyAssetImage(
  126. Assets.rewardsRewardsIconDatd,
  127. width: 25,
  128. height: 25,
  129. ).marginOnly(right: 15),
  130. Text(
  131. redeemedEnd,
  132. style: TextStyle(fontSize: 15.0, color: context.appColors.textBlack, fontWeight: FontWeight.w400),
  133. )
  134. ],
  135. ).marginOnly(bottom: 20),
  136. Row(
  137. // mainAxisSize: MainAxisSize.min,
  138. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  139. crossAxisAlignment: CrossAxisAlignment.center,
  140. children: [
  141. Row(
  142. children: [
  143. const MyAssetImage(
  144. Assets.rewardsRewardsIcon123,
  145. width: 25,
  146. height: 25,
  147. ).marginOnly(right: 15),
  148. Text(
  149. S.current.verification_code,
  150. style: TextStyle(fontSize: 15.0, color: context.appColors.textBlack, fontWeight: FontWeight.w400),
  151. ),
  152. ],
  153. ),
  154. Text(
  155. '$code',
  156. style: TextStyle(fontSize: 15.0, color: context.appColors.textPrimary, fontWeight: FontWeight.w500),
  157. ),
  158. ],
  159. ),
  160. ],
  161. ).paddingOnly(left: 15, right: 15, top: 12, bottom: 20),
  162. ),
  163. ],
  164. ).marginOnly(left: 15, bottom: 15, right: 15);
  165. }
  166. Widget _buildPackage(BuildContext context, WidgetRef ref, _vm) {
  167. return Column(
  168. children: [
  169. Container(
  170. decoration: BoxDecoration(
  171. color: context.appColors.whiteBG,
  172. borderRadius: const BorderRadius.all(Radius.circular(6.0)),
  173. boxShadow: const [BoxShadow(color: Color.fromRGBO(184, 191, 217, 0.3), blurRadius: 6)],
  174. ),
  175. width: MediaQuery.of(context).size.width - 30,
  176. child: Column(
  177. crossAxisAlignment: CrossAxisAlignment.start,
  178. children: [
  179. Row(
  180. mainAxisSize: MainAxisSize.min,
  181. mainAxisAlignment: MainAxisAlignment.start,
  182. crossAxisAlignment: CrossAxisAlignment.center,
  183. children: [
  184. Expanded(
  185. child: Text(
  186. S.current.issue_contact_phone,
  187. style: TextStyle(fontSize: 15.0, color: context.appColors.textBlack, fontWeight: FontWeight.w500),
  188. ),
  189. )
  190. ],
  191. ).marginOnly(bottom: 10, top: 10),
  192. ],
  193. ).paddingOnly(left: 15, right: 35, top: 12, bottom: 20),
  194. ),
  195. ],
  196. ).marginOnly(left: 15, bottom: 25, right: 15);
  197. }
  198. Widget _buildNotice(BuildContext context, WidgetRef ref, _vm, types, detailInfo) {
  199. int phone = detailInfo.account.phone ?? 0;
  200. String createdAt = detailInfo.createdAt ?? "";
  201. String usedAt = detailInfo.usedAt ?? "";
  202. int point = detailInfo.reward.point ?? 0;
  203. int originalPoint = detailInfo.reward.originalPoint ?? 0;
  204. int quantity = detailInfo.quantity ?? 0;
  205. return Column(
  206. children: [
  207. Container(
  208. decoration: BoxDecoration(
  209. color: context.appColors.whiteBG,
  210. borderRadius: const BorderRadius.all(Radius.circular(6.0)),
  211. boxShadow: const [BoxShadow(color: Color.fromRGBO(184, 191, 217, 0.3), blurRadius: 6)],
  212. ),
  213. width: MediaQuery.of(context).size.width - 30,
  214. child: Column(
  215. crossAxisAlignment: CrossAxisAlignment.start,
  216. children: [
  217. Row(
  218. mainAxisSize: MainAxisSize.min,
  219. mainAxisAlignment: MainAxisAlignment.start,
  220. crossAxisAlignment: CrossAxisAlignment.center,
  221. children: [
  222. const MyAssetImage(
  223. Assets.rewardsRewardsIconFile,
  224. width: 25,
  225. height: 25,
  226. ).marginOnly(right: 10),
  227. Text(
  228. S.current.transaction_details,
  229. style: TextStyle(fontSize: 15.0, color: context.appColors.textBlack, fontWeight: FontWeight.w500),
  230. )
  231. ],
  232. ).marginOnly(bottom: 12),
  233. Row(
  234. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  235. crossAxisAlignment: CrossAxisAlignment.center,
  236. children: [
  237. Text(
  238. '${S.current.purchase_mobile_no} :',
  239. style: TextStyle(fontSize: 15.0, color: context.appColors.textBlack, fontWeight: FontWeight.w400),
  240. ),
  241. Row(
  242. children: [
  243. Text(
  244. '$phone',
  245. style: TextStyle(fontSize: 15.0, color: context.appColors.textBlack, fontWeight: FontWeight.w500),
  246. ),
  247. ],
  248. ),
  249. ],
  250. ).marginOnly(bottom: 25),
  251. Row(
  252. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  253. crossAxisAlignment: CrossAxisAlignment.center,
  254. children: [
  255. Text(
  256. '${S.current.purchase_date} :',
  257. style: TextStyle(fontSize: 15.0, color: context.appColors.textBlack, fontWeight: FontWeight.w400),
  258. ),
  259. Row(
  260. children: [
  261. Text(
  262. createdAt,
  263. style: TextStyle(fontSize: 15.0, color: context.appColors.textBlack, fontWeight: FontWeight.w500),
  264. ),
  265. ],
  266. ),
  267. ],
  268. ).marginOnly(bottom: 25),
  269. types != "expired"
  270. ? Row(
  271. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  272. crossAxisAlignment: CrossAxisAlignment.center,
  273. children: [
  274. Text(
  275. '${S.current.redeemed_date} :',
  276. style: TextStyle(fontSize: 15.0, color: context.appColors.textBlack, fontWeight: FontWeight.w400),
  277. ),
  278. Row(
  279. children: [
  280. Text(
  281. usedAt,
  282. style: TextStyle(fontSize: 15.0, color: context.appColors.textBlack, fontWeight: FontWeight.w500),
  283. ),
  284. ],
  285. ),
  286. ],
  287. ).marginOnly(bottom: 25)
  288. : Container(),
  289. Row(
  290. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  291. crossAxisAlignment: CrossAxisAlignment.center,
  292. children: [
  293. Text(
  294. '${S.current.quantity} :',
  295. style: TextStyle(fontSize: 15.0, color: context.appColors.textBlack, fontWeight: FontWeight.w400),
  296. ),
  297. Row(
  298. children: [
  299. Text(
  300. '$quantity',
  301. style: TextStyle(fontSize: 15.0, color: context.appColors.textBlack, fontWeight: FontWeight.w500),
  302. ),
  303. ],
  304. ),
  305. ],
  306. ).marginOnly(bottom: 25),
  307. Row(
  308. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  309. crossAxisAlignment: CrossAxisAlignment.center,
  310. children: [
  311. Text(
  312. '${S.current.points} :',
  313. style: TextStyle(fontSize: 15.0, color: context.appColors.tabTextUnSelectedPrimary, fontWeight: FontWeight.w400),
  314. ),
  315. Row(
  316. children: [
  317. Text(
  318. '$originalPoint',
  319. style: TextStyle(
  320. decoration: TextDecoration.lineThrough,
  321. decorationColor: DarkThemeUtil.multiColors(context, ColorUtils.string2Color('#54638C'),darkColor: Colors.white),
  322. decorationStyle: TextDecorationStyle.solid,
  323. fontSize: 14.0,
  324. color: DarkThemeUtil.multiColors(context, ColorUtils.string2Color('#54638C'),darkColor: Colors.white),
  325. fontWeight: FontWeight.w400),
  326. ),
  327. Text(
  328. '$point',
  329. style: TextStyle(fontSize: 19.0, color: context.appColors.tabTextUnSelectedPrimary, fontWeight: FontWeight.w500),
  330. ).marginOnly(left: 10),
  331. ],
  332. ),
  333. ],
  334. ).marginOnly(bottom: 25),
  335. ],
  336. ).paddingOnly(left: 15, right: 15, top: 15, bottom: 5),
  337. ),
  338. ],
  339. ).marginOnly(left: 15, bottom: 15, right: 15);
  340. }
  341. @override
  342. Widget build(BuildContext context, WidgetRef ref) {
  343. final _vm = ref.read(rewardsTransactionVmProvider.notifier);
  344. final state = ref.watch(rewardsTransactionVmProvider);
  345. RewardsMyDetailEntity? detailInfo = state.detailInfo;
  346. String? types = type;
  347. useEffect(() {
  348. // 组件挂载时执行 - 执行接口请求
  349. Future.microtask(() => _vm.initPageData(id: id));
  350. return () {
  351. // 组件卸载时执行
  352. Log.d("property_news_page 组件卸载时执行");
  353. };
  354. }, []);
  355. return Scaffold(
  356. appBar: MyAppBar.appBar(
  357. context,
  358. S.current.my_rewards_details,
  359. backgroundColor: context.appColors.whiteBG,
  360. ),
  361. body: detailInfo?.createdAt != ''
  362. ? Column(
  363. children: [
  364. Expanded(
  365. child: SingleChildScrollView(
  366. scrollDirection: Axis.vertical,
  367. physics: const BouncingScrollPhysics(),
  368. clipBehavior: Clip.none,
  369. child: Column(
  370. children: [
  371. Container(
  372. color: context.appColors.backgroundDark,
  373. padding: const EdgeInsets.only(top: 15),
  374. child: Column(
  375. children: [
  376. _buildSaleItem(context, ref, _vm, detailInfo),
  377. _buildDeal(context, ref, _vm, detailInfo),
  378. _buildNotice(context, ref, _vm, types, detailInfo),
  379. _buildPackage(context, ref, _vm),
  380. ],
  381. )),
  382. ],
  383. ))),
  384. ],
  385. )
  386. : const SizedBox.shrink(),
  387. );
  388. }
  389. }