123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494 |
- import 'dart:async';
- import 'package:flutter/material.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:liftmanager/internal/bbs/model/coupon_model_page.dart';
- import 'package:liftmanager/internal/search/presenter/base_list_provider.dart';
- import 'package:liftmanager/internal/wode/presenter/red_list_presenter.dart';
- import 'package:liftmanager/mvp/base_page_state.dart';
- import 'package:liftmanager/utils/time_format.dart';
- import 'package:liftmanager/widgets/app_bar.dart';
- import 'package:liftmanager/widgets/load_image.dart';
- import 'package:liftmanager/widgets/my_refresh_list.dart';
- import 'package:liftmanager/widgets/state_layout.dart';
- // import 'package:amap_all_fluttify/amap_all_fluttify.dart';
- import 'package:provider/provider.dart';
- class CouponPage extends StatefulWidget {
- @override
- CouponPageState createState() => CouponPageState();
- }
- class CouponPageState extends BasePageState<CouponPage, CoupontListPresenter>
- with AutomaticKeepAliveClientMixin {
- static const staticList = [
- {
- "price": "5",
- "time": "2019-12-30",
- },
- {
- "price": "5",
- "time": "2019-12-30",
- },
- {
- "price": "5",
- "time": "2019-12-30",
- },
- {
- "price": "5",
- "time": "2019-12-30",
- },
- {
- "price": "5",
- "time": "2019-12-30",
- },
- {
- "price": "5",
- "time": "2019-12-30",
- },
- {
- "price": "5",
- "time": "2019-12-30",
- },
- {
- "price": "5",
- "time": "2019-12-30",
- },
- {
- "price": "5",
- "time": "2019-12-30",
- },
- ];
- int checkIndex = 0;
- // NewsDetailItem item = NewsDetailItem();
- BaseListProvider<Records> provider = BaseListProvider<Records>();
- int usedFlag = 1; //0失效1可使用
- int _page = 1;
- ScrollController _scrollController = new ScrollController();
- @override
- CoupontListPresenter createPresenter() {
- return CoupontListPresenter();
- }
- @override
- void dispose() {
- _scrollController.dispose();
- super.dispose();
- }
- @override
- void initState() {
- provider.setStateTypeNotNotify(StateType.loading);
- super.initState();
- _onRefresh();
- print(66666);
- }
- // getScenario(int type) {
- // String str;
- // if (type == 0) {
- // str = "全场通用";
- // } else if (type == 1) {
- // str = "仅限出诊问诊服务";
- // } else if (type == 2) {
- // str = "仅限题库";
- // } else if (type == 3) {
- // str = "仅限视频";
- // }
- // return str;
- // }
- getScenario(int type) {
- String str;
- if (type == 0) {
- str = "全场通用";
- } else if (type == 1) {
- str = "出诊问诊服务";
- } else if (type == 2) {
- str = "题库";
- } else if (type == 3) {
- str = "视频";
- }
- return str;
- }
- Future _onRefresh() async {
- _page = 1;
- await presenter.getRedList(_page, usedFlag);
- }
- Future _loadMore() async {
- _page++;
- await presenter.getRedList(_page, usedFlag);
- }
- bool get wantKeepAlive => true;
- @override
- Widget build(BuildContext context) {
- double width = MediaQuery.of(context).size.width;
- return ChangeNotifierProvider<BaseListProvider<Records>>(
- create: (_) => provider,
- child: Scaffold(
- resizeToAvoidBottomPadding: true,
- appBar: MyAppBar(centerTitle: "我的优惠券"),
- body: Container(
- // color: Color(0xFFF1F4FC),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Container(
- padding: EdgeInsets.only(bottom: 5),
- // color:Color(0xffFAF7FA),
- decoration: BoxDecoration(
- border: Border(
- bottom:
- BorderSide(width: 0.5, color: Color(0xffeeeeee)),
- ),
- // color: Color(0xff9FD1FE),
- ),
- child: Row(children: <Widget>[
- Container(
- width: width / 2,
- padding: EdgeInsets.only(top: 10),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- GestureDetector(
- onTap: () {
- print(6663);
- provider.list.clear();
- setState(() {
- checkIndex = 0;
- usedFlag = 1;
- });
- _onRefresh();
- },
- child: Container(
- padding: EdgeInsets.only(bottom: 6),
- decoration: BoxDecoration(
- border: Border(
- bottom: BorderSide(
- width: 2,
- color: checkIndex == 0
- ? Color(0xff02A0FD)
- : Colors.white),
- ),
- // color: Color(0xff9FD1FE),
- ),
- child: Text(
- '可使用',
- style: TextStyle(
- color: checkIndex == 0
- ? Color(0xff02A0FD)
- : Color(0xff666666),
- // fontSize:ScreenUtil().setSp(14)
- ),
- textAlign: TextAlign.center,
- ),
- ))
- ])),
- Container(
- width: width / 2,
- padding:
- EdgeInsets.only(top: ScreenUtil().setWidth(10)),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- GestureDetector(
- onTap: () {
- // Provider.of<BaseListProvider<Records>>(context,listen: false).list.clear();
- provider.list.clear();
- setState(() {
- checkIndex = 1;
- usedFlag = 0;
- });
- _onRefresh();
- },
- child: Container(
- padding: EdgeInsets.only(bottom: 6),
- decoration: BoxDecoration(
- border: Border(
- bottom: BorderSide(
- width: 2,
- color: checkIndex == 1
- ? Color(0xff02A0FD)
- : Colors.transparent),
- ),
- ),
- child: Text(
- '已失效',
- style: TextStyle(
- color: checkIndex == 1
- ? Color(0xff02A0FD)
- : Color(0xff666666),
- // fontSize:ScreenUtil().setSp(14)
- ),
- textAlign: TextAlign.center,
- ),
- ))
- ])),
- ])),
- Expanded(
- flex: 1,
- child: Consumer<BaseListProvider<Records>>(
- builder: (_, provider, __) {
- return MyListView(
- key: Key('coupon_list'),
- itemCount: provider.list.length,
- stateType: provider.stateType,
- onRefresh: _onRefresh,
- loadMore: _loadMore,
- pageSize: 8,
- hasMore: provider.hasMore,
- itemBuilder: (_, index) {
- return Container(
- child: Column(
- children: <Widget>[
- Container(
- child: Row(children: <Widget>[
- Container(
- padding: EdgeInsets.only(
- top: 10,
- ),
- child: Stack(
- children: <Widget>[
- Positioned(
- top: 0,
- left: -10,
- // right: -30,
- child: Container(
- width: width + 10,
- height: 122,
- child: LoadAssetImage(
- // image: AssetImage(i['img']),
- checkIndex == 0
- ? "wode/bg_front"
- : "wode/bg_back",
- fit: BoxFit.fill,
- // alignment: Alignment.centerLeft,
- ),
- )),
- Container(
- // decoration: BoxDecoration(
- // border:Border.all(
- // width:2,
- // color:Colors.red
- // )
- // ),
- width: width,
- height: 120,
- child: Row(
- children: <Widget>[
- Container(
- padding: EdgeInsets.only(
- right: 10, left: 15),
- child: Column(
- crossAxisAlignment:
- CrossAxisAlignment
- .start,
- mainAxisAlignment:
- MainAxisAlignment
- .center,
- children: <Widget>[
- Container(
- width: 120,
- child: Row(
- crossAxisAlignment:
- CrossAxisAlignment
- .end,
- mainAxisAlignment:
- MainAxisAlignment
- .center,
- children: <Widget>[
- Text(
- '¥',
- textAlign:
- TextAlign
- .center,
- style: TextStyle(
- fontSize: ScreenUtil()
- .setSp(
- 16),
- color: Colors
- .white),
- ),
- Text(
- // '999.0',
- provider
- .list[index]
- .coupon
- ?.discount
- ?.toString(),
- textAlign:
- TextAlign
- .left,
- style: TextStyle(
- fontSize: ScreenUtil()
- .setSp(
- 28),
- color: Colors
- .white,
- fontWeight:
- FontWeight
- .bold),
- ),
- SizedBox(
- width: 10,
- )
- ],
- ),
- ),
- Container(
- margin:
- EdgeInsets.only(
- left: 30),
- padding: EdgeInsets
- .fromLTRB(
- 5, 1, 5, 1),
- child: Text(
- // getScenario(provider
- // .list[index]
- // .coupon
- // ?.scenario ??
- // 0),
- '代金劵',
- textAlign: TextAlign
- .center,
- style: TextStyle(
- fontSize:
- ScreenUtil()
- .setSp(
- 11),
- color: Colors
- .white),
- ),
- decoration:
- new BoxDecoration(
- //背景
- // color: Colors.white,
- //设置四周圆角 角度
- borderRadius:
- BorderRadius
- .all(Radius
- .circular(
- 4.0)),
- //设置四周边框
- border: Border.all(
- width: 1,
- color: Colors
- .white),
- ),
- ),
- ]),
- ),
- Container(
- padding: EdgeInsets.only(
- top: 30),
- child: Column(
- crossAxisAlignment:
- CrossAxisAlignment
- .start,
- children: <Widget>[
- Text(
- '${getScenario(provider.list[index].coupon?.scenario ?? 0)}${provider.list[index].coupon?.name ?? ""}',
- textAlign:
- TextAlign.left,
- style: TextStyle(
- fontSize:
- ScreenUtil()
- .setSp(
- 17),
- color: Color(
- 0xff333333),
- ),
- ),
- Text(
- '有效时间: ' +
- DateUtils.instance.getFormartData(
- timeSamp: provider
- .list[
- index]
- .coupon
- ?.validity,
- format:
- "yyyy.MM.dd HH:mm"),
- textAlign:
- TextAlign.left,
- style: TextStyle(
- fontSize:
- ScreenUtil()
- .setSp(
- 13),
- color: Color(
- 0xff9F9C9F),
- ),
- ),
- SizedBox(height: 20),
- Container(
- width: width * 0.5,
- height: 0.5,
- color: Color(
- 0xffeeeeee),
- child: null,
- ),
- SizedBox(height: 3),
- Text(
- provider
- .list[index]
- .coupon
- ?.remark ??
- "",
- textAlign:
- TextAlign.left,
- style: TextStyle(
- fontSize:
- ScreenUtil()
- .setSp(
- 13),
- color: Color(
- 0xff9F9C9F),
- ),
- ),
- ])),
- ],
- )),
- // Positioned(
- // top: 0,
- // right: 5,
- // child: checkIndex == 1
- // ? Container(
- // child: Icon(
- // const IconData(0xe6d9,
- // fontFamily: "myfont"),
- // size: 50.0,
- // color: Color(0xff999999),
- // ),
- // )
- // : Container(child: null))
- ],
- ),
- ),
- Container()
- ]))
- ],
- ),
- );
- },
- );
- }))
- ],
- ),
- ),
- ));
- }
- }
|