store_page.dart 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233
  1. import 'package:auto_size_text/auto_size_text.dart';
  2. import 'package:carousel_slider/carousel_slider.dart';
  3. import 'package:collection/collection.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:flutter_screenutil/flutter_screenutil.dart';
  6. import 'package:get/get.dart';
  7. import 'package:keyboard/base/base_page.dart';
  8. import 'package:keyboard/data/consts/payment_type.dart';
  9. import 'package:keyboard/data/consts/web_url.dart';
  10. import 'package:keyboard/module/store/store_controller.dart';
  11. import 'package:keyboard/module/store/store_user_reviews_bean.dart';
  12. import 'package:keyboard/resource/string.gen.dart';
  13. import 'package:keyboard/widget/platform_util.dart';
  14. import '../../data/bean/goods_info.dart';
  15. import '../../data/consts/constants.dart';
  16. import '../../resource/assets.gen.dart';
  17. import '../../resource/colors.gen.dart';
  18. import '../../router/app_pages.dart';
  19. import '../../utils/count_down_timer.dart';
  20. import '../../utils/date_util.dart';
  21. import '../../widget/horizontal_dashed_line.dart';
  22. import '../../utils/styles.dart';
  23. import '../../widget/click_text_span.dart';
  24. import '../browser/browser_page.dart';
  25. class StorePage extends BasePage<StoreController> {
  26. const StorePage({super.key});
  27. static start() {
  28. Get.toNamed(RoutePath.store);
  29. }
  30. @override
  31. backgroundColor() => const Color(0xFFFFF8D4);
  32. @override
  33. bool immersive() {
  34. return true;
  35. }
  36. @override
  37. Widget buildBody(BuildContext context) {
  38. Widget bottomArea;
  39. if (PlatformUtil.isIOS) {
  40. bottomArea = Column(
  41. children: [
  42. // iOS平台的隐私协议和服务条款
  43. _buildLastBottomCorner(
  44. child: Container(
  45. // margin: EdgeInsets.only(left: 16.w),
  46. child: _buildPrivacy(
  47. privacyColor: Color(0x99673300),
  48. mainAxisAlignment: MainAxisAlignment.start,
  49. ),
  50. ),
  51. ),
  52. // 恢复订阅入口
  53. _buildRecoverSubscribe(),
  54. SizedBox(height: 20.h),
  55. _buildUserReviews(),
  56. SizedBox(height: 20.h),
  57. _buildUserNotice(),
  58. ],
  59. );
  60. } else {
  61. // 安卓端,可以有会员心声和购买须知
  62. bottomArea = Column(
  63. children: [
  64. // 产品描述
  65. _buildLastBottomCorner(child: _buildVipDesc()),
  66. SizedBox(height: 32.h),
  67. _buildUserReviews(),
  68. SizedBox(height: 20.h),
  69. _buildUserNotice(),
  70. ],
  71. );
  72. }
  73. return Stack(
  74. children: [
  75. SingleChildScrollView(
  76. child: Column(
  77. children: [
  78. _buildBanner(context),
  79. SizedBox(height: 12.h),
  80. _buildGoodsCard(),
  81. bottomArea,
  82. ],
  83. ),
  84. ),
  85. Positioned(top: 0, left: 0, right: 0, child: _buildTitle()),
  86. Positioned(bottom: 0, left: 0, right: 0, child: _buildBuyButtonCard()),
  87. ],
  88. );
  89. }
  90. _buildTitle() {
  91. return SafeArea(
  92. child: Container(
  93. alignment: Alignment.centerLeft,
  94. padding: EdgeInsets.only(top: 16.h, left: 16.w, right: 16.w),
  95. child: Row(
  96. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  97. children: [
  98. GestureDetector(
  99. onTap: controller.clickBack,
  100. child: Assets.images.iconStoreBack.image(
  101. width: 32.w,
  102. height: 32.w,
  103. ),
  104. ),
  105. Obx(() {
  106. return SizedBox(
  107. height: 32.h,
  108. child: Row(
  109. mainAxisSize: MainAxisSize.min,
  110. mainAxisAlignment: MainAxisAlignment.center,
  111. crossAxisAlignment: CrossAxisAlignment.center,
  112. children: [
  113. // 会员状态信息
  114. _buildMemberInfo(),
  115. SizedBox(width: 8.w),
  116. controller.isLogin
  117. ? Assets.images.iconMineUserLogged.image(
  118. width: 28.w,
  119. height: 28.w,
  120. )
  121. : Assets.images.iconMineUserNoLogin.image(
  122. width: 28.w,
  123. height: 28.w,
  124. ),
  125. ],
  126. ),
  127. );
  128. }),
  129. ],
  130. ),
  131. ),
  132. );
  133. }
  134. // 会员信息
  135. Widget _buildMemberInfo() {
  136. return Container(
  137. height: 32.h,
  138. alignment: Alignment.center,
  139. padding: EdgeInsets.symmetric(horizontal: 12.w),
  140. decoration: BoxDecoration(
  141. color: Colors.black.withAlpha(77),
  142. borderRadius: BorderRadius.circular(21.r),
  143. ),
  144. child: Text.rich(
  145. TextSpan(children: _getMemberStatusText()),
  146. textAlign: TextAlign.right,
  147. ),
  148. );
  149. }
  150. // 会员状态文字逻辑提取
  151. List<TextSpan> _getMemberStatusText() {
  152. // // 未登录
  153. // if (!controller.isLogin) {
  154. // return [
  155. // TextSpan(
  156. // text: StringName.memberNoLogged,
  157. // style: _vipTextStyle(isHighlight: true),
  158. // ),
  159. // TextSpan(text: StringName.memberCardNoVipDesc, style: _vipTextStyle()),
  160. // ];
  161. // }
  162. final isMember = controller.memberStatusInfo?.isMember ?? false;
  163. final isPermanent = controller.memberStatusInfo?.permanent ?? false;
  164. final username = controller.userInfo?.name ?? '';
  165. if (isMember) {
  166. if (isPermanent) {
  167. return [
  168. TextSpan(
  169. text: StringName.memberCardPermanentVipDesc1,
  170. style: _vipTextStyle(),
  171. ),
  172. TextSpan(
  173. text: StringName.memberCardPermanentVipDesc2,
  174. style: _vipTextStyle(isHighlight: true),
  175. ),
  176. ];
  177. } else {
  178. return [
  179. TextSpan(text: StringName.memberVipDesc, style: _vipTextStyle()),
  180. TextSpan(
  181. text: DateUtil.fromMillisecondsSinceEpoch(
  182. 'yyyy.MM.dd',
  183. controller.memberStatusInfo?.endTimestamp ?? 0,
  184. ),
  185. style: _vipTextStyle(isHighlight: true),
  186. ),
  187. ];
  188. }
  189. }
  190. // 登录但不是会员
  191. return [
  192. TextSpan(
  193. text: controller.userInfo?.name ?? controller.getUserName(),
  194. style: _vipTextStyle(isHighlight: true),
  195. ),
  196. TextSpan(text: StringName.memberCardNoVipDesc, style: _vipTextStyle()),
  197. ];
  198. }
  199. // 统一的会员状态文本样式
  200. TextStyle _vipTextStyle({bool isHighlight = false}) {
  201. return TextStyle(
  202. color: isHighlight ? const Color(0xFFFFD273) : Colors.white,
  203. fontSize: 12.sp,
  204. fontWeight: FontWeight.w400,
  205. );
  206. }
  207. Widget _buildGoodsCard() {
  208. return Container(
  209. margin: EdgeInsets.symmetric(horizontal: 16.w),
  210. padding: EdgeInsets.only(
  211. top: 16.h,
  212. left: 16.w,
  213. right: 16.w,
  214. bottom: 24.h,
  215. ),
  216. decoration: BoxDecoration(
  217. color: Colors.white,
  218. borderRadius: BorderRadius.only(
  219. topLeft: Radius.circular(16.r),
  220. topRight: Radius.circular(16.r),
  221. ),
  222. ),
  223. child: Column(
  224. crossAxisAlignment: CrossAxisAlignment.start,
  225. mainAxisAlignment: MainAxisAlignment.start,
  226. children: [
  227. Assets.images.iconGoodsInfoTitle.image(
  228. width: 115.w,
  229. fit: BoxFit.cover,
  230. ),
  231. SizedBox(height: 16.h),
  232. Obx(() {
  233. return Column(
  234. children:
  235. controller.filteredGoodsList.mapIndexed((index, item) {
  236. return Obx(() {
  237. return GestureDetector(
  238. onTap: () => controller.onGoodsItemClick(item),
  239. child:
  240. PlatformUtil.isIOS
  241. ? _buildGoodsItemIos(
  242. index,
  243. item,
  244. controller.selectedGoodsInfoItem?.id ==
  245. item.id,
  246. )
  247. : _buildGoodsItem(
  248. item,
  249. controller.selectedGoodsInfoItem?.id ==
  250. item.id,
  251. ),
  252. );
  253. });
  254. }).toList(),
  255. );
  256. }),
  257. // iOS平台的产品描述
  258. if (PlatformUtil.isIOS) _buildVipDesc(),
  259. // 非iOS平台,才有支付宝支付和微信支付
  260. if (!PlatformUtil.isIOS) _buildPayWayCard(),
  261. ],
  262. ),
  263. );
  264. }
  265. Widget _buildPayWayCard() {
  266. return GestureDetector(
  267. onTap: () => controller.clickPayWaySwitch(),
  268. child: Container(
  269. height: 36.h,
  270. padding: EdgeInsets.symmetric(horizontal: 10.w),
  271. decoration: ShapeDecoration(
  272. shape: RoundedRectangleBorder(
  273. side: BorderSide(width: 1, color: const Color(0xFFECEBE0)),
  274. borderRadius: BorderRadius.circular(10.r),
  275. ),
  276. ),
  277. child: Row(
  278. children: [
  279. Text(
  280. StringName.storePayWay,
  281. style: Styles.getTextStyleBlack204W400(14.sp),
  282. ),
  283. const Spacer(),
  284. Obx(() {
  285. if (controller.selectedPayWay == null) {
  286. return SizedBox.shrink();
  287. }
  288. return Row(
  289. children: [
  290. Image.asset(
  291. getPaymentIconPath(
  292. payMethod: controller.selectedPayWay!.payMethod,
  293. payPlatform: controller.selectedPayWay!.payPlatform,
  294. ),
  295. width: 20.w,
  296. height: 20.w,
  297. ),
  298. SizedBox(width: 4.w),
  299. Text(
  300. controller.selectedPayWay?.title ?? '',
  301. style: Styles.getTextStyleBlack204W400(14.sp),
  302. ),
  303. SizedBox(width: 6.w),
  304. Assets.images.iconStoreSwitchPay.image(
  305. width: 20.w,
  306. height: 20.w,
  307. fit: BoxFit.fill,
  308. ),
  309. ],
  310. );
  311. }),
  312. ],
  313. ),
  314. ),
  315. );
  316. }
  317. /// 商品-iOS端
  318. Widget _buildGoodsItemIos(int index, GoodsInfo item, bool isSelected) {
  319. // 第一个商品,才有有倒计时
  320. bool hasCountdown = index == 0;
  321. var amountText = item.amountText;
  322. if (index == 0) {
  323. if (controller.isDiscount.value) {
  324. amountText = item.firstAmountText;
  325. }
  326. }
  327. Widget contentWidget = Stack(
  328. children: [
  329. Positioned(
  330. left: 16.w,
  331. top: 0,
  332. right: 0,
  333. bottom: 0,
  334. child: Row(
  335. children: [
  336. // 价格
  337. RichText(
  338. text: TextSpan(
  339. children: [
  340. TextSpan(
  341. text: '¥',
  342. style: Styles.getTextStyleFF663300W700(14.sp),
  343. ),
  344. TextSpan(
  345. text: amountText,
  346. style: Styles.getTextStyleFF663300W700(18.sp),
  347. ),
  348. ],
  349. ),
  350. ),
  351. SizedBox(width: 18.w),
  352. // 名称和描述
  353. Column(
  354. // 垂直居中
  355. mainAxisAlignment: MainAxisAlignment.center,
  356. // 水平左对齐
  357. crossAxisAlignment: CrossAxisAlignment.start,
  358. children: [
  359. // 名称
  360. Text(
  361. item.name,
  362. style: Styles.getTextStyleFF663300W500(15.sp),
  363. ),
  364. // 描述
  365. if (item.mostDesc?.isNotEmpty == true)
  366. AutoSizeText(
  367. item.mostDesc!,
  368. style: TextStyle(
  369. color: Color(0x99673300),
  370. fontSize: 12.sp,
  371. fontWeight: FontWeight.w500,
  372. letterSpacing: -0.60,
  373. ),
  374. maxLines: 1,
  375. overflow: TextOverflow.ellipsis,
  376. // 最小字体
  377. minFontSize: 8,
  378. // 缩小步长,越小越丝滑
  379. stepGranularity: 0.5,
  380. ),
  381. ],
  382. ),
  383. ],
  384. ),
  385. ),
  386. // 勾选状态
  387. Positioned(
  388. top: 0,
  389. right: 22.w,
  390. bottom: 0,
  391. child: Image(
  392. image:
  393. isSelected
  394. ? Assets.images.iconStoreGoodsSelectedSymbolIos.provider()
  395. : Assets.images.iconStoreGoodsNormalSymbolIos.provider(),
  396. width: 20.w,
  397. height: 20.w,
  398. ),
  399. ),
  400. // 倒计时
  401. Positioned(
  402. top: 0,
  403. right: 8,
  404. child: Visibility(
  405. visible: hasCountdown,
  406. child: Row(
  407. crossAxisAlignment: CrossAxisAlignment.center,
  408. mainAxisAlignment: MainAxisAlignment.center,
  409. children: [
  410. Text(
  411. "倒计时",
  412. style: TextStyle(
  413. color: isSelected ? Color(0xFFFFECBB) : Color(0xFFFF9416),
  414. fontSize: 12.sp,
  415. fontWeight: FontWeight.w500,
  416. ),
  417. ),
  418. SizedBox(width: 4.w),
  419. Container(
  420. width: 57.w,
  421. child: Obx(() {
  422. return Text(
  423. CountdownTimer.format(controller.goodsCountdown.value),
  424. style: TextStyle(
  425. color: isSelected ? ColorName.white : Color(0xFFFF9416),
  426. fontSize: 12.sp,
  427. fontWeight: FontWeight.w500,
  428. ),
  429. );
  430. }),
  431. ),
  432. ],
  433. ),
  434. ),
  435. ),
  436. ],
  437. );
  438. // 最终呈现的内容组件
  439. Widget resultWidget;
  440. if (hasCountdown) {
  441. // 有倒计时的商品,不规则,使用图片背景
  442. resultWidget = Container(
  443. decoration: BoxDecoration(
  444. image: DecorationImage(
  445. image:
  446. isSelected
  447. ? Assets.images.bgStoreGoodsItemWithCountdownSelectedIos
  448. .provider()
  449. : Assets.images.bgStoreGoodsItemWithCountdownNormalIos
  450. .provider(),
  451. fit: BoxFit.fill,
  452. ),
  453. ),
  454. child: contentWidget,
  455. );
  456. } else {
  457. // 没有倒计时的商品
  458. resultWidget = Container(
  459. decoration: BoxDecoration(
  460. shape: BoxShape.rectangle,
  461. borderRadius: BorderRadius.circular(8.r),
  462. border: Border.all(
  463. color: isSelected ? Color(0xFFFF9416) : Color(0xFFFEE86B),
  464. width: 2.w,
  465. ),
  466. ),
  467. child: contentWidget,
  468. );
  469. }
  470. // 最后面背景透出来的颜色
  471. Decoration bgDecoration;
  472. if (isSelected) {
  473. // 渐变背景
  474. bgDecoration = ShapeDecoration(
  475. gradient: LinearGradient(
  476. begin: Alignment(-0.06, 0.50),
  477. end: Alignment(1.14, 0.50),
  478. colors: [const Color(0xFFFFF895), const Color(0xFFFFE941)],
  479. ),
  480. shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8.r)),
  481. );
  482. } else {
  483. // 纯色背景
  484. bgDecoration = BoxDecoration(
  485. color: Color(0xFFFFFEEE),
  486. borderRadius: BorderRadius.circular(6.r),
  487. );
  488. }
  489. return Container(
  490. margin: EdgeInsets.only(bottom: 8.h),
  491. width: 296.w,
  492. height: 70.h,
  493. decoration: bgDecoration,
  494. child: Stack(
  495. children: [
  496. // 对勾图片
  497. Positioned(
  498. top: 0,
  499. right: 0,
  500. bottom: 0,
  501. child: Assets.images.bgStoreSelectedArrow1Ios.image(
  502. width: 85.w,
  503. height: double.infinity,
  504. ),
  505. ),
  506. resultWidget,
  507. ],
  508. ),
  509. );
  510. }
  511. /// 商品-Android端
  512. Widget _buildGoodsItem(GoodsInfo item, bool isSelected) {
  513. return Container(
  514. margin: EdgeInsets.only(bottom: 8.h),
  515. width: 296.w,
  516. height: 70.h,
  517. decoration: ShapeDecoration(
  518. gradient: LinearGradient(
  519. begin: Alignment(0.77, -0.00),
  520. end: Alignment(0.77, 1.00),
  521. colors:
  522. isSelected
  523. ? [const Color(0xFFFF9416), const Color(0xFFFF7813)]
  524. : [const Color(0xFFFEE057), const Color(0xFFFFC400)],
  525. ),
  526. shape: RoundedRectangleBorder(
  527. borderRadius: BorderRadius.circular(10.r),
  528. ),
  529. ),
  530. child: Row(
  531. children: [
  532. Container(
  533. width: 212.w,
  534. height: 70.h,
  535. decoration: ShapeDecoration(
  536. gradient:
  537. isSelected
  538. ? LinearGradient(
  539. begin: Alignment(-0.06, 0.50),
  540. end: Alignment(1.14, 0.50),
  541. colors: [
  542. const Color(0xFFFFF895),
  543. const Color(0xFFFFE941),
  544. ],
  545. )
  546. : null,
  547. color: isSelected ? null : const Color(0xFFFFFDEE),
  548. shape: RoundedRectangleBorder(
  549. side: BorderSide(width: 1, color: const Color(0xFFFEE86B)),
  550. borderRadius: BorderRadius.circular(isSelected ? 8 : 10.r),
  551. ),
  552. ),
  553. child: Stack(
  554. children: [
  555. if (isSelected)
  556. IgnorePointer(
  557. child: Assets.images.bgStoreSelectedItem.image(
  558. width: 212.w,
  559. height: 70.h,
  560. fit: BoxFit.fill,
  561. ),
  562. ),
  563. Padding(
  564. padding: EdgeInsets.only(left: 16.w),
  565. child: Column(
  566. crossAxisAlignment: CrossAxisAlignment.start,
  567. mainAxisAlignment: MainAxisAlignment.center,
  568. children: [
  569. Row(
  570. children: [
  571. RichText(
  572. text: TextSpan(
  573. children: [
  574. TextSpan(
  575. text: '¥',
  576. style: Styles.getTextStyleFF663300W700(14.sp),
  577. ),
  578. TextSpan(
  579. text: item.priceDescNumber,
  580. style: Styles.getTextStyleFF663300W700(18.sp),
  581. ),
  582. TextSpan(
  583. text: item.priceDescUnit,
  584. style: Styles.getTextStyleFF663300W400(13.sp),
  585. ),
  586. ],
  587. ),
  588. ),
  589. if (item.mostDesc?.isNotEmpty == true)
  590. Container(
  591. constraints: BoxConstraints(
  592. minHeight: 20.w,
  593. maxHeight: 20.w,
  594. minWidth: 40.w,
  595. maxWidth: 120.w,
  596. ),
  597. padding: EdgeInsets.only(
  598. left: 16.w,
  599. top: 2.h,
  600. bottom: 2.h,
  601. right: 4.w,
  602. ),
  603. decoration: BoxDecoration(
  604. image: DecorationImage(
  605. image: Assets.images.iconStoreMost.provider(),
  606. fit: BoxFit.fill,
  607. alignment: Alignment.bottomLeft,
  608. ),
  609. ),
  610. child: AutoSizeText(
  611. item.mostDesc!,
  612. style: TextStyle(
  613. color: Colors.white,
  614. fontSize: 12.sp,
  615. fontWeight: FontWeight.w500,
  616. letterSpacing: -0.60,
  617. ),
  618. maxLines: 1,
  619. overflow: TextOverflow.ellipsis,
  620. minFontSize: 8,
  621. // 最小字体
  622. stepGranularity: 0.5, // 缩小步长,越小越丝滑
  623. ),
  624. ),
  625. ],
  626. ),
  627. Text(
  628. item.description!,
  629. style: Styles.getTextStyle99673300W400(12.sp),
  630. ),
  631. ],
  632. ),
  633. ),
  634. ],
  635. ),
  636. ),
  637. // 右侧
  638. Expanded(
  639. child: Column(
  640. mainAxisAlignment: MainAxisAlignment.center,
  641. crossAxisAlignment: CrossAxisAlignment.center,
  642. children: [
  643. Text(
  644. item.name,
  645. style:
  646. isSelected
  647. ? Styles.getTextStyleFFECBBW500(15.sp)
  648. : Styles.getTextStyleFF663300W500(15.sp),
  649. ),
  650. Container(
  651. padding: EdgeInsets.symmetric(horizontal: 8.w),
  652. decoration: ShapeDecoration(
  653. color: isSelected ? const Color(0xFFFFECBB) : null,
  654. gradient:
  655. isSelected
  656. ? null
  657. : LinearGradient(
  658. begin: Alignment(0.77, -0.00),
  659. end: Alignment(0.77, 1.00),
  660. colors: [
  661. const Color(0xFFFF9416),
  662. const Color(0xFFFF7813),
  663. ],
  664. ),
  665. shape: RoundedRectangleBorder(
  666. borderRadius: BorderRadius.circular(
  667. isSelected ? 17.r : 10.r,
  668. ),
  669. ),
  670. ),
  671. child: Text(
  672. '¥${item.amountText}',
  673. textAlign: TextAlign.center,
  674. style:
  675. isSelected
  676. ? Styles.getTextStyleFF7F14W500(12.sp)
  677. : Styles.getTextStyleWhiteW500(12.sp),
  678. ),
  679. ),
  680. ],
  681. ),
  682. ),
  683. ],
  684. ),
  685. );
  686. }
  687. /// 最后的底部圆角
  688. Widget _buildLastBottomCorner({required Widget child}) {
  689. return Container(
  690. alignment: Alignment.centerLeft,
  691. margin: EdgeInsets.symmetric(horizontal: 16.w),
  692. padding: EdgeInsets.symmetric(
  693. horizontal: PlatformUtil.isIOS ? 4.w : 16.w,
  694. ),
  695. width: double.infinity,
  696. decoration: ShapeDecoration(
  697. gradient: LinearGradient(
  698. begin: Alignment(0.00, 0.50),
  699. end: Alignment(1.00, 0.50),
  700. colors: [const Color(0x7FFFF3A3), const Color(0x21FFF3A3)],
  701. ),
  702. shape: RoundedRectangleBorder(
  703. borderRadius: BorderRadius.only(
  704. bottomLeft: Radius.circular(20.r),
  705. bottomRight: Radius.circular(20.r),
  706. ),
  707. ),
  708. shadows: [
  709. BoxShadow(
  710. color: Colors.black.withAlpha(10),
  711. blurRadius: 10.r,
  712. spreadRadius: 0.r,
  713. offset: Offset(0, 8.r),
  714. ),
  715. ],
  716. ),
  717. child: Column(children: [child]),
  718. );
  719. }
  720. /// 产品描述
  721. Widget _buildVipDesc() {
  722. return Obx(() {
  723. return Text(
  724. controller.selectedGoodsInfoItem?.selectDesc ?? "",
  725. style: Styles.getTextStyle99673300W400(12.sp),
  726. );
  727. });
  728. }
  729. // 轮播图
  730. Widget _buildBanner(BuildContext context) {
  731. return SizedBox(
  732. width: double.infinity,
  733. child: Stack(
  734. children: [
  735. CarouselSlider(
  736. carouselController: controller.carouselSliderController,
  737. options: CarouselOptions(
  738. height: 280.h,
  739. viewportFraction: 1,
  740. initialPage: 0,
  741. enableInfiniteScroll: true,
  742. reverse: false,
  743. autoPlay: true,
  744. autoPlayInterval: const Duration(seconds: 3),
  745. autoPlayAnimationDuration: const Duration(milliseconds: 800),
  746. autoPlayCurve: Curves.fastOutSlowIn,
  747. scrollDirection: Axis.horizontal,
  748. onPageChanged: (index, reason) {
  749. controller.onBannerChanged(index, reason);
  750. },
  751. ),
  752. items:
  753. controller.bannerList.map((item) {
  754. return item.banner.image(
  755. width: double.infinity,
  756. fit: BoxFit.cover,
  757. );
  758. }).toList(),
  759. ),
  760. Positioned(bottom: 0, left: 0, right: 0, child: _buildIndicator()),
  761. ],
  762. ),
  763. );
  764. }
  765. // 指示器
  766. _buildIndicator() {
  767. return Container(
  768. height: 36.h,
  769. margin: EdgeInsets.symmetric(horizontal: 16.w),
  770. decoration: ShapeDecoration(
  771. color: const Color(0xE5121212),
  772. shape: RoundedRectangleBorder(
  773. borderRadius: BorderRadius.circular(21.r),
  774. ),
  775. ),
  776. child: Row(
  777. mainAxisAlignment: MainAxisAlignment.spaceAround,
  778. children:
  779. controller.bannerList.asMap().entries.map((entry) {
  780. return Obx(() {
  781. final isSelectedBanner =
  782. controller.currentBannerIndex == entry.key;
  783. return Row(
  784. mainAxisAlignment: MainAxisAlignment.spaceAround,
  785. children: [
  786. GestureDetector(
  787. onTap:
  788. () => controller.carouselSliderController
  789. .animateToPage(entry.key),
  790. child: SizedBox(
  791. width: 100.w,
  792. child: Stack(
  793. alignment: Alignment.center,
  794. clipBehavior: Clip.none,
  795. children: [
  796. if (isSelectedBanner)
  797. Positioned(
  798. top: -8.h,
  799. child: controller
  800. .bannerList[entry.key]
  801. .indicatorImg
  802. .image(
  803. width: 100.w,
  804. height: 40.h,
  805. fit: BoxFit.fill,
  806. ),
  807. )
  808. else
  809. Text(
  810. controller.bannerList[entry.key].unSelectedDesc,
  811. style: Styles.getTextStyleWhiteW400(14.sp),
  812. ),
  813. ],
  814. ),
  815. ),
  816. ),
  817. if (entry.key != controller.bannerList.length - 1)
  818. Padding(
  819. padding: EdgeInsets.only(left: 4.w),
  820. child: Assets.images.iconStoreDivider.image(
  821. width: 2.w,
  822. height: 17.h,
  823. fit: BoxFit.fill,
  824. ),
  825. ),
  826. ],
  827. );
  828. });
  829. }).toList(),
  830. ),
  831. );
  832. }
  833. Widget _buildUserReviews() {
  834. return Container(
  835. width: double.infinity,
  836. child: Column(
  837. crossAxisAlignment: CrossAxisAlignment.center,
  838. children: [
  839. Assets.images.iconStoreUserReviewsTitle.image(
  840. width: 240.w,
  841. fit: BoxFit.cover,
  842. ),
  843. SizedBox(height: 16.h),
  844. Container(
  845. width: double.infinity,
  846. decoration: BoxDecoration(
  847. borderRadius: BorderRadius.circular(19.r),
  848. gradient: LinearGradient(
  849. begin: Alignment.topCenter,
  850. end: Alignment.bottomCenter,
  851. colors: [Colors.white, Color(0xfffff8d4)],
  852. ),
  853. ),
  854. child: Column(
  855. children: [
  856. SizedBox(height: 20.h),
  857. Container(
  858. width: 326.w,
  859. decoration: BoxDecoration(
  860. borderRadius: BorderRadius.circular(19.r),
  861. image: DecorationImage(
  862. alignment: Alignment.topCenter,
  863. image: Assets.images.bgStoreUserReviews.provider(),
  864. fit: BoxFit.contain,
  865. ),
  866. ),
  867. child: Column(
  868. children: [
  869. Container(
  870. padding: EdgeInsets.only(left: 16.w),
  871. alignment: Alignment.centerLeft,
  872. height: 39.h,
  873. child: Assets.images.iconStoreUserReviewsLogo.image(
  874. width: 92.w,
  875. height: 24.h,
  876. ),
  877. ),
  878. Container(
  879. width: 326.w,
  880. decoration: ShapeDecoration(
  881. color: Colors.white,
  882. shape: RoundedRectangleBorder(
  883. borderRadius: BorderRadius.circular(16.r),
  884. ),
  885. shadows: [
  886. BoxShadow(
  887. color: Colors.black.withAlpha(10),
  888. blurRadius: 10.r,
  889. spreadRadius: 0.r,
  890. offset: Offset(0, 5.r),
  891. ),
  892. ],
  893. ),
  894. child: Column(
  895. children:
  896. controller.userReviewsList.map((item) {
  897. return _buildReviewsItem(item);
  898. }).toList(),
  899. ),
  900. ),
  901. ],
  902. ),
  903. ),
  904. ],
  905. ),
  906. ),
  907. ],
  908. ),
  909. );
  910. }
  911. Widget _buildReviewsItem(StoreUserReviewsBean item) {
  912. return Container(
  913. padding: EdgeInsets.only(left: 16.w, right: 16.w, top: 12.h),
  914. child: Column(
  915. crossAxisAlignment: CrossAxisAlignment.start,
  916. children: [
  917. Row(
  918. children: [
  919. item.avatar.image(width: 28.w, height: 28.h, fit: BoxFit.cover),
  920. SizedBox(width: 10.w),
  921. Text(
  922. item.userName,
  923. style: Styles.getTextStyleBlack204W500(14.sp),
  924. ),
  925. SizedBox(width: 6.w),
  926. Assets.images.iconStorePermanentMember.image(
  927. width: 70.w,
  928. height: 20.h,
  929. fit: BoxFit.cover,
  930. ),
  931. ],
  932. ),
  933. SizedBox(height: 4.h),
  934. Padding(
  935. padding: EdgeInsets.only(left: 38.w),
  936. child: Text(
  937. item.userReviews,
  938. style: TextStyle(
  939. color: Colors.black.withAlpha(153),
  940. fontSize: 12.sp,
  941. fontWeight: FontWeight.w400,
  942. ),
  943. ),
  944. ),
  945. SizedBox(height: 12.h),
  946. if (controller.userReviewsList.indexOf(item) !=
  947. controller.userReviewsList.length - 1)
  948. HorizontalDashedLine(
  949. width: 304.w,
  950. color: const Color(0XFFEDEBE1),
  951. strokeWidth: 2.h,
  952. dashLength: 4.w,
  953. dashSpace: 4.w,
  954. ),
  955. ],
  956. ),
  957. );
  958. }
  959. // 用户须知
  960. Widget _buildUserNotice() {
  961. return Container(
  962. margin: EdgeInsets.symmetric(horizontal: 16.w),
  963. decoration: BoxDecoration(borderRadius: BorderRadius.circular(16.r)),
  964. child: Column(
  965. crossAxisAlignment: CrossAxisAlignment.start,
  966. children: [
  967. Text('购买须知', style: Styles.getTextStyleFF663300W400(12.sp)),
  968. SizedBox(height: 8.h),
  969. Obx(() {
  970. return Text(
  971. controller.configRepository.memberTips.value,
  972. style: Styles.getTextStyle99673300W400(10.sp),
  973. );
  974. }),
  975. SizedBox(height: 110.h),
  976. ],
  977. ),
  978. );
  979. }
  980. /// 恢复订阅
  981. Widget _buildRecoverSubscribe() {
  982. return Container(
  983. margin: EdgeInsets.only(left: 16.w, top: 8.h, right: 16.w),
  984. child: Row(
  985. children: [
  986. Text(
  987. "⚠️ 订阅未生效?点此试试",
  988. style: TextStyle(
  989. color: Color(0xFF666355),
  990. fontSize: 13.sp,
  991. fontWeight: FontWeight.w400,
  992. ),
  993. ),
  994. GestureDetector(
  995. onTap: () {
  996. // 恢复订阅
  997. controller.clickRecoverSubscribe();
  998. },
  999. child: Text(
  1000. " 恢复订阅>",
  1001. style: TextStyle(
  1002. color: Color(0xFF479DF7),
  1003. fontSize: 13.sp,
  1004. fontWeight: FontWeight.w400,
  1005. ),
  1006. ),
  1007. ),
  1008. ],
  1009. ),
  1010. );
  1011. }
  1012. Widget _buildBuyButtonCard() {
  1013. return Container(
  1014. width: 360.w,
  1015. padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 11.h),
  1016. decoration: ShapeDecoration(
  1017. color: Colors.white,
  1018. shape: RoundedRectangleBorder(
  1019. borderRadius: BorderRadius.only(
  1020. topLeft: Radius.circular(24.r),
  1021. topRight: Radius.circular(24.r),
  1022. ),
  1023. ),
  1024. shadows: [
  1025. BoxShadow(
  1026. color: Color(0x99FFE498),
  1027. blurRadius: 20,
  1028. offset: Offset(0, 0),
  1029. spreadRadius: 0,
  1030. ),
  1031. ],
  1032. ),
  1033. child: Column(
  1034. children: [
  1035. GestureDetector(
  1036. onTap: controller.clickPayNow,
  1037. child: Container(
  1038. alignment: Alignment.topCenter,
  1039. width: 328.w,
  1040. height: 56.w,
  1041. decoration: ShapeDecoration(
  1042. color: const Color(0xFFFFF587),
  1043. shape: RoundedRectangleBorder(
  1044. borderRadius: BorderRadius.circular(30.55.r),
  1045. ),
  1046. ),
  1047. child: Container(
  1048. width: 328.w,
  1049. height: 54.w,
  1050. decoration: ShapeDecoration(
  1051. gradient: LinearGradient(
  1052. begin: Alignment(0.60, -0.39),
  1053. end: Alignment(0.60, 0.95),
  1054. colors: [
  1055. const Color(0xFFF95FAC),
  1056. const Color(0xFFFD5E4D),
  1057. const Color(0xFFFD5E4D),
  1058. const Color(0xFFFB8A3C),
  1059. ],
  1060. ),
  1061. shape: RoundedRectangleBorder(
  1062. borderRadius: BorderRadius.circular(30.55.r),
  1063. ),
  1064. ),
  1065. child: Center(
  1066. child: Text(
  1067. StringName.storePayNow,
  1068. style: Styles.getTextStyleWhiteW500(17.sp),
  1069. ),
  1070. ),
  1071. ),
  1072. ),
  1073. ),
  1074. // 安卓平台的隐私协议和服务条款
  1075. if (!PlatformUtil.isIOS) _buildPrivacy(),
  1076. ],
  1077. ),
  1078. );
  1079. }
  1080. /// 隐私协议和服务条款
  1081. Widget _buildPrivacy({
  1082. Color privacyColor = const Color(0xFF459FFF),
  1083. MainAxisAlignment mainAxisAlignment = MainAxisAlignment.center,
  1084. }) {
  1085. return Row(
  1086. mainAxisAlignment: mainAxisAlignment,
  1087. children: [
  1088. Obx(() {
  1089. return GestureDetector(
  1090. behavior: HitTestBehavior.opaque,
  1091. onTap: () {
  1092. controller.isAgree.value = !controller.isAgree.value;
  1093. },
  1094. child: Padding(
  1095. padding: EdgeInsets.symmetric(vertical: 5.w, horizontal: 5.w),
  1096. child:
  1097. controller.isAgree.value
  1098. ? Assets.images.iconStoreAgreePrivacy.image(
  1099. width: 16.w,
  1100. height: 16.w,
  1101. )
  1102. : SizedBox(
  1103. child: Container(
  1104. padding: EdgeInsets.all(1.w),
  1105. width: 16.w,
  1106. height: 16.w,
  1107. child: Container(
  1108. decoration: BoxDecoration(
  1109. shape: BoxShape.circle,
  1110. border: Border.all(
  1111. color: Colors.black.withAlpha(153),
  1112. width: 1.w,
  1113. ),
  1114. ),
  1115. ),
  1116. ),
  1117. ),
  1118. ),
  1119. );
  1120. }),
  1121. Transform.translate(
  1122. offset: Offset(-2.w, 0),
  1123. child: Text.rich(
  1124. PlatformUtil.isIOS
  1125. ? TextSpan(
  1126. children: [
  1127. TextSpan(
  1128. text: StringName.textSpanIHaveReadAndAgree,
  1129. style: TextStyle(
  1130. color: Colors.black.withAlpha(153),
  1131. fontSize: 10.sp,
  1132. fontWeight: FontWeight.w400,
  1133. ),
  1134. ),
  1135. ClickTextSpan(
  1136. text: StringName.textSpanPrivacyPolicy,
  1137. url: WebUrl.privacyPolicy,
  1138. color: privacyColor,
  1139. ),
  1140. ClickTextSpan(
  1141. text: StringName.textSpanServiceTerms,
  1142. url: WebUrl.serviceAgreement,
  1143. color: privacyColor,
  1144. ),
  1145. TextSpan(
  1146. text: StringName.textSpanAnd,
  1147. style: TextStyle(
  1148. color: Colors.black.withAlpha(153),
  1149. fontSize: 10.sp,
  1150. fontWeight: FontWeight.w400,
  1151. ),
  1152. ),
  1153. ClickTextSpan(
  1154. text: StringName.textSpanMembershipAgreement,
  1155. url: WebUrl.subscribeAgreement,
  1156. color: privacyColor,
  1157. ),
  1158. ],
  1159. )
  1160. : TextSpan(
  1161. children: [
  1162. TextSpan(
  1163. text: StringName.textSpanIHaveReadAndAgree,
  1164. style: TextStyle(
  1165. color: Colors.black.withAlpha(153),
  1166. fontSize: 10.sp,
  1167. fontWeight: FontWeight.w400,
  1168. ),
  1169. ),
  1170. ClickTextSpan(
  1171. text: StringName.textSpanPrivacyPolicy,
  1172. url: WebUrl.privacyPolicy,
  1173. color: privacyColor,
  1174. ),
  1175. TextSpan(
  1176. text: StringName.textSpanAnd,
  1177. style: TextStyle(
  1178. color: Colors.black.withAlpha(153),
  1179. fontSize: 10.sp,
  1180. fontWeight: FontWeight.w400,
  1181. ),
  1182. ),
  1183. ClickTextSpan(
  1184. text: StringName.textSpanServiceTerms,
  1185. url: WebUrl.serviceAgreement,
  1186. color: privacyColor,
  1187. ),
  1188. ],
  1189. ),
  1190. ),
  1191. ),
  1192. ],
  1193. );
  1194. }
  1195. }