Commit ba728755379907ee985a5a1c58e2a359b9eeb59d

Authored by weixin_45529955
1 parent b4359594

买单前送消费金 UI OK

@@ -81,6 +81,10 @@ class _FinanceManageHomePageState extends State<FinanceManageHomePage> { @@ -81,6 +81,10 @@ class _FinanceManageHomePageState extends State<FinanceManageHomePage> {
81 NavigatorUtil.goReturnMoneyPage(context); 81 NavigatorUtil.goReturnMoneyPage(context);
82 }), 82 }),
83 83
  84 + _item('买单前送消费金', () {
  85 + NavigatorUtil.goGiveMoneyBeforePayPage(context);
  86 + }),
  87 +
84 _item('交易记录', () { 88 _item('交易记录', () {
85 NavigatorUtil.goTransactionRecordHomePage(context); 89 NavigatorUtil.goTransactionRecordHomePage(context);
86 }), 90 }),
  1 +import 'package:common_utils/common_utils.dart';
  2 +import 'package:flutter/material.dart';
  3 +import 'package:flutter/services.dart';
  4 +import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
  5 +import 'package:flutter_picker_plus/picker.dart';
  6 +import 'package:flutter_screenutil/flutter_screenutil.dart';
  7 +import 'package:one_key/provider/finance_provider.dart';
  8 +import 'package:one_key/provider/user_model.dart';
  9 +import 'package:one_key/res/colors.dart';
  10 +import 'package:one_key/utils/dialog_util.dart';
  11 +import 'package:one_key/utils/screen_util.dart';
  12 +import 'package:one_key/utils/utils.dart';
  13 +import 'package:one_key/widgets/h_empty_view.dart';
  14 +import 'package:one_key/widgets/round_button.dart';
  15 +import 'package:one_key/widgets/system_app_bar.dart';
  16 +import 'package:one_key/widgets/v_empty_view.dart';
  17 +import 'package:provider/provider.dart';
  18 +
  19 +/**
  20 + * 买单前送消费金 配置页
  21 + */
  22 +class GiveMoneyBeforePayPage extends StatefulWidget {
  23 + const GiveMoneyBeforePayPage({super.key});
  24 +
  25 + @override
  26 + State<GiveMoneyBeforePayPage> createState() => _GiveMoneyBeforePayPageState();
  27 +}
  28 +
  29 +class _GiveMoneyBeforePayPageState extends State<GiveMoneyBeforePayPage> {
  30 + String fromDateNew = '选择日期';
  31 + String endDateNew = '选择日期';
  32 +
  33 + String fromDateOld = '选择日期';
  34 + String endDateOld = '选择日期';
  35 +
  36 + final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
  37 +
  38 + FinanceProvider? financeProvider;
  39 + ScrollController controller = ScrollController();
  40 +
  41 + bool isNew = false;
  42 + bool isOld = false;
  43 + bool isRandomNew = false; //是否按照随机金额 true 随机/false固定 新用户配置
  44 + bool isRandomOld = false; //是否按照随机金额 true 随机/false固定 老用户配置
  45 +
  46 + TextEditingController fixCNew = TextEditingController(); //固定金额 新用户
  47 + FocusNode fixNodeNew = FocusNode(); //固定金额 新用户
  48 +
  49 + TextEditingController fixCOld = TextEditingController(); //固定金额 老用户
  50 + FocusNode fixNodeOld = FocusNode(); // 固定金额 老用户
  51 +
  52 + TextEditingController minCNew = TextEditingController(); //新用户配置
  53 + FocusNode minNodeNew = FocusNode(); //新用户配置
  54 +
  55 + TextEditingController maxCNew = TextEditingController(); //新用户配置
  56 + FocusNode maxNodeNew = FocusNode(); //新用户配置
  57 +
  58 + TextEditingController minC = TextEditingController(); //老用户配置
  59 + FocusNode minNode = FocusNode(); //老用户配置
  60 +
  61 + TextEditingController maxC = TextEditingController(); //老用户配置
  62 + FocusNode maxNode = FocusNode(); //老用户配置
  63 +
  64 + bool isCoexist = false; //消费金可与优惠券同时使用
  65 +
  66 + @override
  67 + void initState() {
  68 + super.initState();
  69 +
  70 + WidgetsBinding.instance.addPostFrameCallback((_) {
  71 + // _getConsumeConfig();
  72 + });
  73 + }
  74 +
  75 + // _getConsumeConfig() async {
  76 + // Map<String, String?> pramas = {
  77 + // 'sellerid':
  78 + // Provider.of<UserModel>(context, listen: false).user!.sellerid!,
  79 + // };
  80 +
  81 + // await financeProvider!.getConsumeConfig(context, pramas);
  82 + // if (financeProvider!.returnMoneySunModel != null) {
  83 + // isOld =
  84 + // financeProvider!.returnMoneySunModel?.isReturn == '1' ? true : false;
  85 + // if (financeProvider!.returnMoneySunModel!.returnJson?.stime != null) {
  86 + // DateTime dateTimes = DateTime.fromMillisecondsSinceEpoch(int.parse(
  87 + // financeProvider!.returnMoneySunModel!.returnJson!.stime
  88 + // .toString()) *
  89 + // 1000);
  90 + // fromDateNew =
  91 + // DateUtil.formatDate(dateTimes, format: DateFormats.y_mo_d);
  92 + // }
  93 + // if (financeProvider!.returnMoneySunModel!.returnJson?.etime != null) {
  94 + // DateTime dateTimee = DateTime.fromMillisecondsSinceEpoch(int.parse(
  95 + // financeProvider!.returnMoneySunModel!.returnJson!.etime
  96 + // .toString()) *
  97 + // 1000);
  98 + // endDateNew =
  99 + // DateUtil.formatDate(dateTimee, format: DateFormats.y_mo_d);
  100 + // }
  101 + // isRandom = financeProvider!.returnMoneySunModel!.returnJson?.isRandom == '1'
  102 + // ? true
  103 + // : false;
  104 + // ratioC.text =
  105 + // financeProvider!.returnMoneySunModel!.returnJson?.ratioData ?? '';
  106 + // ladderSelectFree =
  107 + // financeProvider!.returnMoneySunModel!.returnJson?.ladderData ?? [];
  108 +
  109 + // if (ladderSelectFree.length == 0) {
  110 + // LadderData ladderReturnMoneyModel = LadderData();
  111 + // ladderSelectFree.add(ladderReturnMoneyModel);
  112 + // }
  113 +
  114 + // isCoexist = financeProvider!.returnMoneySunModel!.isTogether == '1'
  115 + // ? true
  116 + // : false;
  117 + // proportionC.text =
  118 + // financeProvider!.returnMoneySunModel!.togetherJson?.ratioData ?? '';
  119 +
  120 + // setState(() {});
  121 + // }
  122 + // }
  123 +
  124 +//提交接口
  125 + // _setConsumeConfig() async {
  126 + // FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
  127 + // Map<String, String?> fullReductionData = {};
  128 +
  129 + // if (isOld) {
  130 + // if (fromDateNew == '选择日期') {
  131 + // Utils.showToast('请选择活动的开始时间!');
  132 + // return;
  133 + // }
  134 + // if (endDateNew == '选择日期') {
  135 + // Utils.showToast('请选择活动的结束时间!');
  136 + // return;
  137 + // }
  138 +
  139 + // if (isRandom) {
  140 + // //按照比例返还
  141 + // //需要填写比例百分比
  142 + // if (ratioC.text.trim().length == 0) {
  143 + // Utils.showToast('请输入返还消费金占实际支付金额的百分比!');
  144 + // return;
  145 + // }
  146 +
  147 + // fullReductionData['is_ratio'] = '1';
  148 + // fullReductionData['ratio_data'] = ratioC.text;
  149 + // } else {
  150 + // //按阶梯返还
  151 + // //没有数据时,提示新增阶梯设置数据
  152 + // if (ladderSelectFree.length == 0) {
  153 + // Utils.showToast('请点击增加阶梯设置数据!');
  154 + // return;
  155 + // }
  156 +
  157 + // //判断阶梯里面的数据 实际支付金额是否输入
  158 +
  159 + // bool canPrice =
  160 + // ladderSelectFree.any((e) => e.givePriceC.text.trim().length == 0);
  161 + // if (canPrice) {
  162 + // int index = ladderSelectFree
  163 + // .indexWhere((e) => e.givePriceC.text.trim().length == 0);
  164 +
  165 + // Utils.showToast('请输入阶梯(${index + 1})的实际支付金额!');
  166 + // return;
  167 + // }
  168 +
  169 + // //判断返回消费金额是否输入
  170 +
  171 + // bool can =
  172 + // ladderSelectFree.any((e) => e.backPriceC.text.trim().length == 0);
  173 + // if (can) {
  174 + // int index = ladderSelectFree
  175 + // .indexWhere((e) => e.backPriceC.text.trim().length == 0);
  176 +
  177 + // Utils.showToast('请输入阶梯(${index + 1})的返还消费金额!');
  178 + // return;
  179 + // }
  180 +
  181 + // fullReductionData['is_ratio'] = '0'; //按阶梯
  182 +
  183 + // List<Map<String, String>> ladderData = [];
  184 + // ladderSelectFree.forEach((e) {
  185 + // Map<String, String> price = {
  186 + // 'give_price': e.givePriceC.text,
  187 + // 'back_price': e.backPriceC.text,
  188 + // };
  189 + // ladderData.add(price);
  190 + // });
  191 +
  192 + // fullReductionData['ladder_data'] =
  193 + // (ladderData.length == 0 ? null : jsonEncode(ladderData));
  194 + // }
  195 +
  196 + // //设置数据
  197 +
  198 + // if (fromDateNew != '选择日期') {
  199 + // String fromfull = fromDateNew + ' 00:00:00';
  200 +
  201 + // String sfull =
  202 + // '${(DateUtil.getDateMsByTimeStr(fromfull)! / 1000).floor()}';
  203 +
  204 + // fullReductionData['stime'] = sfull;
  205 + // }
  206 + // if (endDateNew != '选择日期') {
  207 + // String endfull = endDateNew + ' 23:59:59';
  208 +
  209 + // String efull =
  210 + // '${(DateUtil.getDateMsByTimeStr(endfull)! / 1000).floor()}';
  211 +
  212 + // fullReductionData['etime'] = efull;
  213 + // }
  214 + // }
  215 + // if (proportionC.text.trim().length == 0) {
  216 + // Utils.showToast('请输入消费金支付占实际消费金额的百分比!');
  217 + // return;
  218 + // }
  219 +
  220 + // Map<String, String?> togetherJson = {};
  221 + // togetherJson['is_coexist'] = isCoexist ? '1' : '0';
  222 + // togetherJson['ratio_data'] = proportionC.text;
  223 +
  224 + // Map<String, String?> pramas = {
  225 + // 'sellerid':
  226 + // Provider.of<UserModel>(context, listen: false).user!.sellerid!,
  227 + // 'is_return': isOld ? '1' : '0',
  228 + // 'return_json':
  229 + // fullReductionData.length == 0 ? null : jsonEncode(fullReductionData),
  230 + // 'is_together': isCoexist ? '1' : '0',
  231 + // 'together_json':
  232 + // togetherJson.length == 0 ? null : jsonEncode(togetherJson),
  233 + // };
  234 + // bool success = await financeProvider!.setConsumeConfig(context, pramas);
  235 + // if (success) {
  236 + // if (Navigator.canPop(context)) {
  237 + // Navigator.pop(context);
  238 + // }
  239 + // }
  240 + // }
  241 +
  242 + ///是否立即启用
  243 + Widget _canUse(
  244 + String title,
  245 + bool swich,
  246 + GestureTapCallback onTap,
  247 + ) {
  248 + return InkWell(
  249 + onTap: onTap,
  250 + child: Container(
  251 + padding: EdgeInsets.symmetric(vertical: ScreenUtil().setWidth(24)),
  252 + margin: EdgeInsets.only(left: ScreenUtil().setWidth(32)),
  253 + decoration: BoxDecoration(
  254 + border: Border(
  255 + bottom:
  256 + BorderSide(color: MyColours.color_E7E7E7, width: w(0.5)))),
  257 + child: Row(
  258 + crossAxisAlignment: CrossAxisAlignment.center,
  259 + mainAxisAlignment: MainAxisAlignment.center,
  260 + children: [
  261 + Container(
  262 + // height: ScreenUtil().setWidth(40),
  263 + // color: Colors.red,
  264 + child: Text(
  265 + title,
  266 + style: TextStyle(
  267 + color: MyColours.color_515151, fontSize: font(16)),
  268 + ),
  269 + ),
  270 + Spacer(),
  271 + Image.asset(
  272 + swich
  273 + ? Utils.getImgPath('swich_on')
  274 + : Utils.getImgPath('swich_off'),
  275 + width: ScreenUtil().setWidth(44 * 2),
  276 + ),
  277 + HEmptyView(32)
  278 + ],
  279 + ),
  280 + ),
  281 + );
  282 + }
  283 +
  284 +//阶梯返还金额widget
  285 + Widget _randomWidget(
  286 + TextEditingController controllerGive,
  287 + FocusNode focusNodeGive,
  288 + TextEditingController controllerBack,
  289 + FocusNode focusNodeBack,
  290 + {num width = 40}) {
  291 + return Container(
  292 + height: w(40),
  293 + margin: EdgeInsets.only(left: w(width)),
  294 + padding: EdgeInsets.only(top: w(8), bottom: w(8)),
  295 + decoration: BoxDecoration(
  296 + border: Border(
  297 + bottom:
  298 + BorderSide(color: MyColours.color_E7E7E7, width: w(0.5)))),
  299 + child: Row(
  300 + children: [
  301 + Text(
  302 + '最少',
  303 + style: TextStyle(color: MyColours.color_515151, fontSize: font(14)),
  304 + ),
  305 + HEmptyView(10),
  306 + Container(
  307 + width: w(54),
  308 + height: w(26),
  309 + alignment: Alignment.center,
  310 + decoration: BoxDecoration(
  311 + border: Border.all(color: MyColours.color_999999, width: w(1))),
  312 + child: TextField(
  313 + controller: controllerGive,
  314 + textAlign: TextAlign.center,
  315 + textAlignVertical: TextAlignVertical.center,
  316 + maxLines: 1,
  317 + // //光标颜色
  318 + // cursorColor:
  319 + // widget.isSelect ? Colors.white : MyColours.color_199095,
  320 + //输入文本的样式
  321 + inputFormatters: [
  322 + FilteringTextInputFormatter.allow(RegExp("[0-9.]")),
  323 + ], // 限制输入为数字,
  324 + style: TextStyle(
  325 + color: MyColours.color_515151,
  326 + fontSize: ScreenUtil().setSp(20),
  327 + ),
  328 + focusNode: focusNodeGive,
  329 + decoration: InputDecoration(
  330 + isCollapsed: true,
  331 + border: OutlineInputBorder(borderSide: BorderSide.none),
  332 + hintText: '请输入数字',
  333 + hintStyle: TextStyle(
  334 + color: MyColours.color_999999,
  335 + fontSize: ScreenUtil().setSp(20),
  336 + ),
  337 + enabledBorder: new UnderlineInputBorder(
  338 + borderSide: BorderSide.none,
  339 + ),
  340 + focusedBorder: new UnderlineInputBorder(
  341 + borderSide: BorderSide.none,
  342 + ),
  343 + ),
  344 + onChanged: (value) {},
  345 + onEditingComplete: () {
  346 + FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
  347 + },
  348 + keyboardType: TextInputType.numberWithOptions()),
  349 + ),
  350 + HEmptyView(10),
  351 + Text(
  352 + '元,最多',
  353 + style: TextStyle(color: MyColours.color_515151, fontSize: font(14)),
  354 + ),
  355 + HEmptyView(10),
  356 + Container(
  357 + width: w(54),
  358 + height: w(26),
  359 + alignment: Alignment.center,
  360 + decoration: BoxDecoration(
  361 + border: Border.all(color: MyColours.color_999999, width: w(1))),
  362 + child: TextField(
  363 + controller: controllerBack,
  364 + textAlign: TextAlign.center,
  365 + textAlignVertical: TextAlignVertical.center,
  366 + maxLines: 1,
  367 + // //光标颜色
  368 + // cursorColor:
  369 + // widget.isSelect ? Colors.white : MyColours.color_199095,
  370 + //输入文本的样式
  371 + inputFormatters: [
  372 + FilteringTextInputFormatter.allow(RegExp("[0-9.]")),
  373 + ], // 限制输入为数字,
  374 + style: TextStyle(
  375 + color: MyColours.color_515151,
  376 + fontSize: ScreenUtil().setSp(20),
  377 + ),
  378 + focusNode: focusNodeBack,
  379 + decoration: InputDecoration(
  380 + isCollapsed: true,
  381 + border: OutlineInputBorder(borderSide: BorderSide.none),
  382 + hintText: '请输入数字',
  383 + hintStyle: TextStyle(
  384 + color: MyColours.color_999999,
  385 + fontSize: ScreenUtil().setSp(20),
  386 + ),
  387 + enabledBorder: new UnderlineInputBorder(
  388 + borderSide: BorderSide.none,
  389 + ),
  390 + focusedBorder: new UnderlineInputBorder(
  391 + borderSide: BorderSide.none,
  392 + ),
  393 + ),
  394 + onChanged: (value) {},
  395 + onEditingComplete: () {
  396 + FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
  397 + },
  398 + keyboardType: TextInputType.numberWithOptions()),
  399 + ),
  400 + HEmptyView(10),
  401 + Text(
  402 + '元',
  403 + style: TextStyle(color: MyColours.color_515151, fontSize: font(14)),
  404 + ),
  405 + ],
  406 + ),
  407 + );
  408 + }
  409 +
  410 + Widget _priceWidget(
  411 + String title, TextEditingController controller, FocusNode focusNode,
  412 + {num width = 40}) {
  413 + return Container(
  414 + height: w(40),
  415 + margin: EdgeInsets.only(left: w(width)),
  416 + padding: EdgeInsets.only(top: w(8), bottom: w(8), right: w(16)),
  417 + decoration: BoxDecoration(
  418 + border: Border(
  419 + bottom:
  420 + BorderSide(color: MyColours.color_E7E7E7, width: w(0.5)))),
  421 + child: Row(
  422 + children: [
  423 + Text(
  424 + title,
  425 + style: TextStyle(color: MyColours.color_515151, fontSize: font(14)),
  426 + ),
  427 + HEmptyView(10),
  428 + Container(
  429 + width: w(70),
  430 + height: w(26),
  431 + alignment: Alignment.center,
  432 + decoration: BoxDecoration(
  433 + border: Border.all(color: MyColours.color_999999, width: w(1))),
  434 + child: TextField(
  435 + controller: controller,
  436 + textAlign: TextAlign.center,
  437 + textAlignVertical: TextAlignVertical.center,
  438 + maxLines: 1,
  439 + // //光标颜色
  440 + // cursorColor:
  441 + // widget.isSelect ? Colors.white : MyColours.color_199095,
  442 + //输入文本的样式
  443 + inputFormatters: [
  444 + FilteringTextInputFormatter.allow(RegExp("[0-9.]")),
  445 + ], // 限制输入为数字,
  446 + style: TextStyle(
  447 + color: MyColours.color_515151,
  448 + fontSize: ScreenUtil().setSp(20),
  449 + ),
  450 + focusNode: focusNode,
  451 + decoration: InputDecoration(
  452 + isCollapsed: true,
  453 + border: OutlineInputBorder(borderSide: BorderSide.none),
  454 + hintText: '请输入数字',
  455 + hintStyle: TextStyle(
  456 + color: MyColours.color_999999,
  457 + fontSize: ScreenUtil().setSp(20),
  458 + ),
  459 + enabledBorder: new UnderlineInputBorder(
  460 + borderSide: BorderSide.none,
  461 + ),
  462 + focusedBorder: new UnderlineInputBorder(
  463 + borderSide: BorderSide.none,
  464 + ),
  465 + ),
  466 + onChanged: (value) {},
  467 + onEditingComplete: () {
  468 + FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
  469 + },
  470 + keyboardType: TextInputType.numberWithOptions()),
  471 + ),
  472 + HEmptyView(10),
  473 + Text(
  474 + '元',
  475 + style: TextStyle(color: MyColours.color_515151, fontSize: font(14)),
  476 + ),
  477 + ],
  478 + ),
  479 + );
  480 + }
  481 +
  482 + ///时间选择
  483 + Widget _select(String title, String hintText, GestureTapCallback onTap) {
  484 + return InkWell(
  485 + onTap: onTap,
  486 + child: Container(
  487 + height: w(40),
  488 + margin: EdgeInsets.only(left: w(40)),
  489 + padding: EdgeInsets.only(
  490 + top: w(8),
  491 + bottom: w(8),
  492 + ),
  493 + decoration: BoxDecoration(
  494 + border: Border(
  495 + bottom:
  496 + BorderSide(color: MyColours.color_E7E7E7, width: w(0.5)))),
  497 + child: Row(
  498 + crossAxisAlignment: CrossAxisAlignment.center,
  499 + mainAxisAlignment: MainAxisAlignment.center,
  500 + children: [
  501 + Container(
  502 + // height: ScreenUtil().setWidth(40),
  503 + // color: Colors.red,
  504 + child: Text(
  505 + title,
  506 + style: TextStyle(
  507 + color: MyColours.color_515151,
  508 + fontSize: ScreenUtil().setSp(28)),
  509 + ),
  510 + ),
  511 + HEmptyView(20),
  512 + Spacer(),
  513 + Text(hintText,
  514 + style: TextStyle(
  515 + color: hintText == '选择日期'
  516 + ? MyColours.color_999999
  517 + : MyColours.color_515151,
  518 + fontSize: ScreenUtil().setSp(24),
  519 + )),
  520 + HEmptyView(20),
  521 + Image.asset(
  522 + Utils.getImgPath('arrow_right_new'),
  523 + width: ScreenUtil().setWidth(16),
  524 + ),
  525 + HEmptyView(32),
  526 + ],
  527 + ),
  528 + ),
  529 + );
  530 + }
  531 +
  532 + _radioWidget(String title, bool select, {GestureTapCallback? onTap}) {
  533 + return InkWell(
  534 + onTap: onTap,
  535 + child: Container(
  536 + height: w(40),
  537 + margin: EdgeInsets.only(left: w(40)),
  538 + padding: EdgeInsets.only(
  539 + top: w(8),
  540 + bottom: w(8),
  541 + ),
  542 + decoration: BoxDecoration(
  543 + border: Border(
  544 + bottom:
  545 + BorderSide(color: MyColours.color_E7E7E7, width: w(0.5)))),
  546 + child: Row(
  547 + crossAxisAlignment: CrossAxisAlignment.center,
  548 + mainAxisAlignment: MainAxisAlignment.start,
  549 + children: [
  550 + Image.asset(
  551 + Utils.getImgPath(select ? 'radio_back' : 'radio_back_un'),
  552 + width: ScreenUtil().setWidth(18),
  553 + ),
  554 + HEmptyView(4),
  555 + Container(
  556 + // height: ScreenUtil().setWidth(40),
  557 + // color: Colors.red,
  558 + child: Text(
  559 + title,
  560 + style: TextStyle(
  561 + color: MyColours.color_515151,
  562 + fontSize: ScreenUtil().setSp(28)),
  563 + ),
  564 + ),
  565 + ],
  566 + ),
  567 + ),
  568 + );
  569 + }
  570 +
  571 + @override
  572 + Widget build(BuildContext context) {
  573 + financeProvider = Provider.of<FinanceProvider>(context, listen: true);
  574 +
  575 + return KeyboardDismissOnTap(
  576 + child: Scaffold(
  577 + backgroundColor: MyColours.color_ffffff,
  578 + appBar: SystemAppBar('买单前送消费金'),
  579 + key: scaffoldKey,
  580 + body: Column(children: [
  581 + Expanded(
  582 + child: SingleChildScrollView(
  583 + controller: controller,
  584 + child: Column(children: [
  585 + _canUse('新用户买单前送消费金', isNew, () {
  586 + setState(() {
  587 + isNew = !isNew;
  588 + });
  589 + }),
  590 + _select('活动开始于', fromDateNew, () {
  591 + FocusScope.of(context)
  592 + .requestFocus(FocusNode()); //点击空白处隐藏键盘
  593 + //弹出时间选择器
  594 + // showPickerDateTime(context);
  595 + // showDateSelWidget = true;
  596 + DialogUtil.showPickerDateTime24(
  597 + context,
  598 + scaffoldKey,
  599 + (value) {
  600 + // {'text': picker.adapter.text, 'select': selecteds}
  601 + if (value != null) {
  602 + if (endDateNew != '选择日期') {
  603 + if (DateUtil.getDateTime(endDateNew)
  604 + .compareTo(DateUtil.getDateTime(
  605 + DateUtil.formatDateStr(value,
  606 + format:
  607 + DateFormats.y_mo_d))) <
  608 + 0) {
  609 + Utils.showToast('活动开始时间不能迟于活动结束时间');
  610 + return;
  611 + }
  612 + }
  613 +
  614 + setState(() {
  615 + print(value);
  616 + fromDateNew = DateUtil.formatDateStr(value,
  617 + format: DateFormats.y_mo_d);
  618 + });
  619 + }
  620 + // showDateSelWidget = false;
  621 + },
  622 + minValue: DateTime(1987, 1, 1),
  623 + dateTime: fromDateNew == '选择日期'
  624 + ? null
  625 + : DateUtil.getDateTime(fromDateNew),
  626 + pickerDateTimeType: PickerDateTimeType.kYMD,
  627 + onCancel: () {
  628 + // showDateSelWidget = false;
  629 + });
  630 + }),
  631 + _select('活动结束于', endDateNew, () {
  632 + FocusScope.of(context)
  633 + .requestFocus(FocusNode()); //点击空白处隐藏键盘
  634 + //弹出时间选择器
  635 + // showPickerDateTime(context);
  636 + // showDateSelWidget = true;
  637 + DialogUtil.showPickerDateTime24(
  638 + context,
  639 + scaffoldKey,
  640 + (value) {
  641 + // {'text': picker.adapter.text, 'select': selecteds}
  642 + if (value != null) {
  643 + if (fromDateNew != '选择日期') {
  644 + if (DateUtil.getDateTime(
  645 + DateUtil.formatDateStr(value,
  646 + format: DateFormats.y_mo_d))
  647 + .compareTo(DateUtil.getDateTime(
  648 + fromDateNew)) <
  649 + 0) {
  650 + Utils.showToast('活动结束时间不能早于活动开始时间');
  651 + return;
  652 + }
  653 + }
  654 + setState(() {
  655 + print(value);
  656 + endDateNew = DateUtil.formatDateStr(value,
  657 + format: DateFormats.y_mo_d);
  658 + });
  659 + }
  660 + // showDateSelWidget = false;
  661 + },
  662 + minValue: DateTime(1987, 1, 1),
  663 + dateTime: endDateNew == '选择日期'
  664 + ? null
  665 + : DateUtil.getDateTime(endDateNew),
  666 + pickerDateTimeType: PickerDateTimeType.kYMD,
  667 + onCancel: () {
  668 + // showDateSelWidget = false;
  669 + });
  670 + }),
  671 + _radioWidget('固定金额', !isRandomNew, onTap: () {
  672 + if (isRandomNew) {
  673 + setState(() {
  674 + isRandomNew = !isRandomNew;
  675 + });
  676 + }
  677 + }),
  678 + if (!isRandomNew)
  679 + _priceWidget('送', fixCNew, fixNodeNew, width: 60),
  680 + _radioWidget('随机金额', isRandomNew, onTap: () {
  681 + if (!isRandomNew) {
  682 + setState(() {
  683 + isRandomNew = !isRandomNew;
  684 + });
  685 + }
  686 + }),
  687 + if (isRandomNew)
  688 + _randomWidget(
  689 + minCNew, minNodeNew, maxCNew, maxNodeNew),
  690 + VEmptyView(24),
  691 + _canUse('老用户买单前送消费金', isOld, () {
  692 + setState(() {
  693 + isOld = !isOld;
  694 + });
  695 + }),
  696 + _select('活动开始于', fromDateOld, () {
  697 + FocusScope.of(context)
  698 + .requestFocus(FocusNode()); //点击空白处隐藏键盘
  699 + //弹出时间选择器
  700 + // showPickerDateTime(context);
  701 + // showDateSelWidget = true;
  702 + DialogUtil.showPickerDateTime24(
  703 + context,
  704 + scaffoldKey,
  705 + (value) {
  706 + // {'text': picker.adapter.text, 'select': selecteds}
  707 + if (value != null) {
  708 + if (endDateOld != '选择日期') {
  709 + if (DateUtil.getDateTime(endDateOld)
  710 + .compareTo(DateUtil.getDateTime(
  711 + DateUtil.formatDateStr(value,
  712 + format:
  713 + DateFormats.y_mo_d))) <
  714 + 0) {
  715 + Utils.showToast('活动开始时间不能迟于活动结束时间');
  716 + return;
  717 + }
  718 + }
  719 +
  720 + setState(() {
  721 + print(value);
  722 + fromDateOld = DateUtil.formatDateStr(value,
  723 + format: DateFormats.y_mo_d);
  724 + });
  725 + }
  726 + // showDateSelWidget = false;
  727 + },
  728 + minValue: DateTime(1987, 1, 1),
  729 + dateTime: fromDateOld == '选择日期'
  730 + ? null
  731 + : DateUtil.getDateTime(fromDateOld),
  732 + pickerDateTimeType: PickerDateTimeType.kYMD,
  733 + onCancel: () {
  734 + // showDateSelWidget = false;
  735 + });
  736 + }),
  737 + _select('活动结束于', endDateOld, () {
  738 + FocusScope.of(context)
  739 + .requestFocus(FocusNode()); //点击空白处隐藏键盘
  740 + //弹出时间选择器
  741 + // showPickerDateTime(context);
  742 + // showDateSelWidget = true;
  743 + DialogUtil.showPickerDateTime24(
  744 + context,
  745 + scaffoldKey,
  746 + (value) {
  747 + // {'text': picker.adapter.text, 'select': selecteds}
  748 + if (value != null) {
  749 + if (fromDateOld != '选择日期') {
  750 + if (DateUtil.getDateTime(
  751 + DateUtil.formatDateStr(value,
  752 + format: DateFormats.y_mo_d))
  753 + .compareTo(DateUtil.getDateTime(
  754 + fromDateOld)) <
  755 + 0) {
  756 + Utils.showToast('活动结束时间不能早于活动开始时间');
  757 + return;
  758 + }
  759 + }
  760 + setState(() {
  761 + print(value);
  762 + endDateOld = DateUtil.formatDateStr(value,
  763 + format: DateFormats.y_mo_d);
  764 + });
  765 + }
  766 + // showDateSelWidget = false;
  767 + },
  768 + minValue: DateTime(1987, 1, 1),
  769 + dateTime: endDateOld == '选择日期'
  770 + ? null
  771 + : DateUtil.getDateTime(endDateOld),
  772 + pickerDateTimeType: PickerDateTimeType.kYMD,
  773 + onCancel: () {
  774 + // showDateSelWidget = false;
  775 + });
  776 + }),
  777 + _radioWidget('固定金额', !isRandomOld, onTap: () {
  778 + if (isRandomOld) {
  779 + setState(() {
  780 + isRandomOld = !isRandomOld;
  781 + });
  782 + }
  783 + }),
  784 + if (!isRandomOld)
  785 + _priceWidget('送', fixCOld, fixNodeOld, width: 60),
  786 + _radioWidget('随机金额', isRandomOld, onTap: () {
  787 + if (!isRandomOld) {
  788 + setState(() {
  789 + isRandomOld = !isRandomOld;
  790 + });
  791 + }
  792 + }),
  793 + if (isRandomOld)
  794 + _randomWidget(minC, minNode, maxC, maxNode),
  795 + ]))),
  796 + Container(
  797 + padding: EdgeInsets.only(
  798 + top: w(13), left: w(45), right: w(45), bottom: w(26)),
  799 + child: RoundButton(
  800 + text: '立即提交',
  801 + height: w(43),
  802 + radius: r(5),
  803 + gradientStart: MyColours.color_438E93,
  804 + gradientEnd: MyColours.color_438E93,
  805 + borderColor: MyColours.color_438E93,
  806 + textColor: MyColours.color_ffffff,
  807 + isBold: true,
  808 + fontSize: 32,
  809 + onPressed: () {
  810 + // 调用接口
  811 + // _setConsumeConfig()
  812 + },
  813 + ),
  814 + )
  815 + ])));
  816 + }
  817 +}
