From f88ce0040e42af1285c08b205aa2e817ac4d9b78 Mon Sep 17 00:00:00 2001 From: w-R <953969641@qq.com> Date: Thu, 8 Jul 2021 15:56:44 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/generated/intl/messages_en.dart | 3 +- lib/generated/l10n.dart | 18 +- lib/l10n/intl_en.arb | 4 +- lib/mine/coupons_page.dart | 315 +++++--------------- lib/mine/mine_card_page.dart | 106 ------- lib/mine/mine_page.dart | 2 +- lib/mine/roll_center_page.dart | 112 ++----- lib/mine/vip_card_page.dart | 61 +--- lib/mine/vip_detail_page.dart | 321 +++----------------- lib/retrofit/data/coupon.dart | 2 + lib/view_widget/coupon_widget.dart | 221 -------------- lib/view_widget/new_coupon_widget.dart | 392 +++++++++++++++++++++++++ pubspec.yaml | 6 +- 13 files changed, 568 insertions(+), 995 deletions(-) create mode 100644 lib/view_widget/new_coupon_widget.dart diff --git a/lib/generated/intl/messages_en.dart b/lib/generated/intl/messages_en.dart index 6192d94c..4ccc7a86 100644 --- a/lib/generated/intl/messages_en.dart +++ b/lib/generated/intl/messages_en.dart @@ -173,11 +173,11 @@ class MessageLookup extends MessageLookupByLibrary { "lijiqiandao" : MessageLookupByLibrary.simpleMessage("立即签到"), "lingjuanzhongxing" : MessageLookupByLibrary.simpleMessage("领卷中心"), "lingqu" : MessageLookupByLibrary.simpleMessage("领取"), + "lingquanzhongxin" : MessageLookupByLibrary.simpleMessage("领券中心"), "lingquchenggong" : MessageLookupByLibrary.simpleMessage("领取成功"), "lingqudaokabao" : MessageLookupByLibrary.simpleMessage("领取到卡包"), "lingqufangshi" : MessageLookupByLibrary.simpleMessage("领取方式"), "lingqushijian" : m9, - "linjuanzhongxin" : MessageLookupByLibrary.simpleMessage("领卷中心"), "lishijilu" : MessageLookupByLibrary.simpleMessage("历史记录"), "login" : MessageLookupByLibrary.simpleMessage("Login"), "login_splash" : MessageLookupByLibrary.simpleMessage("Welcome to Yixin Homecoming"), @@ -244,6 +244,7 @@ class MessageLookup extends MessageLookupByLibrary { "ricahngfenxiang" : MessageLookupByLibrary.simpleMessage("日常分享"), "send_code" : MessageLookupByLibrary.simpleMessage("发送验证"), "shanchudingdan" : MessageLookupByLibrary.simpleMessage("删除订单"), + "shangjiaquan" : MessageLookupByLibrary.simpleMessage("商家券"), "shangpinjifen" : m15, "shenmijifendali" : MessageLookupByLibrary.simpleMessage("神秘积分大礼"), "shezhi" : MessageLookupByLibrary.simpleMessage("设置"), diff --git a/lib/generated/l10n.dart b/lib/generated/l10n.dart index 300e7a4a..ef64d6e6 100644 --- a/lib/generated/l10n.dart +++ b/lib/generated/l10n.dart @@ -1617,11 +1617,11 @@ class S { ); } - /// `领卷中心` - String get linjuanzhongxin { + /// `领券中心` + String get lingquanzhongxin { return Intl.message( - '领卷中心', - name: 'linjuanzhongxin', + '领券中心', + name: 'lingquanzhongxin', desc: '', args: [], ); @@ -2717,6 +2717,16 @@ class S { ); } + /// `商家券` + String get shangjiaquan { + return Intl.message( + '商家券', + name: 'shangjiaquan', + desc: '', + args: [], + ); + } + /// `满{man}元可用` String manyuankeyong(Object man) { return Intl.message( diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index 148d79ce..41786369 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -160,7 +160,7 @@ "quanxian": "权限", "tuichudenglu": "退出登录", "xiaoxi": "消息", - "linjuanzhongxin": "领卷中心", + "lingquanzhongxin": "领券中心", "guanyu": "关于", "huodongzixun": "活动资讯", "wodexiaoxi": "我的消息", @@ -275,7 +275,9 @@ "huiyuankaxiangqing": "会员卡详情", "yuemingxi": "余额明细", "kelingqudeyouhuiquan": "可领取的优惠券", + "shangjiaquan": "商家券", "manyuankeyong": "满{man}元可用", + "jifen": "积分", diff --git a/lib/mine/coupons_page.dart b/lib/mine/coupons_page.dart index ae7cc7b9..10c26f7e 100644 --- a/lib/mine/coupons_page.dart +++ b/lib/mine/coupons_page.dart @@ -1,15 +1,8 @@ -import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:fluttertoast/fluttertoast.dart'; import 'package:huixiang/generated/l10n.dart'; -import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/coupon.dart'; -import 'package:huixiang/retrofit/data/page.dart'; -import 'package:huixiang/retrofit/retrofit_api.dart'; -import 'package:huixiang/view_widget/coupon_widget.dart'; -import 'package:pull_to_refresh/pull_to_refresh.dart'; -import 'package:shared_preferences/shared_preferences.dart'; +import 'package:huixiang/view_widget/new_coupon_widget.dart'; class CouponsPage extends StatefulWidget { @override @@ -19,254 +12,92 @@ class CouponsPage extends StatefulWidget { } class _CouponsPage extends State { - RefreshController _refreshController; - - ApiService apiService; + int btnStatus = 0; @override void initState() { super.initState(); - - SharedPreferences.getInstance().then((value) => { - apiService = ApiService(Dio(), token: value.getString('token')), - queryCard(), - }); - - _refreshController = RefreshController(initialRefresh: false); - } - - int pageNum = 1; - List coupons = []; - - void _onRefresh() async { - pageNum = 1; - queryCard(); } - queryCard() async { - BaseData baseData = await apiService.queryCard({ - "centre": true, - "pageNum": pageNum, - "pageSize": 10, - "searchKey": "", - "state": 3 - }).catchError((error) { - _refreshController.loadFailed(); - _refreshController.refreshFailed(); - }); - if (baseData.isSuccess) { - PageInfo pageInfo = PageInfo.fromJson(baseData.data); - if (pageNum == 1) { - coupons.clear(); - } - coupons.addAll(pageInfo.list.map((e) => Coupon.fromJson(e))); - setState(() { - _refreshController.refreshCompleted(); - _refreshController.loadComplete(); - if (pageInfo.pageNum == pageInfo.pages) { - _refreshController.loadNoData(); - } else { - pageNum += 1; - } - }); - } else { - _refreshController.loadFailed(); - _refreshController.refreshFailed(); - Fluttertoast.showToast(msg: baseData.msg); - } - } + List coupons = [ + Coupon.test("",0,false),Coupon.test("",1,false),Coupon.test("",1,false),Coupon.test("",0,false),Coupon.test("",0,false) + ]; @override Widget build(BuildContext context) { return Scaffold( - body: Container( - child: Row( - children: [ - Container( - width: 68, - height: 26, - alignment: Alignment.center, - margin: EdgeInsets.only(left: 16, right: 12, top: 10, bottom: 14), - decoration:BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(2)), - color: Colors.white, - ), - child:GestureDetector( - onTap: (){ - - }, - child: Text( - S.of(context).keyongquan, - style:TextStyle( - fontSize: 14, - fontWeight:FontWeight.bold, - color: Colors.black, - ), - ), - ), - ), - Container( - width: 68, - height: 26, - alignment: Alignment.center, - margin: EdgeInsets.only(left: 16, top: 10, bottom: 14), - decoration:BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(2)), - color: Color(0xffE5E5E5), - ), - child: - GestureDetector( - onTap: (){ - Navigator.of(context).pushNamed('/router/mine_card_invalid'); - }, - child: Text( - S.of(context).shixiaoquan, - style:TextStyle( - fontSize: 14, - color: Color(0xff727272), - ), - ), - ), - ), - ], + body: Column(children: [ + Row( + children: [ + Container( + width: 68, + height: 26, + alignment: Alignment.center, + margin: EdgeInsets.only(left: 16, right: 12, top: 10, bottom: 14), + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(2)), + color: btnStatus == 0 ? Colors.white : Color(0xffE5E5E5), ), - ), - ); - } - - Widget vipCardItem() { - return Container( - margin: EdgeInsets.fromLTRB(16, 8, 16, 8), - // margin: EdgeInsets.all(16), - child: Stack( - // alignment: Alignment.center, - children: [ - Image.asset( - "assets/image/icon_vip_bj.png", - fit: BoxFit.contain, //填充剩余空间 - height: 185, - ), - Container( - padding: EdgeInsets.only(left: 16,right: 16), - child:Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox(height: 16), - Row( - children: [ - ClipOval( - child:Image.asset( - "assets/image/icon_vip_name.png", - ), - clipBehavior: Clip.hardEdge, - ), - SizedBox( - width: 12, - ), - Expanded( - child: Container( - height: 54, - child: Column( - mainAxisAlignment: - MainAxisAlignment.spaceEvenly, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Text( - "百年川椒火锅店", - overflow: TextOverflow.ellipsis, - maxLines: 2, - style: TextStyle( - fontSize: 20, - color: Colors.white, - ), - ), - Image.asset( - "assets/image/icon_vip.png", - ), - ], - ), - Text.rich( - TextSpan(children: [ - TextSpan( - text: "会员卡", - style: TextStyle( - fontSize: 12, - color: Colors.white), - ), - ]), - textDirection: TextDirection.ltr, - ), - ], - ), - ), - flex: 1, - ) - ], - ), - SizedBox(height: 50), - Row( - textDirection: TextDirection.rtl, - children: [ - Image.asset( - "assets/image/icon_right.png", - ), - Text.rich( - TextSpan(children: [ - TextSpan( - text: "查看详情", - style: TextStyle(fontSize: 12, color: Colors.white), - ), - ]), - ), - ], - ), - SizedBox( - height: 10, + child: GestureDetector( + onTap: () { + setState(() { + btnStatus = 0; + coupons = [Coupon.test("",0,false),Coupon.test("",1,false),Coupon.test("",1,false),Coupon.test("",0,false),Coupon.test("",0,false)]; + }); + }, + child: Text( + S.of(context).keyongquan, + style: TextStyle( + fontSize: 14, + fontWeight: btnStatus == 0 ? FontWeight.bold : FontWeight.normal, + color: btnStatus == 0 ? Colors.black : Color(0xff727272), + ), ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - flex: 1, - child: Text.rich( - TextSpan(children: [ - TextSpan( - text: "No.202107021324199", - style: TextStyle(fontSize: 14, color: Colors.white), - ), - ]), - ), - ), - Text.rich( - TextSpan(children: [ - TextSpan( - text: "有效期限:", - style: TextStyle(fontSize: 12, color: Colors.white), - ), - ]), - ), - Text.rich( - TextSpan(children: [ - TextSpan( - text: "长期有效", - style: TextStyle(fontSize: 12, color: Colors.white), - ), - ]), - ), - ], + ), + ), + Container( + width: 68, + height: 26, + alignment: Alignment.center, + margin: EdgeInsets.only(left: 16, top: 10, bottom: 14), + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(2)), + color: btnStatus == 1 ? Colors.white : Color(0xffE5E5E5), + ), + child: GestureDetector( + onTap: () { + setState(() { + btnStatus = 1; + coupons = [Coupon.test("",2,false),Coupon.test("",2,false),Coupon.test("",2,false),Coupon.test("",2,false),Coupon.test("",2,false)]; + }); + }, + child: Text( + S.of(context).shixiaoquan, + style: TextStyle( + fontSize: 14, + fontWeight: btnStatus == 1 ? FontWeight.bold : FontWeight.normal, + color: btnStatus == 1 ? Colors.black : Color(0xff727272), + ), ), - ], + ), ), - ), - ], - ), + ], + ), + Expanded(child: ListView.builder( + itemBuilder: (context, position) { + return GestureDetector( + child: NewCouponWidget(coupons[position],(){ + + },(){ + setState(() { + coupons[position].isEx = !coupons[position].isEx; + }); + }), + ); + }, + itemCount: 5, + ),) + ]), ); } - } diff --git a/lib/mine/mine_card_page.dart b/lib/mine/mine_card_page.dart index 71f5d2cb..33e0c077 100644 --- a/lib/mine/mine_card_page.dart +++ b/lib/mine/mine_card_page.dart @@ -150,112 +150,6 @@ class _MineCardPage extends State body: TabBarView( children: _pages, ), - // body: Container( - // child: Column( - // children: [ - // Row( - // children: [ - // Container( - // width: 68, - // height: 26, - // alignment: Alignment.center, - // margin: EdgeInsets.only(left: 16, right: 12, top: 10, bottom: 14), - // decoration:BoxDecoration( - // borderRadius: BorderRadius.all(Radius.circular(2)), - // color: Colors.white, - // ), - // child:GestureDetector( - // onTap: (){ - // - // }, - // child: Text( - // S.of(context).keyongquan, - // style:TextStyle( - // fontSize: 14, - // fontWeight:FontWeight.bold, - // color: Colors.black, - // ), - // ), - // ), - // ), - // Container( - // width: 68, - // height: 26, - // alignment: Alignment.center, - // margin: EdgeInsets.only(left: 16, top: 10, bottom: 14), - // decoration:BoxDecoration( - // borderRadius: BorderRadius.all(Radius.circular(2)), - // color: Color(0xffE5E5E5), - // ), - // child: - // GestureDetector( - // onTap: (){ - // Navigator.of(context).pushNamed('/router/mine_card_invalid'); - // }, - // child: Text( - // S.of(context).shixiaoquan, - // style:TextStyle( - // fontSize: 14, - // color: Color(0xff727272), - // ), - // ), - // ), - // ), - // ], - // ), - // // ItemTitle( - // // text: S.of(context).keyongquan, - // // imgPath: "assets/image/icon_card_coupon.png", - // // moreText: S.of(context).shixiaoquan, - // // onTap: () { - // // Navigator.of(context).pushNamed('/router/mine_card_invalid'); - // // }, - // // ), - // Expanded( - // flex: 1, - // child: Container( - // child: SmartRefresher( - // enablePullDown: true, - // enablePullUp: true, - // header: MyHeader(), - // footer: CustomFooter( - // builder: (context, mode) { - // Widget body; - // if (mode == LoadStatus.idle) { - // body = Text("pull up load"); - // } else if (mode == LoadStatus.loading) { - // body = CupertinoActivityIndicator(); - // } else if (mode == LoadStatus.failed) { - // body = Text("Load Failed!Click retry!"); - // } else if (mode == LoadStatus.canLoading) { - // body = Text("release to load more"); - // } else { - // body = Text(S.of(context).meiyougengduoyouhuiquan); - // } - // return Container( - // height: 55.0, - // child: Center(child: body), - // ); - // }, - // ), - // controller: _refreshController, - // onRefresh: _onRefresh, - // onLoading: queryCard, - // child: ListView.builder( - // itemBuilder: (context, position) { - // return CouponWidget( - // coupons[position], - // () {}, - // ); - // }, - // itemCount: coupons.length, - // ), - // ), - // ), - // ), - // ], - // ), - // ), ), ); } diff --git a/lib/mine/mine_page.dart b/lib/mine/mine_page.dart index 7d1fdfdc..374fa4bc 100644 --- a/lib/mine/mine_page.dart +++ b/lib/mine/mine_page.dart @@ -238,7 +238,7 @@ class _MinePage extends State with AutomaticKeepAliveClientMixin { Navigator.of(context).pushNamed('/router/roll_center_page'); }, child: mineItem( - S.of(context).linjuanzhongxin, + S.of(context).lingquanzhongxin, "assets/image/icon_mine_invoice_assistant.png", ), ), diff --git a/lib/mine/roll_center_page.dart b/lib/mine/roll_center_page.dart index 43219c7b..a5d38c5c 100644 --- a/lib/mine/roll_center_page.dart +++ b/lib/mine/roll_center_page.dart @@ -9,6 +9,7 @@ import 'package:huixiang/retrofit/data/page.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/view_widget/coupon_widget.dart'; import 'package:huixiang/view_widget/item_title.dart'; +import 'package:huixiang/view_widget/new_coupon_widget.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -20,7 +21,7 @@ class RollCenterPage extends StatefulWidget { } class _RollCenterPage extends State { - RefreshController _refreshController; + // RefreshController _refreshController; ApiService apiService; @@ -28,61 +29,24 @@ class _RollCenterPage extends State { void initState() { super.initState(); - SharedPreferences.getInstance().then((value) => { - apiService = ApiService(Dio(), token: value.getString('token')), - queryCoupon(), - }); - - _refreshController = RefreshController(initialRefresh: false); + // SharedPreferences.getInstance().then((value) => { + // apiService = ApiService(Dio(), token: value.getString('token')), + // queryCoupon(), + // }); + // + // _refreshController = RefreshController(initialRefresh: false); } int pageNum = 1; - List coupons = []; - - queryCoupon() async { - BaseData baseData = await apiService.queryCoupon({ - "centre": true, - "pageNum": pageNum, - "pageSize": 10, - "searchKey": "", - "state": 1 - }).catchError((error) { - _refreshController.loadFailed(); - _refreshController.refreshFailed(); - }); - if (baseData.isSuccess) { - PageInfo pageInfo = PageInfo.fromJson(baseData.data); - if (pageNum == 1) { - coupons.clear(); - } - coupons.addAll(pageInfo.list.map((e) => Coupon.fromJson(e))); - setState(() { - _refreshController.refreshCompleted(); - _refreshController.loadComplete(); - if (pageInfo.pageNum == pageInfo.pages) { - _refreshController.loadNoData(); - } else { - pageNum += 1; - } - }); - } else { - _refreshController.loadFailed(); - _refreshController.refreshFailed(); - Fluttertoast.showToast(msg: baseData.msg); - } - } + List coupons = [Coupon.test("",1,false),Coupon.test("",1,false),Coupon.test("",1,false),Coupon.test("",1,false),Coupon.test("",1,false)]; - void _onRefresh() async { - pageNum = 1; - queryCoupon(); - } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text( - "领卷中心", + S.of(context).lingquanzhongxin, style: TextStyle( color: Colors.black, fontWeight: FontWeight.bold, @@ -114,51 +78,29 @@ class _RollCenterPage extends State { children: [ ItemTitle( text: S.of(context).kelingqudeyouhuiquan, + imgPath: "assets/image/icon_card_coupon.png", moreText: S.of(context).chakanwodekaquan, onTap: () { Navigator.of(context).pushNamed('/router/mine_card'); }, ), - Expanded( - flex: 1, - child: Container( - child: SmartRefresher( - enablePullDown: true, - enablePullUp: true, - header: ClassicHeader(), - footer: CustomFooter( - builder: (context, mode) { - Widget body; - if (mode == LoadStatus.idle) { - body = Text("pull up load"); - } else if (mode == LoadStatus.loading) { - body = CupertinoActivityIndicator(); - } else if (mode == LoadStatus.failed) { - body = Text("Load Failed!Click retry!"); - } else if (mode == LoadStatus.canLoading) { - body = Text("release to load more"); - } else { - body = Text(S.of(context).meiyougengduoyouhuiquan); - } - return Container( - height: 55.0, - child: Center(child: body), - ); - }, - ), - controller: _refreshController, - onRefresh: _onRefresh, - onLoading: queryCoupon, - child: ListView.builder( - itemBuilder: (context, position) { - return CouponWidget(coupons[position], () {}); - }, - itemCount: coupons.length, - ), - ), - ), - ) + Expanded(child: ListView.builder( + itemBuilder: (context, position) { + return GestureDetector( + child: NewCouponWidget(coupons[position],(){ + setState(() { + coupons = [Coupon.test("",1,false),Coupon.test("",1,false),Coupon.test("",1,false),Coupon.test("",1,false),Coupon.test("",1,false)]; + }); + },(){ + setState(() { + coupons[position].isEx = !coupons[position].isEx; + }); + }), + ); + }, + itemCount: 5, + ),) ], ), ), diff --git a/lib/mine/vip_card_page.dart b/lib/mine/vip_card_page.dart index 688d0b7f..88a2522b 100644 --- a/lib/mine/vip_card_page.dart +++ b/lib/mine/vip_card_page.dart @@ -1,15 +1,8 @@ -import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:fluttertoast/fluttertoast.dart'; import 'package:huixiang/generated/l10n.dart'; -import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/coupon.dart'; -import 'package:huixiang/retrofit/data/page.dart'; -import 'package:huixiang/retrofit/retrofit_api.dart'; -import 'package:huixiang/view_widget/coupon_widget.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; -import 'package:shared_preferences/shared_preferences.dart'; class VipCardPage extends StatefulWidget { @override @@ -21,59 +14,19 @@ class VipCardPage extends StatefulWidget { class _VipCardPage extends State { RefreshController _refreshController; - ApiService apiService; - @override void initState() { super.initState(); - - SharedPreferences.getInstance().then((value) => { - apiService = ApiService(Dio(), token: value.getString('token')), - queryCard(), - }); - _refreshController = RefreshController(initialRefresh: false); } int pageNum = 1; - List coupons = []; + List coupons = [ + Coupon(),Coupon(),Coupon(),Coupon() + ]; void _onRefresh() async { pageNum = 1; - queryCard(); - } - - queryCard() async { - BaseData baseData = await apiService.queryCard({ - "centre": true, - "pageNum": pageNum, - "pageSize": 10, - "searchKey": "", - "state": 3 - }).catchError((error) { - _refreshController.loadFailed(); - _refreshController.refreshFailed(); - }); - if (baseData.isSuccess) { - PageInfo pageInfo = PageInfo.fromJson(baseData.data); - if (pageNum == 1) { - coupons.clear(); - } - coupons.addAll(pageInfo.list.map((e) => Coupon.fromJson(e))); - setState(() { - _refreshController.refreshCompleted(); - _refreshController.loadComplete(); - if (pageInfo.pageNum == pageInfo.pages) { - _refreshController.loadNoData(); - } else { - pageNum += 1; - } - }); - } else { - _refreshController.loadFailed(); - _refreshController.refreshFailed(); - Fluttertoast.showToast(msg: baseData.msg); - } } @override @@ -106,7 +59,7 @@ class _VipCardPage extends State { ), controller: _refreshController, onRefresh: _onRefresh, - onLoading: queryCard, + child: ListView.builder( itemBuilder: (context, position) { return GestureDetector( @@ -115,12 +68,6 @@ class _VipCardPage extends State { }, child: vipCardItem(), ); - return GestureDetector( - onTap: () { - Navigator.of(context).pushNamed('/router/vip_details_page'); - }, - child: vipCardItem(), - ); }, itemCount: coupons.length, ), diff --git a/lib/mine/vip_detail_page.dart b/lib/mine/vip_detail_page.dart index ec0ba451..0bde3695 100644 --- a/lib/mine/vip_detail_page.dart +++ b/lib/mine/vip_detail_page.dart @@ -1,9 +1,6 @@ import 'package:flutter/material.dart'; import 'package:huixiang/generated/l10n.dart'; -import 'package:huixiang/view_widget/border_text.dart'; -import 'package:huixiang/view_widget/pay_input_view.dart'; import 'package:huixiang/view_widget/round_button.dart'; -import 'package:huixiang/view_widget/separator.dart'; class VipDetailPage extends StatefulWidget { @override @@ -43,172 +40,57 @@ class _VipDetailPage extends State { ), titleSpacing: 2, leadingWidth: 56, - // bottom: PreferredSize( - // preferredSize: Size(double.infinity, 88), - // child: Container( - // height: 88, - // padding: EdgeInsets.fromLTRB(16, 0, 16, 14), - // child: Row( - // mainAxisAlignment: MainAxisAlignment.end, - // crossAxisAlignment: CrossAxisAlignment.end, - // children: [ - // Expanded( - // child: Column( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - // crossAxisAlignment: CrossAxisAlignment.start, - // children: [ - // Container( - // height: 20, - // width: 82, - // decoration: BoxDecoration( - // borderRadius: BorderRadius.circular(15), - // border: Border.all( - // width: 1, - // color: Color(0xFF32A060), - // ), - // ), - // child: Stack( - // alignment: Alignment.lerp( - // Alignment.centerLeft, - // Alignment.centerRight, - // 0, - // ), - // children: [ - // Positioned( - // left: 0, - // child: GestureDetector( - // onTap: () { - // setState(() { - // type = 0; - // }); - // }, - // child: RoundButton( - // text: S.of(context).ziqu, - // width: 42, - // height: 20, - // textColor: Colors.white, - // padding: EdgeInsets.fromLTRB(8, 1, 8, 1), - // backgroup: type == 0 - // ? Color(0xFF32A060) - // : Colors.transparent, - // radius: 15, - // ), - // ), - // ), - // Positioned( - // right: 0, - // child: GestureDetector( - // onTap: () { - // setState(() { - // type = 1; - // }); - // }, - // child: RoundButton( - // text: S.of(context).waisong, - // width: 42, - // height: 20, - // textColor: Colors.white, - // padding: EdgeInsets.fromLTRB(8, 1, 8, 1), - // backgroup: type == 1 - // ? Color(0xFF32A060) - // : Colors.transparent, - // radius: 15, - // ), - // ), - // ), - // ], - // ), - // ), - // Text( - // S.of(context).qingzaiguidingshijianneizhifu, - // style: TextStyle( - // color: Colors.white, - // fontSize: 12, - // ), - // ), - // ], - // ), - // ), - // Container( - // height: 33, - // child: Row( - // mainAxisSize: MainAxisSize.min, - // children: [ - // AspectRatio( - // aspectRatio: 1, - // child: BorderText( - // text: "02", - // textColor: Colors.white, - // fontSize: 21, - // fontWeight: FontWeight.bold, - // borderColor: Colors.white, - // borderWidth: 1, - // padding: EdgeInsets.all(2), - // ), - // ), - // SizedBox( - // width: 8, - // ), - // Text( - // ":", - // style: TextStyle( - // color: Colors.white, - // fontSize: 21, - // ), - // ), - // SizedBox( - // width: 8, - // ), - // AspectRatio( - // aspectRatio: 1, - // child: BorderText( - // text: "02", - // textColor: Colors.white, - // fontSize: 21, - // fontWeight: FontWeight.bold, - // borderColor: Colors.white, - // borderWidth: 1, - // padding: EdgeInsets.all(2), - // ), - // ), - // ], - // ), - // ) - // ], - // ), - // ), - // ), ), - body: Container( - child: Stack( - children: [ - Container( - height: 150, - color: Color(0xFF3A405A), - ), - SingleChildScrollView( - physics: BouncingScrollPhysics(), - child: Container( - child: Column( - children: [ - buildAddress(), - buildCommodity(), - Container( - height: 42, - ), - ], - ), + body: Column( + children: [ + Stack( + children: [ + Container( + height: 150, + color: Color(0xFF3A405A), ), + buildAddress(), + ], + ), + Padding( + padding: EdgeInsets.only(left: 16,top: 35,bottom: 32), + child: Row( + children: [ + Text( + "历史订单", + overflow: TextOverflow.ellipsis, + maxLines: 2, + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + color: Colors.black, + ), + ), + SizedBox(width: 8,), + Image.asset( + "assets/image/icon_history.png", + ), + ], ), - - ], - ), + ), + Expanded( + child: ListView.builder( + itemBuilder: (context, position) { + return GestureDetector( + onTap: () { + // Navigator.of(context).pushNamed('/router/vip_details_page'); + }, + child: historyItem(), + ); + }, + itemCount: 5, + ), + ) + ], ), ); } - var type = 0; - Widget buildAddress() { return Container( margin: EdgeInsets.fromLTRB(16, 8, 16, 8), @@ -308,7 +190,7 @@ class _VipDetailPage extends State { Text.rich( TextSpan(children: [ TextSpan( - text: "余额", + text: S.of(context).yue, style: TextStyle( fontSize: 14, color: Colors.white), @@ -340,7 +222,7 @@ class _VipDetailPage extends State { Text.rich( TextSpan(children: [ TextSpan( - text: "积分", + text: S.of(context).jifen, style: TextStyle(fontSize: 14, color: Colors.white), ), ]), @@ -350,119 +232,10 @@ class _VipDetailPage extends State { ], ),), - ], - ), - ), - ], - ), - ); - } - Widget buildCommodity() { - return Stack( - alignment: Alignment.centerRight, - children: [ - Container( - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: historyList(), - ), - ), - ], - ); - } - - List historyList() { - return [ - Padding(padding: EdgeInsets.only(left: 16,top: 35,bottom: 32),child: - Row( - children: [ - Text( - "历史订单", - overflow: TextOverflow.ellipsis, - maxLines: 2, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - ), - SizedBox(width: 8,), - Image.asset( - "assets/image/icon_history.png", - ), - ], - ),), - historyItem(), - historyItem(), - historyItem(), - historyItem(), - historyItem(), - historyItem(), - historyItem(), - ]; - } - - - Widget buildOrderInfo() { - return Container( - margin: EdgeInsets.only(left: 16, right: 16, top: 16, bottom: 8), - padding: EdgeInsets.only(left: 20, right: 20, top: 12, bottom: 12), - decoration: BoxDecoration( - color: Colors.white, - boxShadow: [ - BoxShadow( - color: Colors.black.withAlpha(12), - offset: Offset(0, 1), - blurRadius: 12, - spreadRadius: 0) - ], - borderRadius: BorderRadius.all(Radius.circular(8))), - child: Column( - children: [ - orderInfoItem(S.of(context).shoujihao, "13800138000"), - orderInfoItem( - S.of(context).beizhu, S.of(context).qingshurubeizhuyaoqiu), - orderInfoItem(S.of(context).fapiao, S.of(context).buzhichikaipiao), - orderInfoItem(S.of(context).zhifufangshi, S.of(context).yue), - ], - ), - ); - } - - Widget orderInfoItem(leftText, rightText) { - return Container( - margin: EdgeInsets.only(top: 8, bottom: 8), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Text( - leftText, - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 12, - color: Color(0xFF727272)), - ), - Expanded( - child: Text( - rightText, - textAlign: TextAlign.end, - style: TextStyle( - fontSize: 12, - color: Color(0xFF353535), - ), + ], ), - flex: 1, ), - SizedBox( - width: 16, - ), - Icon( - Icons.keyboard_arrow_right, - size: 16, - color: Colors.black, - ) ], ), ); diff --git a/lib/retrofit/data/coupon.dart b/lib/retrofit/data/coupon.dart index 6f364a49..b8925ad1 100644 --- a/lib/retrofit/data/coupon.dart +++ b/lib/retrofit/data/coupon.dart @@ -39,6 +39,7 @@ class Coupon { Coupon(); + Coupon.test(this.couponName,this.status,this.isEx); String id; String createTime; @@ -65,6 +66,7 @@ class Coupon { String receiveTime; dynamic useTime; int status; + bool isEx; factory Coupon.fromJson(Map json) => diff --git a/lib/view_widget/coupon_widget.dart b/lib/view_widget/coupon_widget.dart index 9a16f4a1..29735322 100644 --- a/lib/view_widget/coupon_widget.dart +++ b/lib/view_widget/coupon_widget.dart @@ -216,227 +216,6 @@ class CouponWidget extends StatelessWidget { ), ), ); - return Container( - margin: EdgeInsets.fromLTRB(14, 6, 14, 6), - child: AspectRatio( - aspectRatio: 2.485, - child: Stack( - children: [ - Image.asset( - "assets/image/ic_coupon_bg.png", - fit: BoxFit.cover, - width: double.infinity, - height: double.infinity, - ), - // if (coupon.status == 3) - // Positioned( - // top: 10, - // right: 0, - // child: Transform.rotate( - // angle: pi / 5.0, - // child: Text( - // S.of(context).yishijiao, //已失效 - // style: TextStyle( - // fontSize: 8, - // color: Color(0xFF353535), - // ), - // ), - // ), - // ), - Opacity( - opacity: coupon.status != 3 ? 1 : 0.54, - child: Container( - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - flex: 7, - child: Container( - padding: EdgeInsets.only(top: 18, bottom: 20), - child: Row( - children: [ - Container( - margin: EdgeInsets.only(left: 20), - child: Image.network( - (coupon == null || - coupon.couponImg == null || - coupon.couponImg == "") - ? "" - : coupon.couponImg, - width: 60, - height: 60, - fit: BoxFit.cover, - errorBuilder: (context, error, e) { - return Column( - children: [ - Row( - children: [ - Text("¥",style: TextStyle( - fontSize: 22,color: Color(0xff32A060) - ),), - SizedBox(width: 5,), - Text("5",style: TextStyle( - fontSize: 40,fontWeight: FontWeight.bold,color: Color(0xff32A060) - ),), - ], - ), - Text(S.of(context).manyuankeyong(30), - style: TextStyle(fontSize: 12,fontWeight: FontWeight.bold,color:Color(0xff32A060))), - ], - ); - }, - ), - ), - Expanded( - flex: 1, - child: Container( - height: 60, - margin: EdgeInsets.only(left: 12), - child: Column( - mainAxisAlignment: - MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - margin: EdgeInsets.only(right: 15), - child: Row( - children: [ - Expanded( - flex: 1, - child: Text( - coupon.couponName ?? "", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 14, - color: Color(0xFF353535), - ), - ), - ), - (coupon.status == 0) - ? Row( - children: [ - RoundButton( - width: 42, - height: 21, - text: - S.of(context).lingqu, - textColor: Colors.white, - fontSize: 12, - padding: EdgeInsets.only( - top: 2, - bottom: 2, - left: 8, - right: 8), - backgroup: - Color(0xff32A060), - callback: () { - showAlertDialog( - context); - }, - ), - ], - ) - : (coupon.status == 1) - ? Row( - children: [ - Text( - S - .of(context) - .qushiyong, - style: TextStyle( - color: Color( - 0xFF32A060), - fontSize: 12, - ), - ), - Icon( - Icons - .keyboard_arrow_right, - size: 16, - color: - Color(0xFF32A060), - ) - ], - ) - : Container(), - ], - ), - ), - Expanded( - flex: 1, - child: Container( - margin: EdgeInsets.only(right: 37), - alignment: Alignment.centerLeft, - child: Text( - coupon.couponDescription ?? "", - style: TextStyle( - fontSize: 10, - color: Color(0xFF4C4C4C), - ), - ), - ), - ), - ], - ), - ), - ), - ], - ), - ), - ), - Container( - margin: EdgeInsets.only(left: 23, right: 23), - child: MySeparator( - width: 5, - height: 1, - color: Color(0xFF353535), - ), - ), - // Expanded( - // flex: 3, - // child: Container( - // padding: EdgeInsets.only(left: 20), - // alignment: Alignment.centerLeft, - // child: Text( - // coupon.status == 0 - // ? S.of(context).faxingshijian(coupon.publishStartTime) - // : coupon.status == 1 - // ? S.of(context).lingqushijian(coupon.receiveTime) - // : S.of(context).shiyongriqi(coupon.useTime), - // style: TextStyle( - // color: Color(0xFF727272), - // fontSize: 10, - // ), - // ), - // ), - // ), - Expanded( - flex: 3, - child: Container( - padding: EdgeInsets.only(left: 20), - alignment: Alignment.centerLeft, - child: Row( - children: [ - Text( - S.of(context).shiyongriqi(coupon.useTime), - style: TextStyle( - color: Color(0xFF727272), - fontSize: 10, - ), - ), - ], - ), - ), - ), - ], - ), - ), - ), - ], - ), - ), - ); } showAlertDialog(BuildContext context) { diff --git a/lib/view_widget/new_coupon_widget.dart b/lib/view_widget/new_coupon_widget.dart new file mode 100644 index 00000000..a655a2fb --- /dev/null +++ b/lib/view_widget/new_coupon_widget.dart @@ -0,0 +1,392 @@ +import 'dart:math'; + +import 'package:flutter/material.dart'; +import 'package:huixiang/generated/l10n.dart'; +import 'package:huixiang/retrofit/data/coupon.dart'; +import 'package:huixiang/view_widget/round_button.dart'; +import 'package:huixiang/view_widget/separator.dart'; + +class NewCouponWidget extends StatelessWidget { + final GestureTapCallback callback; + final GestureTapCallback callbackEx; + final Coupon coupon; + + NewCouponWidget(this.coupon, this.callback, this.callbackEx); + + @override + Widget build(BuildContext context) { + return buildCoupon(context); + } + + Widget buildCoupon(BuildContext context) { + return Container( + margin: EdgeInsets.fromLTRB(14, 6, 14, 6), + child: AspectRatio( + aspectRatio: 2.485, + child: Stack( + children: [ + Image.asset( + "assets/image/ic_coupon_bg.png", + fit: BoxFit.cover, + width: double.infinity, + height: double.infinity, + ), + Opacity( + opacity: coupon.status != 3 ? 1 : 0.54, + child: Container( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 7, + child: Container( + padding: EdgeInsets.only(top: 18, bottom: 8), + child: Row( + children: [ + Container( + margin: EdgeInsets.only(left: 20), + child: Column( + children: [ + Row( + children: [ + Text( + "¥", + style: TextStyle( + fontSize: 22, + color: Color(0xff32A060)), + ), + SizedBox( + width: 5, + ), + Text( + "5", + style: TextStyle( + fontSize: 40, + fontWeight: FontWeight.bold, + color: Color(0xff32A060)), + ), + ], + ), + Text(S.of(context).manyuankeyong(30), + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.bold, + color: Color(0xff32A060))), + ], + ), + ), + SizedBox( + width: 31, + ), + Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Container( + padding: EdgeInsets.fromLTRB(4, 2, 4, 2), + decoration: BoxDecoration( + borderRadius: BorderRadius.all( + Radius.circular(2)), + border: Border.all( + width: 1, + color: Color(0xFFFF7A1A), + style: BorderStyle.solid)), + child: Text( + S.of(context).shangjiaquan, + style: TextStyle( + fontSize: 10, + color: Color(0xFFFF7A1A), + ), + ), + ), + SizedBox( + width: 4, + ), + Text( + "百年川椒火锅店", + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + color: Color(0xff353535)), + ), + ], + ), + SizedBox( + height: 6, + ), + Text( + "#新客户满减优惠#", + style: TextStyle( + fontSize: 14, color: Color(0xff727272)), + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + "全场通用", + style: TextStyle( + fontSize: 12, + color: Color(0xff353535)), + ), + if (coupon.status == 0) + Container( + width: 200, + alignment: Alignment.centerRight, + child: Container( + padding: + EdgeInsets.fromLTRB(9, 3, 9, 3), + decoration: BoxDecoration( + borderRadius: BorderRadius.all( + Radius.circular(10.5)), + color: Color(0xFF32A060), + ), + child: Text( + S.of(context).qushiyong, + style: TextStyle( + fontSize: 12, + color: Colors.white, + ), + ), + )) + else if (coupon.status == 1) + Container( + width: 200, + alignment: Alignment.centerRight, + child: Container( + padding: + EdgeInsets.fromLTRB(9, 3, 9, 3), + decoration: BoxDecoration( + borderRadius: BorderRadius.all( + Radius.circular(10.5)), + color: Color(0xFF32A060), + ), + child: GestureDetector( + onTap: () { + showAlertDialog(context); + }, + child: Text( + S.of(context).lingqu, + style: TextStyle( + fontSize: 12, + color: Colors.white, + ), + ), + ), + )) + else if (coupon.status == 2) + Container( + width: 200, + alignment: Alignment.centerRight, + child: Container( + padding: + EdgeInsets.fromLTRB(9, 3, 9, 3), + decoration: BoxDecoration( + borderRadius: BorderRadius.all( + Radius.circular(10.5)), + // border: Border.all( + // width: 1, color: Color(0xFFA0A0A0), style: BorderStyle.solid) + color: Color(0xFFA0A0A0), + ), + child: Text( + S.of(context).yishixiao, + style: TextStyle( + fontSize: 12, + color: Colors.white, + ), + ), + )) + ], + ), + SizedBox( + height: 2, + ), + ], + ) + ], + ), + ), + ), + Container( + margin: EdgeInsets.only(left: 23, right: 23), + child: MySeparator( + width: 5, + height: 1, + color: Color(0xFF353535), + ), + ), + Expanded( + flex: 4, + child: Container( + padding: EdgeInsets.only(left: 20, right: 20, top: 5), + alignment: Alignment.center, + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + "详情", + style: TextStyle( + color: Color(0xFF353535), + fontSize: 10, + ), + ), + GestureDetector( + child: Icon( + !coupon.isEx + ? Icons.keyboard_arrow_down + : Icons.keyboard_arrow_up, + color: Colors.black, + size: 18, + ), //点击按钮布局 + onTap: callbackEx, + ), + ], + ), + SizedBox( + height: 5, + ), + if (coupon.isEx) + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + S.of(context).shiyongriqi(coupon.useTime), + style: TextStyle( + color: Color(0xFF353535), + fontSize: 10, + ), + ), + Text( + "2020.01.20~2020.01.21", + style: TextStyle( + color: Color(0xFF353535), + fontSize: 10, + ), + ), + // Text( + // S.of(context).shiyongriqi(coupon.useTime), + // style: TextStyle( + // color: Color(0xFF727272), + // fontSize: 10, + // ), + // ), + ], + ), + ], + ), + ), + ), + ], + ), + ), + ), + ], + ), + ), + ); + } + + showAlertDialog(BuildContext context) { + //显示对话框 + showDialog( + context: context, + builder: (BuildContext context) { + return SimpleDialog( + titlePadding: EdgeInsets.all(10), + backgroundColor: Colors.transparent, + elevation: 0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(6))), + children: [ + Stack( + alignment: Alignment.topCenter, + children: [ + Container( + margin: EdgeInsets.only(top: 40), + decoration: new BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all(Radius.circular(8))), + width: 218, + height: 210, + child: Column( + children: [ + Padding( + padding: EdgeInsets.only(top: 50, bottom: 19), + child: Text( + "领取成功", + style: TextStyle( + color: Color(0xff353535), + fontSize: 16, + fontWeight: FontWeight.bold), + ), + ), + Text( + "您已成功领取优惠劵,请在", + style: + TextStyle(color: Color(0xff353535), fontSize: 14), + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + child: Text( + S.of(context).kaquan, + style: TextStyle( + color: Color(0xffFF7A1A), + fontSize: 14, + fontWeight: FontWeight.bold), + ), + onTap: () { + Navigator.of(context) + .pushNamed('/router/mine_card'); + }, + ), + Text( + "中查看", + style: TextStyle( + color: Color(0xff353535), fontSize: 14), + ), + ], + ), + Padding( + padding: EdgeInsets.only(top: 30), + child: RoundButton( + width: 130, + height: 34, + text: S.of(context).queren, + textColor: Colors.white, + fontSize: 12, + callback: () { + Navigator.of(context).pop(); + }, + padding: EdgeInsets.only( + top: 2, bottom: 2, left: 8, right: 8), + backgroup: Color(0xff32A060), + ), + ) + ], + ), + ), + Image.asset( + "assets/image/icon_order_success.png", + fit: BoxFit.cover, + width: 80, + height: 80, + ), + ], + ) + ], + ); + }, + ); + } +} diff --git a/pubspec.yaml b/pubspec.yaml index e0b1882c..f95bdbd1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -47,8 +47,8 @@ dependencies: json_annotation: ^3.1.1 # webview_flutter: ^2.0.8 logger: ^1.0.0 - chewie: ^1.2.2 - video_player: ^2.1.6 + chewie: ^0.12.2 + video_player: ^1.0.1 flutter_screenutil: ^5.0.0+2 bubble_tab_indicator: ^0.1.6 @@ -67,7 +67,7 @@ dependencies: # azlistview: ^1.1.1 flutter_html: ^1.3.0 #2.1.0 - photo_view: ^0.11.1 +# photo_view: ^0.11.1 dev_dependencies: flutter_test: