|
|
|
import 'package:common_utils/common_utils.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_picker/Picker.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:one_key/models/coupon_model.dart';
|
|
|
|
import 'package:one_key/models/filter_btn_model.dart';
|
|
|
|
import 'package:one_key/route/navigator_util.dart';
|
|
|
|
import 'package:one_key/widgets/MyDivider.dart';
|
|
|
|
import 'package:one_key/widgets/system_app_bar.dart';
|
|
|
|
|
|
|
|
import '../../../../res/colors.dart';
|
|
|
|
import '../../../../utils/dialog_util.dart';
|
|
|
|
import '../../../../utils/screen_util.dart';
|
|
|
|
import '../../../../utils/utils.dart';
|
|
|
|
import '../../../../widgets/h_empty_view.dart';
|
|
|
|
import '../../../../widgets/round_button.dart';
|
|
|
|
import '../../../../widgets/v_empty_view.dart';
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* 优惠券详情
|
|
|
|
*/
|
|
|
|
|
|
|
|
class RechargeDetailPage extends StatefulWidget {
|
|
|
|
RechargeDetailPage({Key key}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
_RechargeDetailPageState createState() => _RechargeDetailPageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _RechargeDetailPageState extends State<RechargeDetailPage> {
|
|
|
|
TextEditingController nameC = TextEditingController();
|
|
|
|
TextEditingController priceminC = TextEditingController();
|
|
|
|
TextEditingController givePriceC = TextEditingController(); //赠送金额
|
|
|
|
TextEditingController giveScoreC = TextEditingController(); //积分
|
|
|
|
TextEditingController remarkC = TextEditingController(); //备注
|
|
|
|
|
|
|
|
FocusNode nameF = FocusNode();
|
|
|
|
FocusNode priceminF = FocusNode();
|
|
|
|
FocusNode givePricF = FocusNode();
|
|
|
|
FocusNode giveScoreF = FocusNode();
|
|
|
|
FocusNode remarkF = FocusNode();
|
|
|
|
bool fixdate = true;
|
|
|
|
bool weekly = false;
|
|
|
|
bool birthday = false;
|
|
|
|
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
|
|
|
|
|
|
|
|
bool showDateSelWidget = false;
|
|
|
|
String fromDate = '点击设置开始日期'; //有效期开始时间
|
|
|
|
String endDate = '点击设置结束日期'; //有效期结束时间
|
|
|
|
|
|
|
|
List<FilterBtnModel> weekData = [];
|
|
|
|
|
|
|
|
String weekShow = '点击设置可用日期';
|
|
|
|
bool canUse = false;
|
|
|
|
List<String> coupons = [];
|
|
|
|
|
|
|
|
List<String> selectIDs = [];
|
|
|
|
|
|
|
|
bool givePriceSwich = false;
|
|
|
|
bool giveScoreSwich = false;
|
|
|
|
bool giveCouponsSwich = false;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
_initWeekData();
|
|
|
|
|
|
|
|
nameF.addListener(() {
|
|
|
|
if (nameF.hasFocus) {
|
|
|
|
//有焦点
|
|
|
|
if (showDateSelWidget) {
|
|
|
|
Navigator.pop(context);
|
|
|
|
showDateSelWidget = false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//失去焦点
|
|
|
|
// _editingController.text = '';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
priceminF.addListener(() {
|
|
|
|
if (priceminF.hasFocus) {
|
|
|
|
//有焦点
|
|
|
|
if (showDateSelWidget) {
|
|
|
|
Navigator.pop(context);
|
|
|
|
showDateSelWidget = false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//失去焦点
|
|
|
|
// _editingController.text = '';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
givePricF.addListener(() {
|
|
|
|
if (givePricF.hasFocus) {
|
|
|
|
//有焦点
|
|
|
|
if (showDateSelWidget) {
|
|
|
|
Navigator.pop(context);
|
|
|
|
showDateSelWidget = false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//失去焦点
|
|
|
|
// _editingController.text = '';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
giveScoreF.addListener(() {
|
|
|
|
if (giveScoreF.hasFocus) {
|
|
|
|
//有焦点
|
|
|
|
if (showDateSelWidget) {
|
|
|
|
Navigator.pop(context);
|
|
|
|
showDateSelWidget = false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//失去焦点
|
|
|
|
// _editingController.text = '';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
remarkF.addListener(() {
|
|
|
|
if (remarkF.hasFocus) {
|
|
|
|
//有焦点
|
|
|
|
if (showDateSelWidget) {
|
|
|
|
Navigator.pop(context);
|
|
|
|
showDateSelWidget = false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//失去焦点
|
|
|
|
// _editingController.text = '';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
_initWeekData() {
|
|
|
|
FilterBtnModel filterBtnModel = FilterBtnModel();
|
|
|
|
filterBtnModel.select = false;
|
|
|
|
filterBtnModel.title = '周日';
|
|
|
|
weekData.add(filterBtnModel);
|
|
|
|
for (int i = 1; i < 7; i++) {
|
|
|
|
FilterBtnModel filterBtnModel = FilterBtnModel();
|
|
|
|
filterBtnModel.select = false;
|
|
|
|
filterBtnModel.title = '周${Utils.formatWeekDayNum(i)}';
|
|
|
|
weekData.add(filterBtnModel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///输入框
|
|
|
|
Widget _text(
|
|
|
|
String title,
|
|
|
|
String hintText,
|
|
|
|
) {
|
|
|
|
return Container(
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
child: Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_515151,
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Spacer(),
|
|
|
|
Text(
|
|
|
|
hintText,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_999999,
|
|
|
|
fontSize: ScreenUtil().setSp(32),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
HEmptyView(32)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
///时间选择
|
|
|
|
Widget _select(String title, String hintText, GestureTapCallback onTap) {
|
|
|
|
return InkWell(
|
|
|
|
onTap: onTap,
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.only(left: ScreenUtil().setWidth(32)),
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
// height: ScreenUtil().setWidth(40),
|
|
|
|
// color: Colors.red,
|
|
|
|
child: Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(
|
|
|
|
color: title == '点击设置可用日期'
|
|
|
|
? MyColours.color_999999
|
|
|
|
: MyColours.color_515151,
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
HEmptyView(20),
|
|
|
|
Spacer(),
|
|
|
|
Text(hintText,
|
|
|
|
style: TextStyle(
|
|
|
|
color: hintText == '点击设置开始日期' || hintText == '点击设置结束日期'
|
|
|
|
? MyColours.color_999999
|
|
|
|
: MyColours.color_515151,
|
|
|
|
fontSize: ScreenUtil().setSp(32),
|
|
|
|
)),
|
|
|
|
HEmptyView(20),
|
|
|
|
Image.asset(
|
|
|
|
Utils.getImgPath('arrow_right_new'),
|
|
|
|
width: ScreenUtil().setWidth(18),
|
|
|
|
),
|
|
|
|
HEmptyView(32),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
///券说明
|
|
|
|
Widget _explain(String title, String hintText,
|
|
|
|
TextEditingController controller, FocusNode node) {
|
|
|
|
return Container(
|
|
|
|
// height: ScreenUtil().setWidth(380),
|
|
|
|
// padding: EdgeInsets.symmetric(vertical: ScreenUtil().setWidth(28)),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Align(
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Text(
|
|
|
|
title,
|
|
|
|
textAlign: TextAlign.left,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_515151,
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
)),
|
|
|
|
VEmptyView(26),
|
|
|
|
// Container(
|
|
|
|
// height: ScreenUtil().setWidth(2),
|
|
|
|
// color: MyColours.color_E7E7E7,
|
|
|
|
// ),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.only(left: w(20)),
|
|
|
|
child: Text(
|
|
|
|
'beihaisehfisehfasfhaise',
|
|
|
|
|
|
|
|
// maxLengthEnforced: true,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: ScreenUtil().setSp(32),
|
|
|
|
color: MyColours.color_999999), //输入文本的样式
|
|
|
|
)),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
_itemRadioWidget(bool select, String title, {GestureTapCallback onTap}) {
|
|
|
|
return InkWell(
|
|
|
|
onTap: onTap,
|
|
|
|
child: Row(children: [
|
|
|
|
Image.asset(
|
|
|
|
Utils.getImgPath(
|
|
|
|
select ? 'plan_dish_select' : 'plan_dish_unselect'),
|
|
|
|
width: w(20),
|
|
|
|
),
|
|
|
|
HEmptyView(6),
|
|
|
|
Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_515151,
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
),
|
|
|
|
]));
|
|
|
|
}
|
|
|
|
|
|
|
|
///是否立即启用
|
|
|
|
Widget _canUse(String title, bool swich, GestureTapCallback onTap) {
|
|
|
|
return InkWell(
|
|
|
|
onTap: onTap,
|
|
|
|
child: Container(
|
|
|
|
// padding: EdgeInsets.symmetric(vertical: ScreenUtil().setWidth(24)),
|
|
|
|
// margin: EdgeInsets.only(right: ScreenUtil().setWidth(32)),
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
// height: ScreenUtil().setWidth(40),
|
|
|
|
// color: Colors.red,
|
|
|
|
child: Text(
|
|
|
|
'是否启用',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_515151,
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Spacer(),
|
|
|
|
Container(
|
|
|
|
// height: ScreenUtil().setWidth(40),
|
|
|
|
// color: Colors.red,
|
|
|
|
child: Text(
|
|
|
|
'启用/禁用',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_999999,
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
HEmptyView(20)
|
|
|
|
// Image.asset(
|
|
|
|
// swich
|
|
|
|
// ? Utils.getImgPath('swich_on')
|
|
|
|
// : Utils.getImgPath('swich_off'),
|
|
|
|
// width: ScreenUtil().setWidth(44 * 2),
|
|
|
|
// )
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
key: scaffoldKey,
|
|
|
|
backgroundColor: MyColours.color_ffffff,
|
|
|
|
appBar: SystemAppBar('充值优惠详情'),
|
|
|
|
body: Column(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.only(left: w(32)),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
VEmptyView(24),
|
|
|
|
_text(
|
|
|
|
'活动名称',
|
|
|
|
'活动名称',
|
|
|
|
),
|
|
|
|
VEmptyView(24),
|
|
|
|
MyDivider(
|
|
|
|
double.infinity,
|
|
|
|
w(1),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
VEmptyView(24),
|
|
|
|
_text(
|
|
|
|
'充值满',
|
|
|
|
'充值金额门槛',
|
|
|
|
),
|
|
|
|
VEmptyView(24),
|
|
|
|
MyDivider(
|
|
|
|
double.infinity,
|
|
|
|
w(1),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
VEmptyView(24),
|
|
|
|
Container(
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Text(
|
|
|
|
'优惠活动',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_515151,
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
VEmptyView(26),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.only(left: w(20)),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
// mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
'赠送1000元余额',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_999999,
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
),
|
|
|
|
VEmptyView(20),
|
|
|
|
Text(
|
|
|
|
'赠送1000积分',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_999999,
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
),
|
|
|
|
VEmptyView(20),
|
|
|
|
Text(
|
|
|
|
'赠送优惠券',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_999999,
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
left: w(45),
|
|
|
|
right: w(8),
|
|
|
|
),
|
|
|
|
child: Wrap(
|
|
|
|
spacing: w(9),
|
|
|
|
runSpacing: w(9),
|
|
|
|
alignment: WrapAlignment.start,
|
|
|
|
runAlignment: WrapAlignment.start,
|
|
|
|
children: coupons.map((e) {
|
|
|
|
return Text(
|
|
|
|
e,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_999999,
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
);
|
|
|
|
}).toList())),
|
|
|
|
VEmptyView(20),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
MyDivider(
|
|
|
|
double.infinity,
|
|
|
|
w(1),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
VEmptyView(24),
|
|
|
|
Container(
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Text(
|
|
|
|
'有效期',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_515151,
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
VEmptyView(24),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.only(left: w(20)),
|
|
|
|
child: Text(
|
|
|
|
'2021.2.2-2022.3.4/周日、周一、周二/会员生日当天',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_999999,
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
)),
|
|
|
|
VEmptyView(24),
|
|
|
|
MyDivider(
|
|
|
|
double.infinity,
|
|
|
|
w(1),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
VEmptyView(24),
|
|
|
|
_explain('备注', '请输入备注信息', remarkC, remarkF),
|
|
|
|
VEmptyView(24),
|
|
|
|
_canUse('立即启用', canUse, () {
|
|
|
|
setState(() {
|
|
|
|
canUse = !canUse;
|
|
|
|
});
|
|
|
|
})
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
)),
|
|
|
|
// Container(
|
|
|
|
// height: ScreenUtil().setWidth(91 * 2),
|
|
|
|
// width: double.infinity,
|
|
|
|
// padding: EdgeInsets.only(
|
|
|
|
// top: ScreenUtil().setWidth(16 * 2),
|
|
|
|
// bottom: ScreenUtil().setWidth(35 * 2),
|
|
|
|
// left: ScreenUtil().setWidth(45 * 2),
|
|
|
|
// right: ScreenUtil().setWidth(45 * 2),
|
|
|
|
// ),
|
|
|
|
// decoration: BoxDecoration(
|
|
|
|
// color: MyColours.color_ffffff,
|
|
|
|
// boxShadow: [
|
|
|
|
// BoxShadow(
|
|
|
|
// spreadRadius: ScreenUtil().setWidth(2),
|
|
|
|
// color: Color.fromRGBO(0, 0, 0, 0.1),
|
|
|
|
// offset: Offset(0, ScreenUtil().setWidth(-2)),
|
|
|
|
// blurRadius: ScreenUtil().setWidth(8))
|
|
|
|
// ],
|
|
|
|
// borderRadius: BorderRadius.all(
|
|
|
|
// Radius.circular(ScreenUtil().setWidth(16)),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// child: RoundButton(
|
|
|
|
// text: '保存',
|
|
|
|
// height: ScreenUtil().setWidth(80),
|
|
|
|
// radius: ScreenUtil().setWidth(14),
|
|
|
|
// isBold: false,
|
|
|
|
// fontSize: 28,
|
|
|
|
// onPressed: () async {
|
|
|
|
// // "stime": fromDate == '点击选择'
|
|
|
|
// // ? ""
|
|
|
|
// // : '${DateUtil.getDateMsByTimeStr(fromDate) / 1000}',
|
|
|
|
// // "etime": endDate == '点击选择'
|
|
|
|
// // ? ''
|
|
|
|
// // : '${DateUtil.getDateMsByTimeStr(endDate) / 1000}',
|
|
|
|
// // UserModel userModel =
|
|
|
|
// // Provider.of<UserModel>(context, listen: false);
|
|
|
|
// // if (userModel.user.role_name == '管理员' ||
|
|
|
|
// // userModel.user.role_name == '店长') {
|
|
|
|
// // NavigatorUtil.goRechargeDetailPage(context);
|
|
|
|
// // } else {
|
|
|
|
// // bool needRefresh =
|
|
|
|
// // await NavigatorUtil.goCouponEditPage(context);
|
|
|
|
// // print(needRefresh);
|
|
|
|
// // if (needRefresh != null && needRefresh) {
|
|
|
|
// // bus.emit('refresh_coupon_list_f');
|
|
|
|
// // //刷新页面数据
|
|
|
|
// // // _controller.callRefresh();
|
|
|
|
// // // _couponNetworkData(tabController.index);
|
|
|
|
// // }
|
|
|
|
// // }
|
|
|
|
// },
|
|
|
|
// ),
|
|
|
|
// )
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|