@@ -2480,6 +2480,18 @@ class NavigatorUtil { @@ -2480,6 +2480,18 @@ class NavigatorUtil {
2480 replace: replace); 2480 replace: replace);
2481 } 2481 }
2482 2482
  2483 +
  2484 +
  2485 +
  2486 + ///买单前送消费金
  2487 + static Future<dynamic> goGiveMoneyBeforePayPage(
  2488 + BuildContext context, {
  2489 + replace = false,
  2490 + }) {
  2491 + return _navigateTo(context, "${Routes.give_money_before_pay_page}",
  2492 + replace: replace);
  2493 + }
  2494 +
2483 static Future<dynamic> goSetBirthdayPage( 2495 static Future<dynamic> goSetBirthdayPage(
2484 BuildContext context, String? gid, String? lunar, String? solar, 2496 BuildContext context, String? gid, String? lunar, String? solar,
2485 {replace = false, String from = 'store'}) { 2497 {replace = false, String from = 'store'}) {
@@ -88,6 +88,7 @@ import 'package:one_key/pages/my/feast_manage/feast_deposit_manage_page.dart'; @@ -88,6 +88,7 @@ import 'package:one_key/pages/my/feast_manage/feast_deposit_manage_page.dart';
88 import 'package:one_key/pages/my/feast_manage/feast_personal_page.dart'; 88 import 'package:one_key/pages/my/feast_manage/feast_personal_page.dart';
89 import 'package:one_key/pages/my/feast_manage/feast_setmeal_manage_page.dart'; 89 import 'package:one_key/pages/my/feast_manage/feast_setmeal_manage_page.dart';
90 import 'package:one_key/pages/my/finance_manage/deposit_record_detail_page.dart'; 90 import 'package:one_key/pages/my/finance_manage/deposit_record_detail_page.dart';
  91 +import 'package:one_key/pages/my/finance_manage/give_money_before_pay_page.dart';
91 import 'package:one_key/pages/my/finance_manage/record_home_classify_home_page.dart'; 92 import 'package:one_key/pages/my/finance_manage/record_home_classify_home_page.dart';
92 import 'package:one_key/pages/my/finance_manage/vip_record_detail_page.dart'; 93 import 'package:one_key/pages/my/finance_manage/vip_record_detail_page.dart';
93 import 'package:one_key/pages/my/marketing_center/book_notification/marking_interaction_page.dart'; 94 import 'package:one_key/pages/my/marketing_center/book_notification/marking_interaction_page.dart';
@@ -4328,6 +4329,21 @@ var grantPageHandle = new Handler( @@ -4328,6 +4329,21 @@ var grantPageHandle = new Handler(
4328 create: (_) => FinanceProvider(), child: GrantPage()); 4329 create: (_) => FinanceProvider(), child: GrantPage());
4329 }); 4330 });
4330 4331
  4332 +
  4333 +
  4334 +
  4335 +
  4336 +///买单前送消费金
  4337 +var giveMoneyBeforePayPageHandle = new Handler(
  4338 + handlerFunc: (BuildContext? context, Map<String, List<Object>> params) {
  4339 + // ConsumeQrcodeSunModel data = ConsumeQrcodeSunModel.fromJson(json.decode(
  4340 + // FluroConvertUtils.fluroCnParamsDecode(params["data"]!.first as String)));
  4341 + return ChangeNotifierProvider<FinanceProvider>(
  4342 + create: (_) => FinanceProvider(), child: GiveMoneyBeforePayPage());
  4343 +});
  4344 +
  4345 +
  4346 +
4331 ///扫码领消费金 4347 ///扫码领消费金
4332 var grantWechatPageHandle = new Handler( 4348 var grantWechatPageHandle = new Handler(
4333 handlerFunc: (BuildContext? context, Map<String, List<Object>> params) { 4349 handlerFunc: (BuildContext? context, Map<String, List<Object>> params) {
@@ -437,6 +437,12 @@ class Routes { @@ -437,6 +437,12 @@ class Routes {
437 437
438 static String grant_wechat_page = "/grant_wechat_page"; // 扫码领消费金 438 static String grant_wechat_page = "/grant_wechat_page"; // 扫码领消费金
439 439
  440 +
  441 +
  442 +
  443 +
  444 + static String give_money_before_pay_page = "/give_money_before_pay_page"; // 买单前送消费金
  445 +
440 446
441 447
442 448
@@ -830,7 +836,12 @@ class Routes { @@ -830,7 +836,12 @@ class Routes {
830 router.define( grant_page, handler: grantPageHandle); 836 router.define( grant_page, handler: grantPageHandle);
831 837
832 838
833 - router.define( grant_wechat_page , handler: grantWechatPageHandle); 839 + router.define( grant_wechat_page , handler: grantWechatPageHandle);
  840 +
  841 +
  842 + router.define( give_money_before_pay_page , handler: giveMoneyBeforePayPageHandle);
  843 +
  844 +
834 845
835 } 846 }
836 } 847 }