|
...
|
...
|
@@ -3,6 +3,7 @@ import 'package:flutter_easyrefresh/easy_refresh.dart'; |
|
|
|
import 'package:flutter_screenutil/screenutil.dart';
|
|
|
|
import 'package:one_key/constant/state.dart';
|
|
|
|
import 'package:one_key/pages/coupon/coupon_item.dart';
|
|
|
|
import 'package:one_key/pages/coupon/coupon_item_f.dart';
|
|
|
|
import 'package:one_key/provider/coupon_provider.dart';
|
|
|
|
import 'package:one_key/provider/user_model.dart';
|
|
|
|
import 'package:one_key/res/colors.dart';
|
|
...
|
...
|
@@ -26,9 +27,10 @@ class CouponPage extends StatefulWidget { |
|
|
|
_CouponPageState createState() => _CouponPageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _CouponPageState extends State<CouponPage> {
|
|
|
|
class _CouponPageState extends State<CouponPage> with TickerProviderStateMixin {
|
|
|
|
EasyRefreshController _controller = EasyRefreshController();
|
|
|
|
CouponProvider couponProvider;
|
|
|
|
TabController tabController;
|
|
|
|
|
|
|
|
///获取优惠券列表数据
|
|
|
|
_couponNetworkData({bool isShowLoading = true}) async {
|
|
...
|
...
|
@@ -63,6 +65,15 @@ class _CouponPageState extends State<CouponPage> { |
|
|
|
void initState() {
|
|
|
|
// TODO: implement initState
|
|
|
|
super.initState();
|
|
|
|
tabController = TabController(length: 3, vsync: this);
|
|
|
|
tabController.addListener(() {
|
|
|
|
//点击tab时或滑动tab回调一次
|
|
|
|
// if (tabController.index.toDouble() == tabController.animation.value) {
|
|
|
|
// getMessage(index: tabController.index);
|
|
|
|
// selectIndex = tabController.index;
|
|
|
|
setState(() {});
|
|
|
|
// }
|
|
|
|
});
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
_couponNetworkData();
|
|
|
|
});
|
|
...
|
...
|
@@ -82,7 +93,7 @@ class _CouponPageState extends State<CouponPage> { |
|
|
|
Widget build(BuildContext context) {
|
|
|
|
couponProvider = Provider.of<CouponProvider>(context, listen: true);
|
|
|
|
return Scaffold(
|
|
|
|
backgroundColor: MyColours.color_fefefe,
|
|
|
|
backgroundColor: MyColours.color_f3f3f3,
|
|
|
|
appBar: SystemAppBar('线上券', rightImgName: '历史券', onTap: () {
|
|
|
|
if (widget.needRefrsh) {
|
|
|
|
EventBus().emit('refresh_coupon_invitation');
|
|
...
|
...
|
@@ -95,18 +106,52 @@ class _CouponPageState extends State<CouponPage> { |
|
|
|
NavigatorUtil.goCouponHistoryPage(context);
|
|
|
|
}),
|
|
|
|
body: WillPopScope(
|
|
|
|
onWillPop: () {
|
|
|
|
if (widget.needRefrsh) {
|
|
|
|
EventBus().emit('refresh_coupon_invitation');
|
|
|
|
} else {
|
|
|
|
EventBus().emit('changeStatusColor');
|
|
|
|
}
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
},
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
Expanded(child: Consumer<CouponProvider>(
|
|
|
|
builder: (context, model, _) {
|
|
|
|
onWillPop: () {
|
|
|
|
if (widget.needRefrsh) {
|
|
|
|
EventBus().emit('refresh_coupon_invitation');
|
|
|
|
} else {
|
|
|
|
EventBus().emit('changeStatusColor');
|
|
|
|
}
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
},
|
|
|
|
child: Column(
|
|
|
|
children: <Widget>[
|
|
|
|
Container(
|
|
|
|
width: double.infinity,
|
|
|
|
height: ScreenUtil().setWidth(80),
|
|
|
|
color: MyColours.color_ffffff,
|
|
|
|
padding: EdgeInsets.only(bottom: ScreenUtil().setWidth(6)),
|
|
|
|
child: TabBar(
|
|
|
|
controller: tabController,
|
|
|
|
tabs: [
|
|
|
|
Tab(
|
|
|
|
text: "全部",
|
|
|
|
),
|
|
|
|
Tab(
|
|
|
|
text: "店铺优惠券",
|
|
|
|
),
|
|
|
|
Tab(
|
|
|
|
text: "我的优惠券",
|
|
|
|
)
|
|
|
|
],
|
|
|
|
indicatorColor: MyColours.color_438E93,
|
|
|
|
indicatorSize: TabBarIndicatorSize.label,
|
|
|
|
indicatorWeight: ScreenUtil().setWidth(4),
|
|
|
|
labelColor: MyColours.color_438E93,
|
|
|
|
unselectedLabelColor: MyColours.color_999999,
|
|
|
|
labelStyle: TextStyle(
|
|
|
|
color: MyColours.color_438E93,
|
|
|
|
fontSize: ScreenUtil().setSp(28),
|
|
|
|
fontWeight: FontWeight.bold),
|
|
|
|
unselectedLabelStyle: TextStyle(
|
|
|
|
color: MyColours.color_999999,
|
|
|
|
fontSize: ScreenUtil().setSp(24),
|
|
|
|
),
|
|
|
|
)),
|
|
|
|
VEmptyView(11),
|
|
|
|
Expanded(
|
|
|
|
child: TabBarView(controller: tabController, children: [
|
|
|
|
Consumer<CouponProvider>(builder: (context, model, _) {
|
|
|
|
if (model.pageState != PageState.Success) {
|
|
|
|
return ExceptionPage(
|
|
|
|
pageState: model.pageState,
|
|
...
|
...
|
@@ -127,29 +172,7 @@ class _CouponPageState extends State<CouponPage> { |
|
|
|
SliverList(
|
|
|
|
delegate: SliverChildBuilderDelegate(
|
|
|
|
(BuildContext context, int index) {
|
|
|
|
return Container(
|
|
|
|
margin:
|
|
|
|
EdgeInsets.all(ScreenUtil().setWidth(40)),
|
|
|
|
padding:
|
|
|
|
EdgeInsets.all(ScreenUtil().setWidth(30)),
|
|
|
|
color: MyColours.color_F0F0F0,
|
|
|
|
child: Text(
|
|
|
|
'使用说明:需在结账前出示优惠券二维码,店内工作人员微信扫码核销。超过有效期的券,会自动作废并移出列表。优惠券不可找零、兑现。',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_666666,
|
|
|
|
fontSize: ScreenUtil().setSp(24),
|
|
|
|
),
|
|
|
|
strutStyle: StrutStyle(
|
|
|
|
forceStrutHeight: true,
|
|
|
|
height: 1,
|
|
|
|
leading: 0.3),
|
|
|
|
));
|
|
|
|
}, childCount: 1),
|
|
|
|
),
|
|
|
|
SliverList(
|
|
|
|
delegate: SliverChildBuilderDelegate(
|
|
|
|
(BuildContext context, int index) {
|
|
|
|
return CouponItem(
|
|
|
|
return CouponItemF(
|
|
|
|
from: 'quan',
|
|
|
|
couponSonModel:
|
|
|
|
couponProvider.couponList[index],
|
|
...
|
...
|
@@ -178,31 +201,154 @@ class _CouponPageState extends State<CouponPage> { |
|
|
|
// },
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
)),
|
|
|
|
VEmptyView(20),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.fromLTRB(ScreenUtil().setWidth(40), 0,
|
|
|
|
ScreenUtil().setWidth(40), ScreenUtil().setWidth(40)),
|
|
|
|
child: RoundButton(
|
|
|
|
onPressed: () async {
|
|
|
|
bool needRefresh =
|
|
|
|
await NavigatorUtil.goCouponEditPage(context);
|
|
|
|
print(needRefresh);
|
|
|
|
if (needRefresh != null && needRefresh) {
|
|
|
|
//刷新页面数据
|
|
|
|
// _controller.callRefresh();
|
|
|
|
_couponNetworkData();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
text: '创建新券',
|
|
|
|
fontSize: 34,
|
|
|
|
isBold: false,
|
|
|
|
height: ScreenUtil().setWidth(80),
|
|
|
|
width: double.infinity,
|
|
|
|
radius: ScreenUtil().setWidth(10),
|
|
|
|
))
|
|
|
|
],
|
|
|
|
)));
|
|
|
|
}),
|
|
|
|
Container(
|
|
|
|
width: 100,
|
|
|
|
height: 100,
|
|
|
|
color: Colors.blue,
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
width: 100,
|
|
|
|
height: 100,
|
|
|
|
color: Colors.purple,
|
|
|
|
)
|
|
|
|
// MessageOnlineCheckPage()
|
|
|
|
]),
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
height: ScreenUtil().setWidth(91 * 2),
|
|
|
|
width: double.infinity,
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
top: ScreenUtil().setWidth(16 * 2),
|
|
|
|
bottom: ScreenUtil().setWidth(35 * 2),
|
|
|
|
left: ScreenUtil().setWidth(45 * 2),
|
|
|
|
right: ScreenUtil().setWidth(45 * 2),
|
|
|
|
),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: MyColours.color_ffffff,
|
|
|
|
boxShadow: [
|
|
|
|
BoxShadow(
|
|
|
|
spreadRadius: ScreenUtil().setWidth(2),
|
|
|
|
color: Color.fromRGBO(0, 0, 0, 0.1),
|
|
|
|
offset: Offset(0, ScreenUtil().setWidth(-2)),
|
|
|
|
blurRadius: ScreenUtil().setWidth(8))
|
|
|
|
],
|
|
|
|
borderRadius: BorderRadius.all(
|
|
|
|
Radius.circular(ScreenUtil().setWidth(16)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: RoundButton(
|
|
|
|
text: '创建新的优惠券',
|
|
|
|
height: ScreenUtil().setWidth(80),
|
|
|
|
radius: ScreenUtil().setWidth(14),
|
|
|
|
isBold: false,
|
|
|
|
fontSize: 28,
|
|
|
|
onPressed: () {},
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
// child: Column(
|
|
|
|
// children: [
|
|
|
|
// Expanded(child: Consumer<CouponProvider>(
|
|
|
|
// builder: (context, model, _) {
|
|
|
|
// if (model.pageState != PageState.Success) {
|
|
|
|
// return ExceptionPage(
|
|
|
|
// pageState: model.pageState,
|
|
|
|
// callback: () {
|
|
|
|
// // offset = 0;
|
|
|
|
// // getMessage(showLoading: true);
|
|
|
|
// _couponNetworkData();
|
|
|
|
// },
|
|
|
|
// emptyMsg: "暂时没有列表信息哦",
|
|
|
|
// emptyImg: "empty_search",
|
|
|
|
// showMsg: "加载中,请稍后...",
|
|
|
|
// );
|
|
|
|
// } else {
|
|
|
|
// return EasyRefresh.custom(
|
|
|
|
// controller: _controller,
|
|
|
|
// shrinkWrap: true,
|
|
|
|
// slivers: [
|
|
|
|
// SliverList(
|
|
|
|
// delegate: SliverChildBuilderDelegate(
|
|
|
|
// (BuildContext context, int index) {
|
|
|
|
// return Container(
|
|
|
|
// margin:
|
|
|
|
// EdgeInsets.all(ScreenUtil().setWidth(40)),
|
|
|
|
// padding:
|
|
|
|
// EdgeInsets.all(ScreenUtil().setWidth(30)),
|
|
|
|
// color: MyColours.color_F0F0F0,
|
|
|
|
// child: Text(
|
|
|
|
// '使用说明:需在结账前出示优惠券二维码,店内工作人员微信扫码核销。超过有效期的券,会自动作废并移出列表。优惠券不可找零、兑现。',
|
|
|
|
// style: TextStyle(
|
|
|
|
// color: MyColours.color_666666,
|
|
|
|
// fontSize: ScreenUtil().setSp(24),
|
|
|
|
// ),
|
|
|
|
// strutStyle: StrutStyle(
|
|
|
|
// forceStrutHeight: true,
|
|
|
|
// height: 1,
|
|
|
|
// leading: 0.3),
|
|
|
|
// ));
|
|
|
|
// }, childCount: 1),
|
|
|
|
// ),
|
|
|
|
// SliverList(
|
|
|
|
// delegate: SliverChildBuilderDelegate(
|
|
|
|
// (BuildContext context, int index) {
|
|
|
|
// return CouponItem(
|
|
|
|
// from: 'quan',
|
|
|
|
// couponSonModel:
|
|
|
|
// couponProvider.couponList[index],
|
|
|
|
// showBtn: true,
|
|
|
|
// onPressedSwich: () {
|
|
|
|
// couponProvider.couponList[index].isOpenBool =
|
|
|
|
// !couponProvider
|
|
|
|
// .couponList[index].isOpenBool;
|
|
|
|
// _setCustomerActivity(index);
|
|
|
|
// },
|
|
|
|
// onPressed: () {
|
|
|
|
// NavigatorUtil.goCouponDetailPage(context,
|
|
|
|
// couponProvider.couponList[index]);
|
|
|
|
// },
|
|
|
|
// );
|
|
|
|
// }, childCount: couponProvider.couponList.length),
|
|
|
|
// )
|
|
|
|
// ],
|
|
|
|
// // onRefresh: () async {
|
|
|
|
// // // offset = 0;
|
|
|
|
// // // getMessage(showLoading: false);
|
|
|
|
// // },
|
|
|
|
// // onLoad: () async {
|
|
|
|
// // // offset++;
|
|
|
|
// // // getMessage(showLoading: false);
|
|
|
|
// // },
|
|
|
|
// );
|
|
|
|
// }
|
|
|
|
// },
|
|
|
|
// )),
|
|
|
|
// VEmptyView(20),
|
|
|
|
// Padding(
|
|
|
|
// padding: EdgeInsets.fromLTRB(ScreenUtil().setWidth(40), 0,
|
|
|
|
// ScreenUtil().setWidth(40), ScreenUtil().setWidth(40)),
|
|
|
|
// child: RoundButton(
|
|
|
|
// onPressed: () async {
|
|
|
|
// bool needRefresh =
|
|
|
|
// await NavigatorUtil.goCouponEditPage(context);
|
|
|
|
// print(needRefresh);
|
|
|
|
// if (needRefresh != null && needRefresh) {
|
|
|
|
// //刷新页面数据
|
|
|
|
// // _controller.callRefresh();
|
|
|
|
// _couponNetworkData();
|
|
|
|
// }
|
|
|
|
// },
|
|
|
|
// text: '创建新券',
|
|
|
|
// fontSize: 34,
|
|
|
|
// isBold: false,
|
|
|
|
// height: ScreenUtil().setWidth(80),
|
|
|
|
// width: double.infinity,
|
|
|
|
// radius: ScreenUtil().setWidth(10),
|
|
|
|
// ))
|
|
|
|
// ],
|
|
|
|
// )
|
|
|
|
));
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|