rewards_transaction_page.dart 19 KB

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