|
...
|
...
|
@@ -19,7 +19,8 @@ import 'package:provider/provider.dart'; |
|
|
|
*/
|
|
|
|
|
|
|
|
class CouponPage extends StatefulWidget {
|
|
|
|
CouponPage({Key key}) : super(key: key);
|
|
|
|
final bool needRefrsh;
|
|
|
|
CouponPage({Key key, this.needRefrsh = false}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
_CouponPageState createState() => _CouponPageState();
|
|
...
|
...
|
@@ -81,110 +82,127 @@ 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_fefefe,
|
|
|
|
appBar: SystemAppBar('线上券', rightImgName: '历史券', onTap: () {
|
|
|
|
EventBus().emit('changeStatusColor');
|
|
|
|
if (widget.needRefrsh) {
|
|
|
|
EventBus().emit('refresh_coupon_invitation');
|
|
|
|
} else {
|
|
|
|
EventBus().emit('changeStatusColor');
|
|
|
|
}
|
|
|
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
}, onTapRight: () {
|
|
|
|
NavigatorUtil.goCouponHistoryPage(context);
|
|
|
|
}),
|
|
|
|
body: 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();
|
|
|
|
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, _) {
|
|
|
|
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);
|
|
|
|
// },
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
text: '创建新券',
|
|
|
|
fontSize: 34,
|
|
|
|
isBold: false,
|
|
|
|
height: ScreenUtil().setWidth(80),
|
|
|
|
width: double.infinity,
|
|
|
|
radius: ScreenUtil().setWidth(10),
|
|
|
|
))
|
|
|
|
],
|
|
|
|
));
|
|
|
|
)),
|
|
|
|
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),
|
|
|
|
))
|
|
|
|
],
|
|
|
|
)));
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|