Commit 662bac0486112802b606d0d88895a2468ee08a78

Authored by wdn127929
1 parent 6f0f5277

预订安排页添加优惠按钮

... ... @@ -11,14 +11,14 @@ if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = "254"
def flutterVersionCode = "260"
if (flutterVersionCode == null) {
flutterVersionCode = '254'
flutterVersionCode = '260'
}
def flutterVersionName = "2.5.4"
def flutterVersionName = "2.6.0"
if (flutterVersionName == null) {
flutterVersionName = '2.5.4'
flutterVersionName = '2.6.0'
}
apply plugin: 'com.android.application'
... ...
... ... @@ -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),
))
],
)));
}
}
... ...
... ... @@ -14,6 +14,7 @@ import 'package:one_key/provider/base_info_provider.dart';
import 'package:one_key/provider/coupon_provider.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/event_bus.dart';
import 'package:one_key/utils/misc.dart';
import 'package:one_key/route/navigator_util.dart';
import 'package:one_key/utils/utils.dart';
... ... @@ -68,6 +69,9 @@ class InvicationPageState extends State<InvicationPage> {
_getCustomerActivityBaseinfo();
_getSellerPhotoById();
});
bus.on("refresh_coupon_invitation", (args) {
_couponNetworkData(isShowLoading: false);
});
Utils.changeStatusColor(color: Colors.transparent);
dateTime =
DateTime.fromMillisecondsSinceEpoch(int.parse(widget.ddate) * 1000);
... ... @@ -77,6 +81,14 @@ class InvicationPageState extends State<InvicationPage> {
"${dateTime.year}/${Utils.addZeroNumber(dateTime.month)}/${Utils.addZeroNumber(dateTime.day)} 星期${Utils.formatWeekDayNum(dateTime.weekday)} ${widget.ddateStr}";
}
@override
void dispose() {
Utils.changeStatusColor();
couponProvider.clearSelect();
bus.off("refresh_coupon_invitation");
super.dispose();
}
_getSellerPhotoById() async {
Map<String, String> params = {
'sellerid': Provider.of<UserModel>(context, listen: false).user.sellerid,
... ... @@ -182,13 +194,6 @@ class InvicationPageState extends State<InvicationPage> {
}
}
@override
void dispose() {
Utils.changeStatusColor();
couponProvider.clearSelect();
super.dispose();
}
//中间内容显示组件
Widget _middleWidget(String title, String content) {
return Column(
... ... @@ -374,18 +379,67 @@ class InvicationPageState extends State<InvicationPage> {
CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.only(
left: ScreenUtil()
.setWidth(70)),
child: Image.network(
qiniuUrl == ''
? 'http://nosqn.colorcun.com/yd_person.png'
: qiniuUrl,
width: ScreenUtil()
.setWidth(143 * 2),
height: ScreenUtil()
.setWidth(190 * 2)),
),
padding: EdgeInsets.only(
left: ScreenUtil()
.setWidth(70)),
child: Stack(
alignment:
Alignment.bottomCenter,
children: [
Image.network(
qiniuUrl == ''
? 'http://nosqn.colorcun.com/yd_person.png'
: qiniuUrl,
// 'http://nosqn.colorcun.com/yd_person.png',
width: ScreenUtil()
.setWidth(143 * 2),
height: ScreenUtil()
.setWidth(190 * 2)),
couponProvider.coupons
.length ==
0
? Align(
alignment: Alignment
.bottomCenter,
child: RoundButton(
width: ScreenUtil()
.setWidth(
86 * 2),
height:
ScreenUtil()
.setWidth(
30 *
2),
radius:
ScreenUtil()
.setWidth(
30),
space:
ScreenUtil()
.setWidth(
20),
text: '添加优惠',
textColor: MyColours
.color_ffffff,
isBold: false,
fontSize: 28,
gradientStart:
MyColours
.color_199095,
gradientEnd: MyColours
.color_199095,
onPressed: () {
NavigatorUtil
.goCouponPage(
context,
needRefrsh:
true);
},
),
)
: Container()
],
)),
HEmptyView(10),
Spacer(),
Container(
... ... @@ -907,7 +961,8 @@ class InvicationPageState extends State<InvicationPage> {
right: 0,
child: Container(
// padding: EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(16),vertical: ScreenUtil().setWidth(4)),
padding: EdgeInsets.only(bottom: ScreenUtil().setWidth(6)),
padding: EdgeInsets.only(
bottom: ScreenUtil().setWidth(6)),
alignment: Alignment.center,
width: ScreenUtil().setWidth(62 * 2),
height: ScreenUtil().setWidth(42),
... ...
... ... @@ -165,30 +165,38 @@ class CouponProvider with ChangeNotifier {
.catchError((error) {
print(error.toString());
if (error is MyError) {
switch (error.type) {
case 1:
pageState = PageState.ConnectivityError;
break;
case 2:
pageState = PageState.ConnectivityTimeOut;
break;
default:
pageState = PageState.ConnectivityError;
break;
if (isShowLoading) {
switch (error.type) {
case 1:
pageState = PageState.ConnectivityError;
break;
case 2:
pageState = PageState.ConnectivityTimeOut;
break;
default:
pageState = PageState.ConnectivityError;
break;
}
}
}
notifyListeners();
});
if (baseResp.code == Constant.status_success) {
if (baseResp.data.isEmpty) {
pageState = PageState.Empty;
if (isShowLoading) {
pageState = PageState.Empty;
}
} else {
pageState = PageState.Success;
if (isShowLoading) {
pageState = PageState.Success;
}
}
couponList = CouponModel.fromJson(baseResp.responseData).data;
notifyListeners();
} else {
pageState = PageState.ConnectivityError;
if (isShowLoading) {
pageState = PageState.ConnectivityError;
}
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
... ...
... ... @@ -164,8 +164,10 @@ class NavigatorUtil {
}
/// 优惠券列表
static void goCouponPage(BuildContext context, {replace = false}) {
_navigateTo(context, "${Routes.coupon}", replace: replace);
static void goCouponPage(BuildContext context,
{replace = false, needRefrsh = false}) {
_navigateTo(context, "${Routes.coupon}?needRefrsh=${needRefrsh}",
replace: replace);
}
/// 优惠券历史列表
... ...
... ... @@ -250,8 +250,10 @@ var handleInvoiceDetailPageHandler = new Handler(
var handleCouponPageHandler = new Handler(
handlerFunc: (BuildContext context, Map<String, List<Object>> params) {
// String rid = params["rid"].first;
// bool fromNotify = FluroConvertUtils.string2bool(params["fromNotify"].first);
return CouponPage();
bool needRefrsh = FluroConvertUtils.string2bool(params["needRefrsh"].first);
return CouponPage(
needRefrsh: needRefrsh,
);
});
///优惠券历史列表
... ...