|
|
|
import 'dart:convert';
|
|
|
|
|
|
|
|
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/models/ladder_return_money_model.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 ReturnMoneyPage extends StatefulWidget {
|
|
|
|
const ReturnMoneyPage({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<ReturnMoneyPage> createState() => _ReturnMoneyPageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _ReturnMoneyPageState extends State<ReturnMoneyPage> {
|
|
|
|
String fromDateFull = '选择日期';
|
|
|
|
String endDateFull = '选择日期';
|
|
|
|
|
|
|
|
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
|
|
|
|
|
|
|
|
FinanceProvider? financeProvider;
|
|
|
|
ScrollController controller = ScrollController();
|
|
|
|
|
|
|
|
bool isBack = false;
|
|
|
|
bool isRatio = true; //是否按照比例返还 true按照比例/false按照阶梯返还
|
|
|
|
|
|
|
|
TextEditingController ratioC = TextEditingController(); //比例输入框
|
|
|
|
FocusNode ratioNode = FocusNode(); //比例输入框
|
|
|
|
|
|
|
|
//消费金支付占实际消费金额比例
|
|
|
|
|
|
|
|
TextEditingController proportionC = TextEditingController(); //消费金支付占实际消费金额比例
|
|
|
|
FocusNode proportionNode = FocusNode(); //消费金支付占实际消费金额比例
|
|
|
|
|
|
|
|
List<LadderReturnMoneyModel> ladderSelectFree = [];
|
|
|
|
|
|
|
|
bool isCoexist = false; //消费金可与优惠券同时使用
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
LadderReturnMoneyModel ladderReturnMoneyModel = LadderReturnMoneyModel();
|
|
|
|
ladderSelectFree.add(ladderReturnMoneyModel);
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {});
|
|
|
|
}
|
|
|
|
|
|
|
|
//提交接口
|
|
|
|
_setConsumeConfig() async {
|
|
|
|
FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
Map<String, String?> fullReductionData = {};
|
|
|
|
|
|
|
|
|
|
|
|
if (isBack) {
|
|
|
|
if (fromDateFull == '选择日期') {
|
|
|
|
Utils.showToast('请选择活动的开始时间!');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (endDateFull == '选择日期') {
|
|
|
|
Utils.showToast('请选择活动的结束时间!');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isRatio) {
|
|
|
|
//按照比例返还
|
|
|
|
//需要填写比例百分比
|
|
|
|
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 (fromDateFull != '选择日期') {
|
|
|
|
String fromfull = fromDateFull + ' 00:00:00';
|
|
|
|
|
|
|
|
String sfull =
|
|
|
|
'${(DateUtil.getDateMsByTimeStr(fromfull)! / 1000).floor()}';
|
|
|
|
|
|
|
|
fullReductionData['stime'] = sfull;
|
|
|
|
}
|
|
|
|
if (endDateFull != '选择日期') {
|
|
|
|
String endfull = endDateFull + ' 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': isBack ? '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 _ladderPriceWidget(
|
|
|
|
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),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
///发放阶梯
|
|
|
|
Widget _ladderWidget() {
|
|
|
|
return ListView.builder(
|
|
|
|
controller: controller,
|
|
|
|
shrinkWrap: true,
|
|
|
|
itemCount: ladderSelectFree.length,
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
LadderReturnMoneyModel data = ladderSelectFree[index];
|
|
|
|
return Container(
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
left: w(40), top: w(8), bottom: w(8), right: w(16)),
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
'阶梯(${index + 1})',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_515151, fontSize: font(14)),
|
|
|
|
),
|
|
|
|
InkWell(
|
|
|
|
onTap: () {
|
|
|
|
//删除媒体
|
|
|
|
ladderSelectFree.remove(data);
|
|
|
|
setState(() {});
|
|
|
|
},
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.only(top: w(8), bottom: w(8)),
|
|
|
|
child: Text(
|
|
|
|
'删除',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_438E93,
|
|
|
|
fontSize: font(12)),
|
|
|
|
),
|
|
|
|
))
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
_ladderPriceWidget(
|
|
|
|
data.givePriceC, FocusNode(), data.backPriceC, FocusNode(),
|
|
|
|
width: 0),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
_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('顾客支付后返消费金', isBack, () {
|
|
|
|
setState(() {
|
|
|
|
isBack = !isBack;
|
|
|
|
});
|
|
|
|
}),
|
|
|
|
_select('活动开始于', fromDateFull, () {
|
|
|
|
FocusScope.of(context)
|
|
|
|
.requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
//弹出时间选择器
|
|
|
|
// showPickerDateTime(context);
|
|
|
|
// showDateSelWidget = true;
|
|
|
|
DialogUtil.showPickerDateTime24(
|
|
|
|
context,
|
|
|
|
scaffoldKey,
|
|
|
|
(value) {
|
|
|
|
// {'text': picker.adapter.text, 'select': selecteds}
|
|
|
|
if (value != null) {
|
|
|
|
if (endDateFull != '选择日期') {
|
|
|
|
if (DateUtil.getDateTime(endDateFull)
|
|
|
|
.compareTo(DateUtil.getDateTime(
|
|
|
|
DateUtil.formatDateStr(value,
|
|
|
|
format:
|
|
|
|
DateFormats.y_mo_d))) <
|
|
|
|
0) {
|
|
|
|
Utils.showToast('满减返券的活动开始时间不能迟于活动结束时间');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
print(value);
|
|
|
|
fromDateFull = DateUtil.formatDateStr(value,
|
|
|
|
format: DateFormats.y_mo_d);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
// showDateSelWidget = false;
|
|
|
|
},
|
|
|
|
minValue: DateTime(1987, 1, 1),
|
|
|
|
dateTime: fromDateFull == '选择日期'
|
|
|
|
? null
|
|
|
|
: DateUtil.getDateTime(fromDateFull),
|
|
|
|
pickerDateTimeType: PickerDateTimeType.kYMD,
|
|
|
|
onCancel: () {
|
|
|
|
// showDateSelWidget = false;
|
|
|
|
});
|
|
|
|
}),
|
|
|
|
_select('活动结束于', endDateFull, () {
|
|
|
|
FocusScope.of(context)
|
|
|
|
.requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
//弹出时间选择器
|
|
|
|
// showPickerDateTime(context);
|
|
|
|
// showDateSelWidget = true;
|
|
|
|
DialogUtil.showPickerDateTime24(
|
|
|
|
context,
|
|
|
|
scaffoldKey,
|
|
|
|
(value) {
|
|
|
|
// {'text': picker.adapter.text, 'select': selecteds}
|
|
|
|
if (value != null) {
|
|
|
|
if (fromDateFull != '选择日期') {
|
|
|
|
if (DateUtil.getDateTime(
|
|
|
|
DateUtil.formatDateStr(value,
|
|
|
|
format: DateFormats.y_mo_d))
|
|
|
|
.compareTo(DateUtil.getDateTime(
|
|
|
|
fromDateFull)) <
|
|
|
|
0) {
|
|
|
|
Utils.showToast('满减返券的活动结束时间不能早于活动开始时间');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setState(() {
|
|
|
|
print(value);
|
|
|
|
endDateFull = DateUtil.formatDateStr(value,
|
|
|
|
format: DateFormats.y_mo_d);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
// showDateSelWidget = false;
|
|
|
|
},
|
|
|
|
minValue: DateTime(1987, 1, 1),
|
|
|
|
dateTime: endDateFull == '选择日期'
|
|
|
|
? null
|
|
|
|
: DateUtil.getDateTime(endDateFull),
|
|
|
|
pickerDateTimeType: PickerDateTimeType.kYMD,
|
|
|
|
onCancel: () {
|
|
|
|
// showDateSelWidget = false;
|
|
|
|
});
|
|
|
|
}),
|
|
|
|
_radioWidget('按比例返还', isRatio, onTap: () {
|
|
|
|
if (!isRatio) {
|
|
|
|
setState(() {
|
|
|
|
isRatio = !isRatio;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
if (isRatio)
|
|
|
|
_priceWidget('返还消费金占实际支付金额', ratioC, ratioNode,
|
|
|
|
width: 60),
|
|
|
|
_radioWidget('按阶梯返还', !isRatio, onTap: () {
|
|
|
|
if (isRatio) {
|
|
|
|
setState(() {
|
|
|
|
isRatio = !isRatio;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
if (!isRatio) _ladderWidget(),
|
|
|
|
if (!isRatio)
|
|
|
|
InkWell(
|
|
|
|
onTap: () {
|
|
|
|
LadderReturnMoneyModel data =
|
|
|
|
LadderReturnMoneyModel();
|
|
|
|
ladderSelectFree.add(data);
|
|
|
|
setState(() {});
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
// height: w(30),
|
|
|
|
|
|
|
|
margin: EdgeInsets.only(
|
|
|
|
left: w(60), top: w(8), right: w(16)),
|
|
|
|
padding: EdgeInsets.symmetric(vertical: w(8)),
|
|
|
|
alignment: Alignment.centerRight,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
// color: Colors.red,
|
|
|
|
border: Border(
|
|
|
|
bottom: BorderSide(
|
|
|
|
width: w(0.5),
|
|
|
|
color: MyColours.color_E7E7E7))),
|
|
|
|
child: Text(
|
|
|
|
'+增加阶梯',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_438E93,
|
|
|
|
fontSize: font(12)),
|
|
|
|
),
|
|
|
|
)),
|
|
|
|
VEmptyView(24),
|
|
|
|
Container(
|
|
|
|
height: w(48),
|
|
|
|
// 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: Container(
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
// height: ScreenUtil().setWidth(40),
|
|
|
|
// color: Colors.red,
|
|
|
|
child: Text(
|
|
|
|
'消费金支付规则',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_515151,
|
|
|
|
fontSize: font(16)),
|
|
|
|
),
|
|
|
|
)),
|
|
|
|
InkWell(
|
|
|
|
onTap: () {
|
|
|
|
//消费金可与优惠券同时使用
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
isCoexist = !isCoexist;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
height: w(40),
|
|
|
|
padding: EdgeInsets.only(right: w(16)),
|
|
|
|
margin: EdgeInsets.only(left: w(40)),
|
|
|
|
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(
|
|
|
|
'消费金可与优惠券同时使用',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_515151,
|
|
|
|
fontSize: font(14)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Spacer(),
|
|
|
|
Image.asset(
|
|
|
|
isCoexist
|
|
|
|
? Utils.getImgPath('swich_on')
|
|
|
|
: Utils.getImgPath('swich_off'),
|
|
|
|
width: ScreenUtil().setWidth(44 * 2),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
_priceWidget(
|
|
|
|
'消费金支付占实际消费金额', proportionC, proportionNode,
|
|
|
|
width: 40),
|
|
|
|
]))),
|
|
|
|
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();
|
|
|
|
},
|
|
|
|
),
|
|
|
|
)
|
|
|
|
])));
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|