| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- import 'package:bbyyy/my_tools/event_bus.dart';
- import 'package:bbyyy/my_tools/my_colors.dart';
- import 'package:bbyyy/my_tools/my_views.dart';
- import 'package:bbyyy/paegs/mine_page/coupon_page/coupon_view.dart';
- import 'package:flutter/material.dart';
- import 'package:pull_to_refresh/pull_to_refresh.dart';
- import '../../../https/MyDio.dart';
- import '../../../my_tools/dims.dart';
- import '../../../my_tools/my_cookie.dart';
- import '../../../my_tools/my_tools.dart';
- class CouponPage extends StatefulWidget {
- @override
- _CouponPageState createState() => _CouponPageState();
- }
- class _CouponPageState extends State<CouponPage> {
- // int selectedIndex = 0;
- int page = 1;
- RefreshController controller = RefreshController(initialRefresh: true);
- @override
- void initState() {
- // TODO: implement initState
- super.initState();
- EventBus().on('showCouponIndex', (arg) {
- setState(() {
- });
- });
- }
- @override
- void dispose() {
- // TODO: implement dispose
- super.dispose();
- CouponView().showIndexs.clear();
- EventBus().off('showCouponIndex');
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- backgroundColor: MyColors.cF7F7F7,
- body: Column(
- children: [
- MyViews().myAppBar('优惠券', context, []),
- // Container(
- // height: 40,
- // color: Colors.white,
- // child: Row(
- // children: [
- // GestureDetector(
- // onTap: () {
- // setState(() {
- // selectedIndex = 0;
- // });
- // },
- // behavior: HitTestBehavior.translucent,
- // child: Padding(
- // padding: EdgeInsets.only(left: 10, right: 10),
- // child: Column(
- // children: [
- // Text(
- // '有效',
- // style: TextStyle(
- // color: selectedIndex == 0
- // ? MyColors.cFF4233
- // : MyColors.c666666,
- // fontSize: 15),
- // ),
- // Container(
- // height: 10,
- // child: Visibility(
- // child: SvgPicture.asset('images/svg/tab.svg'),
- // visible: selectedIndex == 0,
- // ),
- // )
- // ],
- // mainAxisAlignment: MainAxisAlignment.end,
- // ),
- // ),
- // ),
- // GestureDetector(
- // onTap: () {
- // setState(() {
- // selectedIndex = 1;
- // });
- // },
- // behavior: HitTestBehavior.translucent,
- // child: Padding(
- // padding: EdgeInsets.only(left: 10, right: 10),
- // child: Column(
- // children: [
- // Text(
- // '已用',
- // style: TextStyle(
- // color: selectedIndex == 1
- // ? MyColors.cFF4233
- // : MyColors.c666666,
- // fontSize: 15),
- // ),
- // Container(
- // height: 10,
- // child: Visibility(
- // child: SvgPicture.asset('images/svg/tab.svg'),
- // visible: selectedIndex == 1,
- // ),
- // )
- // ],
- // mainAxisAlignment: MainAxisAlignment.end,
- // ),
- // ),
- // )
- // ],
- // mainAxisAlignment: MainAxisAlignment.spaceAround,
- // ),
- // ),
- Expanded(
- child: SmartRefresher(
- controller: controller,
- onRefresh: onRefresh,
- onLoading: onLoading,
- enablePullUp: true,
- enablePullDown: true,
- child: ListView.builder(
- itemBuilder: (c, index) {
- return CouponView().ticketItem(index);
- },
- itemCount: 20,
- 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()}"]
- }
- ],
- "dims": couponDims,
- "paging": [page, 20]
- }, (response, hasError) {
- endRe(controller);
- }, (error) {
- endRe(controller);
- });
- }
- }
|