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