| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884 |
- import 'dart:convert';
- import 'package:bbyyy/beans/my_coupon_bean_entity.dart';
- import 'package:bbyyy/beans/pay_way_bean_entity.dart';
- import 'package:bbyyy/beans/user_balance_entity.dart';
- import 'package:bbyyy/https/MyDio.dart';
- import 'package:bbyyy/https/url.dart';
- import 'package:bbyyy/my_tools/const.dart';
- import 'package:bbyyy/my_tools/dims.dart';
- import 'package:bbyyy/my_tools/easy_loading/easy_loading.dart';
- import 'package:bbyyy/my_tools/event_bus.dart';
- import 'package:bbyyy/my_tools/my_colors.dart';
- import 'package:bbyyy/my_tools/my_cookie.dart';
- import 'package:bbyyy/my_tools/my_tools.dart';
- import 'package:bbyyy/my_tools/my_views.dart';
- import 'package:bbyyy/paegs/mine_page/coupon_page/coupon_view.dart';
- import 'package:bbyyy/paegs/pay_page/pay_page.dart';
- import 'package:bbyyy/pay/pay_tools.dart';
- import 'package:flustars/flustars.dart';
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter_svg/svg.dart';
- import 'package:pull_to_refresh/pull_to_refresh.dart';
- class OrderInformationPage extends StatefulWidget {
- int orderType;
- double amount;
- int uid;
- String sellName;
- int sellUid;
- String sellPic;
- String buyerName;
- int buyerUid;
- String buyerPic;
- int commodityCount;
- String commodityCover;
- String commodityTitle;
- bool cancelOrder;
- double discountAmount;
- OrderInformationPage(this.cancelOrder,
- {this.orderType,
- this.sellName,
- this.sellPic,
- this.sellUid,
- this.amount,
- this.buyerName,
- this.uid,
- this.buyerUid,
- this.buyerPic,
- this.commodityCover,
- this.commodityTitle,
- this.commodityCount,
- this.discountAmount=0.0});
- @override
- _OrderInformationPageState createState() => _OrderInformationPageState();
- }
- class _OrderInformationPageState extends State<OrderInformationPage> {
- int payWay = 0; //0; //钱包 1; //支付宝支付 2; //微信支付
- List<PayWayBeanData> payWays;
- String coupon = '未选择优惠券';
- MyCouponBeanDataData couponData;
- double balance = 0.0;
- @override
- void initState() {
- // TODO: implement initState
- super.initState();
- Future.delayed(Duration.zero, () {
- EasyLoading.show();
- checkPaymentMethod((response, hasError) {
- if (!hasError) {
- PayWayBeanEntity entity =
- PayWayBeanEntity().fromJson(json.decode(response.toString()));
- payWays = entity.data;
- getUserWalletBalance((re, hE) {
- if (!hE) {
- UserBalanceEntity balance =
- UserBalanceEntity().fromJson(json.decode(re.data.toString()));
- MyCookie().balance = balance.data;
- this.balance = balanceDisplay(balance.data);
- if (widget.amount > balance.data) {
- payWays.forEach((element) {
- if (payWay == 0) {
- if (element.pay) {
- payWay = element.way;
- }
- }
- });
- }
- EasyLoading.dismiss();
- setState(() {});
- }
- }, (e) {
- EasyLoading.dismiss();
- }, context);
- }
- }, (error) {
- EasyLoading.dismiss();
- });
- });
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- backgroundColor: MyColors.cEFEFEF,
- body: Column(
- children: [
- MyViews().myAppBar('订单信息', context, []),
- Container(
- height: 10,
- color: MyColors.cEFEFEF,
- ),
- Expanded(
- child: SingleChildScrollView(
- child: Column(
- children: [
- Container(
- child: orderInformation(),
- color: Colors.white,
- padding: EdgeInsets.symmetric(vertical: 10),
- ),
- Container(
- height: 10,
- color: MyColors.cEFEFEF,
- ),
- Container(
- color: Colors.white,
- child: Row(
- children: [
- MyViews().myText('支付方式', MyColors.c333333, 14),
- GestureDetector(
- onTap: () {
- showPayWayPicker();
- },
- behavior: HitTestBehavior.translucent,
- child: Row(
- children: [
- SvgPicture.asset(
- payWayIcon(payWay),
- width: 20,
- height: 20,
- ),
- Container(
- child: MyViews().myText(
- payWayText(payWay), MyColors.c333333, 13),
- margin: EdgeInsets.only(left: 6, right: 6),
- ),
- SvgPicture.asset(
- 'images/svg/箭头.svg',
- color: MyColors.c999999,
- width: 6,
- height: 11,
- ),
- ],
- ),
- )
- ],
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- ),
- alignment: Alignment.centerLeft,
- padding: EdgeInsets.all(10),
- ),
- Container(
- height: 10,
- color: MyColors.cEFEFEF,
- ),
- Container(
- color: Colors.white,
- child: Row(
- children: [
- MyViews().myText('优惠券', MyColors.c333333, 16),
- GestureDetector(
- onTap: () {
- MyTools().toPage(context, ChooseACoupon(), (then) {
- if (then is MyCouponBeanDataData) {
- couponData = then;
- coupon = couponType(couponData.type) +
- ': ${couponData.amount}元';
- setState(() {});
- }
- });
- },
- behavior: HitTestBehavior.translucent,
- child: Row(
- children: [
- Container(
- child: MyViews()
- .myText(coupon, MyColors.c333333, 13),
- margin: EdgeInsets.only(left: 6, right: 6),
- ),
- SvgPicture.asset(
- 'images/svg/箭头.svg',
- color: MyColors.c999999,
- width: 6,
- height: 11,
- ),
- ],
- ),
- )
- ],
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- ),
- alignment: Alignment.centerLeft,
- padding: EdgeInsets.all(10),
- ),
- if(widget.discountAmount!=null&&widget.discountAmount!=0)
- Container(
- height: 10,
- color: MyColors.cEFEFEF,
- ),
- if(widget.discountAmount!=null&&widget.discountAmount!=0)
- Container(
- color: Colors.white,
- child: Row(
- children: [
- MyViews().myText('店铺折扣', MyColors.c333333, 16),
- Row(
- children: [
- Container(
- child: MyViews().myText(
- widget.discountAmount.toStringAsFixed(2),
- MyColors.c333333,
- 13),
- margin: EdgeInsets.only(left: 6, right: 6),
- ),
- ],
- )
- ],
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- ),
- alignment: Alignment.centerLeft,
- padding: EdgeInsets.all(10),
- ),
- ],
- ),
- ),
- ),
- Container(
- color: Colors.white,
- child: SafeArea(
- top: false,
- child: Container(
- color: Colors.white,
- padding: EdgeInsets.only(right: 10, left: 10),
- height: 60,
- child: Row(
- children: [
- Row(
- children: [
- MyViews().myText('合计:', MyColors.c333333, 16),
- MyViews().myText(
- '¥${couponData == null ? NumUtil.subtract(widget.amount, widget.discountAmount).toStringAsFixed(2) : NumUtil.subtract(widget.amount, couponData.amount) < 0 ? 0.0.toStringAsFixed(2) : NumUtil.subtract(widget.amount, couponData.amount).toStringAsFixed(2)}',
- MyColors.cFF4233,
- 18),
- ],
- ),
- Expanded(
- child: Row(
- children: [
- GestureDetector(
- onTap: () {
- toPayPage();
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(20),
- color: MyColors.cFF4233),
- height: 40,
- width: 160,
- child:
- MyViews().myText('确 认', Colors.white, 14),
- alignment: Alignment.center),
- )
- ],
- mainAxisAlignment: MainAxisAlignment.end,
- ),
- )
- ],
- ),
- ),
- ),
- )
- ],
- ),
- );
- }
- Widget orderInformation() {
- if (widget.orderType == orderTypeThirdPlatform) {
- //第三方平台订单
- return Container(
- margin: EdgeInsets.symmetric(horizontal: 12),
- child: Row(
- children: [
- Container(
- child: SvgPicture.asset(
- 'images/svg/第三方.svg',
- height: 45,
- width: 45,
- ),
- margin: EdgeInsets.only(right: 8),
- height: 60,
- width: 60,
- decoration: BoxDecoration(
- border: Border.all(color: MyColors.cEBEBEB, width: 1)),
- alignment: Alignment.center,
- ),
- Expanded(
- child: Container(
- height: 60,
- child: Column(
- children: [
- MyViews()
- .myText('第三方订单(${widget.uid})', MyColors.c333333, 13),
- Row(
- children: [
- MyViews()
- .myText('¥${widget.amount}', MyColors.cFF4233, 12),
- MyViews().myText(
- 'x${widget.commodityCount}', MyColors.c999999, 12),
- ],
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- )
- ],
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- crossAxisAlignment: CrossAxisAlignment.start,
- ),
- ),
- ),
- ],
- ),
- );
- } else if (widget.orderType == orderTypeAnnualFee) {
- //平台年费
- return Container(
- margin: EdgeInsets.symmetric(horizontal: 12),
- child: Row(
- children: [
- Container(
- child: Image.asset(
- 'images/app_logo.png',
- height: 45,
- width: 45,
- ),
- margin: EdgeInsets.only(right: 8),
- height: 60,
- width: 60,
- decoration: BoxDecoration(
- border: Border.all(color: MyColors.cEBEBEB, width: 1)),
- alignment: Alignment.center,
- ),
- Expanded(
- child: Container(
- height: 60,
- child: Column(
- children: [
- MyViews().myText('平台服务费', MyColors.c333333, 13),
- Row(
- children: [
- MyViews()
- .myText('¥${widget.amount}', MyColors.cFF4233, 12),
- MyViews().myText(
- 'x${widget.commodityCount}', MyColors.c999999, 12),
- ],
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- )
- ],
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- crossAxisAlignment: CrossAxisAlignment.start,
- ),
- ),
- ),
- ],
- ),
- );
- } else if (widget.orderType == orderTypeAdvertise) {
- //平台广告订单
- return Container(
- margin: EdgeInsets.symmetric(horizontal: 12),
- child: Row(
- children: [
- Container(
- child: SvgPicture.asset(
- 'images/svg/平台广告.svg',
- height: 45,
- width: 45,
- ),
- margin: EdgeInsets.only(right: 8),
- height: 60,
- width: 60,
- decoration: BoxDecoration(
- border: Border.all(color: MyColors.cEBEBEB, width: 1)),
- alignment: Alignment.center,
- ),
- Expanded(
- child: Container(
- height: 60,
- child: Column(
- children: [
- MyViews().myText('广告费', MyColors.c333333, 13),
- Row(
- children: [
- MyViews()
- .myText('¥${widget.amount}', MyColors.cFF4233, 12),
- MyViews().myText(
- 'x${widget.commodityCount}', MyColors.c999999, 12),
- ],
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- )
- ],
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- crossAxisAlignment: CrossAxisAlignment.start,
- ),
- ),
- ),
- ],
- ),
- );
- } else if (widget.orderType == orderTypeCommodity) {
- //商品订单
- return Container(
- margin: EdgeInsets.only(left: 10, right: 10),
- child: Row(
- children: [
- MyViews().netImg(imgURL(widget.commodityCover), 60, 60,
- placeholder: 'images/svg/goodsDefImg.svg'),
- Expanded(
- child: Container(
- padding: EdgeInsets.only(left: 8),
- height: 60,
- child: Column(
- children: [
- Text(
- '${widget.commodityTitle}',
- style: TextStyle(color: MyColors.c333333, fontSize: 13),
- maxLines: 2,
- overflow: TextOverflow.ellipsis,
- softWrap: true,
- ),
- Row(
- children: [
- Text(
- '¥${double.parse('${widget.amount}').toStringAsFixed(2)}',
- style:
- TextStyle(color: MyColors.cFF4233, fontSize: 12),
- ),
- Text(
- 'x${widget.commodityCount}',
- style:
- TextStyle(color: MyColors.c999999, fontSize: 12),
- ),
- ],
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- crossAxisAlignment: CrossAxisAlignment.start,
- ),
- ],
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- ),
- ),
- )
- ],
- ),
- );
- } else if (widget.orderType == orderTypeVirtualProduct) {
- //虚拟物品
- return Container(
- margin: EdgeInsets.only(left: 10, right: 10),
- child: Row(
- children: [
- Container(
- child: SvgPicture.asset(
- 'images/svg/虚拟物品.svg',
- height: 45,
- width: 45,
- ),
- margin: EdgeInsets.only(right: 8),
- height: 60,
- width: 60,
- decoration: BoxDecoration(
- border: Border.all(color: MyColors.cEBEBEB, width: 1)),
- alignment: Alignment.center,
- ),
- Expanded(
- child: Container(
- padding: EdgeInsets.only(left: 8),
- height: 60,
- child: Column(
- children: [
- Text(
- '虚拟道具',
- style: TextStyle(color: MyColors.c333333, fontSize: 13),
- maxLines: 2,
- overflow: TextOverflow.ellipsis,
- softWrap: true,
- ),
- Row(
- children: [
- Text(
- '¥${double.parse('${widget.amount}').toStringAsFixed(2)}',
- style:
- TextStyle(color: MyColors.cFF4233, fontSize: 12),
- ),
- Text(
- 'x${widget.commodityCount}',
- style:
- TextStyle(color: MyColors.c999999, fontSize: 12),
- ),
- ],
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- crossAxisAlignment: CrossAxisAlignment.start,
- ),
- ],
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- ),
- ),
- )
- ],
- ),
- );
- } else if (widget.orderType == orderTypeOfflineTransfer) {
- //线下付款
- return Container(
- margin: EdgeInsets.only(left: 10, right: 10),
- child: Row(
- children: [
- Container(
- child: SvgPicture.asset(
- 'images/svg/线下付款.svg',
- height: 45,
- width: 45,
- ),
- margin: EdgeInsets.only(right: 8),
- height: 60,
- width: 60,
- decoration: BoxDecoration(
- border: Border.all(color: MyColors.cEBEBEB, width: 1)),
- alignment: Alignment.center,
- ),
- Expanded(
- child: Container(
- padding: EdgeInsets.only(left: 8),
- height: 60,
- child: Column(
- children: [
- Text(
- '到店付款',
- style: TextStyle(color: MyColors.c333333, fontSize: 13),
- maxLines: 2,
- overflow: TextOverflow.ellipsis,
- softWrap: true,
- ),
- Row(
- children: [
- Text(
- '¥${double.parse('${widget.amount}').toStringAsFixed(2)}',
- style:
- TextStyle(color: MyColors.cFF4233, fontSize: 12),
- ),
- Text(
- 'x${widget.commodityCount}',
- style:
- TextStyle(color: MyColors.c999999, fontSize: 12),
- ),
- ],
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- crossAxisAlignment: CrossAxisAlignment.start,
- ),
- ],
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- ),
- ),
- )
- ],
- ),
- );
- } else {
- return Container(
- margin: EdgeInsets.only(left: 10, right: 10),
- child: Row(
- children: [
- MyViews().netImg(imgURL(widget.commodityCover), 82, 84,
- placeholder: 'images/svg/goodsDefImg.svg'),
- Expanded(
- child: Container(
- padding: EdgeInsets.only(left: 8),
- height: 82,
- child: Column(
- children: [
- Text(
- '${widget.commodityTitle}',
- style: TextStyle(color: MyColors.c333333, fontSize: 13),
- maxLines: 2,
- overflow: TextOverflow.ellipsis,
- softWrap: true,
- ),
- Row(
- children: [
- Text(
- '¥${double.parse('${widget.amount}').toStringAsFixed(2)}',
- style:
- TextStyle(color: MyColors.cFF4233, fontSize: 12),
- ),
- Text(
- 'x${widget.commodityCount}',
- style:
- TextStyle(color: MyColors.c999999, fontSize: 12),
- ),
- ],
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- crossAxisAlignment: CrossAxisAlignment.start,
- ),
- ],
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- ),
- ),
- )
- ],
- ),
- );
- }
- }
- void toPayPage() {
- MyTools().toPage(
- context,
- PayPage(
- widget.uid, widget.cancelOrder, widget.amount, payWay, couponData,widget.discountAmount),
- (then) {
- if (then is int) {
- if (then == 1) {
- Navigator.pop(context, then);
- }
- }
- });
- }
- String payWayIcon(int payWay) {
- switch (payWay) {
- case 1:
- return 'images/svg/支付宝.svg';
- case 2:
- return 'images/svg/微信.svg';
- case 0:
- return 'images/svg/积分支付.svg';
- default:
- return 'images/svg/支付宝.svg';
- }
- }
- String payWayText(int payWay) {
- switch (payWay) {
- case 1:
- return '支付宝';
- case 2:
- return '微信';
- case 0:
- return '积分支付';
- default:
- return '支付宝';
- }
- }
- void showPayWayPicker() {
- bool aliPay =
- payWays[payWays.indexWhere((element) => element.way == 1)].pay;
- bool weChat =
- payWays[payWays.indexWhere((element) => element.way == 2)].pay;
- showCupertinoModalPopup(
- context: context,
- builder: (BuildContext context) {
- return CupertinoActionSheet(
- title: MyViews().myText('选择支付方式', MyColors.c333333, 20),
- actions: [
- if (aliPay)
- CupertinoActionSheetAction(
- child: Row(
- children: [
- SvgPicture.asset(
- 'images/svg/支付宝.svg',
- width: 24,
- height: 24,
- ),
- Container(
- child: MyViews().myText(
- aliPay ? '支付宝支付' : '支付宝支付(暂不可用)',
- aliPay ? MyColors.c333333 : MyColors.cEFEFEF,
- 16),
- margin: EdgeInsets.only(left: 6, right: 6),
- ),
- ],
- mainAxisAlignment: MainAxisAlignment.center,
- ),
- onPressed: (() {
- if (aliPay) {
- payWay = 1;
- setState(() {});
- Navigator.pop(context, 'Edit');
- } else {
- showToast('支付宝支付暂不可用');
- }
- }),
- ),
- if (weChat)
- CupertinoActionSheetAction(
- child: Row(
- children: [
- SvgPicture.asset(
- 'images/svg/微信.svg',
- width: 24,
- height: 24,
- ),
- Container(
- child: MyViews().myText(weChat ? '微信支付' : '微信支付(暂不可用)',
- weChat ? MyColors.c333333 : MyColors.c999999, 16),
- margin: EdgeInsets.only(left: 6, right: 6),
- ),
- ],
- mainAxisAlignment: MainAxisAlignment.center,
- ),
- onPressed: (() {
- if (weChat) {
- payWay = 2;
- setState(() {});
- Navigator.pop(context, 'Edit');
- } else {
- showToast('微信支付暂不可用');
- }
- }),
- ),
- CupertinoActionSheetAction(
- child: Row(
- children: [
- SvgPicture.asset(
- 'images/svg/积分支付.svg',
- width: 24,
- height: 24,
- ),
- Container(
- child: MyViews().myText('积分支付', MyColors.c333333, 16),
- margin: EdgeInsets.only(left: 6, right: 6),
- ),
- Container(
- child: MyViews().myText(
- '当前积分${balanceDisplay(balance).toStringAsFixed(2)}',
- MyColors.cFF4233,
- 16),
- margin: EdgeInsets.only(left: 6, right: 6),
- ),
- ],
- mainAxisAlignment: MainAxisAlignment.center,
- ),
- onPressed: (() {
- payWay = 0;
- setState(() {});
- Navigator.pop(context, 'Edit');
- }),
- ),
- ],
- cancelButton: CupertinoActionSheetAction(
- child: Text("取消"),
- isDefaultAction: true,
- onPressed: (() {
- Navigator.pop(context, 'Cancel');
- }),
- ),
- );
- });
- }
- }
- class ChooseACoupon extends StatefulWidget {
- @override
- _ChooseACouponState createState() => _ChooseACouponState();
- }
- class _ChooseACouponState extends State<ChooseACoupon> {
- int page = 1;
- RefreshController controller = RefreshController(initialRefresh: true);
- List<MyCouponBeanDataData> coupons = [];
- @override
- void initState() {
- // TODO: implement initState
- super.initState();
- EventBus().on('showCouponIndex', (arg) {
- setState(() {});
- });
- }
- @override
- void dispose() {
- // TODO: implement dispose
- super.dispose();
- EventBus().off('showCouponIndex');
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- backgroundColor: MyColors.cF7F7F7,
- body: Column(
- children: [
- MyViews().myAppBar('优惠券', context, []),
- Expanded(
- child: SmartRefresher(
- controller: controller,
- onRefresh: onRefresh,
- onLoading: onLoading,
- enablePullUp: true,
- enablePullDown: true,
- child: coupons.length == 0
- ? SingleChildScrollView(child: noData())
- : ListView.builder(
- itemBuilder: (c, index) {
- return GestureDetector(
- onTap: () {
- Navigator.pop(context, coupons[index]);
- },
- behavior: HitTestBehavior.translucent,
- child: CouponView().ticketItem(coupons[index]),
- );
- },
- itemCount: coupons.length,
- padding: EdgeInsets.only(
- top: 5, left: 24, right: 24, bottom: 20),
- ),
- ),
- ),
- ],
- ),
- );
- }
- void onRefresh() {
- page = 1;
- checkCoupons();
- }
- void onLoading() {
- page++;
- checkCoupons();
- }
- checkCoupons() {
- MyDio().query({
- "key": "coupon",
- "filters": {
- "conditions": ["user_uid==${MyCookie().getUID()}", "used == false"]
- },
- "dims": couponDims,
- "paging": [page, 20]
- }, (response, hasError) {
- if (!hasError) {
- MyCouponBeanEntity entity = MyCouponBeanEntity()
- .fromJson(json.decode(response.data.toString()));
- if (page == 1) {
- coupons.clear();
- }
- coupons.addAll(entity.data.data);
- setState(() {});
- }
- endRe(controller);
- }, (error) {
- endRe(controller);
- });
- }
- }
|