|
...
|
...
|
@@ -50,7 +50,12 @@ class _CouponEidtPageState extends State<CouponEidtPage> { |
|
|
|
TextEditingController _couponRequireEditControl = TextEditingController();
|
|
|
|
TextEditingController _couponExplainEditControl = TextEditingController();
|
|
|
|
TextEditingController _limitNumControl = TextEditingController();
|
|
|
|
TextEditingController _commissionControl = TextEditingController();
|
|
|
|
TextEditingController _limitDay = TextEditingController();
|
|
|
|
FocusNode _limitNumFocusNode = FocusNode();
|
|
|
|
FocusNode _limitDayFocusNode = FocusNode();
|
|
|
|
FocusNode _commissionFocusNode = FocusNode();
|
|
|
|
|
|
|
|
final heightCell = ScreenUtil().setWidth(48 * 2);
|
|
|
|
bool swichState = true; //默认启用 开关状态
|
|
|
|
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
|
|
...
|
...
|
@@ -62,6 +67,9 @@ class _CouponEidtPageState extends State<CouponEidtPage> { |
|
|
|
late CouponProvider couponProvider;
|
|
|
|
bool swichHexiao = true; //默认启用 核销状态
|
|
|
|
String? uids = '';
|
|
|
|
|
|
|
|
// bool swichHexiao = true; //默认启用 核销状态
|
|
|
|
|
|
|
|
TextEditingController _priceControl = TextEditingController();
|
|
|
|
FocusNode _priceFocusNode = FocusNode();
|
|
|
|
|
|
...
|
...
|
@@ -80,7 +88,7 @@ class _CouponEidtPageState extends State<CouponEidtPage> { |
|
|
|
bool limitNone = true;
|
|
|
|
bool limitWeek = false;
|
|
|
|
bool limitBirthday = false;
|
|
|
|
String weekShow = '点击设置可用日期';
|
|
|
|
String weekShow = '无';
|
|
|
|
List<FilterBtnModel> weekData = [];
|
|
|
|
|
|
|
|
// morning == "00:00-00:00"
|
|
...
|
...
|
@@ -93,6 +101,20 @@ class _CouponEidtPageState extends State<CouponEidtPage> { |
|
|
|
|
|
|
|
List<String?> imgAll = [];
|
|
|
|
|
|
|
|
bool isSameDay = true; //领取当日可用
|
|
|
|
|
|
|
|
bool isAccumulation = true; //叠加使用
|
|
|
|
|
|
|
|
bool isCompartment = true; //包间可用
|
|
|
|
|
|
|
|
bool isEatin = true; //堂食
|
|
|
|
bool isTakeout = true; //外带
|
|
|
|
bool isAppointment = true; //预约
|
|
|
|
|
|
|
|
bool isShareLose = true; //分享好友
|
|
|
|
bool isShareHave = true; //分享好友后继续拥有此券
|
|
|
|
bool isCommission = true; //返佣金
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
...
|
...
|
@@ -194,15 +216,26 @@ class _CouponEidtPageState extends State<CouponEidtPage> { |
|
|
|
endDate = DateUtil.formatDate(dateTimee, format: DateFormats.y_mo_d);
|
|
|
|
|
|
|
|
swichState = widget.couponSunModel!.status == '1' ? true : false;
|
|
|
|
_priceControl.text = widget.couponSunModel!.price;
|
|
|
|
_limitDay.text = widget.couponSunModel!.aexpiration ??'';
|
|
|
|
|
|
|
|
isSameDay = widget.couponSunModel!.arule!.isSameDay;
|
|
|
|
isAccumulation = widget.couponSunModel!.arule!.isAccumulation;
|
|
|
|
isCompartment = widget.couponSunModel!.arule!.isCompartment;
|
|
|
|
isEatin = widget.couponSunModel!.arule!.isEatin; //堂食
|
|
|
|
isTakeout = widget.couponSunModel!.arule!.isTakeout; //外带
|
|
|
|
isAppointment = widget.couponSunModel!.arule!.isAppointment;
|
|
|
|
isShareLose = widget.couponSunModel!.arule!.isShareLose; //分享好友
|
|
|
|
isShareHave = widget.couponSunModel!.arule!.isShareHave; //分享好友后继续拥有此券
|
|
|
|
isCommission = widget.couponSunModel!.arule!.isCommission; //返佣金
|
|
|
|
_commissionControl.text = widget.couponSunModel!.arule!.commission;
|
|
|
|
weekShow = widget.couponSunModel!.expDate!.weekShow ?? '无';
|
|
|
|
weekData = widget.couponSunModel!.expDate!.weekData ?? [];
|
|
|
|
_limitNumControl.text = widget.couponSunModel!.grantNum??'';
|
|
|
|
|
|
|
|
if (widget.isMine) {
|
|
|
|
//我的优惠券
|
|
|
|
|
|
|
|
} else {
|
|
|
|
//店铺
|
|
|
|
swichHexiao = widget.couponSunModel!.isExamine == '1' ? true : false;
|
|
|
|
_priceControl.text = widget.couponSunModel!.price;
|
|
|
|
|
|
|
|
if (!widget.isMine) {
|
|
|
|
//付费优惠券
|
|
|
|
// swichHexiao = widget.couponSunModel.isExamine == '1' ? true : false;
|
|
|
|
money = widget.couponSunModel!.use!.isCash;
|
|
|
|
dish = widget.couponSunModel!.use!.isDish;
|
|
|
|
discount = widget.couponSunModel!.use!.isDiscount;
|
|
...
|
...
|
@@ -224,10 +257,7 @@ class _CouponEidtPageState extends State<CouponEidtPage> { |
|
|
|
limitBirthday = widget.couponSunModel!.expDate!.isBirthday ? true : false;
|
|
|
|
limitWeek = widget.couponSunModel!.expDate!.isWeek ? true : false;
|
|
|
|
|
|
|
|
weekShow = widget.couponSunModel!.expDate!.weekShow ?? '点击设置可用日期';
|
|
|
|
weekData = widget.couponSunModel!.expDate!.weekData ;
|
|
|
|
uids = widget.couponSunModel!.uidList;
|
|
|
|
_limitNumControl.text = widget.couponSunModel!.grantNum??'';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -287,6 +317,11 @@ class _CouponEidtPageState extends State<CouponEidtPage> { |
|
|
|
filterBtnModel.title = '周${Utils.formatWeekDayNum(i)}';
|
|
|
|
weekData.add(filterBtnModel);
|
|
|
|
}
|
|
|
|
FilterBtnModel filterBtnModel1 = FilterBtnModel();
|
|
|
|
filterBtnModel1.selectNoon = false;
|
|
|
|
filterBtnModel1.selectNig = false;
|
|
|
|
filterBtnModel1.title = '法定假日';
|
|
|
|
weekData.add(filterBtnModel1);
|
|
|
|
}
|
|
|
|
|
|
|
|
//创建新券 客户经理创建活动
|
|
...
|
...
|
@@ -308,14 +343,46 @@ class _CouponEidtPageState extends State<CouponEidtPage> { |
|
|
|
"explain": _couponExplainEditControl.text,
|
|
|
|
"is_open": swichState ? "1" : "0",
|
|
|
|
"status": swichState ? "1" : "0",
|
|
|
|
'is_type': widget.isMine ? "2" : "1"
|
|
|
|
'is_type': widget.isMine ? "3" : "4"
|
|
|
|
};
|
|
|
|
|
|
|
|
params['aexpiration'] = _limitDay.text;
|
|
|
|
|
|
|
|
// params['arule'] = ;
|
|
|
|
params['price'] =
|
|
|
|
_priceControl.text.trim().length == 0 ? '0' : _priceControl.text;
|
|
|
|
Map expDate = {
|
|
|
|
// 'is_none': limitNone ? '1' : '0',
|
|
|
|
// 'is_week': limitWeek ? '1' : '0',
|
|
|
|
// 'is_birthday': limitBirthday ? '1' : '0',
|
|
|
|
'week_show': weekShow,
|
|
|
|
'week_data': weekData
|
|
|
|
};
|
|
|
|
params['exp_date'] = jsonEncode(expDate);
|
|
|
|
|
|
|
|
if (_limitNumControl.text.trim().length == 0) {
|
|
|
|
params['grant_num'] = '1000';
|
|
|
|
} else {
|
|
|
|
params['grant_num'] = _limitNumControl.text;
|
|
|
|
}
|
|
|
|
|
|
|
|
Map setting = {
|
|
|
|
'is_same_day': isSameDay ? '1' : '0',
|
|
|
|
'is_accumulation': isAccumulation ? '1' : '0',
|
|
|
|
'is_compartment': isCompartment ? '1' : '0',
|
|
|
|
'is_eatin': isEatin ? '1' : '0',
|
|
|
|
'is_takeout': isTakeout ? '1' : '0',
|
|
|
|
'is_appointment': isAppointment ? '1' : '0',
|
|
|
|
'is_share_lose': isShareLose ? '1' : '0',
|
|
|
|
'is_share_have': isShareHave ? '1' : '0',
|
|
|
|
'is_commission': isCommission ? '1' : '0',
|
|
|
|
'commission': _commissionControl.text
|
|
|
|
};
|
|
|
|
params['arule'] = jsonEncode(setting);
|
|
|
|
params['is_examine'] = "1";
|
|
|
|
List<String?> images = [];
|
|
|
|
if (!widget.isMine) {
|
|
|
|
params['is_examine'] = swichHexiao ? "1" : "0";
|
|
|
|
params['uid_list'] = uids;
|
|
|
|
params['price'] =
|
|
|
|
_priceControl.text.trim().length == 0 ? '0' : _priceControl.text;
|
|
|
|
|
|
|
|
if (img.length > 0) {
|
|
|
|
img.forEach((value) {
|
|
...
|
...
|
@@ -333,21 +400,6 @@ class _CouponEidtPageState extends State<CouponEidtPage> { |
|
|
|
'images': json.encode(images)
|
|
|
|
};
|
|
|
|
params['use'] = jsonEncode(use);
|
|
|
|
|
|
|
|
Map expDate = {
|
|
|
|
'is_none': limitNone ? '1' : '0',
|
|
|
|
'is_week': limitWeek ? '1' : '0',
|
|
|
|
'is_birthday': limitBirthday ? '1' : '0',
|
|
|
|
'week_show': weekShow,
|
|
|
|
'week_data': weekData
|
|
|
|
};
|
|
|
|
params['exp_date'] = jsonEncode(expDate);
|
|
|
|
|
|
|
|
if (_limitNumControl.text.trim().length == 0) {
|
|
|
|
params['grant_num'] = '1000';
|
|
|
|
} else {
|
|
|
|
params['grant_num'] = _limitNumControl.text;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool isSuccess =
|
|
|
|
await couponProvider.createCustomerActivity(context, params) ;
|
|
...
|
...
|
@@ -381,6 +433,8 @@ class _CouponEidtPageState extends State<CouponEidtPage> { |
|
|
|
TextEditingController controller, FocusNode focusNode,
|
|
|
|
{TextInputType textInputType = TextInputType.text}) {
|
|
|
|
return Container(
|
|
|
|
margin: EdgeInsets.only(bottom: w(12)),
|
|
|
|
height: w(24),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
...
|
...
|
@@ -389,11 +443,12 @@ class _CouponEidtPageState extends State<CouponEidtPage> { |
|
|
|
title,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Color.fromRGBO(0, 0, 0, 0.9),
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
fontWeight:
|
|
|
|
title == '分享佣金' ? FontWeight.normal : FontWeight.bold,
|
|
|
|
fontSize: title == '分享佣金' ? font(14) : font(16)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
HEmptyView(80),
|
|
|
|
// HEmptyView(10),
|
|
|
|
Expanded(
|
|
|
|
// width: ScreenUtil().setWidth(231 * 2),
|
|
|
|
child: TextField(
|
|
...
|
...
|
@@ -407,18 +462,25 @@ class _CouponEidtPageState extends State<CouponEidtPage> { |
|
|
|
//输入文本的样式
|
|
|
|
inputFormatters: title == '券名称'
|
|
|
|
? [LengthLimitingTextInputFormatter(15)]
|
|
|
|
: [],
|
|
|
|
: title == '券金额' ||
|
|
|
|
title == '领取后有效天数' ||
|
|
|
|
title == '消费要求(0为无门槛)' ||
|
|
|
|
title == '分享佣金' ||
|
|
|
|
title == '发放总量限制'
|
|
|
|
? [FilteringTextInputFormatter.digitsOnly]
|
|
|
|
: [], // 限制输入为数字,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_515151,
|
|
|
|
fontSize: ScreenUtil().setSp(32),
|
|
|
|
fontSize: ScreenUtil().setSp(28),
|
|
|
|
),
|
|
|
|
focusNode: focusNode,
|
|
|
|
decoration: InputDecoration(
|
|
|
|
isCollapsed: true,
|
|
|
|
border: OutlineInputBorder(borderSide: BorderSide.none),
|
|
|
|
hintText: hintText,
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
color: MyColours.color_999999,
|
|
|
|
fontSize: ScreenUtil().setSp(32),
|
|
|
|
fontSize: ScreenUtil().setSp(28),
|
|
|
|
),
|
|
|
|
enabledBorder: new UnderlineInputBorder(
|
|
|
|
borderSide: BorderSide.none,
|
|
...
|
...
|
@@ -433,7 +495,26 @@ class _CouponEidtPageState extends State<CouponEidtPage> { |
|
|
|
},
|
|
|
|
keyboardType: textInputType),
|
|
|
|
),
|
|
|
|
HEmptyView(32)
|
|
|
|
HEmptyView(5),
|
|
|
|
if (title == '领取后有效天数')
|
|
|
|
Text(
|
|
|
|
'天',
|
|
|
|
style: TextStyle(
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: MyColours.color_515151,
|
|
|
|
fontSize: font(14),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (title == '分享佣金')
|
|
|
|
Text(
|
|
|
|
'%',
|
|
|
|
style: TextStyle(
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: MyColours.color_515151,
|
|
|
|
fontSize: font(14),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
HEmptyView(22)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
...
|
...
|
@@ -570,16 +651,16 @@ class _CouponEidtPageState extends State<CouponEidtPage> { |
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
)),
|
|
|
|
VEmptyView(26),
|
|
|
|
Container(
|
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
// VEmptyView(26),
|
|
|
|
// Container(
|
|
|
|
// height: ScreenUtil().setWidth(2),
|
|
|
|
// color: MyColours.color_E7E7E7,
|
|
|
|
// ),
|
|
|
|
TextField(
|
|
|
|
controller: _couponExplainEditControl,
|
|
|
|
// keyboardType: TextInputType.number, //键盘类型,数字键盘
|
|
|
|
maxLines: 3,
|
|
|
|
maxLength: 50,
|
|
|
|
maxLines: 5,
|
|
|
|
maxLength: 500,
|
|
|
|
|
|
|
|
// maxLengthEnforced: true,
|
|
|
|
style: TextStyle(
|
|
...
|
...
|
@@ -633,11 +714,14 @@ class _CouponEidtPageState extends State<CouponEidtPage> { |
|
|
|
}
|
|
|
|
|
|
|
|
///是否立即启用
|
|
|
|
Widget _canUse(String title, bool swich, GestureTapCallback onTap) {
|
|
|
|
Widget _canUse(String title, bool swich, GestureTapCallback onTap,
|
|
|
|
{bool isBig = true}) {
|
|
|
|
return InkWell(
|
|
|
|
onTap: onTap,
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.symmetric(vertical: ScreenUtil().setWidth(24)),
|
|
|
|
padding: isBig
|
|
|
|
? EdgeInsets.symmetric(vertical: ScreenUtil().setWidth(24))
|
|
|
|
: EdgeInsets.only(bottom: w(17)),
|
|
|
|
margin: EdgeInsets.only(right: ScreenUtil().setWidth(32)),
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
...
|
...
|
@@ -650,15 +734,16 @@ class _CouponEidtPageState extends State<CouponEidtPage> { |
|
|
|
title,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Color.fromRGBO(0, 0, 0, 0.9),
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
fontWeight:
|
|
|
|
title == '立即启用' ? FontWeight.bold : FontWeight.normal,
|
|
|
|
fontSize: title == '立即启用' ? font(16) : font(14)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Spacer(),
|
|
|
|
Image.asset(
|
|
|
|
swich
|
|
|
|
? Utils.getImgPath('swich_on')
|
|
|
|
: Utils.getImgPath('swich_off'),
|
|
|
|
? Utils.getImgPath(isBig ? 'swich_on' : 'swich_on_lit')
|
|
|
|
: Utils.getImgPath(isBig ? 'swich_off' : 'swich_off_lit'),
|
|
|
|
width: ScreenUtil().setWidth(44 * 2),
|
|
|
|
)
|
|
|
|
],
|
|
...
|
...
|
@@ -798,51 +883,52 @@ class _CouponEidtPageState extends State<CouponEidtPage> { |
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
VEmptyView(56),
|
|
|
|
_item('券类型', widget.isMine ? '我的优惠券' : '店铺优惠券'),
|
|
|
|
// _item('券类型', widget.isMine ? '我的优惠券' : '店铺优惠券'),
|
|
|
|
// Container(
|
|
|
|
// height: ScreenUtil().setWidth(2),
|
|
|
|
// color: MyColours.color_E7E7E7,
|
|
|
|
// ),
|
|
|
|
// VEmptyView(24),
|
|
|
|
// widget.isMine
|
|
|
|
// ? SizedBox()
|
|
|
|
// : _canUse('是否核销', swichHexiao, () {
|
|
|
|
// setState(() {
|
|
|
|
// swichHexiao = !swichHexiao;
|
|
|
|
// });
|
|
|
|
// }),
|
|
|
|
// widget.isMine
|
|
|
|
// ? SizedBox()
|
|
|
|
// : Container(
|
|
|
|
// height: ScreenUtil().setWidth(2),
|
|
|
|
// color: MyColours.color_E7E7E7,
|
|
|
|
// ),
|
|
|
|
// widget.isMine ? SizedBox() : VEmptyView(24),
|
|
|
|
_textfield('券名称', '点击输入券名称',
|
|
|
|
_couponNameEditControl, _nameFocusNode),
|
|
|
|
Container(
|
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
VEmptyView(24),
|
|
|
|
widget.isMine
|
|
|
|
? SizedBox()
|
|
|
|
: _canUse('是否核销', swichHexiao, () {
|
|
|
|
setState(() {
|
|
|
|
swichHexiao = !swichHexiao;
|
|
|
|
});
|
|
|
|
}),
|
|
|
|
widget.isMine
|
|
|
|
? SizedBox()
|
|
|
|
: Container(
|
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
widget.isMine ? SizedBox() : VEmptyView(24),
|
|
|
|
_textfield('券名称', '例:9折券/200元代金券/菜品券',
|
|
|
|
_couponNameEditControl, _nameFocusNode),
|
|
|
|
VEmptyView(48),
|
|
|
|
//销售价
|
|
|
|
|
|
|
|
_textfield(widget.isMine ? '券金额' : '销售价',
|
|
|
|
'点击输入代金券金额', _priceControl, _priceFocusNode,
|
|
|
|
textInputType:
|
|
|
|
TextInputType.numberWithOptions(
|
|
|
|
decimal: true)),
|
|
|
|
|
|
|
|
Container(
|
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
VEmptyView(24),
|
|
|
|
VEmptyView(48),
|
|
|
|
if (!widget.isMine)
|
|
|
|
Column(
|
|
|
|
children: [
|
|
|
|
//销售价
|
|
|
|
|
|
|
|
_textfield('销售价', '默认0元,可以免费发放',
|
|
|
|
_priceControl, _priceFocusNode,
|
|
|
|
textInputType:
|
|
|
|
TextInputType.numberWithOptions(
|
|
|
|
decimal: true)),
|
|
|
|
|
|
|
|
Container(
|
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
// VEmptyView(24),
|
|
|
|
//券用途
|
|
|
|
VEmptyView(56),
|
|
|
|
|
|
|
|
Container(
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Text(
|
|
...
|
...
|
@@ -1060,16 +1146,18 @@ class _CouponEidtPageState extends State<CouponEidtPage> { |
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
VEmptyView(48),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
_textfield('券要求', '例:无门槛/满2000元',
|
|
|
|
|
|
|
|
_textfield('消费要求(0为无门槛)', '点击输入最低消费金额需求',
|
|
|
|
_couponRequireEditControl, _requireFocusNode),
|
|
|
|
Container(
|
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
VEmptyView(24),
|
|
|
|
_select('有效期从', fromDate, () {
|
|
|
|
_select('活动开始于', fromDate, () {
|
|
|
|
FocusScope.of(context)
|
|
|
|
.requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
//弹出时间选择器
|
|
...
|
...
|
@@ -1101,7 +1189,7 @@ class _CouponEidtPageState extends State<CouponEidtPage> { |
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
VEmptyView(24),
|
|
|
|
_select('有效期至', endDate, () {
|
|
|
|
_select('活动结束于', endDate, () {
|
|
|
|
FocusScope.of(context)
|
|
|
|
.requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
//弹出时间选择器
|
|
...
|
...
|
@@ -1132,128 +1220,294 @@ class _CouponEidtPageState extends State<CouponEidtPage> { |
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
VEmptyView(24),
|
|
|
|
if (!widget.isMine)
|
|
|
|
Column(
|
|
|
|
children: [
|
|
|
|
//使用限制
|
|
|
|
VEmptyView(24),
|
|
|
|
Container(
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Text(
|
|
|
|
'使用限制',
|
|
|
|
style: TextStyle(
|
|
|
|
color: Color.fromRGBO(0, 0, 0, 0.9),
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
VEmptyView(40),
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
HEmptyView(30),
|
|
|
|
_itemRadioWidget(limitNone, '无',
|
|
|
|
onTap: () {
|
|
|
|
if (!limitNone) {
|
|
|
|
setState(() {
|
|
|
|
limitNone = true;
|
|
|
|
|
|
|
|
limitWeek = false;
|
|
|
|
limitBirthday = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
Spacer(),
|
|
|
|
_itemRadioWidget(limitWeek, '每周',
|
|
|
|
onTap: () {
|
|
|
|
if (!limitWeek) {
|
|
|
|
setState(() {
|
|
|
|
limitWeek = true;
|
|
|
|
VEmptyView(48),
|
|
|
|
|
|
|
|
limitNone = false;
|
|
|
|
limitBirthday = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
Spacer(),
|
|
|
|
_itemRadioWidget(
|
|
|
|
limitBirthday, '会员生日当天', onTap: () {
|
|
|
|
if (!limitBirthday) {
|
|
|
|
setState(() {
|
|
|
|
limitBirthday = true;
|
|
|
|
limitNone = false;
|
|
|
|
limitWeek = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
HEmptyView(30),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
if (limitWeek) VEmptyView(30),
|
|
|
|
|
|
|
|
if (limitWeek)
|
|
|
|
_select1(weekShow, '', () async {
|
|
|
|
FocusScope.of(context).requestFocus(
|
|
|
|
FocusNode()); //点击空白处隐藏键盘
|
|
|
|
//弹出时间选择器
|
|
|
|
// showPickerDateTime(context);
|
|
|
|
showDateSelWidget = false;
|
|
|
|
|
|
|
|
List<FilterBtnModel> data = await DialogUtil
|
|
|
|
.openCoponsWeekSelectModalBottomSheet(
|
|
|
|
context, weekData);
|
|
|
|
if (data != null) {
|
|
|
|
//改变了
|
|
|
|
weekData = [];
|
|
|
|
weekData.addAll(data);
|
|
|
|
weekShow = '';
|
|
|
|
|
|
|
|
String noonStr = '午餐:';
|
|
|
|
String nightStr = '晚餐:';
|
|
|
|
|
|
|
|
weekData.forEach((element) {
|
|
|
|
if (element.selectNoon!) {
|
|
|
|
noonStr += '${element.title} ';
|
|
|
|
}
|
|
|
|
if (element.selectNig!) {
|
|
|
|
nightStr += '${element.title} ';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (noonStr.endsWith(' ')) {
|
|
|
|
noonStr = noonStr.substring(
|
|
|
|
0, noonStr.length - 1);
|
|
|
|
}
|
|
|
|
if (nightStr.endsWith(' ')) {
|
|
|
|
nightStr = nightStr.substring(
|
|
|
|
0, nightStr.length - 1);
|
|
|
|
}
|
|
|
|
_textfield('领取后有效天数', '点击输入,0表示到活动结束', _limitDay,
|
|
|
|
_limitDayFocusNode,
|
|
|
|
textInputType: TextInputType.number),
|
|
|
|
Container(
|
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
VEmptyView(24),
|
|
|
|
|
|
|
|
if (noonStr == '午餐:' &&
|
|
|
|
nightStr == '晚餐:') {
|
|
|
|
weekShow = '点击设置可用日期';
|
|
|
|
} else {
|
|
|
|
if (noonStr != '午餐:' &&
|
|
|
|
nightStr != '晚餐:') {
|
|
|
|
weekShow =
|
|
|
|
noonStr + '\n' + nightStr;
|
|
|
|
} else if (noonStr != '午餐:') {
|
|
|
|
weekShow = noonStr;
|
|
|
|
} else {
|
|
|
|
weekShow = nightStr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_select('不可用日期', weekShow, () async {
|
|
|
|
FocusScope.of(context)
|
|
|
|
.requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
//弹出时间选择器
|
|
|
|
// showPickerDateTime(context);
|
|
|
|
showDateSelWidget = false;
|
|
|
|
|
|
|
|
List<FilterBtnModel> data = await DialogUtil
|
|
|
|
.openCoponsWeekSelectModalBottomSheet(
|
|
|
|
context, weekData);
|
|
|
|
if (data != null) {
|
|
|
|
//改变了
|
|
|
|
weekData = [];
|
|
|
|
weekData.addAll(data);
|
|
|
|
weekShow = '';
|
|
|
|
|
|
|
|
String noonStr = '午餐:';
|
|
|
|
String nightStr = '晚餐:';
|
|
|
|
|
|
|
|
weekData.forEach((element) {
|
|
|
|
if (element.selectNoon!) {
|
|
|
|
noonStr += '${element.title} ';
|
|
|
|
}
|
|
|
|
if (element.selectNig!) {
|
|
|
|
nightStr += '${element.title} ';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (noonStr.endsWith(' ')) {
|
|
|
|
noonStr = noonStr.substring(
|
|
|
|
0, noonStr.length - 1);
|
|
|
|
}
|
|
|
|
if (nightStr.endsWith(' ')) {
|
|
|
|
nightStr = nightStr.substring(
|
|
|
|
0, nightStr.length - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (noonStr == '午餐:' && nightStr == '晚餐:') {
|
|
|
|
weekShow = '无';
|
|
|
|
} else {
|
|
|
|
if (noonStr != '午餐:' && nightStr != '晚餐:') {
|
|
|
|
weekShow = noonStr + '\n' + nightStr;
|
|
|
|
} else if (noonStr != '午餐:') {
|
|
|
|
weekShow = noonStr;
|
|
|
|
} else {
|
|
|
|
weekShow = nightStr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
Container(
|
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
VEmptyView(48),
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
limitWeek ? VEmptyView(22) : VEmptyView(48),
|
|
|
|
Container(
|
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
VEmptyView(48),
|
|
|
|
Container(
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Text(
|
|
|
|
'使用规则:',
|
|
|
|
style: TextStyle(
|
|
|
|
color: Color.fromRGBO(0, 0, 0, 0.9),
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
VEmptyView(24),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
left: w(32),
|
|
|
|
),
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
_canUse('领取当日可用', isSameDay, () {
|
|
|
|
setState(() {
|
|
|
|
isSameDay = !isSameDay;
|
|
|
|
});
|
|
|
|
}, isBig: false),
|
|
|
|
_canUse('可以叠加使用其他优惠券', isAccumulation, () {
|
|
|
|
setState(() {
|
|
|
|
isAccumulation = !isAccumulation;
|
|
|
|
});
|
|
|
|
}, isBig: false),
|
|
|
|
_canUse('可使用包间', isCompartment, () {
|
|
|
|
setState(() {
|
|
|
|
isCompartment = !isCompartment;
|
|
|
|
});
|
|
|
|
}, isBig: false),
|
|
|
|
_canUse('堂食可用', isEatin, () {
|
|
|
|
setState(() {
|
|
|
|
isEatin = !isEatin;
|
|
|
|
});
|
|
|
|
}, isBig: false),
|
|
|
|
_canUse('外带可用', isTakeout, () {
|
|
|
|
setState(() {
|
|
|
|
isTakeout = !isTakeout;
|
|
|
|
});
|
|
|
|
}, isBig: false),
|
|
|
|
_canUse('是否需要提前预约', isAppointment, () {
|
|
|
|
setState(() {
|
|
|
|
isAppointment = !isAppointment;
|
|
|
|
});
|
|
|
|
}, isBig: false),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
VEmptyView(24),
|
|
|
|
Container(
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Text(
|
|
|
|
'分享设置:',
|
|
|
|
style: TextStyle(
|
|
|
|
color: Color.fromRGBO(0, 0, 0, 0.9),
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
VEmptyView(24),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
left: w(32),
|
|
|
|
),
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
_canUse('用户可以分享给好友', isShareLose, () {
|
|
|
|
setState(() {
|
|
|
|
isShareLose = !isShareLose;
|
|
|
|
});
|
|
|
|
}, isBig: false),
|
|
|
|
_canUse('用户分享给好友后继续拥有此券', isShareHave, () {
|
|
|
|
setState(() {
|
|
|
|
isShareHave = !isShareHave;
|
|
|
|
});
|
|
|
|
}, isBig: false),
|
|
|
|
_canUse('分享核销后,分享用户获得佣金', isCommission, () {
|
|
|
|
setState(() {
|
|
|
|
isCommission = !isCommission;
|
|
|
|
});
|
|
|
|
}, isBig: false),
|
|
|
|
_textfield(
|
|
|
|
'分享佣金',
|
|
|
|
'点击输入佣金比例(实际消费金额计算)',
|
|
|
|
_commissionControl,
|
|
|
|
_commissionFocusNode,
|
|
|
|
textInputType: TextInputType.number),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
VEmptyView(24),
|
|
|
|
Container(
|
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
|
|
|
|
// if (!widget.isMine)
|
|
|
|
// Column(
|
|
|
|
// children: [
|
|
|
|
// //使用限制
|
|
|
|
// VEmptyView(24),
|
|
|
|
// Container(
|
|
|
|
// alignment: Alignment.centerLeft,
|
|
|
|
// child: Text(
|
|
|
|
// '使用限制',
|
|
|
|
// style: TextStyle(
|
|
|
|
// color: Color.fromRGBO(0, 0, 0, 0.9),
|
|
|
|
// fontWeight: FontWeight.bold,
|
|
|
|
// fontSize: ScreenUtil().setSp(32)),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// VEmptyView(40),
|
|
|
|
// Row(
|
|
|
|
// children: [
|
|
|
|
// HEmptyView(30),
|
|
|
|
// _itemRadioWidget(limitNone, '无',
|
|
|
|
// onTap: () {
|
|
|
|
// if (!limitNone) {
|
|
|
|
// setState(() {
|
|
|
|
// limitNone = true;
|
|
|
|
|
|
|
|
// limitWeek = false;
|
|
|
|
// limitBirthday = false;
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
// }),
|
|
|
|
// Spacer(),
|
|
|
|
// _itemRadioWidget(limitWeek, '每周',
|
|
|
|
// onTap: () {
|
|
|
|
// if (!limitWeek) {
|
|
|
|
// setState(() {
|
|
|
|
// limitWeek = true;
|
|
|
|
|
|
|
|
// limitNone = false;
|
|
|
|
// limitBirthday = false;
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
// }),
|
|
|
|
// Spacer(),
|
|
|
|
// _itemRadioWidget(
|
|
|
|
// limitBirthday, '会员生日当天', onTap: () {
|
|
|
|
// if (!limitBirthday) {
|
|
|
|
// setState(() {
|
|
|
|
// limitBirthday = true;
|
|
|
|
// limitNone = false;
|
|
|
|
// limitWeek = false;
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
// }),
|
|
|
|
// HEmptyView(30),
|
|
|
|
// ],
|
|
|
|
// ),
|
|
|
|
// if (limitWeek) VEmptyView(30),
|
|
|
|
|
|
|
|
// if (limitWeek)
|
|
|
|
// _select1(weekShow, '', () async {
|
|
|
|
// FocusScope.of(context).requestFocus(
|
|
|
|
// FocusNode()); //点击空白处隐藏键盘
|
|
|
|
// //弹出时间选择器
|
|
|
|
// // showPickerDateTime(context);
|
|
|
|
// showDateSelWidget = false;
|
|
|
|
|
|
|
|
// List<FilterBtnModel> data = await DialogUtil
|
|
|
|
// .openCoponsWeekSelectModalBottomSheet(
|
|
|
|
// context, weekData);
|
|
|
|
// if (data != null) {
|
|
|
|
// //改变了
|
|
|
|
// weekData = [];
|
|
|
|
// weekData.addAll(data);
|
|
|
|
// weekShow = '';
|
|
|
|
|
|
|
|
// String noonStr = '午餐:';
|
|
|
|
// String nightStr = '晚餐:';
|
|
|
|
|
|
|
|
// weekData.forEach((element) {
|
|
|
|
// if (element.selectNoon) {
|
|
|
|
// noonStr += '${element.title} ';
|
|
|
|
// }
|
|
|
|
// if (element.selectNig) {
|
|
|
|
// nightStr += '${element.title} ';
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// if (noonStr.endsWith(' ')) {
|
|
|
|
// noonStr = noonStr.substring(
|
|
|
|
// 0, noonStr.length - 1);
|
|
|
|
// }
|
|
|
|
// if (nightStr.endsWith(' ')) {
|
|
|
|
// nightStr = nightStr.substring(
|
|
|
|
// 0, nightStr.length - 1);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (noonStr == '午餐:' &&
|
|
|
|
// nightStr == '晚餐:') {
|
|
|
|
// weekShow = '点击设置可用日期';
|
|
|
|
// } else {
|
|
|
|
// if (noonStr != '午餐:' &&
|
|
|
|
// nightStr != '晚餐:') {
|
|
|
|
// weekShow =
|
|
|
|
// noonStr + '\n' + nightStr;
|
|
|
|
// } else if (noonStr != '午餐:') {
|
|
|
|
// weekShow = noonStr;
|
|
|
|
// } else {
|
|
|
|
// weekShow = nightStr;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// setState(() {});
|
|
|
|
// }
|
|
|
|
// }),
|
|
|
|
// limitWeek ? VEmptyView(22) : VEmptyView(48),
|
|
|
|
// Container(
|
|
|
|
// height: ScreenUtil().setWidth(2),
|
|
|
|
// color: MyColours.color_E7E7E7,
|
|
|
|
// ),
|
|
|
|
// VEmptyView(48),
|
|
|
|
// ],
|
|
|
|
// ),
|
|
|
|
widget.isMine ? VEmptyView(48) : VEmptyView(24),
|
|
|
|
widget.isMine
|
|
|
|
? SizedBox()
|
|
|
|
: _select('谁可以发放', '编辑', () async {
|
|
...
|
...
|
@@ -1271,19 +1525,15 @@ class _CouponEidtPageState extends State<CouponEidtPage> { |
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
widget.isMine ? SizedBox() : VEmptyView(24),
|
|
|
|
widget.isMine
|
|
|
|
? SizedBox()
|
|
|
|
: _textfield('发放总量限制', '点击输入总数量限制',
|
|
|
|
_limitNumControl, _limitNumFocusNode,
|
|
|
|
textInputType: TextInputType.number),
|
|
|
|
widget.isMine
|
|
|
|
? SizedBox()
|
|
|
|
: Container(
|
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
widget.isMine ? SizedBox() : VEmptyView(24),
|
|
|
|
widget.isMine ? SizedBox() : VEmptyView(48),
|
|
|
|
_textfield('发放总量限制', '点击输入总数量限制',
|
|
|
|
_limitNumControl, _limitNumFocusNode,
|
|
|
|
textInputType: TextInputType.number),
|
|
|
|
Container(
|
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
VEmptyView(24),
|
|
|
|
_explain('券说明', '例:可用包间,停车免费,不与店内其他活动共享等'),
|
|
|
|
VEmptyView(20),
|
|
|
|
_canUse('立即启用', swichState, () {
|
|
...
|
...
|
@@ -1314,6 +1564,11 @@ class _CouponEidtPageState extends State<CouponEidtPage> { |
|
|
|
Utils.showToast('请填写券名称');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (_priceControl.text.trim().length == 0) {
|
|
|
|
Utils.showToast(widget.isMine ? '请填写券金额' : '请填写销售价');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!widget.isMine) {
|
|
|
|
if (money && moneyControl.text.trim().length == 0) {
|
|
|
|
Utils.showToast('请输入代金券金额!');
|
|
...
|
...
|
@@ -1328,42 +1583,55 @@ class _CouponEidtPageState extends State<CouponEidtPage> { |
|
|
|
Utils.showToast('请输入菜品!');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (limitWeek && weekShow == '点击设置可用日期') {
|
|
|
|
Utils.showToast('请设置可用日期!');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (uids == null || uids == '') {
|
|
|
|
Utils.showToast('请设置发放人!');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isNumber = Utils.isInteger(
|
|
|
|
_limitNumControl.text.trim()); //判断输入的内容是否是数字
|
|
|
|
if (!isNumber) {
|
|
|
|
Utils.showToast('发放总量限制请输入数字');
|
|
|
|
_limitNumControl.text = '';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_couponRequireEditControl.text.trim().length == 0) {
|
|
|
|
Utils.showToast('请填写券要求');
|
|
|
|
Utils.showToast('请填写消费要求');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (fromDate == '点击选择') {
|
|
|
|
Utils.showToast('请选择有效期起始时间');
|
|
|
|
Utils.showToast('请选择活动开始时间');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (endDate == '点击选择') {
|
|
|
|
Utils.showToast('请选择有效期结束时间');
|
|
|
|
Utils.showToast('请选择活动结束时间');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (DateUtil.getDateTime(endDate)!
|
|
|
|
.compareTo(DateUtil.getDateTime(fromDate)!) <
|
|
|
|
|
|
|
|
if (DateUtil.getDateTime(endDate)
|
|
|
|
.compareTo(DateUtil.getDateTime(fromDate)) <
|
|
|
|
0) {
|
|
|
|
Utils.showToast('有效期结束时间不能早于起始时间');
|
|
|
|
Utils.showToast('活动结束时间不能早于活动开始时间');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (_limitDay.text.trim().length == 0) {
|
|
|
|
Utils.showToast('请填写领取后有效天数');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isCommission &&
|
|
|
|
(_commissionControl.text.trim().length == 0 ||
|
|
|
|
_commissionControl.text == '0')) {
|
|
|
|
Utils.showToast('请填写分享佣金的比例');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!widget.isMine) {
|
|
|
|
if (uids == null || uids == '') {
|
|
|
|
Utils.showToast('请设置发放人!');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (_limitNumControl.text.trim().length == 0) {
|
|
|
|
Utils.showToast('请填写发放总量限制');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// bool isNumber = Utils.isInteger(
|
|
|
|
// _limitNumControl.text.trim()); //判断输入的内容是否是数字
|
|
|
|
// if (!isNumber) {
|
|
|
|
// Utils.showToast('发放总量限制请输入数字');
|
|
|
|
// _limitNumControl.text = '';
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// ***参数***
|
|
|
|
// _couponNameEditControl.text
|
|
...
|
...
|
@@ -1376,8 +1644,8 @@ class _CouponEidtPageState extends State<CouponEidtPage> { |
|
|
|
}
|
|
|
|
},
|
|
|
|
text: '立即创建',
|
|
|
|
fontSize: 24,
|
|
|
|
isBold: false,
|
|
|
|
fontSize: 32,
|
|
|
|
isBold: true,
|
|
|
|
height: ScreenUtil().setWidth(37 * 2),
|
|
|
|
width: ScreenUtil().setWidth(130 * 2),
|
|
|
|
radius: ScreenUtil().setWidth(22),
|
...
|
...
|
|