|
|
|
import 'package:common_utils/common_utils.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
|
|
|
|
import 'package:flutter_picker_plus/picker.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:one_key/provider/finance_provider.dart';
|
|
|
|
import 'package:one_key/provider/user_model.dart';
|
|
|
|
import 'package:one_key/res/colors.dart';
|
|
|
|
import 'package:one_key/utils/dialog_util.dart';
|
|
|
|
import 'package:one_key/utils/screen_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';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 买单前送消费金 配置页
|
|
|
|
*/
|
|
|
|
class GiveMoneyBeforePayPage extends StatefulWidget {
|
|
|
|
const GiveMoneyBeforePayPage({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<GiveMoneyBeforePayPage> createState() => _GiveMoneyBeforePayPageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _GiveMoneyBeforePayPageState extends State<GiveMoneyBeforePayPage> {
|
|
|
|
String fromDateNew = '选择日期';
|
|
|
|
String endDateNew = '选择日期';
|
|
|
|
|
|
|
|
String fromDateOld = '选择日期';
|
|
|
|
String endDateOld = '选择日期';
|
|
|
|
|
|
|
|
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
|
|
|
|
|
|
|
|
FinanceProvider? financeProvider;
|
|
|
|
ScrollController controller = ScrollController();
|
|
|
|
|
|
|
|
bool isNew = false;
|
|
|
|
bool isOld = false;
|
|
|
|
bool isRandomNew = false; //是否按照随机金额 true 随机/false固定 新用户配置
|
|
|
|
bool isRandomOld = false; //是否按照随机金额 true 随机/false固定 老用户配置
|
|
|
|
|
|
|
|
TextEditingController fixCNew = TextEditingController(); //固定金额 新用户
|
|
|
|
FocusNode fixNodeNew = FocusNode(); //固定金额 新用户
|
|
|
|
|
|
|
|
TextEditingController fixCOld = TextEditingController(); //固定金额 老用户
|
|
|
|
FocusNode fixNodeOld = FocusNode(); // 固定金额 老用户
|
|
|
|
|
|
|
|
TextEditingController minCNew = TextEditingController(); //新用户配置
|
|
|
|
FocusNode minNodeNew = FocusNode(); //新用户配置
|
|
|
|
|
|
|
|
TextEditingController maxCNew = TextEditingController(); //新用户配置
|
|
|
|
FocusNode maxNodeNew = FocusNode(); //新用户配置
|
|
|
|
|
|
|
|
TextEditingController minC = TextEditingController(); //老用户配置
|
|
|
|
FocusNode minNode = FocusNode(); //老用户配置
|
|
|
|
|
|
|
|
TextEditingController maxC = TextEditingController(); //老用户配置
|
|
|
|
FocusNode maxNode = FocusNode(); //老用户配置
|
|
|
|
|
|
|
|
bool isCoexist = false; //消费金可与优惠券同时使用
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
// _getConsumeConfig();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// _getConsumeConfig() async {
|
|
|
|
// Map<String, String?> pramas = {
|
|
|
|
// 'sellerid':
|
|
|
|
// Provider.of<UserModel>(context, listen: false).user!.sellerid!,
|
|
|
|
// };
|
|
|
|
|
|
|
|
// await financeProvider!.getConsumeConfig(context, pramas);
|
|
|
|
// if (financeProvider!.returnMoneySunModel != null) {
|
|
|
|
// isOld =
|
|
|
|
// financeProvider!.returnMoneySunModel?.isReturn == '1' ? true : false;
|
|
|
|
// if (financeProvider!.returnMoneySunModel!.returnJson?.stime != null) {
|
|
|
|
// DateTime dateTimes = DateTime.fromMillisecondsSinceEpoch(int.parse(
|
|
|
|
// financeProvider!.returnMoneySunModel!.returnJson!.stime
|
|
|
|
// .toString()) *
|
|
|
|
// 1000);
|
|
|
|
// fromDateNew =
|
|
|
|
// DateUtil.formatDate(dateTimes, format: DateFormats.y_mo_d);
|
|
|
|
// }
|
|
|
|
// if (financeProvider!.returnMoneySunModel!.returnJson?.etime != null) {
|
|
|
|
// DateTime dateTimee = DateTime.fromMillisecondsSinceEpoch(int.parse(
|
|
|
|
// financeProvider!.returnMoneySunModel!.returnJson!.etime
|
|
|
|
// .toString()) *
|
|
|
|
// 1000);
|
|
|
|
// endDateNew =
|
|
|
|
// DateUtil.formatDate(dateTimee, format: DateFormats.y_mo_d);
|
|
|
|
// }
|
|
|
|
// isRandom = financeProvider!.returnMoneySunModel!.returnJson?.isRandom == '1'
|
|
|
|
// ? true
|
|
|
|
// : false;
|
|
|
|
// ratioC.text =
|
|
|
|
// financeProvider!.returnMoneySunModel!.returnJson?.ratioData ?? '';
|
|
|
|
// ladderSelectFree =
|
|
|
|
// financeProvider!.returnMoneySunModel!.returnJson?.ladderData ?? [];
|
|
|
|
|
|
|
|
// if (ladderSelectFree.length == 0) {
|
|
|
|
// LadderData ladderReturnMoneyModel = LadderData();
|
|
|
|
// ladderSelectFree.add(ladderReturnMoneyModel);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// isCoexist = financeProvider!.returnMoneySunModel!.isTogether == '1'
|
|
|
|
// ? true
|
|
|
|
// : false;
|
|
|
|
// proportionC.text =
|
|
|
|
// financeProvider!.returnMoneySunModel!.togetherJson?.ratioData ?? '';
|
|
|
|
|
|
|
|
// setState(() {});
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
//提交接口
|
|
|
|
// _setConsumeConfig() async {
|
|
|
|
// FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
// Map<String, String?> fullReductionData = {};
|
|
|
|
|
|
|
|
// if (isOld) {
|
|
|
|
// if (fromDateNew == '选择日期') {
|
|
|
|
// Utils.showToast('请选择活动的开始时间!');
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
// if (endDateNew == '选择日期') {
|
|
|
|
// Utils.showToast('请选择活动的结束时间!');
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (isRandom) {
|
|
|
|
// //按照比例返还
|
|
|
|
// //需要填写比例百分比
|
|
|
|
// if (ratioC.text.trim().length == 0) {
|
|
|
|
// Utils.showToast('请输入返还消费金占实际支付金额的百分比!');
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// fullReductionData['is_ratio'] = '1';
|
|
|
|
// fullReductionData['ratio_data'] = ratioC.text;
|
|
|
|
// } else {
|
|
|
|
// //按阶梯返还
|
|
|
|
// //没有数据时,提示新增阶梯设置数据
|
|
|
|
// if (ladderSelectFree.length == 0) {
|
|
|
|
// Utils.showToast('请点击增加阶梯设置数据!');
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// //判断阶梯里面的数据 实际支付金额是否输入
|
|
|
|
|
|
|
|
// bool canPrice =
|
|
|
|
// ladderSelectFree.any((e) => e.givePriceC.text.trim().length == 0);
|
|
|
|
// if (canPrice) {
|
|
|
|
// int index = ladderSelectFree
|
|
|
|
// .indexWhere((e) => e.givePriceC.text.trim().length == 0);
|
|
|
|
|
|
|
|
// Utils.showToast('请输入阶梯(${index + 1})的实际支付金额!');
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// //判断返回消费金额是否输入
|
|
|
|
|
|
|
|
// bool can =
|
|
|
|
// ladderSelectFree.any((e) => e.backPriceC.text.trim().length == 0);
|
|
|
|
// if (can) {
|
|
|
|
// int index = ladderSelectFree
|
|
|
|
// .indexWhere((e) => e.backPriceC.text.trim().length == 0);
|
|
|
|
|
|
|
|
// Utils.showToast('请输入阶梯(${index + 1})的返还消费金额!');
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// fullReductionData['is_ratio'] = '0'; //按阶梯
|
|
|
|
|
|
|
|
// List<Map<String, String>> ladderData = [];
|
|
|
|
// ladderSelectFree.forEach((e) {
|
|
|
|
// Map<String, String> price = {
|
|
|
|
// 'give_price': e.givePriceC.text,
|
|
|
|
// 'back_price': e.backPriceC.text,
|
|
|
|
// };
|
|
|
|
// ladderData.add(price);
|
|
|
|
// });
|
|
|
|
|
|
|
|
// fullReductionData['ladder_data'] =
|
|
|
|
// (ladderData.length == 0 ? null : jsonEncode(ladderData));
|
|
|
|
// }
|
|
|
|
|
|
|
|
// //设置数据
|
|
|
|
|
|
|
|
// if (fromDateNew != '选择日期') {
|
|
|
|
// String fromfull = fromDateNew + ' 00:00:00';
|
|
|
|
|
|
|
|
// String sfull =
|
|
|
|
// '${(DateUtil.getDateMsByTimeStr(fromfull)! / 1000).floor()}';
|
|
|
|
|
|
|
|
// fullReductionData['stime'] = sfull;
|
|
|
|
// }
|
|
|
|
// if (endDateNew != '选择日期') {
|
|
|
|
// String endfull = endDateNew + ' 23:59:59';
|
|
|
|
|
|
|
|
// String efull =
|
|
|
|
// '${(DateUtil.getDateMsByTimeStr(endfull)! / 1000).floor()}';
|
|
|
|
|
|
|
|
// fullReductionData['etime'] = efull;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// if (proportionC.text.trim().length == 0) {
|
|
|
|
// Utils.showToast('请输入消费金支付占实际消费金额的百分比!');
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// Map<String, String?> togetherJson = {};
|
|
|
|
// togetherJson['is_coexist'] = isCoexist ? '1' : '0';
|
|
|
|
// togetherJson['ratio_data'] = proportionC.text;
|
|
|
|
|
|
|
|
// Map<String, String?> pramas = {
|
|
|
|
// 'sellerid':
|
|
|
|
// Provider.of<UserModel>(context, listen: false).user!.sellerid!,
|
|
|
|
// 'is_return': isOld ? '1' : '0',
|
|
|
|
// 'return_json':
|
|
|
|
// fullReductionData.length == 0 ? null : jsonEncode(fullReductionData),
|
|
|
|
// 'is_together': isCoexist ? '1' : '0',
|
|
|
|
// 'together_json':
|
|
|
|
// togetherJson.length == 0 ? null : jsonEncode(togetherJson),
|
|
|
|
// };
|
|
|
|
// bool success = await financeProvider!.setConsumeConfig(context, pramas);
|
|
|
|
// if (success) {
|
|
|
|
// if (Navigator.canPop(context)) {
|
|
|
|
// Navigator.pop(context);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
///是否立即启用
|
|
|
|
Widget _canUse(
|
|
|
|
String title,
|
|
|
|
bool swich,
|
|
|
|
GestureTapCallback onTap,
|
|
|
|
) {
|
|
|
|
return InkWell(
|
|
|
|
onTap: onTap,
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.symmetric(vertical: ScreenUtil().setWidth(24)),
|
|
|
|
margin: EdgeInsets.only(left: ScreenUtil().setWidth(32)),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border(
|
|
|
|
bottom:
|
|
|
|
BorderSide(color: MyColours.color_E7E7E7, width: w(0.5)))),
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
// height: ScreenUtil().setWidth(40),
|
|
|
|
// color: Colors.red,
|
|
|
|
child: Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_515151, fontSize: font(16)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Spacer(),
|
|
|
|
Image.asset(
|
|
|
|
swich
|
|
|
|
? Utils.getImgPath('swich_on')
|
|
|
|
: Utils.getImgPath('swich_off'),
|
|
|
|
width: ScreenUtil().setWidth(44 * 2),
|
|
|
|
),
|
|
|
|
HEmptyView(32)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
//阶梯返还金额widget
|
|
|
|
Widget _randomWidget(
|
|
|
|
TextEditingController controllerGive,
|
|
|
|
FocusNode focusNodeGive,
|
|
|
|
TextEditingController controllerBack,
|
|
|
|
FocusNode focusNodeBack,
|
|
|
|
{num width = 40}) {
|
|
|
|
return Container(
|
|
|
|
height: w(40),
|
|
|
|
margin: EdgeInsets.only(left: w(width)),
|
|
|
|
padding: EdgeInsets.only(top: w(8), bottom: w(8)),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border(
|
|
|
|
bottom:
|
|
|
|
BorderSide(color: MyColours.color_E7E7E7, width: w(0.5)))),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
'最少',
|
|
|
|
style: TextStyle(color: MyColours.color_515151, fontSize: font(14)),
|
|
|
|
),
|
|
|
|
HEmptyView(10),
|
|
|
|
Container(
|
|
|
|
width: w(54),
|
|
|
|
height: w(26),
|
|
|
|
alignment: Alignment.center,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border.all(color: MyColours.color_999999, width: w(1))),
|
|
|
|
child: TextField(
|
|
|
|
controller: controllerGive,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
textAlignVertical: TextAlignVertical.center,
|
|
|
|
maxLines: 1,
|
|
|
|
// //光标颜色
|
|
|
|
// cursorColor:
|
|
|
|
// widget.isSelect ? Colors.white : MyColours.color_199095,
|
|
|
|
//输入文本的样式
|
|
|
|
inputFormatters: [
|
|
|
|
FilteringTextInputFormatter.allow(RegExp("[0-9.]")),
|
|
|
|
], // 限制输入为数字,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_515151,
|
|
|
|
fontSize: ScreenUtil().setSp(20),
|
|
|
|
),
|
|
|
|
focusNode: focusNodeGive,
|
|
|
|
decoration: InputDecoration(
|
|
|
|
isCollapsed: true,
|
|
|
|
border: OutlineInputBorder(borderSide: BorderSide.none),
|
|
|
|
hintText: '请输入数字',
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
color: MyColours.color_999999,
|
|
|
|
fontSize: ScreenUtil().setSp(20),
|
|
|
|
),
|
|
|
|
enabledBorder: new UnderlineInputBorder(
|
|
|
|
borderSide: BorderSide.none,
|
|
|
|
),
|
|
|
|
focusedBorder: new UnderlineInputBorder(
|
|
|
|
borderSide: BorderSide.none,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
onChanged: (value) {},
|
|
|
|
onEditingComplete: () {
|
|
|
|
FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
},
|
|
|
|
keyboardType: TextInputType.numberWithOptions()),
|
|
|
|
),
|
|
|
|
HEmptyView(10),
|
|
|
|
Text(
|
|
|
|
'元,最多',
|
|
|
|
style: TextStyle(color: MyColours.color_515151, fontSize: font(14)),
|
|
|
|
),
|
|
|
|
HEmptyView(10),
|
|
|
|
Container(
|
|
|
|
width: w(54),
|
|
|
|
height: w(26),
|
|
|
|
alignment: Alignment.center,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border.all(color: MyColours.color_999999, width: w(1))),
|
|
|
|
child: TextField(
|
|
|
|
controller: controllerBack,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
textAlignVertical: TextAlignVertical.center,
|
|
|
|
maxLines: 1,
|
|
|
|
// //光标颜色
|
|
|
|
// cursorColor:
|
|
|
|
// widget.isSelect ? Colors.white : MyColours.color_199095,
|
|
|
|
//输入文本的样式
|
|
|
|
inputFormatters: [
|
|
|
|
FilteringTextInputFormatter.allow(RegExp("[0-9.]")),
|
|
|
|
], // 限制输入为数字,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_515151,
|
|
|
|
fontSize: ScreenUtil().setSp(20),
|
|
|
|
),
|
|
|
|
focusNode: focusNodeBack,
|
|
|
|
decoration: InputDecoration(
|
|
|
|
isCollapsed: true,
|
|
|
|
border: OutlineInputBorder(borderSide: BorderSide.none),
|
|
|
|
hintText: '请输入数字',
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
color: MyColours.color_999999,
|
|
|
|
fontSize: ScreenUtil().setSp(20),
|
|
|
|
),
|
|
|
|
enabledBorder: new UnderlineInputBorder(
|
|
|
|
borderSide: BorderSide.none,
|
|
|
|
),
|
|
|
|
focusedBorder: new UnderlineInputBorder(
|
|
|
|
borderSide: BorderSide.none,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
onChanged: (value) {},
|
|
|
|
onEditingComplete: () {
|
|
|
|
FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
},
|
|
|
|
keyboardType: TextInputType.numberWithOptions()),
|
|
|
|
),
|
|
|
|
HEmptyView(10),
|
|
|
|
Text(
|
|
|
|
'元',
|
|
|
|
style: TextStyle(color: MyColours.color_515151, fontSize: font(14)),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _priceWidget(
|
|
|
|
String title, TextEditingController controller, FocusNode focusNode,
|
|
|
|
{num width = 40}) {
|
|
|
|
return Container(
|
|
|
|
height: w(40),
|
|
|
|
margin: EdgeInsets.only(left: w(width)),
|
|
|
|
padding: EdgeInsets.only(top: w(8), bottom: w(8), right: w(16)),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border(
|
|
|
|
bottom:
|
|
|
|
BorderSide(color: MyColours.color_E7E7E7, width: w(0.5)))),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(color: MyColours.color_515151, fontSize: font(14)),
|
|
|
|
),
|
|
|
|
HEmptyView(10),
|
|
|
|
Container(
|
|
|
|
width: w(70),
|
|
|
|
height: w(26),
|
|
|
|
alignment: Alignment.center,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border.all(color: MyColours.color_999999, width: w(1))),
|
|
|
|
child: TextField(
|
|
|
|
controller: controller,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
textAlignVertical: TextAlignVertical.center,
|
|
|
|
maxLines: 1,
|
|
|
|
// //光标颜色
|
|
|
|
// cursorColor:
|
|
|
|
// widget.isSelect ? Colors.white : MyColours.color_199095,
|
|
|
|
//输入文本的样式
|
|
|
|
inputFormatters: [
|
|
|
|
FilteringTextInputFormatter.allow(RegExp("[0-9.]")),
|
|
|
|
], // 限制输入为数字,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_515151,
|
|
|
|
fontSize: ScreenUtil().setSp(20),
|
|
|
|
),
|
|
|
|
focusNode: focusNode,
|
|
|
|
decoration: InputDecoration(
|
|
|
|
isCollapsed: true,
|
|
|
|
border: OutlineInputBorder(borderSide: BorderSide.none),
|
|
|
|
hintText: '请输入数字',
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
color: MyColours.color_999999,
|
|
|
|
fontSize: ScreenUtil().setSp(20),
|
|
|
|
),
|
|
|
|
enabledBorder: new UnderlineInputBorder(
|
|
|
|
borderSide: BorderSide.none,
|
|
|
|
),
|
|
|
|
focusedBorder: new UnderlineInputBorder(
|
|
|
|
borderSide: BorderSide.none,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
onChanged: (value) {},
|
|
|
|
onEditingComplete: () {
|
|
|
|
FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
},
|
|
|
|
keyboardType: TextInputType.numberWithOptions()),
|
|
|
|
),
|
|
|
|
HEmptyView(10),
|
|
|
|
Text(
|
|
|
|
'元',
|
|
|
|
style: TextStyle(color: MyColours.color_515151, fontSize: font(14)),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
///时间选择
|
|
|
|
Widget _select(String title, String hintText, GestureTapCallback onTap) {
|
|
|
|
return InkWell(
|
|
|
|
onTap: onTap,
|
|
|
|
child: Container(
|
|
|
|
height: w(40),
|
|
|
|
margin: EdgeInsets.only(left: w(40)),
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
top: w(8),
|
|
|
|
bottom: w(8),
|
|
|
|
),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border(
|
|
|
|
bottom:
|
|
|
|
BorderSide(color: MyColours.color_E7E7E7, width: w(0.5)))),
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
// height: ScreenUtil().setWidth(40),
|
|
|
|
// color: Colors.red,
|
|
|
|
child: Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_515151,
|
|
|
|
fontSize: ScreenUtil().setSp(28)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
HEmptyView(20),
|
|
|
|
Spacer(),
|
|
|
|
Text(hintText,
|
|
|
|
style: TextStyle(
|
|
|
|
color: hintText == '选择日期'
|
|
|
|
? MyColours.color_999999
|
|
|
|
: MyColours.color_515151,
|
|
|
|
fontSize: ScreenUtil().setSp(24),
|
|
|
|
)),
|
|
|
|
HEmptyView(20),
|
|
|
|
Image.asset(
|
|
|
|
Utils.getImgPath('arrow_right_new'),
|
|
|
|
width: ScreenUtil().setWidth(16),
|
|
|
|
),
|
|
|
|
HEmptyView(32),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
_radioWidget(String title, bool select, {GestureTapCallback? onTap}) {
|
|
|
|
return InkWell(
|
|
|
|
onTap: onTap,
|
|
|
|
child: Container(
|
|
|
|
height: w(40),
|
|
|
|
margin: EdgeInsets.only(left: w(40)),
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
top: w(8),
|
|
|
|
bottom: w(8),
|
|
|
|
),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border(
|
|
|
|
bottom:
|
|
|
|
BorderSide(color: MyColours.color_E7E7E7, width: w(0.5)))),
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Image.asset(
|
|
|
|
Utils.getImgPath(select ? 'radio_back' : 'radio_back_un'),
|
|
|
|
width: ScreenUtil().setWidth(18),
|
|
|
|
),
|
|
|
|
HEmptyView(4),
|
|
|
|
Container(
|
|
|
|
// height: ScreenUtil().setWidth(40),
|
|
|
|
// color: Colors.red,
|
|
|
|
child: Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_515151,
|
|
|
|
fontSize: ScreenUtil().setSp(28)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
financeProvider = Provider.of<FinanceProvider>(context, listen: true);
|
|
|
|
|
|
|
|
return KeyboardDismissOnTap(
|
|
|
|
child: Scaffold(
|
|
|
|
backgroundColor: MyColours.color_ffffff,
|
|
|
|
appBar: SystemAppBar('买单前送消费金'),
|
|
|
|
key: scaffoldKey,
|
|
|
|
body: Column(children: [
|
|
|
|
Expanded(
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
controller: controller,
|
|
|
|
child: Column(children: [
|
|
|
|
_canUse('新用户买单前送消费金', isNew, () {
|
|
|
|
setState(() {
|
|
|
|
isNew = !isNew;
|
|
|
|
});
|
|
|
|
}),
|
|
|
|
_select('活动开始于', fromDateNew, () {
|
|
|
|
FocusScope.of(context)
|
|
|
|
.requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
//弹出时间选择器
|
|
|
|
// showPickerDateTime(context);
|
|
|
|
// showDateSelWidget = true;
|
|
|
|
DialogUtil.showPickerDateTime24(
|
|
|
|
context,
|
|
|
|
scaffoldKey,
|
|
|
|
(value) {
|
|
|
|
// {'text': picker.adapter.text, 'select': selecteds}
|
|
|
|
if (value != null) {
|
|
|
|
if (endDateNew != '选择日期') {
|
|
|
|
if (DateUtil.getDateTime(endDateNew)
|
|
|
|
.compareTo(DateUtil.getDateTime(
|
|
|
|
DateUtil.formatDateStr(value,
|
|
|
|
format:
|
|
|
|
DateFormats.y_mo_d))) <
|
|
|
|
0) {
|
|
|
|
Utils.showToast('活动开始时间不能迟于活动结束时间');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
print(value);
|
|
|
|
fromDateNew = DateUtil.formatDateStr(value,
|
|
|
|
format: DateFormats.y_mo_d);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
// showDateSelWidget = false;
|
|
|
|
},
|
|
|
|
minValue: DateTime(1987, 1, 1),
|
|
|
|
dateTime: fromDateNew == '选择日期'
|
|
|
|
? null
|
|
|
|
: DateUtil.getDateTime(fromDateNew),
|
|
|
|
pickerDateTimeType: PickerDateTimeType.kYMD,
|
|
|
|
onCancel: () {
|
|
|
|
// showDateSelWidget = false;
|
|
|
|
});
|
|
|
|
}),
|
|
|
|
_select('活动结束于', endDateNew, () {
|
|
|
|
FocusScope.of(context)
|
|
|
|
.requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
//弹出时间选择器
|
|
|
|
// showPickerDateTime(context);
|
|
|
|
// showDateSelWidget = true;
|
|
|
|
DialogUtil.showPickerDateTime24(
|
|
|
|
context,
|
|
|
|
scaffoldKey,
|
|
|
|
(value) {
|
|
|
|
// {'text': picker.adapter.text, 'select': selecteds}
|
|
|
|
if (value != null) {
|
|
|
|
if (fromDateNew != '选择日期') {
|
|
|
|
if (DateUtil.getDateTime(
|
|
|
|
DateUtil.formatDateStr(value,
|
|
|
|
format: DateFormats.y_mo_d))
|
|
|
|
.compareTo(DateUtil.getDateTime(
|
|
|
|
fromDateNew)) <
|
|
|
|
0) {
|
|
|
|
Utils.showToast('活动结束时间不能早于活动开始时间');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setState(() {
|
|
|
|
print(value);
|
|
|
|
endDateNew = DateUtil.formatDateStr(value,
|
|
|
|
format: DateFormats.y_mo_d);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
// showDateSelWidget = false;
|
|
|
|
},
|
|
|
|
minValue: DateTime(1987, 1, 1),
|
|
|
|
dateTime: endDateNew == '选择日期'
|
|
|
|
? null
|
|
|
|
: DateUtil.getDateTime(endDateNew),
|
|
|
|
pickerDateTimeType: PickerDateTimeType.kYMD,
|
|
|
|
onCancel: () {
|
|
|
|
// showDateSelWidget = false;
|
|
|
|
});
|
|
|
|
}),
|
|
|
|
_radioWidget('固定金额', !isRandomNew, onTap: () {
|
|
|
|
if (isRandomNew) {
|
|
|
|
setState(() {
|
|
|
|
isRandomNew = !isRandomNew;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
if (!isRandomNew)
|
|
|
|
_priceWidget('送', fixCNew, fixNodeNew, width: 60),
|
|
|
|
_radioWidget('随机金额', isRandomNew, onTap: () {
|
|
|
|
if (!isRandomNew) {
|
|
|
|
setState(() {
|
|
|
|
isRandomNew = !isRandomNew;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
if (isRandomNew)
|
|
|
|
_randomWidget(
|
|
|
|
minCNew, minNodeNew, maxCNew, maxNodeNew),
|
|
|
|
VEmptyView(24),
|
|
|
|
_canUse('老用户买单前送消费金', isOld, () {
|
|
|
|
setState(() {
|
|
|
|
isOld = !isOld;
|
|
|
|
});
|
|
|
|
}),
|
|
|
|
_select('活动开始于', fromDateOld, () {
|
|
|
|
FocusScope.of(context)
|
|
|
|
.requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
//弹出时间选择器
|
|
|
|
// showPickerDateTime(context);
|
|
|
|
// showDateSelWidget = true;
|
|
|
|
DialogUtil.showPickerDateTime24(
|
|
|
|
context,
|
|
|
|
scaffoldKey,
|
|
|
|
(value) {
|
|
|
|
// {'text': picker.adapter.text, 'select': selecteds}
|
|
|
|
if (value != null) {
|
|
|
|
if (endDateOld != '选择日期') {
|
|
|
|
if (DateUtil.getDateTime(endDateOld)
|
|
|
|
.compareTo(DateUtil.getDateTime(
|
|
|
|
DateUtil.formatDateStr(value,
|
|
|
|
format:
|
|
|
|
DateFormats.y_mo_d))) <
|
|
|
|
0) {
|
|
|
|
Utils.showToast('活动开始时间不能迟于活动结束时间');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
print(value);
|
|
|
|
fromDateOld = DateUtil.formatDateStr(value,
|
|
|
|
format: DateFormats.y_mo_d);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
// showDateSelWidget = false;
|
|
|
|
},
|
|
|
|
minValue: DateTime(1987, 1, 1),
|
|
|
|
dateTime: fromDateOld == '选择日期'
|
|
|
|
? null
|
|
|
|
: DateUtil.getDateTime(fromDateOld),
|
|
|
|
pickerDateTimeType: PickerDateTimeType.kYMD,
|
|
|
|
onCancel: () {
|
|
|
|
// showDateSelWidget = false;
|
|
|
|
});
|
|
|
|
}),
|
|
|
|
_select('活动结束于', endDateOld, () {
|
|
|
|
FocusScope.of(context)
|
|
|
|
.requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
//弹出时间选择器
|
|
|
|
// showPickerDateTime(context);
|
|
|
|
// showDateSelWidget = true;
|
|
|
|
DialogUtil.showPickerDateTime24(
|
|
|
|
context,
|
|
|
|
scaffoldKey,
|
|
|
|
(value) {
|
|
|
|
// {'text': picker.adapter.text, 'select': selecteds}
|
|
|
|
if (value != null) {
|
|
|
|
if (fromDateOld != '选择日期') {
|
|
|
|
if (DateUtil.getDateTime(
|
|
|
|
DateUtil.formatDateStr(value,
|
|
|
|
format: DateFormats.y_mo_d))
|
|
|
|
.compareTo(DateUtil.getDateTime(
|
|
|
|
fromDateOld)) <
|
|
|
|
0) {
|
|
|
|
Utils.showToast('活动结束时间不能早于活动开始时间');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setState(() {
|
|
|
|
print(value);
|
|
|
|
endDateOld = DateUtil.formatDateStr(value,
|
|
|
|
format: DateFormats.y_mo_d);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
// showDateSelWidget = false;
|
|
|
|
},
|
|
|
|
minValue: DateTime(1987, 1, 1),
|
|
|
|
dateTime: endDateOld == '选择日期'
|
|
|
|
? null
|
|
|
|
: DateUtil.getDateTime(endDateOld),
|
|
|
|
pickerDateTimeType: PickerDateTimeType.kYMD,
|
|
|
|
onCancel: () {
|
|
|
|
// showDateSelWidget = false;
|
|
|
|
});
|
|
|
|
}),
|
|
|
|
_radioWidget('固定金额', !isRandomOld, onTap: () {
|
|
|
|
if (isRandomOld) {
|
|
|
|
setState(() {
|
|
|
|
isRandomOld = !isRandomOld;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
if (!isRandomOld)
|
|
|
|
_priceWidget('送', fixCOld, fixNodeOld, width: 60),
|
|
|
|
_radioWidget('随机金额', isRandomOld, onTap: () {
|
|
|
|
if (!isRandomOld) {
|
|
|
|
setState(() {
|
|
|
|
isRandomOld = !isRandomOld;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
if (isRandomOld)
|
|
|
|
_randomWidget(minC, minNode, maxC, maxNode),
|
|
|
|
]))),
|
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
top: w(13), left: w(45), right: w(45), bottom: w(26)),
|
|
|
|
child: RoundButton(
|
|
|
|
text: '立即提交',
|
|
|
|
height: w(43),
|
|
|
|
radius: r(5),
|
|
|
|
gradientStart: MyColours.color_438E93,
|
|
|
|
gradientEnd: MyColours.color_438E93,
|
|
|
|
borderColor: MyColours.color_438E93,
|
|
|
|
textColor: MyColours.color_ffffff,
|
|
|
|
isBold: true,
|
|
|
|
fontSize: 32,
|
|
|
|
onPressed: () {
|
|
|
|
// 调用接口
|
|
|
|
// _setConsumeConfig()
|
|
|
|
},
|
|
|
|
),
|
|
|
|
)
|
|
|
|
])));
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|