Commit 035b1ebe67282c558511a6a73347d705edcb6f97

Authored by wdn127929
1 parent 6597b3b7

优惠券新建相关静态页面

... ... @@ -10,6 +10,7 @@ import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_easyrefresh/material_header.dart';
import 'package:fluwx/fluwx.dart';
import 'package:one_key/pages/detail/handle_online_page.dart';
import 'package:one_key/provider/coupon_provider.dart';
import 'package:one_key/provider/message_dialog_model.dart';
import 'package:intl/date_symbol_data_local.dart';
import 'package:one_key/provider/notebook_detail_model.dart';
... ... @@ -61,6 +62,9 @@ Future<void> main() async {
ChangeNotifierProvider<NotebookDetailModel>(
create: (_) => NotebookDetailModel(),
),
ChangeNotifierProvider<CouponProvider>(
create: (_) => CouponProvider(),
),
],
child: MyApp(),
));
... ...
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/navigator_util.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/round_button.dart';
import 'package:one_key/widgets/system_app_bar.dart';
import 'package:one_key/widgets/v_empty_view.dart';
/**
* 新建券
*/
class CouponEidtPage extends StatefulWidget {
CouponEidtPage({Key key}) : super(key: key);
@override
_CouponEidtPageState createState() => _CouponEidtPageState();
}
class _CouponEidtPageState extends State<CouponEidtPage> {
ScrollController controller = ScrollController();
TextEditingController _couponNameEditControl;
final heightCell = ScreenUtil().setWidth(80);
bool swichState = true; //默认启用
///输入框
Widget _textfield(String title, String hintText) {
return Container(
height: heightCell,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
// height: ScreenUtil().setWidth(40),
// color: Colors.red,
child: Text(
title,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: ScreenUtil().setSp(30)),
),
),
HEmptyView(20),
Expanded(
child: TextField(
controller: _couponNameEditControl,
textAlign: TextAlign.right,
maxLines: 1,
// //光标颜色
// cursorColor:
// widget.isSelect ? Colors.white : MyColours.color_199095,
//输入文本的样式
style: TextStyle(
fontSize: ScreenUtil().setSp(26),
),
// focusNode: _cancelNode,
// textAlignVertical: TextAlignVertical.bottom,
decoration: InputDecoration(
// fillColor: Colors.lightGreenAccent,
// filled: true,
border: OutlineInputBorder(borderSide: BorderSide.none),
hintText: hintText,
hintStyle: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(26),
),
// contentPadding: EdgeInsets.only(
// bottom: ScreenUtil().setWidth(30)), //ios 17
// border: InputBorder.none,
),
onChanged: (value) {},
onEditingComplete: () {
FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
},
keyboardType: TextInputType.text,
),
)
],
),
);
}
///时间选择
Widget _select(String title, String hintText) {
return InkWell(
onTap: () {
//弹出时间选择器
},
child: Container(
height: heightCell,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
// height: ScreenUtil().setWidth(40),
// color: Colors.red,
child: Text(
title,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: ScreenUtil().setSp(30)),
),
),
HEmptyView(20),
Spacer(),
Text(hintText,
style: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(26),
)),
HEmptyView(20),
Image.asset(
Utils.getImgPath('arr_right_gray'),
width: ScreenUtil().setWidth(12),
height: ScreenUtil().setWidth(22),
)
],
),
),
);
}
///券说明
Widget _explain(String title, String hintText) {
return Container(
// height: ScreenUtil().setWidth(380),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: heightCell,
child: Align(
alignment: Alignment.centerLeft,
child: Text(
title,
textAlign: TextAlign.left,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: ScreenUtil().setSp(30)),
)),
),
VEmptyView(10),
TextField(
// keyboardType: TextInputType.number, //键盘类型,数字键盘
maxLines: 7,
// maxLength: 200,
// maxLengthEnforced: true,
decoration: InputDecoration(
contentPadding: EdgeInsets.all(ScreenUtil().setWidth(20)),
hintText: hintText,
fillColor: MyColours.color_EEEEEE,
filled: true,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(15),
borderSide: BorderSide.none),
),
onChanged: (value) {},
),
],
),
);
}
///是否立即启用
Widget _canUse(String title) {
return InkWell(
onTap: () {
setState(() {
swichState = !swichState;
});
},
child: Container(
padding: EdgeInsets.only(top: ScreenUtil().setWidth(30)),
// height: heightCell,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
// height: ScreenUtil().setWidth(40),
// color: Colors.red,
child: Text(
title,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: ScreenUtil().setSp(30)),
),
),
Spacer(),
Image.asset(
swichState
? Utils.getImgPath('swich_on')
: Utils.getImgPath('swich_off'),
width: ScreenUtil().setWidth(122),
height: ScreenUtil().setWidth(82),
)
],
),
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: SystemAppBar(
'创建新券',
onTap: () {
Navigator.pop(context, false);
},
),
body: InkWell(
onTap: () {
FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
},
child: Column(children: [
Expanded(
child: SingleChildScrollView(
controller: controller,
physics: BouncingScrollPhysics(),
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40)),
child: Column(
children: [
VEmptyView(20),
_textfield('券名称', '例:9折券/200元代金券/菜品券'),
_textfield('券要求', '例:无门槛/满2000元'),
_select('有效期从', '点击选择'),
_select('有效期至', '点击选择'),
_explain('券说明', '例:可用包间,停车免费,不与店内其他活动共享等'),
_canUse('是否立即启用'),
],
))),
),
VEmptyView(20),
Padding(
padding: EdgeInsets.fromLTRB(ScreenUtil().setWidth(40), 0,
ScreenUtil().setWidth(40), ScreenUtil().setWidth(40)),
child: RoundButton(
onPressed: () {
Navigator.pop(context, true);
},
text: '保存',
fontSize: 34,
isBold: false,
height: ScreenUtil().setWidth(80),
width: double.infinity,
radius: ScreenUtil().setWidth(10),
))
])),
);
}
}
... ...
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/pages/coupon/coupon_item.dart';
import 'package:one_key/provider/coupon_provider.dart';
import 'package:one_key/widgets/page_exception.dart';
import 'package:one_key/widgets/system_app_bar.dart';
import 'package:provider/provider.dart';
/**
* 历史券
*/
class CouponHistoryPage extends StatefulWidget {
CouponHistoryPage({Key key}) : super(key: key);
@override
_CouponHistoryPageState createState() => _CouponHistoryPageState();
}
class _CouponHistoryPageState extends State<CouponHistoryPage> {
EasyRefreshController _controller = EasyRefreshController();
CouponProvider couponProvider;
///获取优惠券列表数据
_couponNetworkData() {
return Future.delayed(Duration(seconds: 1),
() => couponProvider.pageStateHistory = PageState.Success);
}
@override
void initState() {
// TODO: implement initState
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
_couponNetworkData();
});
}
@override
Widget build(BuildContext context) {
couponProvider = Provider.of<CouponProvider>(context, listen: true);
return Scaffold(
appBar: SystemAppBar(
' 历史券',
onTap: () {
Navigator.of(context).pop();
},
),
body: Consumer<CouponProvider>(
builder: (context, model, _) {
if (model.pageStateHistory != PageState.Success) {
return ExceptionPage(
pageState: model.pageState,
callback: () {
// offset = 0;
// getMessage(showLoading: true);
},
emptyMsg: "暂时没有列表信息哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return EasyRefresh.custom(
controller: _controller,
slivers: [
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return CouponItem(
index: index,
couponProvider: couponProvider,
onPressed: () {
couponProvider.swichStateData[index] =
!couponProvider.swichStateData[index];
couponProvider.notifyListeners();
},
);
}, childCount: couponProvider.swichStateData.length),
)
],
onRefresh: () async {
// offset = 0;
// getMessage(showLoading: false);
},
onLoad: () async {
// offset++;
// getMessage(showLoading: false);
},
);
}
},
));
}
}
... ...
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/provider/coupon_provider.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/round_button.dart';
import 'package:one_key/widgets/v_empty_view.dart';
class CouponItem extends StatefulWidget {
final int index;
final VoidCallback onPressed;
final CouponProvider couponProvider;
CouponItem({Key key, this.index, this.onPressed, this.couponProvider})
: super(key: key);
@override
_CouponItemState createState() => _CouponItemState();
}
class _CouponItemState extends State<CouponItem> {
@override
Widget build(BuildContext context) {
bool switchState = widget.couponProvider.swichStateData[widget.index];
return Padding(
padding: EdgeInsets.all(ScreenUtil().setWidth(20)),
child: Container(
height: ScreenUtil().setWidth(300),
padding: EdgeInsets.all(ScreenUtil().setWidth(20)),
decoration: BoxDecoration(
color: switchState ? MyColours.app_main : MyColours.color_E0E0E0,
borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10))),
child: Stack(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
'九折券',
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(50),
fontWeight: FontWeight.bold),
),
Text('(无门槛)',
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(22),
fontWeight: FontWeight.bold))
],
),
VEmptyView(20),
Container(
padding: EdgeInsets.all(ScreenUtil().setWidth(20)),
child: Text(
'说明:大家发哈接电话发费哈咖啡的哈快递费哈就快递费哈加客服哈艰苦奋斗哈佛等哈快回复解答快回复',
style: TextStyle(
color: switchState
? MyColours.app_main
: MyColours.color_e5e5e5,
fontSize: ScreenUtil().setSp(22))),
decoration: BoxDecoration(
color: MyColours.color_ffffff,
borderRadius:
BorderRadius.circular(ScreenUtil().setWidth(10))),
),
Container(
padding: EdgeInsets.only(top: ScreenUtil().setWidth(20)),
child: Text('有效期:2021.01.01 00:00:00 至 2021.01.31 23:59:59',
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(22))),
),
],
),
Positioned(
top: 0,
right: 0,
child: Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('被领取:99张',
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(22))),
Text('已使用:9张',
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(22))),
],
),
HEmptyView(20),
RoundButton(
width: ScreenUtil().setWidth(100),
height: ScreenUtil().setWidth(50),
radius: ScreenUtil().setWidth(10),
text: switchState ? '停用' : '启用',
textColor: MyColours.color_666666,
gradientStart: Colors.white,
gradientEnd: Colors.white,
onPressed: widget.onPressed,
)
],
),
)
],
),
));
}
}
... ...
import 'package:flutter/material.dart';
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/provider/coupon_provider.dart';
import 'package:one_key/utils/event_bus.dart';
import 'package:one_key/utils/navigator_util.dart';
import 'package:one_key/widgets/page_exception.dart';
import 'package:one_key/widgets/round_button.dart';
import 'package:one_key/widgets/system_app_bar.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';
/**
* 优惠券列表
*/
class CouponPage extends StatefulWidget {
CouponPage({Key key}) : super(key: key);
@override
_CouponPageState createState() => _CouponPageState();
}
class _CouponPageState extends State<CouponPage> {
EasyRefreshController _controller = EasyRefreshController();
CouponProvider couponProvider;
///获取优惠券列表数据
_couponNetworkData() {
return Future.delayed(Duration(seconds: 1),
() => couponProvider.pageState = PageState.Success);
}
@override
void initState() {
// TODO: implement initState
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
_couponNetworkData();
});
}
@override
Widget build(BuildContext context) {
couponProvider = Provider.of<CouponProvider>(context, listen: true);
return Scaffold(
appBar: SystemAppBar('线上券', rightImgName: '历史券', onTap: () {
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);
},
emptyMsg: "暂时没有列表信息哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return EasyRefresh.custom(
controller: _controller,
shrinkWrap: true,
slivers: [
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return Container(
padding:
EdgeInsets.all(ScreenUtil().setWidth(20)),
child: Text(
'使用说明:回家啊喝点酒啊喝酒啊电话噶记得发快递费哈咖啡和大号发客服哈空腹喝酒啊快递费哈快递费哈看警方还会发卡号发快回复'));
}, childCount: 1),
),
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return CouponItem(
index: index,
couponProvider: couponProvider,
onPressed: () {
couponProvider.swichStateData[index] =
!couponProvider.swichStateData[index];
couponProvider.notifyListeners();
},
);
}, childCount: couponProvider.swichStateData.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) {
//刷新页面数据
_controller.callRefresh();
}
},
text: '创建新券',
fontSize: 34,
isBold: false,
height: ScreenUtil().setWidth(80),
width: double.infinity,
radius: ScreenUtil().setWidth(10),
))
],
));
}
}
... ...
... ... @@ -209,6 +209,18 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver {
// ),
VEmptyView(40),
MyItem(
title: "活动创建",
content: '',
callback: () {
NavigatorUtil.goCouponPage(context);
},
),
MyDivider(
double.infinity,
ScreenUtil().setHeight(1),
color: MyColours.color_f3f3f3,
),
MyItem(
title: "短信管理",
content:
myModel.smsInfo.isNotEmpty ? '剩余${myModel.smsInfo}条' : '',
... ...
import 'package:flutter/material.dart';
import 'package:one_key/constant/state.dart';
class CouponProvider with ChangeNotifier {
List<bool> swichStateData = []; //优惠券是否启用 true启用 false停用
PageState pageState = PageState.Loading;
PageState pageStateHistory = PageState.Loading;
CouponProvider() {
for (int i = 0; i < 20; i++) {
swichStateData.add(true);
}
}
}
... ...
... ... @@ -5,6 +5,9 @@ import 'package:flutter/material.dart';
import 'package:one_key/models/notebook.dart';
import 'package:one_key/models/notebook_detail.dart';
import 'package:one_key/models/table_list.dart';
import 'package:one_key/pages/coupon/coupon_edit_page.dart';
import 'package:one_key/pages/coupon/coupon_history_page.dart';
import 'package:one_key/pages/coupon/coupon_page.dart';
import 'package:one_key/pages/detail/notebook_detail_change_page.dart';
import 'package:one_key/pages/home/home_page.dart';
import 'package:one_key/pages/invicate/invitation_page.dart';
... ... @@ -212,3 +215,27 @@ var handleInvoiceDetailPageHandler = new Handler(
create: (_) => OrderFoodProvider(),
child: InvoiceDetailPage(fromNotify: fromNotify, rid: rid));
});
///优惠券列表
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();
});
///优惠券历史列表
var handleCouponHistoryPageHandler = new Handler(
handlerFunc: (BuildContext context, Map<String, List<Object>> params) {
// String rid = params["rid"].first;
// bool fromNotify = FluroConvertUtils.string2bool(params["fromNotify"].first);
return CouponHistoryPage();
});
///创建优惠券
var handleCouponEditPageHandler = new Handler(
handlerFunc: (BuildContext context, Map<String, List<Object>> params) {
// String rid = params["rid"].first;
// bool fromNotify = FluroConvertUtils.string2bool(params["fromNotify"].first);
return CouponEidtPage();
});
... ...
... ... @@ -22,6 +22,9 @@ class Routes {
static String online_check_edit = "/online_check_edit"; //提前买单处理
static String online_check_detail = "/online_check_detail"; //提前买单查看
static String invoice_detail = "/invoice_detail"; //查看发票详情
static String coupon = "/coupon"; //优惠券列表页
static String coupon_history = "/coupon_history"; //优惠券历史列表页
static String coupon_edit = "/coupon_edit"; //创建优惠券
static void configureRoutes(FluroRouter router) {
router.notFoundHandler = new Handler(
... ... @@ -47,8 +50,9 @@ class Routes {
router.define(online_check_edit, handler: handleOnlineCheckEditHandler);
router.define(online_check_detail,
handler: handleOnlineCheckDetailPageHandler);
router.define(invoice_detail,
handler: handleInvoiceDetailPageHandler);
router.define(invoice_detail, handler: handleInvoiceDetailPageHandler);
router.define(coupon, handler: handleCouponPageHandler);
router.define(coupon_history, handler: handleCouponHistoryPageHandler);
router.define(coupon_edit, handler: handleCouponEditPageHandler);
}
}
... ...
... ... @@ -152,4 +152,20 @@ class NavigatorUtil {
context, "${Routes.invoice_detail}?fromNotify=${fromNotify}&rid=${rid}",
replace: replace);
}
/// 优惠券列表
static void goCouponPage(BuildContext context, {replace = false}) {
_navigateTo(context, "${Routes.coupon}", replace: replace);
}
/// 优惠券历史列表
static void goCouponHistoryPage(BuildContext context, {replace = false}) {
_navigateTo(context, "${Routes.coupon_history}", replace: replace);
}
/// 创建优惠券
static Future<dynamic> goCouponEditPage(BuildContext context,
{replace = false}) {
return _navigateTo(context, "${Routes.coupon_edit}", replace: replace);
}
}
... ...
... ... @@ -79,7 +79,8 @@ class SetTimeWidget {
'晚上23时': [00, 30]
}
];
showTimeSelector(context, data, hourAndMinute, SetTimeCallback setTimeCallback) {
showTimeSelector(
context, data, hourAndMinute, SetTimeCallback setTimeCallback) {
DialogUtil.showSelectCusmanDialog(context, data, (value) {
setTimeCallback(value);
}, selecteds: [
... ...
import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/utils.dart';
class SystemAppBar extends StatelessWidget implements PreferredSizeWidget {
final String title;
final String rightImgName;
final GestureTapCallback onTap;
final GestureTapCallback onTapRight;
const SystemAppBar(this.title, {Key key, this.rightImgName, this.onTap})
const SystemAppBar(this.title,
{Key key, this.rightImgName, this.onTap, this.onTapRight})
: super(key: key);
@override
... ... @@ -37,6 +41,26 @@ class SystemAppBar extends StatelessWidget implements PreferredSizeWidget {
fontSize: ScreenUtil().setSp(34),
decoration: TextDecoration.none),
),
actions: <Widget>[
ObjectUtil.isNotEmpty(rightImgName)
? InkWell(
onTap: onTapRight,
child: Padding(
padding: EdgeInsets.only(right: ScreenUtil().setWidth(40)),
child: rightImgName.endsWith('png')
? Image.asset(Utils.getImgPath(rightImgName),
width: ScreenUtil().setWidth(40))
: Container(
// color: Colors.red,
alignment: Alignment.center,
child: Text(
rightImgName,
style: TextStyle(color: MyColours.app_main),
),
)),
)
: Text('')
],
centerTitle: true, // 标题居中
);
}
... ...