order_information_page.dart 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760
  1. import 'dart:convert';
  2. import 'package:bbyyy/beans/my_coupon_bean_entity.dart';
  3. import 'package:bbyyy/beans/user_balance_entity.dart';
  4. import 'package:bbyyy/https/MyDio.dart';
  5. import 'package:bbyyy/https/url.dart';
  6. import 'package:bbyyy/my_tools/const.dart';
  7. import 'package:bbyyy/my_tools/dims.dart';
  8. import 'package:bbyyy/my_tools/event_bus.dart';
  9. import 'package:bbyyy/my_tools/my_colors.dart';
  10. import 'package:bbyyy/my_tools/my_cookie.dart';
  11. import 'package:bbyyy/my_tools/my_tools.dart';
  12. import 'package:bbyyy/my_tools/my_views.dart';
  13. import 'package:bbyyy/paegs/mine_page/coupon_page/coupon_view.dart';
  14. import 'package:bbyyy/paegs/pay_page/pay_page.dart';
  15. import 'package:bbyyy/pay/pay_tools.dart';
  16. import 'package:flustars/flustars.dart';
  17. import 'package:flutter/cupertino.dart';
  18. import 'package:flutter/material.dart';
  19. import 'package:flutter_svg/svg.dart';
  20. import 'package:pull_to_refresh/pull_to_refresh.dart';
  21. class OrderInformationPage extends StatefulWidget {
  22. int orderType;
  23. double amount;
  24. int uid;
  25. String sellName;
  26. int sellUid;
  27. String sellPic;
  28. String buyerName;
  29. int buyerUid;
  30. String buyerPic;
  31. int commodityCount;
  32. String commodityCover;
  33. String commodityTitle;
  34. bool cancelOrder;
  35. OrderInformationPage(this.cancelOrder,
  36. {this.orderType,
  37. this.sellName,
  38. this.sellPic,
  39. this.sellUid,
  40. this.amount,
  41. this.buyerName,
  42. this.uid,
  43. this.buyerUid,
  44. this.buyerPic,
  45. this.commodityCover,
  46. this.commodityTitle,
  47. this.commodityCount});
  48. @override
  49. _OrderInformationPageState createState() => _OrderInformationPageState();
  50. }
  51. class _OrderInformationPageState extends State<OrderInformationPage> {
  52. bool payWay = false; //true - 支付宝 false - 微信
  53. String coupon = '未选择优惠券';
  54. MyCouponBeanDataData couponData;
  55. @override
  56. void initState() {
  57. // TODO: implement initState
  58. super.initState();
  59. Future.delayed(Duration.zero,(){
  60. getUserWalletBalance((re,hE){
  61. if (!hE) {
  62. UserBalanceEntity balance =
  63. UserBalanceEntity().fromJson(json.decode(re.data.toString()));
  64. payWay = widget.amount>balance.data;
  65. setState(() {});
  66. }
  67. },(e){
  68. },context);
  69. });
  70. }
  71. @override
  72. Widget build(BuildContext context) {
  73. return Scaffold(
  74. backgroundColor: MyColors.cEFEFEF,
  75. body: Column(
  76. children: [
  77. MyViews().myAppBar('订单信息', context, []),
  78. Container(
  79. height: 10,
  80. color: MyColors.cEFEFEF,
  81. ),
  82. Expanded(
  83. child: SingleChildScrollView(
  84. child: Column(
  85. children: [
  86. Container(
  87. child: orderInformation(),
  88. color: Colors.white,
  89. padding: EdgeInsets.symmetric(vertical: 10),
  90. ),
  91. Container(
  92. height: 10,
  93. color: MyColors.cEFEFEF,
  94. ),
  95. Container(
  96. color: Colors.white,
  97. child: Row(
  98. children: [
  99. MyViews().myText('支付方式', MyColors.c333333, 14),
  100. GestureDetector(
  101. onTap: () {
  102. showCupertinoModalPopup(
  103. context: context,
  104. builder: (BuildContext context) {
  105. return CupertinoActionSheet(
  106. title: MyViews()
  107. .myText('选择支付方式', MyColors.c333333, 20),
  108. actions: [
  109. CupertinoActionSheetAction(
  110. child: Row(
  111. children: [
  112. SvgPicture.asset(
  113. 'images/svg/支付宝.svg',
  114. width: 24,
  115. height: 24,
  116. ),
  117. Container(
  118. child: MyViews().myText('支付宝支付',
  119. MyColors.c333333, 16),
  120. margin: EdgeInsets.only(
  121. left: 6, right: 6),
  122. ),
  123. ],
  124. mainAxisAlignment:
  125. MainAxisAlignment.center,
  126. ),
  127. onPressed: (() {
  128. payWay = true;
  129. setState(() {});
  130. Navigator.pop(context, 'Edit');
  131. }),
  132. ),
  133. CupertinoActionSheetAction(
  134. child: Row(
  135. children: [
  136. SvgPicture.asset(
  137. 'images/svg/积分支付.svg',
  138. width: 24,
  139. height: 24,
  140. ),
  141. Container(
  142. child: MyViews().myText(
  143. '积分支付', MyColors.c333333, 16),
  144. margin: EdgeInsets.only(
  145. left: 6, right: 6),
  146. ),
  147. ],
  148. mainAxisAlignment:
  149. MainAxisAlignment.center,
  150. ),
  151. onPressed: (() {
  152. payWay = false;
  153. setState(() {});
  154. Navigator.pop(context, 'Edit');
  155. }),
  156. ),
  157. ],
  158. cancelButton: CupertinoActionSheetAction(
  159. child: Text("取消"),
  160. isDefaultAction: true,
  161. onPressed: (() {
  162. Navigator.pop(context, 'Cancel');
  163. }),
  164. ),
  165. );
  166. });
  167. },
  168. behavior: HitTestBehavior.translucent,
  169. child: Row(
  170. children: [
  171. SvgPicture.asset(
  172. 'images/svg/${payWay ? '支付宝' : '积分支付'}.svg',
  173. width: 20,
  174. height: 20,
  175. ),
  176. Container(
  177. child: MyViews().myText(
  178. '${payWay ? '支付宝' : '积分'}支付',
  179. MyColors.c333333,
  180. 13),
  181. margin: EdgeInsets.only(left: 6, right: 6),
  182. ),
  183. SvgPicture.asset(
  184. 'images/svg/箭头.svg',
  185. color: MyColors.c999999,
  186. width: 6,
  187. height: 11,
  188. ),
  189. ],
  190. ),
  191. )
  192. ],
  193. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  194. ),
  195. alignment: Alignment.centerLeft,
  196. padding: EdgeInsets.all(10),
  197. ),
  198. Container(
  199. height: 10,
  200. color: MyColors.cEFEFEF,
  201. ),
  202. Container(
  203. color: Colors.white,
  204. child: Row(
  205. children: [
  206. MyViews().myText('优惠券', MyColors.c333333, 16),
  207. GestureDetector(
  208. onTap: () {
  209. MyTools().toPage(context, ChooseACoupon(), (then) {
  210. if (then is MyCouponBeanDataData) {
  211. couponData = then;
  212. coupon = couponType(couponData.type) +
  213. ': ${couponData.amount}元';
  214. setState(() {});
  215. }
  216. });
  217. },
  218. behavior: HitTestBehavior.translucent,
  219. child: Row(
  220. children: [
  221. Container(
  222. child: MyViews()
  223. .myText(coupon, MyColors.c333333, 13),
  224. margin: EdgeInsets.only(left: 6, right: 6),
  225. ),
  226. SvgPicture.asset(
  227. 'images/svg/箭头.svg',
  228. color: MyColors.c999999,
  229. width: 6,
  230. height: 11,
  231. ),
  232. ],
  233. ),
  234. )
  235. ],
  236. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  237. ),
  238. alignment: Alignment.centerLeft,
  239. padding: EdgeInsets.all(10),
  240. ),
  241. ],
  242. ),
  243. ),
  244. ),
  245. Container(
  246. color: Colors.white,
  247. child: SafeArea(
  248. top: false,
  249. child: Container(
  250. color: Colors.white,
  251. padding: EdgeInsets.only(right: 10, left: 10),
  252. height: 60,
  253. child: Row(
  254. children: [
  255. Row(
  256. children: [
  257. MyViews().myText('合计:', MyColors.c333333, 16),
  258. MyViews().myText(
  259. '¥${couponData == null ? widget.amount.toStringAsFixed(2) : NumUtil.subtract(widget.amount, couponData.amount) < 0 ? 0.0.toStringAsFixed(2) : NumUtil.subtract(widget.amount, couponData.amount).toStringAsFixed(2)}',
  260. MyColors.cFF4233,
  261. 18),
  262. ],
  263. ),
  264. Expanded(
  265. child: Row(
  266. children: [
  267. GestureDetector(
  268. onTap: () {
  269. toPayPage();
  270. },
  271. behavior: HitTestBehavior.translucent,
  272. child: Container(
  273. decoration: BoxDecoration(
  274. borderRadius: BorderRadius.circular(20),
  275. color: MyColors.cFF4233),
  276. height: 40,
  277. width: 160,
  278. child:
  279. MyViews().myText('确 认', Colors.white, 14),
  280. alignment: Alignment.center),
  281. )
  282. ],
  283. mainAxisAlignment: MainAxisAlignment.end,
  284. ),
  285. )
  286. ],
  287. ),
  288. ),
  289. ),
  290. )
  291. ],
  292. ),
  293. );
  294. }
  295. Widget orderInformation() {
  296. if (widget.orderType == orderTypeThirdPlatform) {
  297. //第三方平台订单
  298. return Container(
  299. margin: EdgeInsets.symmetric(horizontal: 12),
  300. child: Row(
  301. children: [
  302. Container(
  303. child: SvgPicture.asset(
  304. 'images/svg/第三方.svg',
  305. height: 45,
  306. width: 45,
  307. ),
  308. margin: EdgeInsets.only(right: 8),
  309. height: 60,
  310. width: 60,
  311. decoration: BoxDecoration(
  312. border: Border.all(color: MyColors.cEBEBEB, width: 1)),
  313. alignment: Alignment.center,
  314. ),
  315. Expanded(
  316. child: Container(
  317. height: 60,
  318. child: Column(
  319. children: [
  320. MyViews()
  321. .myText('第三方订单(${widget.uid})', MyColors.c333333, 13),
  322. Row(
  323. children: [
  324. MyViews()
  325. .myText('¥${widget.amount}', MyColors.cFF4233, 12),
  326. MyViews().myText(
  327. 'x${widget.commodityCount}', MyColors.c999999, 12),
  328. ],
  329. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  330. )
  331. ],
  332. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  333. crossAxisAlignment: CrossAxisAlignment.start,
  334. ),
  335. ),
  336. ),
  337. ],
  338. ),
  339. );
  340. } else if (widget.orderType == orderTypeAnnualFee) {
  341. //平台年费
  342. return Container(
  343. margin: EdgeInsets.symmetric(horizontal: 12),
  344. child: Row(
  345. children: [
  346. Container(
  347. child: Image.asset(
  348. 'images/app_logo.png',
  349. height: 45,
  350. width: 45,
  351. ),
  352. margin: EdgeInsets.only(right: 8),
  353. height: 60,
  354. width: 60,
  355. decoration: BoxDecoration(
  356. border: Border.all(color: MyColors.cEBEBEB, width: 1)),
  357. alignment: Alignment.center,
  358. ),
  359. Expanded(
  360. child: Container(
  361. height: 60,
  362. child: Column(
  363. children: [
  364. MyViews().myText('平台年费', MyColors.c333333, 13),
  365. Row(
  366. children: [
  367. MyViews()
  368. .myText('¥${widget.amount}', MyColors.cFF4233, 12),
  369. MyViews().myText(
  370. 'x${widget.commodityCount}', MyColors.c999999, 12),
  371. ],
  372. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  373. )
  374. ],
  375. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  376. crossAxisAlignment: CrossAxisAlignment.start,
  377. ),
  378. ),
  379. ),
  380. ],
  381. ),
  382. );
  383. } else if (widget.orderType == orderTypeAdvertise) {
  384. //平台广告订单
  385. return Container(
  386. margin: EdgeInsets.symmetric(horizontal: 12),
  387. child: Row(
  388. children: [
  389. Container(
  390. child: SvgPicture.asset(
  391. 'images/svg/平台广告.svg',
  392. height: 45,
  393. width: 45,
  394. ),
  395. margin: EdgeInsets.only(right: 8),
  396. height: 60,
  397. width: 60,
  398. decoration: BoxDecoration(
  399. border: Border.all(color: MyColors.cEBEBEB, width: 1)),
  400. alignment: Alignment.center,
  401. ),
  402. Expanded(
  403. child: Container(
  404. height: 60,
  405. child: Column(
  406. children: [
  407. MyViews().myText('广告费', MyColors.c333333, 13),
  408. Row(
  409. children: [
  410. MyViews()
  411. .myText('¥${widget.amount}', MyColors.cFF4233, 12),
  412. MyViews().myText(
  413. 'x${widget.commodityCount}', MyColors.c999999, 12),
  414. ],
  415. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  416. )
  417. ],
  418. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  419. crossAxisAlignment: CrossAxisAlignment.start,
  420. ),
  421. ),
  422. ),
  423. ],
  424. ),
  425. );
  426. } else if (widget.orderType == orderTypeCommodity) {
  427. //商品订单
  428. return Container(
  429. margin: EdgeInsets.only(left: 10, right: 10),
  430. child: Row(
  431. children: [
  432. MyViews().netImg(imgURL(widget.commodityCover), 60, 60,
  433. placeholder: 'images/svg/goodsDefImg.svg'),
  434. Expanded(
  435. child: Container(
  436. padding: EdgeInsets.only(left: 8),
  437. height: 60,
  438. child: Column(
  439. children: [
  440. Text(
  441. '${widget.commodityTitle}',
  442. style: TextStyle(color: MyColors.c333333, fontSize: 13),
  443. maxLines: 2,
  444. overflow: TextOverflow.ellipsis,
  445. softWrap: true,
  446. ),
  447. Row(
  448. children: [
  449. Text(
  450. '¥${double.parse('${widget.amount}').toStringAsFixed(2)}',
  451. style:
  452. TextStyle(color: MyColors.cFF4233, fontSize: 12),
  453. ),
  454. Text(
  455. 'x${widget.commodityCount}',
  456. style:
  457. TextStyle(color: MyColors.c999999, fontSize: 12),
  458. ),
  459. ],
  460. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  461. crossAxisAlignment: CrossAxisAlignment.start,
  462. ),
  463. ],
  464. crossAxisAlignment: CrossAxisAlignment.start,
  465. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  466. ),
  467. ),
  468. )
  469. ],
  470. ),
  471. );
  472. } else if (widget.orderType == orderTypeVirtualProduct) {
  473. //虚拟物品
  474. return Container(
  475. margin: EdgeInsets.only(left: 10, right: 10),
  476. child: Row(
  477. children: [
  478. Container(
  479. child: SvgPicture.asset(
  480. 'images/svg/虚拟物品.svg',
  481. height: 45,
  482. width: 45,
  483. ),
  484. margin: EdgeInsets.only(right: 8),
  485. height: 60,
  486. width: 60,
  487. decoration: BoxDecoration(
  488. border: Border.all(color: MyColors.cEBEBEB, width: 1)),
  489. alignment: Alignment.center,
  490. ),
  491. Expanded(
  492. child: Container(
  493. padding: EdgeInsets.only(left: 8),
  494. height: 60,
  495. child: Column(
  496. children: [
  497. Text(
  498. '虚拟道具',
  499. style: TextStyle(color: MyColors.c333333, fontSize: 13),
  500. maxLines: 2,
  501. overflow: TextOverflow.ellipsis,
  502. softWrap: true,
  503. ),
  504. Row(
  505. children: [
  506. Text(
  507. '¥${double.parse('${widget.amount}').toStringAsFixed(2)}',
  508. style:
  509. TextStyle(color: MyColors.cFF4233, fontSize: 12),
  510. ),
  511. Text(
  512. 'x${widget.commodityCount}',
  513. style:
  514. TextStyle(color: MyColors.c999999, fontSize: 12),
  515. ),
  516. ],
  517. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  518. crossAxisAlignment: CrossAxisAlignment.start,
  519. ),
  520. ],
  521. crossAxisAlignment: CrossAxisAlignment.start,
  522. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  523. ),
  524. ),
  525. )
  526. ],
  527. ),
  528. );
  529. } else if (widget.orderType == orderTypeOfflineTransfer) {
  530. //线下付款
  531. return Container(
  532. margin: EdgeInsets.only(left: 10, right: 10),
  533. child: Row(
  534. children: [
  535. Container(
  536. child: SvgPicture.asset(
  537. 'images/svg/线下付款.svg',
  538. height: 45,
  539. width: 45,
  540. ),
  541. margin: EdgeInsets.only(right: 8),
  542. height: 60,
  543. width: 60,
  544. decoration: BoxDecoration(
  545. border: Border.all(color: MyColors.cEBEBEB, width: 1)),
  546. alignment: Alignment.center,
  547. ),
  548. Expanded(
  549. child: Container(
  550. padding: EdgeInsets.only(left: 8),
  551. height: 60,
  552. child: Column(
  553. children: [
  554. Text(
  555. '到店付款',
  556. style: TextStyle(color: MyColors.c333333, fontSize: 13),
  557. maxLines: 2,
  558. overflow: TextOverflow.ellipsis,
  559. softWrap: true,
  560. ),
  561. Row(
  562. children: [
  563. Text(
  564. '¥${double.parse('${widget.amount}').toStringAsFixed(2)}',
  565. style:
  566. TextStyle(color: MyColors.cFF4233, fontSize: 12),
  567. ),
  568. Text(
  569. 'x${widget.commodityCount}',
  570. style:
  571. TextStyle(color: MyColors.c999999, fontSize: 12),
  572. ),
  573. ],
  574. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  575. crossAxisAlignment: CrossAxisAlignment.start,
  576. ),
  577. ],
  578. crossAxisAlignment: CrossAxisAlignment.start,
  579. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  580. ),
  581. ),
  582. )
  583. ],
  584. ),
  585. );
  586. } else {
  587. return Container(
  588. margin: EdgeInsets.only(left: 10, right: 10),
  589. child: Row(
  590. children: [
  591. MyViews().netImg(imgURL(widget.commodityCover), 82, 84,
  592. placeholder: 'images/svg/goodsDefImg.svg'),
  593. Expanded(
  594. child: Container(
  595. padding: EdgeInsets.only(left: 8),
  596. height: 82,
  597. child: Column(
  598. children: [
  599. Text(
  600. '${widget.commodityTitle}',
  601. style: TextStyle(color: MyColors.c333333, fontSize: 13),
  602. maxLines: 2,
  603. overflow: TextOverflow.ellipsis,
  604. softWrap: true,
  605. ),
  606. Row(
  607. children: [
  608. Text(
  609. '¥${double.parse('${widget.amount}').toStringAsFixed(2)}',
  610. style:
  611. TextStyle(color: MyColors.cFF4233, fontSize: 12),
  612. ),
  613. Text(
  614. 'x${widget.commodityCount}',
  615. style:
  616. TextStyle(color: MyColors.c999999, fontSize: 12),
  617. ),
  618. ],
  619. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  620. crossAxisAlignment: CrossAxisAlignment.start,
  621. ),
  622. ],
  623. crossAxisAlignment: CrossAxisAlignment.start,
  624. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  625. ),
  626. ),
  627. )
  628. ],
  629. ),
  630. );
  631. }
  632. }
  633. void toPayPage() {
  634. MyTools().toPage(
  635. context,
  636. PayPage(widget.uid, widget.cancelOrder, widget.amount,
  637. payWay ? payWayAliPay : payWayWallet, couponData), (then) {
  638. if (then is int) {
  639. if (then == 1) {
  640. Navigator.pop(context,then);
  641. }
  642. }
  643. });
  644. }
  645. }
  646. class ChooseACoupon extends StatefulWidget {
  647. @override
  648. _ChooseACouponState createState() => _ChooseACouponState();
  649. }
  650. class _ChooseACouponState extends State<ChooseACoupon> {
  651. int page = 1;
  652. RefreshController controller = RefreshController(initialRefresh: true);
  653. List<MyCouponBeanDataData> coupons = [];
  654. @override
  655. void initState() {
  656. // TODO: implement initState
  657. super.initState();
  658. EventBus().on('showCouponIndex', (arg) {
  659. setState(() {});
  660. });
  661. }
  662. @override
  663. void dispose() {
  664. // TODO: implement dispose
  665. super.dispose();
  666. EventBus().off('showCouponIndex');
  667. }
  668. @override
  669. Widget build(BuildContext context) {
  670. return Scaffold(
  671. backgroundColor: MyColors.cF7F7F7,
  672. body: Column(
  673. children: [
  674. MyViews().myAppBar('优惠券', context, []),
  675. Expanded(
  676. child: SmartRefresher(
  677. controller: controller,
  678. onRefresh: onRefresh,
  679. onLoading: onLoading,
  680. enablePullUp: true,
  681. enablePullDown: true,
  682. child: coupons.length == 0
  683. ? SingleChildScrollView(child: noData())
  684. : ListView.builder(
  685. itemBuilder: (c, index) {
  686. return GestureDetector(
  687. onTap: () {
  688. Navigator.pop(context, coupons[index]);
  689. },
  690. behavior: HitTestBehavior.translucent,
  691. child: CouponView().ticketItem(coupons[index]),
  692. );
  693. },
  694. itemCount: coupons.length,
  695. padding: EdgeInsets.only(
  696. top: 5, left: 24, right: 24, bottom: 20),
  697. ),
  698. ),
  699. ),
  700. ],
  701. ),
  702. );
  703. }
  704. void onRefresh() {
  705. page = 1;
  706. checkCoupons();
  707. }
  708. void onLoading() {
  709. page++;
  710. checkCoupons();
  711. }
  712. checkCoupons() {
  713. MyDio().query({
  714. "key": "coupon",
  715. "filters": {
  716. "conditions": ["user_uid==${MyCookie().getUID()}", "used == false"]
  717. },
  718. "dims": couponDims,
  719. "paging": [page, 20]
  720. }, (response, hasError) {
  721. if (!hasError) {
  722. MyCouponBeanEntity entity = MyCouponBeanEntity()
  723. .fromJson(json.decode(response.data.toString()));
  724. if (page == 1) {
  725. coupons.clear();
  726. }
  727. coupons.addAll(entity.data.data);
  728. setState(() {});
  729. }
  730. endRe(controller);
  731. }, (error) {
  732. endRe(controller);
  733. });
  734. }
  735. }