Browse Source

页面更改

null_safety
w-R 4 years ago
parent
commit
f88ce0040e
  1. 3
      lib/generated/intl/messages_en.dart
  2. 18
      lib/generated/l10n.dart
  3. 4
      lib/l10n/intl_en.arb
  4. 315
      lib/mine/coupons_page.dart
  5. 106
      lib/mine/mine_card_page.dart
  6. 2
      lib/mine/mine_page.dart
  7. 112
      lib/mine/roll_center_page.dart
  8. 61
      lib/mine/vip_card_page.dart
  9. 321
      lib/mine/vip_detail_page.dart
  10. 2
      lib/retrofit/data/coupon.dart
  11. 221
      lib/view_widget/coupon_widget.dart
  12. 392
      lib/view_widget/new_coupon_widget.dart
  13. 6
      pubspec.yaml

3
lib/generated/intl/messages_en.dart

@ -173,11 +173,11 @@ class MessageLookup extends MessageLookupByLibrary {
"lijiqiandao" : MessageLookupByLibrary.simpleMessage("立即签到"), "lijiqiandao" : MessageLookupByLibrary.simpleMessage("立即签到"),
"lingjuanzhongxing" : MessageLookupByLibrary.simpleMessage("领卷中心"), "lingjuanzhongxing" : MessageLookupByLibrary.simpleMessage("领卷中心"),
"lingqu" : MessageLookupByLibrary.simpleMessage("领取"), "lingqu" : MessageLookupByLibrary.simpleMessage("领取"),
"lingquanzhongxin" : MessageLookupByLibrary.simpleMessage("领券中心"),
"lingquchenggong" : MessageLookupByLibrary.simpleMessage("领取成功"), "lingquchenggong" : MessageLookupByLibrary.simpleMessage("领取成功"),
"lingqudaokabao" : MessageLookupByLibrary.simpleMessage("领取到卡包"), "lingqudaokabao" : MessageLookupByLibrary.simpleMessage("领取到卡包"),
"lingqufangshi" : MessageLookupByLibrary.simpleMessage("领取方式"), "lingqufangshi" : MessageLookupByLibrary.simpleMessage("领取方式"),
"lingqushijian" : m9, "lingqushijian" : m9,
"linjuanzhongxin" : MessageLookupByLibrary.simpleMessage("领卷中心"),
"lishijilu" : MessageLookupByLibrary.simpleMessage("历史记录"), "lishijilu" : MessageLookupByLibrary.simpleMessage("历史记录"),
"login" : MessageLookupByLibrary.simpleMessage("Login"), "login" : MessageLookupByLibrary.simpleMessage("Login"),
"login_splash" : MessageLookupByLibrary.simpleMessage("Welcome to Yixin Homecoming"), "login_splash" : MessageLookupByLibrary.simpleMessage("Welcome to Yixin Homecoming"),
@ -244,6 +244,7 @@ class MessageLookup extends MessageLookupByLibrary {
"ricahngfenxiang" : MessageLookupByLibrary.simpleMessage("日常分享"), "ricahngfenxiang" : MessageLookupByLibrary.simpleMessage("日常分享"),
"send_code" : MessageLookupByLibrary.simpleMessage("发送验证"), "send_code" : MessageLookupByLibrary.simpleMessage("发送验证"),
"shanchudingdan" : MessageLookupByLibrary.simpleMessage("删除订单"), "shanchudingdan" : MessageLookupByLibrary.simpleMessage("删除订单"),
"shangjiaquan" : MessageLookupByLibrary.simpleMessage("商家券"),
"shangpinjifen" : m15, "shangpinjifen" : m15,
"shenmijifendali" : MessageLookupByLibrary.simpleMessage("神秘积分大礼"), "shenmijifendali" : MessageLookupByLibrary.simpleMessage("神秘积分大礼"),
"shezhi" : MessageLookupByLibrary.simpleMessage("设置"), "shezhi" : MessageLookupByLibrary.simpleMessage("设置"),

18
lib/generated/l10n.dart

@ -1617,11 +1617,11 @@ class S {
); );
} }
/// `` /// ``
String get linjuanzhongxin { String get lingquanzhongxin {
return Intl.message( return Intl.message(
'中心', '中心',
name: 'linjuanzhongxin', name: 'lingquanzhongxin',
desc: '', desc: '',
args: [], args: [],
); );
@ -2717,6 +2717,16 @@ class S {
); );
} }
/// ``
String get shangjiaquan {
return Intl.message(
'商家券',
name: 'shangjiaquan',
desc: '',
args: [],
);
}
/// `{man}` /// `{man}`
String manyuankeyong(Object man) { String manyuankeyong(Object man) {
return Intl.message( return Intl.message(

4
lib/l10n/intl_en.arb

@ -160,7 +160,7 @@
"quanxian": "权限", "quanxian": "权限",
"tuichudenglu": "退出登录", "tuichudenglu": "退出登录",
"xiaoxi": "消息", "xiaoxi": "消息",
"linjuanzhongxin": "领卷中心", "lingquanzhongxin": "领券中心",
"guanyu": "关于", "guanyu": "关于",
"huodongzixun": "活动资讯", "huodongzixun": "活动资讯",
"wodexiaoxi": "我的消息", "wodexiaoxi": "我的消息",
@ -275,7 +275,9 @@
"huiyuankaxiangqing": "会员卡详情", "huiyuankaxiangqing": "会员卡详情",
"yuemingxi": "余额明细", "yuemingxi": "余额明细",
"kelingqudeyouhuiquan": "可领取的优惠券", "kelingqudeyouhuiquan": "可领取的优惠券",
"shangjiaquan": "商家券",
"manyuankeyong": "满{man}元可用", "manyuankeyong": "满{man}元可用",
"jifen": "积分",

315
lib/mine/coupons_page.dart

@ -1,15 +1,8 @@
import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:huixiang/generated/l10n.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/coupon.dart';
import 'package:huixiang/retrofit/data/page.dart'; import 'package:huixiang/view_widget/new_coupon_widget.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 CouponsPage extends StatefulWidget { class CouponsPage extends StatefulWidget {
@override @override
@ -19,254 +12,92 @@ class CouponsPage extends StatefulWidget {
} }
class _CouponsPage extends State<CouponsPage> { class _CouponsPage extends State<CouponsPage> {
RefreshController _refreshController; int btnStatus = 0;
ApiService apiService;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
SharedPreferences.getInstance().then((value) => {
apiService = ApiService(Dio(), token: value.getString('token')),
queryCard(),
});
_refreshController = RefreshController(initialRefresh: false);
}
int pageNum = 1;
List<Coupon> coupons = [];
void _onRefresh() async {
pageNum = 1;
queryCard();
} }
queryCard() async { List<Coupon> coupons = [
BaseData baseData = await apiService.queryCard({ Coupon.test("",0,false),Coupon.test("",1,false),Coupon.test("",1,false),Coupon.test("",0,false),Coupon.test("",0,false)
"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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
body: Container( body: Column(children: [
child: Row( Row(
children: [ children: [
Container( Container(
width: 68, width: 68,
height: 26, height: 26,
alignment: Alignment.center, alignment: Alignment.center,
margin: EdgeInsets.only(left: 16, right: 12, top: 10, bottom: 14), margin: EdgeInsets.only(left: 16, right: 12, top: 10, bottom: 14),
decoration:BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(2)), borderRadius: BorderRadius.all(Radius.circular(2)),
color: Colors.white, color: btnStatus == 0 ? Colors.white : Color(0xffE5E5E5),
),
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),
),
),
),
),
],
), ),
), child: GestureDetector(
); onTap: () {
} setState(() {
btnStatus = 0;
Widget vipCardItem() { coupons = [Coupon.test("",0,false),Coupon.test("",1,false),Coupon.test("",1,false),Coupon.test("",0,false),Coupon.test("",0,false)];
return Container( });
margin: EdgeInsets.fromLTRB(16, 8, 16, 8), },
// margin: EdgeInsets.all(16), child: Text(
child: Stack( S.of(context).keyongquan,
// alignment: Alignment.center, style: TextStyle(
children: [ fontSize: 14,
Image.asset( fontWeight: btnStatus == 0 ? FontWeight.bold : FontWeight.normal,
"assets/image/icon_vip_bj.png", color: btnStatus == 0 ? Colors.black : Color(0xff727272),
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,
), ),
Row( ),
mainAxisAlignment: MainAxisAlignment.spaceBetween, ),
crossAxisAlignment: CrossAxisAlignment.center, Container(
children: [ width: 68,
Expanded( height: 26,
flex: 1, alignment: Alignment.center,
child: Text.rich( margin: EdgeInsets.only(left: 16, top: 10, bottom: 14),
TextSpan(children: [ decoration: BoxDecoration(
TextSpan( borderRadius: BorderRadius.all(Radius.circular(2)),
text: "No.202107021324199", color: btnStatus == 1 ? Colors.white : Color(0xffE5E5E5),
style: TextStyle(fontSize: 14, color: Colors.white), ),
), child: GestureDetector(
]), onTap: () {
), setState(() {
), btnStatus = 1;
Text.rich( coupons = [Coupon.test("",2,false),Coupon.test("",2,false),Coupon.test("",2,false),Coupon.test("",2,false),Coupon.test("",2,false)];
TextSpan(children: [ });
TextSpan( },
text: "有效期限:", child: Text(
style: TextStyle(fontSize: 12, color: Colors.white), S.of(context).shixiaoquan,
), style: TextStyle(
]), fontSize: 14,
), fontWeight: btnStatus == 1 ? FontWeight.bold : FontWeight.normal,
Text.rich( color: btnStatus == 1 ? Colors.black : Color(0xff727272),
TextSpan(children: [ ),
TextSpan(
text: "长期有效",
style: TextStyle(fontSize: 12, color: Colors.white),
),
]),
),
],
), ),
], ),
), ),
), ],
], ),
), Expanded(child: ListView.builder(
itemBuilder: (context, position) {
return GestureDetector(
child: NewCouponWidget(coupons[position],(){
},(){
setState(() {
coupons[position].isEx = !coupons[position].isEx;
});
}),
);
},
itemCount: 5,
),)
]),
); );
} }
} }

