Commit f4b4a6991048976556c276783ef0dccd7663b8b4

Authored by wdn127929
1 parent 035b1ebe

粗略UI

import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_picker/flutter_picker.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/dialog_util.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';
... ... @@ -21,9 +24,48 @@ class CouponEidtPage extends StatefulWidget {
class _CouponEidtPageState extends State<CouponEidtPage> {
ScrollController controller = ScrollController();
TextEditingController _couponNameEditControl;
TextEditingController _couponNameEditControl = TextEditingController();
TextEditingController _couponRequireEditControl = TextEditingController();
TextEditingController _couponExplainEditControl = TextEditingController();
final heightCell = ScreenUtil().setWidth(80);
bool swichState = true; //默认启用
bool swichState = true; //默认启用 开关状态
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
String fromDate = '点击选择'; //有效期开始时间
String endDate = '点击选择'; //有效期结束时间
List<int> fromDateSelect;
List<int> endDateSelect;
FocusNode _nameFocusNode = FocusNode();
FocusNode _requireFocusNode = FocusNode();
bool showDateSelWidget = false;
@override
void initState() {
super.initState();
_nameFocusNode.addListener(() {
if (_nameFocusNode.hasFocus) {
//有焦点
if (showDateSelWidget) {
Navigator.pop(context);
showDateSelWidget = false;
}
} else {
//失去焦点
// _editingController.text = '';
}
});
_requireFocusNode.addListener(() {
if (_requireFocusNode.hasFocus) {
//有焦点
if (showDateSelWidget) {
Navigator.pop(context);
showDateSelWidget = false;
}
} else {
//失去焦点
// _editingController.text = '';
}
});
}
///输入框
Widget _textfield(String title, String hintText) {
... ... @@ -46,7 +88,9 @@ class _CouponEidtPageState extends State<CouponEidtPage> {
HEmptyView(20),
Expanded(
child: TextField(
controller: _couponNameEditControl,
controller: title == '券名称'
? _couponNameEditControl
: _couponRequireEditControl,
textAlign: TextAlign.right,
maxLines: 1,
// //光标颜色
... ... @@ -56,7 +100,7 @@ class _CouponEidtPageState extends State<CouponEidtPage> {
style: TextStyle(
fontSize: ScreenUtil().setSp(26),
),
// focusNode: _cancelNode,
focusNode: title == '券名称' ? _nameFocusNode : _requireFocusNode,
// textAlignVertical: TextAlignVertical.bottom,
decoration: InputDecoration(
// fillColor: Colors.lightGreenAccent,
... ... @@ -87,7 +131,38 @@ class _CouponEidtPageState extends State<CouponEidtPage> {
Widget _select(String title, String hintText) {
return InkWell(
onTap: () {
FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
//弹出时间选择器
// showPickerDateTime(context);
showDateSelWidget = true;
DialogUtil.showPickerDateTime24(
context,
scaffoldKey,
(value) {
// {'text': picker.adapter.text, 'select': selecteds}
if (value != null) {
if (title == '有效期从') {
setState(() {
print(value);
fromDate =
DateUtil.formatDateStr(value, format: DateFormats.full);
});
} else if (title == '有效期至') {
setState(() {
print(value);
endDate =
DateUtil.formatDateStr(value, format: DateFormats.full);
});
}
}
showDateSelWidget = false;
},
dateTime: title == '有效期从'
? DateUtil.getDateTime(fromDate)
: DateUtil.getDateTime(endDate),
onCancel: () {
showDateSelWidget = false;
});
},
child: Container(
height: heightCell,
... ... @@ -109,7 +184,9 @@ class _CouponEidtPageState extends State<CouponEidtPage> {
Spacer(),
Text(hintText,
style: TextStyle(
color: MyColours.color_999999,
color: hintText == '点击选择'
? MyColours.color_999999
: MyColours.color_333333,
fontSize: ScreenUtil().setSp(26),
)),
HEmptyView(20),
... ... @@ -145,6 +222,7 @@ class _CouponEidtPageState extends State<CouponEidtPage> {
),
VEmptyView(10),
TextField(
controller: _couponExplainEditControl,
// keyboardType: TextInputType.number, //键盘类型,数字键盘
maxLines: 7,
// maxLength: 200,
... ... @@ -208,6 +286,7 @@ class _CouponEidtPageState extends State<CouponEidtPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
key: scaffoldKey,
appBar: SystemAppBar(
'创建新券',
onTap: () {
... ... @@ -231,8 +310,8 @@ class _CouponEidtPageState extends State<CouponEidtPage> {
VEmptyView(20),
_textfield('券名称', '例:9折券/200元代金券/菜品券'),
_textfield('券要求', '例:无门槛/满2000元'),
_select('有效期从', '点击选择'),
_select('有效期至', '点击选择'),
_select('有效期从', fromDate),
_select('有效期至', endDate),
_explain('券说明', '例:可用包间,停车免费,不与店内其他活动共享等'),
_canUse('是否立即启用'),
],
... ... @@ -244,6 +323,15 @@ class _CouponEidtPageState extends State<CouponEidtPage> {
ScreenUtil().setWidth(40), ScreenUtil().setWidth(40)),
child: RoundButton(
onPressed: () {
// ***参数***
// _couponNameEditControl.text
// _couponRequireEditControl.text
// fromDate
// endDate
// _couponExplainEditControl.text
// swichState
//成功之后跳回前一个页面
Navigator.pop(context, true);
},
text: '保存',
... ...
... ... @@ -10,7 +10,13 @@ class CouponItem extends StatefulWidget {
final int index;
final VoidCallback onPressed;
final CouponProvider couponProvider;
CouponItem({Key key, this.index, this.onPressed, this.couponProvider})
final bool showBtn;
CouponItem(
{Key key,
this.index,
this.onPressed,
this.couponProvider,
this.showBtn = false})
: super(key: key);
@override
... ... @@ -21,80 +27,86 @@ 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),
return Stack(
children: [
Container(
// width: ScreenUtil().setWidth(610),
margin: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(30),
vertical: ScreenUtil().setWidth(12)),
padding: EdgeInsets.all(ScreenUtil().setWidth(20)),
decoration: BoxDecoration(
color: switchState ? MyColours.app_main : MyColours.color_E0E0E0,
borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10))),
child: Stack(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
Row(
crossAxisAlignment: CrossAxisAlignment.end,
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(
Text(
'九折券',
style: TextStyle(
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))),
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('说明:大哈就快费复大家发哈接电话费哈就快递费快回复解答快回复',
maxLines: 30,
overflow: TextOverflow.ellipsis,
softWrap: false,
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: ScreenUtil().setWidth(40),
right: ScreenUtil().setWidth(40),
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))),
],
),
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(
HEmptyView(20),
widget.showBtn
? RoundButton(
width: ScreenUtil().setWidth(100),
height: ScreenUtil().setWidth(50),
radius: ScreenUtil().setWidth(10),
... ... @@ -104,11 +116,11 @@ class _CouponItemState extends State<CouponItem> {
gradientEnd: Colors.white,
onPressed: widget.onPressed,
)
],
),
)
: Container()
],
),
));
)
],
);
}
}
... ...
... ... @@ -88,6 +88,7 @@ class _CouponPageState extends State<CouponPage> {
return CouponItem(
index: index,
couponProvider: couponProvider,
showBtn: true,
onPressed: () {
couponProvider.swichStateData[index] =
!couponProvider.swichStateData[index];
... ... @@ -118,7 +119,7 @@ class _CouponPageState extends State<CouponPage> {
bool needRefresh =
await NavigatorUtil.goCouponEditPage(context);
print(needRefresh);
if (needRefresh) {
if (needRefresh != null && needRefresh) {
//刷新页面数据
_controller.callRefresh();
}
... ...
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/navigator_util.dart';
import 'package:one_key/widgets/h_empty_view.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 CouponSelectPage extends StatefulWidget {
CouponSelectPage({Key key}) : super(key: key);
@override
_CouponSelectPageState createState() => _CouponSelectPageState();
}
class _CouponSelectPageState extends State<CouponSelectPage> {
EasyRefreshController _controller = EasyRefreshController();
CouponProvider couponProvider;
///获取优惠券列表数据
_couponNetworkData() {
return Future.delayed(Duration(seconds: 1),
() => couponProvider.pageStateSelect = 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.pop(context);
},
rightImgName: couponProvider.checkValue ? '取消全选' : '全选',
onTapRight: () {
if (couponProvider.checkValue) {
couponProvider.cancelAll();
} else {
couponProvider.addAll();
}
},
),
body: Column(
children: [
Expanded(child: Consumer<CouponProvider>(
builder: (context, model, _) {
if (model.pageStateSelect != PageState.Success) {
return ExceptionPage(
pageState: model.pageStateSelect,
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 InkWell(
onTap: () {
couponProvider.listData[index]['checked'] =
!couponProvider.listData[index]['checked'];
if (couponProvider.listData[index]['checked']) {
couponProvider.addData(index);
} else {
couponProvider.cancelData(index);
}
couponProvider.getCheckValue();
},
child: Row(
children: [
HEmptyView(30),
Image.asset(
couponProvider.listData[index]['checked']
? 'assets/select.png'
: 'assets/unselect.png',
width: ScreenUtil().setWidth(44)),
Expanded(
child: CouponItem(
index: index,
couponProvider: couponProvider,
onPressed: () {
couponProvider.listData[index]['checked'] =
!couponProvider.listData[index]
['checked'];
if (couponProvider.listData[index]
['checked']) {
couponProvider.addData(index);
} else {
couponProvider.cancelData(index);
}
couponProvider.getCheckValue();
},
))
],
),
);
}, childCount: couponProvider.listData.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: () {
Navigator.pop(context);
},
text: '已选${couponProvider.coupons.length}个 确定',
fontSize: 34,
isBold: false,
height: ScreenUtil().setWidth(80),
width: double.infinity,
radius: ScreenUtil().setWidth(10),
))
],
),
);
}
}
... ...
... ... @@ -76,7 +76,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
))
..add(ChangeNotifierProvider<TableManagerModel>(
create: (_) => TableManagerModel(),
child: SafeArea(child: TableManagerPage()),
child: TableManagerPage(),
))
..add(ChangeNotifierProvider<MyModel>(
create: (_) => MyModel(),
... ...
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/models/user.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/navigator_util.dart';
... ... @@ -15,7 +16,8 @@ class InvicationPage extends StatefulWidget {
final String ddateStr;
final String phone;
InvicationPage(this.rid, this.tableInfo, this.ddate, this.ddateStr, this.phone);
InvicationPage(
this.rid, this.tableInfo, this.ddate, this.ddateStr, this.phone);
@override
State<StatefulWidget> createState() {
... ... @@ -28,6 +30,9 @@ class InvicationPageState extends State<InvicationPage> {
User user;
DateTime dateTime;
String dateTimeStr = "";
ScrollController controller = ScrollController();
final double couponHeight = 180.0;
CouponProvider couponProvider;
@override
void initState() {
... ... @@ -84,177 +89,218 @@ class InvicationPageState extends State<InvicationPage> {
@override
Widget build(BuildContext context) {
// TODO: implement build
return SafeArea(
child: Container(
width: double.infinity,
height: double.infinity,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/bg_invication.png"), fit: BoxFit.cover),
),
child: DefaultTextStyle(
style: TextStyle(decoration: TextDecoration.none),
child: Column(
children: <Widget>[
GestureDetector(
onTap: () {
Navigator.of(context).pop();
},
behavior: HitTestBehavior.opaque,
child: Container(
width: double.infinity,
alignment: Alignment.centerLeft,
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
vertical: ScreenUtil().setHeight(15)),
child: Image.asset(
"assets/invication_back.png",
width: ScreenUtil().setWidth(20),
height: ScreenUtil().setHeight(31),
)),
),
),
Expanded(
child: Center(
child: Column(
children: <Widget>[
Image.asset(
"assets/img_ydap.png",
width: ScreenUtil().setWidth(500),
height: ScreenUtil().setHeight(300),
),
VEmptyView(69),
Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(
width: ScreenUtil().setWidth(108),
height: ScreenUtil().setHeight(2),
color: MyColours.color_ffffff,
),
Container(
width: ScreenUtil().setWidth(442),
height: ScreenUtil().setHeight(43),
alignment: Alignment.center,
decoration: BoxDecoration(
border: Border.all(
color: MyColours.color_ffffff,
width: ScreenUtil().setWidth(2)),
borderRadius: BorderRadius.all(
Radius.circular(
ScreenUtil().setWidth(18)))),
child: Text(
"订包间,用周到安排",
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(28)),
couponProvider = Provider.of<CouponProvider>(context, listen: true);
return Scaffold(
body: Container(
width: double.infinity,
height: double.infinity,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/bg_invication.png"),
fit: BoxFit.cover),
),
child: Stack(
children: [
Padding(
padding: EdgeInsets.only(top: ScreenUtil().setWidth(0)),
child: Column(children: [
Expanded(
child: ListView(
controller: controller,
physics: BouncingScrollPhysics(),
children: <Widget>[
VEmptyView(60),
Center(
child: Column(
children: <Widget>[
Image.asset(
"assets/img_ydap.png",
width: ScreenUtil().setWidth(500),
height: ScreenUtil().setHeight(300),
),
VEmptyView(69),
Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(
width: ScreenUtil().setWidth(108),
height: ScreenUtil().setHeight(2),
color: MyColours.color_ffffff,
),
Container(
width: ScreenUtil().setWidth(442),
height: ScreenUtil().setHeight(43),
alignment: Alignment.center,
decoration: BoxDecoration(
border: Border.all(
color: MyColours.color_ffffff,
width:
ScreenUtil().setWidth(2)),
borderRadius: BorderRadius.all(
Radius.circular(ScreenUtil()
.setWidth(18)))),
child: Text(
"订包间,用周到安排",
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(28)),
),
),
Container(
width: ScreenUtil().setWidth(108),
height: ScreenUtil().setHeight(2),
color: MyColours.color_ffffff,
),
],
),
_middleWidget("餐厅", user.sellername),
_middleWidget("包间",
widget.tableInfo.replaceAll("\n", "")),
_middleWidget("时间", dateTimeStr),
VEmptyView(38),
Column(
children: <Widget>[
Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Image.asset(
"assets/invication_map.png",
width: ScreenUtil().setWidth(22),
height: ScreenUtil().setWidth(28),
),
Container(
margin: EdgeInsets.symmetric(
horizontal:
ScreenUtil().setWidth(13)),
child: Text("地址导航",
style: TextStyle(
color:
MyColours.color_eadab9,
fontSize: ScreenUtil()
.setSp(32))),
),
Image.asset(
"assets/invication_arrow_right.png",
width: ScreenUtil().setWidth(14),
height: ScreenUtil().setWidth(22),
),
],
),
Container(
margin: EdgeInsets.only(
top: ScreenUtil().setHeight(20)),
child: Text(
user.sellerAddr,
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(34)),
),
)
],
)
],
),
),
Container(
width: ScreenUtil().setWidth(108),
height: ScreenUtil().setHeight(2),
color: MyColours.color_ffffff,
),
],
),
_middleWidget("餐厅", user.sellername),
_middleWidget(
"包间", widget.tableInfo.replaceAll("\n", "")),
_middleWidget("时间", dateTimeStr),
VEmptyView(38),
Column(
VEmptyView(couponHeight),
])),
Container(
width: double.infinity,
height: ScreenUtil().setHeight(99),
child: Row(
children: <Widget>[
Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Image.asset(
"assets/invication_map.png",
width: ScreenUtil().setWidth(22),
height: ScreenUtil().setWidth(28),
),
Container(
margin: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(13)),
child: Text("地址导航",
style: TextStyle(
color: MyColours.color_eadab9,
fontSize: ScreenUtil().setSp(32))),
GestureDetector(
onTap: () {
if (widget.phone.isEmpty) {
Utils.showToast("没有预订人电话信息");
return;
}
NavigatorUtil.goSmsPage(context, widget.rid);
},
child: Container(
width: ScreenUtil().setWidth(232),
height: double.infinity,
color: MyColours.color_000000,
alignment: Alignment.center,
child: Text(
"发短信",
style: TextStyle(
color: MyColours.color_eadab9,
fontSize: ScreenUtil().setSp(34)),
),
Image.asset(
"assets/invication_arrow_right.png",
width: ScreenUtil().setWidth(14),
height: ScreenUtil().setWidth(22),
),
],
),
),
Container(
margin: EdgeInsets.only(
top: ScreenUtil().setHeight(20)),
child: Text(
user.sellerAddr,
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(34)),
Expanded(
child: GestureDetector(
onTap: () {
Utils.goShareInvicationToWeChat(widget.rid);
},
child: Container(
width: double.infinity,
height: double.infinity,
color: MyColours.color_e3d2ac,
alignment: Alignment.center,
child: Text(
"通知客户",
style: TextStyle(
color: MyColours.color_83734d,
fontSize: ScreenUtil().setSp(34)),
),
),
),
)
],
)
],
),
),
)
])),
Positioned(
left: ScreenUtil().setWidth(40),
top: ScreenUtil().setWidth(65),
child: GestureDetector(
onTap: () {
Navigator.of(context).pop();
},
behavior: HitTestBehavior.opaque,
child: Container(
alignment: Alignment.centerLeft,
child: Image.asset(
"assets/invication_back.png",
width: ScreenUtil().setWidth(20),
height: ScreenUtil().setHeight(31),
)),
),
),
Container(
width: double.infinity,
height: ScreenUtil().setHeight(99),
child: Row(
children: <Widget>[
GestureDetector(
onTap: () {
if(widget.phone.isEmpty){
Utils.showToast("没有预订人电话信息");
return;
}
NavigatorUtil.goSmsPage(context, widget.rid);
},
child: Container(
width: ScreenUtil().setWidth(232),
height: double.infinity,
color: MyColours.color_000000,
alignment: Alignment.center,
child: Text(
"发短信",
style: TextStyle(
color: MyColours.color_eadab9,
fontSize: ScreenUtil().setSp(34)),
Positioned(
left: ScreenUtil().setWidth(180),
bottom: ScreenUtil().setWidth(130),
right: ScreenUtil().setWidth(180),
child: GestureDetector(
onTap: () {
NavigatorUtil.goCouponSelectPage(context);
},
behavior: HitTestBehavior.opaque,
child: Center(
child: Container(
// width: ScreenUtil().setWidth(400),
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
vertical: ScreenUtil().setWidth(20)),
// height: ScreenUtil().setWidth(100),
decoration: BoxDecoration(
color: MyColours.color_ffffff,
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(20))),
child: Text(
'共赠送${couponProvider.coupons.length}张优惠券\n点击查看',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: ScreenUtil().setSp(28),
),
),
),
Expanded(
child: GestureDetector(
onTap: () {
Utils.goShareInvicationToWeChat(widget.rid);
},
child: Container(
width: double.infinity,
height: double.infinity,
color: MyColours.color_e3d2ac,
alignment: Alignment.center,
child: Text(
"通知客户",
style: TextStyle(
color: MyColours.color_83734d,
fontSize: ScreenUtil().setSp(34)),
),
),
),
)
],
),
),
)
],
)),
),
);
)));
}
}
... ...
... ... @@ -14,6 +14,7 @@ import 'package:one_key/widgets/app_bar.dart';
import 'package:one_key/widgets/area_item.dart';
import 'package:one_key/widgets/common_button.dart';
import 'package:one_key/widgets/page_exception.dart';
import 'package:one_key/widgets/system_app_bar.dart';
import 'package:one_key/widgets/table_item.dart';
import 'package:one_key/models/table.dart' as t;
import 'package:provider/provider.dart';
... ... @@ -47,347 +48,334 @@ class TableManagerPageState extends State<TableManagerPage> {
@override
Widget build(BuildContext context) {
return SafeArea(
child: Consumer<TableManagerModel>(
builder: (context, model, child) {
return Column(
children: <Widget>[
MyAppBar("桌位", showBack: false),
Container(
color: MyColours.color_ffffff,
width: double.infinity,
padding:
EdgeInsets.symmetric(vertical: ScreenUtil().setHeight(16)),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Expanded(
child: Center(
child: GestureDetector(
onTap: () {
DialogUtil.showCalendarDialog(
context, tableManagerModel.dateTime)
.then((day) {
if (day != null) {
tableManagerModel.createDateText(context, day);
}
});
},
child: Container(
child: Text(
tableManagerModel.dateText,
style: TextStyle(
color: MyColours.color_199095,
fontSize: ScreenUtil().setSp(34)),
),
return Consumer<TableManagerModel>(
builder: (context, model, child) {
return Column(
children: <Widget>[
SystemAppBar("桌位", showLeading: false),
Container(
color: MyColours.color_ffffff,
width: double.infinity,
padding:
EdgeInsets.symmetric(vertical: ScreenUtil().setHeight(16)),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Expanded(
child: Center(
child: GestureDetector(
onTap: () {
DialogUtil.showCalendarDialog(
context, tableManagerModel.dateTime)
.then((day) {
if (day != null) {
tableManagerModel.createDateText(context, day);
}
});
},
child: Container(
child: Text(
tableManagerModel.dateText,
style: TextStyle(
color: MyColours.color_199095,
fontSize: ScreenUtil().setSp(34)),
),
),
),
),
MyDivider(
ScreenUtil().setWidth(2),
ScreenUtil().setHeight(68),
color: MyColours.color_E0E0E0,
),
Expanded(
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(30)),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Offstage(
offstage:
tableManagerModel.morning == "00:00-00:00"
? true
: false,
child: Padding(
padding: EdgeInsets.only(
right: ScreenUtil().setWidth(18)),
child: CommonButton(
content: "早市",
state:
tableManagerModel.currTimeIndex == 1
? 1
: 0,
width: 92,
height: 48,
fontSize: 32,
onPress: () {
if (tableManagerModel.currTimeIndex ==
1) return;
tableManagerModel.currTimeIndex = 1;
tableManagerModel
.getReserveList(context);
},
))),
Offstage(
offstage:
tableManagerModel.noon == "00:00-00:00"
? true
: false,
child: Padding(
padding: EdgeInsets.only(
right: ScreenUtil().setWidth(18)),
child: CommonButton(
content: "午市",
state:
tableManagerModel.currTimeIndex == 2
? 1
: 0,
width: 92,
height: 48,
fontSize: 32,
onPress: () {
if (tableManagerModel.currTimeIndex ==
2) return;
tableManagerModel.currTimeIndex = 2;
tableManagerModel
.getReserveList(context);
},
))),
Offstage(
offstage: tableManagerModel.night == "00:00-00:00"
),
MyDivider(
ScreenUtil().setWidth(2),
ScreenUtil().setHeight(68),
color: MyColours.color_E0E0E0,
),
Expanded(
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(30)),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Offstage(
offstage:
tableManagerModel.morning == "00:00-00:00"
? true
: false,
child: Padding(
padding: EdgeInsets.only(
right: ScreenUtil().setWidth(18)),
child: CommonButton(
content: "早市",
state: tableManagerModel.currTimeIndex == 1
? 1
: 0,
width: 92,
height: 48,
fontSize: 32,
onPress: () {
if (tableManagerModel.currTimeIndex == 1)
return;
tableManagerModel.currTimeIndex = 1;
tableManagerModel.getReserveList(context);
},
))),
Offstage(
offstage: tableManagerModel.noon == "00:00-00:00"
? true
: false,
child: Container(
// padding: EdgeInsets.symmetric(
// horizontal: ScreenUtil().setWidth(10)),
child: Padding(
padding: EdgeInsets.only(
right: ScreenUtil().setWidth(18)),
child: CommonButton(
content: "晚市",
state: tableManagerModel.currTimeIndex == 3
? 1
: 0,
width: 92,
height: 48,
fontSize: 32,
onPress: () {
if (tableManagerModel.currTimeIndex == 3)
return;
tableManagerModel.currTimeIndex = 3;
tableManagerModel.getReserveList(context);
},
)),
),
],
),
content: "午市",
state: tableManagerModel.currTimeIndex == 2
? 1
: 0,
width: 92,
height: 48,
fontSize: 32,
onPress: () {
if (tableManagerModel.currTimeIndex == 2)
return;
tableManagerModel.currTimeIndex = 2;
tableManagerModel.getReserveList(context);
},
))),
Offstage(
offstage: tableManagerModel.night == "00:00-00:00"
? true
: false,
child: Container(
// padding: EdgeInsets.symmetric(
// horizontal: ScreenUtil().setWidth(10)),
child: CommonButton(
content: "晚市",
state:
tableManagerModel.currTimeIndex == 3 ? 1 : 0,
width: 92,
height: 48,
fontSize: 32,
onPress: () {
if (tableManagerModel.currTimeIndex == 3)
return;
tableManagerModel.currTimeIndex = 3;
tableManagerModel.getReserveList(context);
},
)),
),
],
),
)
],
),
),
Container(
height: ScreenUtil().setWidth(20),
width: double.infinity,
color: MyColours.color_f5f5f5,
),
)
],
),
Expanded(
child: Consumer<TableManagerModel>(
builder: (context, model, child) {
if (model.pageState != PageState.Success) {
return ExceptionPage(
pageState: model.pageState,
callback: () {
if (tableManagerModel.tableOuterList.isEmpty) {
tableManagerModel.getTableList(context);
} else {
tableManagerModel.getReserveList(context);
}
},
emptyMsg: "暂时没有桌位哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return Container(
color: MyColours.color_ffffff,
child: Row(
children: <Widget>[
Container(
width: ScreenUtil().setWidth(170),
height: double.infinity,
color: MyColours.color_f1f1f1,
child: ListView.builder(
itemBuilder: (context, index) {
return Selector<TableManagerModel, Area>(
selector: (context, model) =>
model.areas[index],
builder: (context, area, _) {
return AreaItem(
area, tableManagerModel.currentArea,
(area) {
setState(() {
tableManagerModel.currentArea =
(area as Area).name;
tableManagerModel.currentTables =
tableManagerModel.areaTableMap[
tableManagerModel
.currentArea];
});
),
Container(
height: ScreenUtil().setWidth(20),
width: double.infinity,
color: MyColours.color_f5f5f5,
),
Expanded(
child: Consumer<TableManagerModel>(
builder: (context, model, child) {
if (model.pageState != PageState.Success) {
return ExceptionPage(
pageState: model.pageState,
callback: () {
if (tableManagerModel.tableOuterList.isEmpty) {
tableManagerModel.getTableList(context);
} else {
tableManagerModel.getReserveList(context);
}
},
emptyMsg: "暂时没有桌位哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return Container(
color: MyColours.color_ffffff,
child: Row(
children: <Widget>[
Container(
width: ScreenUtil().setWidth(170),
height: double.infinity,
color: MyColours.color_f1f1f1,
child: ListView.builder(
itemBuilder: (context, index) {
return Selector<TableManagerModel, Area>(
selector: (context, model) =>
model.areas[index],
builder: (context, area, _) {
return AreaItem(
area, tableManagerModel.currentArea,
(area) {
setState(() {
tableManagerModel.currentArea =
(area as Area).name;
tableManagerModel.currentTables =
tableManagerModel.areaTableMap[
tableManagerModel.currentArea];
});
},
);
},
itemExtent: ScreenUtil().setHeight(207),
itemCount: tableManagerModel.areas.length,
),
});
},
);
},
itemExtent: ScreenUtil().setHeight(207),
itemCount: tableManagerModel.areas.length,
),
Expanded(
child: Padding(
padding: EdgeInsets.symmetric(
vertical: ScreenUtil().setHeight(10),
horizontal: ScreenUtil().setWidth(9)),
child: Column(
children: [
Expanded(
child: GridView.builder(
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
childAspectRatio: 8 / 9),
itemBuilder: (context, index) {
return Selector<TableManagerModel,
t.Table>(
shouldRebuild: (pre, next) => true,
selector: (context, model) =>
model.currentTables[index],
builder: (context, table, _) {
return TableItem(table,
onSelected: (table) {
if ((table as t.Table)
.selected) {
tableManagerModel.selectTables
.add(table);
} else {
tableManagerModel.selectTables
.removeWhere((t) =>
t.id == table.id);
}
DialogUtil
.showTableManagerDialog(
context, table)
.then((value) {
if (value != null) {
switch (value) {
case 1: //查看详情
NavigatorUtil
.goNotebookDetailPage(
context,
tableManagerModel
.tableMap[
table
.id]
.id);
break;
case 2: //订座
NavigatorUtil.goNoteBookChangePage(
context,
NotebookDetail.fromTableManager(
tableManagerModel
.getCurrDdateStr(),
tableManagerModel
.currTimeIndex
.toString(),
table),
"");
break;
case 3: //停用,启用桌位
Map<String, String>
params = {
"id":
(table as t.Table)
.id,
"status": (table as t
.Table)
.enable ==
"1"
? "0"
: "1"
};
tableManagerModel
.setSwitchStatus(
context, params)
.then((value) {
if (value != null) {
(table as t.Table)
.enable =
((int.parse((table as t.Table).enable) +
1) %
2)
.toString();
if ((table as t
),
Expanded(
child: Padding(
padding: EdgeInsets.symmetric(
vertical: ScreenUtil().setHeight(10),
horizontal: ScreenUtil().setWidth(9)),
child: Column(
children: [
Expanded(
child: GridView.builder(
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
childAspectRatio: 8 / 9),
itemBuilder: (context, index) {
return Selector<TableManagerModel,
t.Table>(
shouldRebuild: (pre, next) => true,
selector: (context, model) =>
model.currentTables[index],
builder: (context, table, _) {
return TableItem(table,
onSelected: (table) {
if ((table as t.Table).selected) {
tableManagerModel.selectTables
.add(table);
} else {
tableManagerModel.selectTables
.removeWhere((t) =>
t.id == table.id);
}
DialogUtil.showTableManagerDialog(
context, table)
.then((value) {
if (value != null) {
switch (value) {
case 1: //查看详情
NavigatorUtil
.goNotebookDetailPage(
context,
tableManagerModel
.tableMap[
table.id]
.id);
break;
case 2: //订座
NavigatorUtil.goNoteBookChangePage(
context,
NotebookDetail.fromTableManager(
tableManagerModel
.getCurrDdateStr(),
tableManagerModel
.currTimeIndex
.toString(),
table),
"");
break;
case 3: //停用,启用桌位
Map<String, String>
params = {
"id": (table as t.Table)
.id,
"status": (table as t
.Table)
.enable ==
"1") {
for (Area area
in tableManagerModel
.areas) {
if (area.name ==
tableManagerModel
.currentArea) {
if (table.sign !=
'5' &&
table.sign !=
'1') {
//已预订
area.count++;
}
break;
"1"
? "0"
: "1"
};
tableManagerModel
.setSwitchStatus(
context, params)
.then((value) {
if (value != null) {
(table as t.Table)
.enable =
((int.parse((table as t.Table)
.enable) +
1) %
2)
.toString();
if ((table as t.Table)
.enable ==
"1") {
for (Area area
in tableManagerModel
.areas) {
if (area.name ==
tableManagerModel
.currentArea) {
if (table.sign !=
'5' &&
table.sign !=
'1') {
//已预订
area.count++;
}
break;
}
} else {
for (Area area
in tableManagerModel
.areas) {
if (area.name ==
tableManagerModel
.currentArea) {
if (table.sign !=
'5' &&
table.sign !=
'1') {
//已预订
area.count--;
}
break;
}
} else {
for (Area area
in tableManagerModel
.areas) {
if (area.name ==
tableManagerModel
.currentArea) {
if (table.sign !=
'5' &&
table.sign !=
'1') {
//已预订
area.count--;
}
break;
}
}
tableManagerModel
.notifyListeners();
}
});
break;
}
tableManagerModel
.notifyListeners();
}
});
break;
}
});
},
canSelected: false,
fromPage: 'table_manage',
tableMap: tableManagerModel
.tableMap,
rid: "");
}
});
},
);
},
itemCount: tableManagerModel
.currentTables.length,
)),
],
)),
)
],
),
);
}
},
),
canSelected: false,
fromPage: 'table_manage',
tableMap:
tableManagerModel.tableMap,
rid: "");
},
);
},
itemCount: tableManagerModel
.currentTables.length,
)),
],
)),
)
],
),
);
}
},
),
],
);
},
),
),
],
);
},
);
}
... ...
... ... @@ -5,10 +5,66 @@ class CouponProvider with ChangeNotifier {
List<bool> swichStateData = []; //优惠券是否启用 true启用 false停用
PageState pageState = PageState.Loading;
PageState pageStateHistory = PageState.Loading;
PageState pageStateSelect = PageState.Loading;
bool checkValue = true; //优惠券页面“全选”按钮状态 ----- 数据状态全部选中为true
List<Map<String, dynamic>> listData = []; //优惠券页面数据
List coupons = []; //选中的优惠券id集合
CouponProvider() {
for (int i = 0; i < 20; i++) {
swichStateData.add(true);
listData.add({'checked': true, 'id': '${i}'});
}
}
//全选按钮执行“全选”
addAll() async {
//把数据状态全部改成true,即选中状态
coupons = [];
for (var i = 0; i < listData.length; i++) {
listData[i]['checked'] = true;
coupons.add(listData[i]['id']);
}
checkValue = true;
notifyListeners();
}
//全选按钮执行“全不选”
cancelAll() async {
//把数据状态全部改成false,即不选中状态
for (var i = 0; i < listData.length; i++) {
listData[i]['checked'] = false;
}
coupons = [];
checkValue = false;
notifyListeners();
}
//选中
addData(int index) {
listData[index]['checked'] = true;
coupons.add(listData[index]['id']);
notifyListeners();
}
//未选中
cancelData(int index) {
listData[index]['checked'] = false;
coupons.removeWhere((element) => element == listData[index]['id']);
notifyListeners();
}
//获取全选按钮的状态 true or false
getCheckValue() {
bool temp = listData.any((value) {
return value['checked'] == false;
});
if (temp == true) {
checkValue = false;
} else {
checkValue = true;
}
notifyListeners();
}
}
... ...
... ... @@ -8,6 +8,7 @@ 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/coupon/coupon_selecet_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';
... ... @@ -239,3 +240,11 @@ var handleCouponEditPageHandler = new Handler(
// bool fromNotify = FluroConvertUtils.string2bool(params["fromNotify"].first);
return CouponEidtPage();
});
///选择优惠券
var handleCouponSelectPageHandler = new Handler(
handlerFunc: (BuildContext context, Map<String, List<Object>> params) {
// String rid = params["rid"].first;
// bool fromNotify = FluroConvertUtils.string2bool(params["fromNotify"].first);
return CouponSelectPage();
});
... ...
... ... @@ -25,6 +25,7 @@ class Routes {
static String coupon = "/coupon"; //优惠券列表页
static String coupon_history = "/coupon_history"; //优惠券历史列表页
static String coupon_edit = "/coupon_edit"; //创建优惠券
static String coupon_select = "/coupon_select"; //优惠券选择
static void configureRoutes(FluroRouter router) {
router.notFoundHandler = new Handler(
... ... @@ -54,5 +55,8 @@ class Routes {
router.define(coupon, handler: handleCouponPageHandler);
router.define(coupon_history, handler: handleCouponHistoryPageHandler);
router.define(coupon_edit, handler: handleCouponEditPageHandler);
router.define(coupon_select, handler: handleCouponSelectPageHandler);
}
}
... ...
... ... @@ -798,6 +798,62 @@ class DialogUtil {
});
}
///年月日时分秒选择器
static Future showPickerDateTime24(BuildContext context,
GlobalKey<ScaffoldState> scaffoldKey, ValueChanged valueChanged,
{List<int> selecteds, VoidCallback onCancel, DateTime dateTime}) {
new Picker(
selecteds: selecteds,
adapter: new DateTimePickerAdapter(
type: PickerDateTimeType.kYMDHMS,
isNumberMonth: true,
yearSuffix: "年",
monthSuffix: "月",
daySuffix: "日",
minHour: 00,
maxHour: 23,
yearBegin: 2021,
yearEnd: 2030,
value: dateTime),
title: new Text(""),
height: ScreenUtil().setWidth(480),
hideHeader: false,
cancelText: "取消",
cancelTextStyle: TextStyle(
color: MyColours.color_828282,
fontSize: ScreenUtil().setSp(36)),
confirmText: "确定",
itemExtent: ScreenUtil().setWidth(90),
confirmTextStyle: TextStyle(
color: MyColours.color_2bb5b7,
fontSize: ScreenUtil().setSp(36)),
selectedTextStyle: TextStyle(
color: MyColours.color_199095,
fontSize: ScreenUtil().setSp(32)),
textStyle: TextStyle(
color: MyColours.color_353535,
fontSize: ScreenUtil().setSp(32)),
onConfirm: (Picker picker, List<int> selecteds) {
// print(value.toString());
// print(picker.adapter.toString());
if (valueChanged != null) {
valueChanged(picker.adapter.text);
}
},
onCancel: onCancel,
onSelect: (Picker picker, int index, List<int> selecteds) {
// this.setState(() {
// // stateText = picker.adapter.toString();
// });
})
// .showModal<List<int>>(context)
// .then((value) {
// LogUtil.v("value:${value.toString()}");
// return value;
// });
.show(scaffoldKey.currentState);
}
static Future confirmDialog(BuildContext context, String title, double height,
{GestureTapCallback onTap, double fontSize = 36}) async {
String showTitle = title;
... ...
... ... @@ -168,4 +168,10 @@ class NavigatorUtil {
{replace = false}) {
return _navigateTo(context, "${Routes.coupon_edit}", replace: replace);
}
/// 选择优惠券
static Future<dynamic> goCouponSelectPage(BuildContext context,
{replace = false}) {
return _navigateTo(context, "${Routes.coupon_select}", replace: replace);
}
}
... ...
... ... @@ -8,32 +8,39 @@ class SystemAppBar extends StatelessWidget implements PreferredSizeWidget {
final String title;
final String rightImgName;
final GestureTapCallback onTap;
final bool showLeading;
final GestureTapCallback onTapRight;
const SystemAppBar(this.title,
{Key key, this.rightImgName, this.onTap, this.onTapRight})
{Key key,
this.rightImgName,
this.onTap,
this.onTapRight,
this.showLeading = true})
: super(key: key);
@override
Widget build(BuildContext context) {
return AppBar(
elevation: 0,
leading: InkWell(
onTap: onTap,
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
vertical: ScreenUtil().setWidth(15)),
child: Row(
children: <Widget>[
Image.asset(
"assets/icon_back.png",
width: ScreenUtil().setWidth(20),
height: ScreenUtil().setWidth(31),
)
],
)),
),
leading: showLeading
? InkWell(
onTap: onTap,
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
vertical: ScreenUtil().setWidth(15)),
child: Row(
children: <Widget>[
Image.asset(
"assets/icon_back.png",
width: ScreenUtil().setWidth(20),
height: ScreenUtil().setWidth(31),
)
],
)),
)
: Container(),
title: Text(
title,
style: TextStyle(
... ...