106
lib/mine/mine_card_page.dart

@ -150,112 +150,6 @@ class _MineCardPage extends State<MineCardPage>
body: TabBarView( body: TabBarView(
children: _pages, 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,
// ),
// ),
// ),
// ),
// ],
// ),
// ),
), ),
); );
} }

2
lib/mine/mine_page.dart

@ -238,7 +238,7 @@ class _MinePage extends State<MinePage> with AutomaticKeepAliveClientMixin {
Navigator.of(context).pushNamed('/router/roll_center_page'); Navigator.of(context).pushNamed('/router/roll_center_page');
}, },
child: mineItem( child: mineItem(
S.of(context).linjuanzhongxin, S.of(context).lingquanzhongxin,
"assets/image/icon_mine_invoice_assistant.png", "assets/image/icon_mine_invoice_assistant.png",
), ),
), ),

112
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/retrofit/retrofit_api.dart';
import 'package:huixiang/view_widget/coupon_widget.dart'; import 'package:huixiang/view_widget/coupon_widget.dart';
import 'package:huixiang/view_widget/item_title.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:pull_to_refresh/pull_to_refresh.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
@ -20,7 +21,7 @@ class RollCenterPage extends StatefulWidget {
} }
class _RollCenterPage extends State<RollCenterPage> { class _RollCenterPage extends State<RollCenterPage> {
RefreshController _refreshController; // RefreshController _refreshController;
ApiService apiService; ApiService apiService;
@ -28,61 +29,24 @@ class _RollCenterPage extends State<RollCenterPage> {
void initState() { void initState() {
super.initState(); super.initState();
SharedPreferences.getInstance().then((value) => { // SharedPreferences.getInstance().then((value) => {
apiService = ApiService(Dio(), token: value.getString('token')), // apiService = ApiService(Dio(), token: value.getString('token')),
queryCoupon(), // queryCoupon(),
}); // });
//
_refreshController = RefreshController(initialRefresh: false); // _refreshController = RefreshController(initialRefresh: false);
} }
int pageNum = 1; int pageNum = 1;
List<Coupon> coupons = []; List<Coupon> coupons = [Coupon.test("",1,false),Coupon.test("",1,false),Coupon.test("",1,false),Coupon.test("",1,false),Coupon.test("",1,false)];
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);
}
}
void _onRefresh() async {
pageNum = 1;
queryCoupon();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text( title: Text(
"领卷中心", S.of(context).lingquanzhongxin,
style: TextStyle( style: TextStyle(
color: Colors.black, color: Colors.black,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -114,51 +78,29 @@ class _RollCenterPage extends State<RollCenterPage> {
children: [ children: [
ItemTitle( ItemTitle(
text: S.of(context).kelingqudeyouhuiquan, text: S.of(context).kelingqudeyouhuiquan,
imgPath: "assets/image/icon_card_coupon.png", imgPath: "assets/image/icon_card_coupon.png",
moreText: S.of(context).chakanwodekaquan, moreText: S.of(context).chakanwodekaquan,
onTap: () { onTap: () {
Navigator.of(context).pushNamed('/router/mine_card'); Navigator.of(context).pushNamed('/router/mine_card');
}, },
), ),
Expanded( Expanded(child: ListView.builder(
flex: 1, itemBuilder: (context, position) {
child: Container( return GestureDetector(
child: SmartRefresher( child: NewCouponWidget(coupons[position],(){
enablePullDown: true, setState(() {
enablePullUp: true, coupons = [Coupon.test("",1,false),Coupon.test("",1,false),Coupon.test("",1,false),Coupon.test("",1,false),Coupon.test("",1,false)];
header: ClassicHeader(), });
footer: CustomFooter( },(){
builder: (context, mode) { setState(() {
Widget body; coupons[position].isEx = !coupons[position].isEx;
if (mode == LoadStatus.idle) { });
body = Text("pull up load"); }),
} else if (mode == LoadStatus.loading) { );
body = CupertinoActivityIndicator(); },
} else if (mode == LoadStatus.failed) { itemCount: 5,
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,
),
),
),
)
], ],
), ),
), ),

61
lib/mine/vip_card_page.dart

@ -1,15 +1,8 @@
import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:huixiang/generated/l10n.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/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:pull_to_refresh/pull_to_refresh.dart';
import 'package:shared_preferences/shared_preferences.dart';
class VipCardPage extends StatefulWidget { class VipCardPage extends StatefulWidget {
@override @override
@ -21,59 +14,19 @@ class VipCardPage extends StatefulWidget {
class _VipCardPage extends State<VipCardPage> { class _VipCardPage extends State<VipCardPage> {
RefreshController _refreshController; RefreshController _refreshController;
ApiService apiService;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
SharedPreferences.getInstance().then((value) => {
apiService = ApiService(Dio(), token: value.getString('token')),
queryCard(),
});
_refreshController = RefreshController(initialRefresh: false); _refreshController = RefreshController(initialRefresh: false);
} }
int pageNum = 1; int pageNum = 1;
List<Coupon> coupons = []; List<Coupon> coupons = [
Coupon(),Coupon(),Coupon(),Coupon()
];
void _onRefresh() async { void _onRefresh() async {
pageNum = 1; 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 @override
@ -106,7 +59,7 @@ class _VipCardPage extends State<VipCardPage> {
), ),
controller: _refreshController, controller: _refreshController,
onRefresh: _onRefresh, onRefresh: _onRefresh,
onLoading: queryCard,
child: ListView.builder( child: ListView.builder(
itemBuilder: (context, position) { itemBuilder: (context, position) {
return GestureDetector( return GestureDetector(
@ -115,12 +68,6 @@ class _VipCardPage extends State<VipCardPage> {
}, },
child: vipCardItem(), child: vipCardItem(),
); );
return GestureDetector(
onTap: () {
Navigator.of(context).pushNamed('/router/vip_details_page');
},
child: vipCardItem(),
);
}, },
itemCount: coupons.length, itemCount: coupons.length,
), ),

321
lib/mine/vip_detail_page.dart

@ -1,9 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:huixiang/generated/l10n.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/round_button.dart';
import 'package:huixiang/view_widget/separator.dart';
class VipDetailPage extends StatefulWidget { class VipDetailPage extends StatefulWidget {
@override @override
@ -43,172 +40,57 @@ class _VipDetailPage extends State<VipDetailPage> {
), ),
titleSpacing: 2, titleSpacing: 2,
leadingWidth: 56, 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( body: Column(
child: Stack( children: [
children: [ Stack(
Container( children: [
height: 150, Container(
color: Color(0xFF3A405A), height: 150,
), color: Color(0xFF3A405A),
SingleChildScrollView(
physics: BouncingScrollPhysics(),
child: Container(
child: Column(
children: [
buildAddress(),
buildCommodity(),
Container(
height: 42,
),
],
),
), ),
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() { Widget buildAddress() {
return Container( return Container(
margin: EdgeInsets.fromLTRB(16, 8, 16, 8), margin: EdgeInsets.fromLTRB(16, 8, 16, 8),
@ -308,7 +190,7 @@ class _VipDetailPage extends State<VipDetailPage> {
Text.rich( Text.rich(
TextSpan(children: [ TextSpan(children: [
TextSpan( TextSpan(
text: "余额", text: S.of(context).yue,
style: TextStyle( style: TextStyle(
fontSize: 14, fontSize: 14,
color: Colors.white), color: Colors.white),
@ -340,7 +222,7 @@ class _VipDetailPage extends State<VipDetailPage> {
Text.rich( Text.rich(
TextSpan(children: [ TextSpan(children: [
TextSpan( TextSpan(
text: "积分", text: S.of(context).jifen,
style: TextStyle(fontSize: 14, color: Colors.white), style: TextStyle(fontSize: 14, color: Colors.white),
), ),
]), ]),
@ -350,119 +232,10 @@ class _VipDetailPage extends State<VipDetailPage> {
], ],
),), ),),
],
),
),
],
),
);
}
Widget buildCommodity() { ],
return Stack(
alignment: Alignment.centerRight,
children: [
Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: historyList(),
),
),
],
);
}
List<Widget> 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,
)
], ],
), ),
); );

2
lib/retrofit/data/coupon.dart

@ -39,6 +39,7 @@ class Coupon {
Coupon(); Coupon();
Coupon.test(this.couponName,this.status,this.isEx);
String id; String id;
String createTime; String createTime;
@ -65,6 +66,7 @@ class Coupon {
String receiveTime; String receiveTime;
dynamic useTime; dynamic useTime;
int status; int status;
bool isEx;
factory Coupon.fromJson(Map<String, dynamic> json) => factory Coupon.fromJson(Map<String, dynamic> json) =>

221
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) { showAlertDialog(BuildContext context) {

392
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: <Widget>[
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,
),
],
)
],
);
},
);
}
}

6
pubspec.yaml

@ -47,8 +47,8 @@ dependencies:
json_annotation: ^3.1.1 json_annotation: ^3.1.1
# webview_flutter: ^2.0.8 # webview_flutter: ^2.0.8
logger: ^1.0.0 logger: ^1.0.0
chewie: ^1.2.2 chewie: ^0.12.2
video_player: ^2.1.6 video_player: ^1.0.1
flutter_screenutil: ^5.0.0+2 flutter_screenutil: ^5.0.0+2
bubble_tab_indicator: ^0.1.6 bubble_tab_indicator: ^0.1.6
@ -67,7 +67,7 @@ dependencies:
# azlistview: ^1.1.1 # azlistview: ^1.1.1
flutter_html: ^1.3.0 #2.1.0 flutter_html: ^1.3.0 #2.1.0
photo_view: ^0.11.1 # photo_view: ^0.11.1
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:

Loading…
Cancel
Save