|
|
|
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_picker_plus/picker.dart';
|
|
|
|
7
|
+// import 'package:flutter_picker/flutter_picker.dart';
|
|
|
|
8
|
+import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
9
|
+import 'package:fluttertoast/fluttertoast.dart';
|
|
|
|
10
|
+import 'package:one_key/constant/constant.dart';
|
|
|
|
11
|
+import 'package:one_key/provider/coupon_provider.dart';
|
|
|
|
12
|
+import 'package:one_key/provider/user_model.dart';
|
|
|
|
13
|
+import 'package:one_key/res/colors.dart';
|
|
|
|
14
|
+import 'package:one_key/utils/dialog_util.dart';
|
|
|
|
15
|
+import 'package:one_key/utils/event_bus.dart';
|
|
|
|
16
|
+import 'package:one_key/route/navigator_util.dart';
|
|
|
|
17
|
+import 'package:one_key/utils/utils.dart';
|
|
|
|
18
|
+import 'package:one_key/widgets/MyDivider.dart';
|
|
|
|
19
|
+import 'package:one_key/widgets/h_empty_view.dart';
|
|
|
|
20
|
+import 'package:one_key/widgets/round_button.dart';
|
|
|
|
21
|
+import 'package:one_key/widgets/system_app_bar.dart';
|
|
|
|
22
|
+import 'package:one_key/widgets/v_empty_view.dart';
|
|
|
|
23
|
+import 'package:provider/provider.dart';
|
|
|
|
24
|
+
|
|
|
|
25
|
+import '../../models/coupon_model.dart';
|
|
|
|
26
|
+import '../../models/filter_btn_model.dart';
|
|
|
|
27
|
+import '../../models/upload_img_model.dart';
|
|
|
|
28
|
+import '../../provider/upload_img_provider.dart';
|
|
|
|
29
|
+import '../../utils/screen_util.dart';
|
|
|
|
30
|
+import '../../utils/upload_image_util.dart';
|
|
|
|
31
|
+import '../online_check/img_picker_widget.dart';
|
|
|
|
32
|
+
|
|
|
|
33
|
+/**
|
|
|
|
34
|
+ * 新建券
|
|
|
|
35
|
+ */
|
|
|
|
36
|
+
|
|
|
|
37
|
+class CouponEidtPayPage extends StatefulWidget {
|
|
|
|
38
|
+ final bool isMine;
|
|
|
|
39
|
+ final CouponSunModel? couponSunModel;
|
|
|
|
40
|
+ CouponEidtPayPage({Key? key, this.isMine = true, this.couponSunModel})
|
|
|
|
41
|
+ : super(key: key);
|
|
|
|
42
|
+
|
|
|
|
43
|
+ @override
|
|
|
|
44
|
+ _CouponEidtPayPageState createState() => _CouponEidtPayPageState();
|
|
|
|
45
|
+}
|
|
|
|
46
|
+
|
|
|
|
47
|
+class _CouponEidtPayPageState extends State<CouponEidtPayPage> {
|
|
|
|
48
|
+ ScrollController controller = ScrollController();
|
|
|
|
49
|
+ TextEditingController _couponNameEditControl = TextEditingController();
|
|
|
|
50
|
+ TextEditingController _couponRequireEditControl = TextEditingController();
|
|
|
|
51
|
+ TextEditingController _couponExplainEditControl = TextEditingController();
|
|
|
|
52
|
+ TextEditingController _limitNumControl = TextEditingController();
|
|
|
|
53
|
+ FocusNode _limitNumFocusNode = FocusNode();
|
|
|
|
54
|
+ final heightCell = ScreenUtil().setWidth(48 * 2);
|
|
|
|
55
|
+ bool swichState = true; //默认启用 开关状态
|
|
|
|
56
|
+ final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
|
|
|
|
57
|
+ String fromDate = '点击选择'; //有效期开始时间
|
|
|
|
58
|
+ String endDate = '点击选择'; //有效期结束时间
|
|
|
|
59
|
+ FocusNode _nameFocusNode = FocusNode();
|
|
|
|
60
|
+ FocusNode _requireFocusNode = FocusNode();
|
|
|
|
61
|
+ bool showDateSelWidget = false;
|
|
|
|
62
|
+ CouponProvider? couponProvider;
|
|
|
|
63
|
+ // bool swichHexiao = true; //默认启用 核销状态
|
|
|
|
64
|
+ String uids = '';
|
|
|
|
65
|
+ TextEditingController _priceControl = TextEditingController();
|
|
|
|
66
|
+ FocusNode _priceFocusNode = FocusNode();
|
|
|
|
67
|
+
|
|
|
|
68
|
+ bool money = true;
|
|
|
|
69
|
+ bool discount = false;
|
|
|
|
70
|
+ bool dish = false;
|
|
|
|
71
|
+
|
|
|
|
72
|
+ TextEditingController moneyControl = TextEditingController();
|
|
|
|
73
|
+ TextEditingController discountControl = TextEditingController();
|
|
|
|
74
|
+ TextEditingController dishControl = TextEditingController();
|
|
|
|
75
|
+
|
|
|
|
76
|
+ FocusNode moneyFocusNode = FocusNode();
|
|
|
|
77
|
+ FocusNode discountFocusNode = FocusNode();
|
|
|
|
78
|
+ FocusNode dishFocusNode = FocusNode();
|
|
|
|
79
|
+
|
|
|
|
80
|
+ bool limitNone = true;
|
|
|
|
81
|
+ bool limitWeek = false;
|
|
|
|
82
|
+ bool limitBirthday = false;
|
|
|
|
83
|
+ String weekShow = '点击设置可用日期';
|
|
|
|
84
|
+ List<FilterBtnModel> weekData = [];
|
|
|
|
85
|
+
|
|
|
|
86
|
+ // morning == "00:00-00:00"
|
|
|
|
87
|
+ String? morning;
|
|
|
|
88
|
+ String? noon;
|
|
|
|
89
|
+ String? night;
|
|
|
|
90
|
+
|
|
|
|
91
|
+ UploadImageProvider? _uploadImageProvider;
|
|
|
|
92
|
+ List<UploadImgModel> img = [];
|
|
|
|
93
|
+
|
|
|
|
94
|
+ List<String> imgAll = [];
|
|
|
|
95
|
+
|
|
|
|
96
|
+ @override
|
|
|
|
97
|
+ void initState() {
|
|
|
|
98
|
+ super.initState();
|
|
|
|
99
|
+ _nameFocusNode.addListener(() {
|
|
|
|
100
|
+ if (_nameFocusNode.hasFocus) {
|
|
|
|
101
|
+ //有焦点
|
|
|
|
102
|
+ if (showDateSelWidget) {
|
|
|
|
103
|
+ if (Navigator.canPop(context)) {
|
|
|
|
104
|
+ Navigator.pop(context);
|
|
|
|
105
|
+ }
|
|
|
|
106
|
+ showDateSelWidget = false;
|
|
|
|
107
|
+ }
|
|
|
|
108
|
+ } else {
|
|
|
|
109
|
+ //失去焦点
|
|
|
|
110
|
+ // _editingController.text = '';
|
|
|
|
111
|
+ }
|
|
|
|
112
|
+ });
|
|
|
|
113
|
+ _requireFocusNode.addListener(() {
|
|
|
|
114
|
+ if (_requireFocusNode.hasFocus) {
|
|
|
|
115
|
+ //有焦点
|
|
|
|
116
|
+ if (showDateSelWidget) {
|
|
|
|
117
|
+ if (Navigator.canPop(context)) {
|
|
|
|
118
|
+ Navigator.pop(context);
|
|
|
|
119
|
+ }
|
|
|
|
120
|
+ showDateSelWidget = false;
|
|
|
|
121
|
+ }
|
|
|
|
122
|
+ } else {
|
|
|
|
123
|
+ //失去焦点
|
|
|
|
124
|
+ // _editingController.text = '';
|
|
|
|
125
|
+ }
|
|
|
|
126
|
+ });
|
|
|
|
127
|
+
|
|
|
|
128
|
+ _priceFocusNode.addListener(() {
|
|
|
|
129
|
+ if (_priceFocusNode.hasFocus) {
|
|
|
|
130
|
+ //有焦点
|
|
|
|
131
|
+ if (showDateSelWidget) {
|
|
|
|
132
|
+ if (Navigator.canPop(context)) {
|
|
|
|
133
|
+ Navigator.pop(context);
|
|
|
|
134
|
+ }
|
|
|
|
135
|
+ showDateSelWidget = false;
|
|
|
|
136
|
+ }
|
|
|
|
137
|
+ } else {
|
|
|
|
138
|
+ //失去焦点
|
|
|
|
139
|
+ // _editingController.text = '';
|
|
|
|
140
|
+ }
|
|
|
|
141
|
+ });
|
|
|
|
142
|
+ moneyFocusNode.addListener(() {
|
|
|
|
143
|
+ if (moneyFocusNode.hasFocus) {
|
|
|
|
144
|
+ //有焦点
|
|
|
|
145
|
+ if (showDateSelWidget) {
|
|
|
|
146
|
+ if (Navigator.canPop(context)) {
|
|
|
|
147
|
+ Navigator.pop(context);
|
|
|
|
148
|
+ }
|
|
|
|
149
|
+ showDateSelWidget = false;
|
|
|
|
150
|
+ }
|
|
|
|
151
|
+ } else {
|
|
|
|
152
|
+ //失去焦点
|
|
|
|
153
|
+ // _editingController.text = '';
|
|
|
|
154
|
+ }
|
|
|
|
155
|
+ });
|
|
|
|
156
|
+ discountFocusNode.addListener(() {
|
|
|
|
157
|
+ if (discountFocusNode.hasFocus) {
|
|
|
|
158
|
+ //有焦点
|
|
|
|
159
|
+ if (showDateSelWidget) {
|
|
|
|
160
|
+ if (Navigator.canPop(context)) {
|
|
|
|
161
|
+ Navigator.pop(context);
|
|
|
|
162
|
+ }
|
|
|
|
163
|
+ showDateSelWidget = false;
|
|
|
|
164
|
+ }
|
|
|
|
165
|
+ } else {
|
|
|
|
166
|
+ //失去焦点
|
|
|
|
167
|
+ // _editingController.text = '';
|
|
|
|
168
|
+ }
|
|
|
|
169
|
+ });
|
|
|
|
170
|
+ dishFocusNode.addListener(() {
|
|
|
|
171
|
+ if (dishFocusNode.hasFocus) {
|
|
|
|
172
|
+ //有焦点
|
|
|
|
173
|
+ if (showDateSelWidget) {
|
|
|
|
174
|
+ if (Navigator.canPop(context)) {
|
|
|
|
175
|
+ Navigator.pop(context);
|
|
|
|
176
|
+ }
|
|
|
|
177
|
+ showDateSelWidget = false;
|
|
|
|
178
|
+ }
|
|
|
|
179
|
+ } else {
|
|
|
|
180
|
+ //失去焦点
|
|
|
|
181
|
+ // _editingController.text = '';
|
|
|
|
182
|
+ }
|
|
|
|
183
|
+ });
|
|
|
|
184
|
+
|
|
|
|
185
|
+ if (widget.couponSunModel != null) {
|
|
|
|
186
|
+ _couponNameEditControl.text = widget.couponSunModel!.aname ?? '';
|
|
|
|
187
|
+ _couponRequireEditControl.text = widget.couponSunModel!.desc ?? '';
|
|
|
|
188
|
+ _couponExplainEditControl.text = widget.couponSunModel!.explain ?? '';
|
|
|
|
189
|
+ DateTime dateTimes = DateTime.fromMillisecondsSinceEpoch(
|
|
|
|
190
|
+ int.parse(widget.couponSunModel!.stime.toString()) * 1000);
|
|
|
|
191
|
+ fromDate = DateUtil.formatDate(dateTimes, format: DateFormats.y_mo_d);
|
|
|
|
192
|
+ DateTime dateTimee = DateTime.fromMillisecondsSinceEpoch(
|
|
|
|
193
|
+ int.parse(widget.couponSunModel!.etime.toString()) * 1000);
|
|
|
|
194
|
+ endDate = DateUtil.formatDate(dateTimee, format: DateFormats.y_mo_d);
|
|
|
|
195
|
+
|
|
|
|
196
|
+ swichState = widget.couponSunModel!.status == '1' ? true : false;
|
|
|
|
197
|
+
|
|
|
|
198
|
+ if (widget.isMine) {
|
|
|
|
199
|
+ //我的优惠券
|
|
|
|
200
|
+ } else {
|
|
|
|
201
|
+ //店铺
|
|
|
|
202
|
+ // swichHexiao = widget.couponSunModel!.isExamine == '1' ? true : false;
|
|
|
|
203
|
+ _priceControl.text = widget.couponSunModel!.price ?? '';
|
|
|
|
204
|
+
|
|
|
|
205
|
+ money = widget.couponSunModel!.use!.isCash;
|
|
|
|
206
|
+ dish = widget.couponSunModel!.use!.isDish;
|
|
|
|
207
|
+ discount = widget.couponSunModel!.use!.isDiscount;
|
|
|
|
208
|
+ moneyControl.text = widget.couponSunModel!.use!.cash ?? '';
|
|
|
|
209
|
+ discountControl.text = widget.couponSunModel!.use!.discount ?? '';
|
|
|
|
210
|
+ dishControl.text = widget.couponSunModel!.use!.dish ?? '';
|
|
|
|
211
|
+
|
|
|
|
212
|
+ if (widget.couponSunModel!.use!.images.length > 0) {
|
|
|
|
213
|
+ widget.couponSunModel!.use!.images.forEach((element) {
|
|
|
|
214
|
+ UploadImgModel uploadImgModel = UploadImgModel();
|
|
|
|
215
|
+ uploadImgModel.qiniuUrl = element;
|
|
|
|
216
|
+ uploadImgModel.process = 1;
|
|
|
|
217
|
+ img.add(uploadImgModel);
|
|
|
|
218
|
+ imgAll.add(element); //初始化数据,同步数据库数据
|
|
|
|
219
|
+ });
|
|
|
|
220
|
+ }
|
|
|
|
221
|
+
|
|
|
|
222
|
+ limitNone = widget.couponSunModel!.expDate!.isNone ? true : false;
|
|
|
|
223
|
+ limitBirthday =
|
|
|
|
224
|
+ widget.couponSunModel!.expDate!.isBirthday ? true : false;
|
|
|
|
225
|
+ limitWeek = widget.couponSunModel!.expDate!.isWeek ? true : false;
|
|
|
|
226
|
+
|
|
|
|
227
|
+ weekShow = widget.couponSunModel!.expDate!.weekShow ?? '点击设置可用日期';
|
|
|
|
228
|
+ weekData = widget.couponSunModel!.expDate!.weekData ?? [];
|
|
|
|
229
|
+ uids = widget.couponSunModel!.uidList ?? '';
|
|
|
|
230
|
+ _limitNumControl.text = widget.couponSunModel!.grantNum ?? '';
|
|
|
|
231
|
+ }
|
|
|
|
232
|
+ }
|
|
|
|
233
|
+
|
|
|
|
234
|
+ WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
235
|
+ // _couponNetworkData(0);
|
|
|
|
236
|
+ if (weekData.length == 0) {
|
|
|
|
237
|
+ _initWeekData();
|
|
|
|
238
|
+ }
|
|
|
|
239
|
+
|
|
|
|
240
|
+ _getQiniuInfo();
|
|
|
|
241
|
+ });
|
|
|
|
242
|
+ }
|
|
|
|
243
|
+
|
|
|
|
244
|
+ @override
|
|
|
|
245
|
+ void dispose() {
|
|
|
|
246
|
+ super.dispose();
|
|
|
|
247
|
+
|
|
|
|
248
|
+ _uploadImageProvider!.qiniuInfoSunModel!.token = null;
|
|
|
|
249
|
+ }
|
|
|
|
250
|
+
|
|
|
|
251
|
+ ///获取七牛云token
|
|
|
|
252
|
+ ///
|
|
|
|
253
|
+ _getQiniuInfo() async {
|
|
|
|
254
|
+ await _uploadImageProvider!.getQiniuInfo(context, {});
|
|
|
|
255
|
+ }
|
|
|
|
256
|
+
|
|
|
|
257
|
+ // //初始化时间
|
|
|
|
258
|
+ // initWeekData() async {
|
|
|
|
259
|
+ // // UserModel userModel = Provider.of<UserModel>(context, listen: false);
|
|
|
|
260
|
+
|
|
|
|
261
|
+ // // morning =
|
|
|
|
262
|
+ // // userModel.user.morning.isEmpty ? "00:00-00:00" : userModel.user.morning;
|
|
|
|
263
|
+ // // noon = userModel.user.noon.isEmpty ? "00:00-00:00" : userModel.user.noon;
|
|
|
|
264
|
+ // // night = userModel.user.night.isEmpty ? "00:00-00:00" : userModel.user.night;
|
|
|
|
265
|
+ // // if (morning != "00:00-00:00") {
|
|
|
|
266
|
+ // // //开通早餐
|
|
|
|
267
|
+ // // }
|
|
|
|
268
|
+ // // if (morning != "00:00-00:00") {
|
|
|
|
269
|
+ // // //开通午餐
|
|
|
|
270
|
+ // // }
|
|
|
|
271
|
+ // // if (morning != "00:00-00:00") {
|
|
|
|
272
|
+ // // //开通晚餐
|
|
|
|
273
|
+ // // }
|
|
|
|
274
|
+
|
|
|
|
275
|
+ // }
|
|
|
|
276
|
+
|
|
|
|
277
|
+ _initWeekData() {
|
|
|
|
278
|
+ FilterBtnModel filterBtnModel = FilterBtnModel();
|
|
|
|
279
|
+ filterBtnModel.selectNoon = false;
|
|
|
|
280
|
+ filterBtnModel.selectNig = false;
|
|
|
|
281
|
+ filterBtnModel.title = '周日';
|
|
|
|
282
|
+ weekData.add(filterBtnModel);
|
|
|
|
283
|
+ for (int i = 1; i < 7; i++) {
|
|
|
|
284
|
+ FilterBtnModel filterBtnModel = FilterBtnModel();
|
|
|
|
285
|
+ filterBtnModel.selectNoon = false;
|
|
|
|
286
|
+ filterBtnModel.selectNig = false;
|
|
|
|
287
|
+ filterBtnModel.title = '周${Utils.formatWeekDayNum(i)}';
|
|
|
|
288
|
+ weekData.add(filterBtnModel);
|
|
|
|
289
|
+ }
|
|
|
|
290
|
+ }
|
|
|
|
291
|
+
|
|
|
|
292
|
+ //创建新券 客户经理创建活动
|
|
|
|
293
|
+ _createNewCoupon() async {
|
|
|
|
294
|
+ FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
295
|
+
|
|
|
|
296
|
+ String from = fromDate + ' 00:00:00';
|
|
|
|
297
|
+ String end = endDate + ' 23:59:59';
|
|
|
|
298
|
+ Map<String, String> params = {
|
|
|
|
299
|
+ "uid": Provider.of<UserModel>(context, listen: false).user!.openid!,
|
|
|
|
300
|
+ "aname": _couponNameEditControl.text.trim(),
|
|
|
|
301
|
+ "desc": _couponRequireEditControl.text.trim(),
|
|
|
|
302
|
+ "stime": fromDate == '点击选择'
|
|
|
|
303
|
+ ? ""
|
|
|
|
304
|
+ : '${(DateUtil.getDateMsByTimeStr(from)! / 1000).floor()}',
|
|
|
|
305
|
+ "etime": endDate == '点击选择'
|
|
|
|
306
|
+ ? ''
|
|
|
|
307
|
+ : '${(DateUtil.getDateMsByTimeStr(end)! / 1000).floor()}',
|
|
|
|
308
|
+ "explain": _couponExplainEditControl.text,
|
|
|
|
309
|
+ "is_open": swichState ? "1" : "0",
|
|
|
|
310
|
+ "status": swichState ? "1" : "0",
|
|
|
|
311
|
+ 'is_type': widget.isMine ? "2" : "1"
|
|
|
|
312
|
+ };
|
|
|
|
313
|
+ List<String> images = [];
|
|
|
|
314
|
+ if (!widget.isMine) {
|
|
|
|
315
|
+ params['is_examine'] = "1";
|
|
|
|
316
|
+ params['uid_list'] = uids;
|
|
|
|
317
|
+ params['price'] =
|
|
|
|
318
|
+ _priceControl.text.trim().length == 0 ? '0' : _priceControl.text;
|
|
|
|
319
|
+
|
|
|
|
320
|
+ if (img.length > 0) {
|
|
|
|
321
|
+ img.forEach((value) {
|
|
|
|
322
|
+ images.add(value.qiniuUrl!);
|
|
|
|
323
|
+ });
|
|
|
|
324
|
+ }
|
|
|
|
325
|
+
|
|
|
|
326
|
+ Map use = {
|
|
|
|
327
|
+ 'is_cash': money ? '1' : '0',
|
|
|
|
328
|
+ 'is_discount': discount ? '1' : '0',
|
|
|
|
329
|
+ 'is_dish': dish ? '1' : '0',
|
|
|
|
330
|
+ 'cash': moneyControl.text,
|
|
|
|
331
|
+ 'discount': discountControl.text,
|
|
|
|
332
|
+ 'dish': dishControl.text,
|
|
|
|
333
|
+ 'images': json.encode(images)
|
|
|
|
334
|
+ };
|
|
|
|
335
|
+ params['use'] = jsonEncode(use);
|
|
|
|
336
|
+
|
|
|
|
337
|
+ Map expDate = {
|
|
|
|
338
|
+ 'is_none': limitNone ? '1' : '0',
|
|
|
|
339
|
+ 'is_week': limitWeek ? '1' : '0',
|
|
|
|
340
|
+ 'is_birthday': limitBirthday ? '1' : '0',
|
|
|
|
341
|
+ 'week_show': weekShow,
|
|
|
|
342
|
+ 'week_data': weekData
|
|
|
|
343
|
+ };
|
|
|
|
344
|
+ params['exp_date'] = jsonEncode(expDate);
|
|
|
|
345
|
+
|
|
|
|
346
|
+ if (_limitNumControl.text.trim().length == 0) {
|
|
|
|
347
|
+ params['grant_num'] = '1000';
|
|
|
|
348
|
+ } else {
|
|
|
|
349
|
+ params['grant_num'] = _limitNumControl.text;
|
|
|
|
350
|
+ }
|
|
|
|
351
|
+ }
|
|
|
|
352
|
+ bool isSuccess =
|
|
|
|
353
|
+ await couponProvider!.createCustomerActivity(context, params);
|
|
|
|
354
|
+ if (isSuccess) {
|
|
|
|
355
|
+ if (!widget.isMine) {
|
|
|
|
356
|
+ // imgAll和images 比较,挑出不一样的,删除七牛云
|
|
|
|
357
|
+ Set<String> difference = Set.from(imgAll)..removeAll(images);
|
|
|
|
358
|
+ List<String> differenceList = difference.toList(); //需要删除的图片
|
|
|
|
359
|
+ if (differenceList.length > 0) {
|
|
|
|
360
|
+ String delImgs = Utils.listToStringEnglish(differenceList);
|
|
|
|
361
|
+
|
|
|
|
362
|
+ _uploadImageProvider!.deleteImg(context, delImgs, needToast: false);
|
|
|
|
363
|
+ }
|
|
|
|
364
|
+ }
|
|
|
|
365
|
+ //成功之后跳回前一个页面
|
|
|
|
366
|
+ // bus.emit('refresh_coupon_list');
|
|
|
|
367
|
+ EventBus().emit('refresh_coupon_invitation');
|
|
|
|
368
|
+ bus.emit('refresh_coupon_list_f');
|
|
|
|
369
|
+ // bus.emit('refresh_marketting_page');
|
|
|
|
370
|
+
|
|
|
|
371
|
+ bus.emit('refresh_table_m_coupon');
|
|
|
|
372
|
+ bus.emit('refresh_wine_msg');
|
|
|
|
373
|
+ if (Navigator.canPop(context)) {
|
|
|
|
374
|
+ Navigator.pop(context, true);
|
|
|
|
375
|
+ }
|
|
|
|
376
|
+ }
|
|
|
|
377
|
+ }
|
|
|
|
378
|
+
|
|
|
|
379
|
+ ///输入框
|
|
|
|
380
|
+ Widget _textfield(String title, String hintText,
|
|
|
|
381
|
+ TextEditingController controller, FocusNode focusNode,
|
|
|
|
382
|
+ {TextInputType textInputType = TextInputType.text}) {
|
|
|
|
383
|
+ return Container(
|
|
|
|
384
|
+ child: Row(
|
|
|
|
385
|
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
386
|
+ children: [
|
|
|
|
387
|
+ Container(
|
|
|
|
388
|
+ child: Text(
|
|
|
|
389
|
+ title,
|
|
|
|
390
|
+ style: TextStyle(
|
|
|
|
391
|
+ color: Color.fromRGBO(0, 0, 0, 0.9),
|
|
|
|
392
|
+ fontWeight: FontWeight.bold,
|
|
|
|
393
|
+ fontSize: ScreenUtil().setSp(32)),
|
|
|
|
394
|
+ ),
|
|
|
|
395
|
+ ),
|
|
|
|
396
|
+ HEmptyView(80),
|
|
|
|
397
|
+ Expanded(
|
|
|
|
398
|
+ // width: ScreenUtil().setWidth(231 * 2),
|
|
|
|
399
|
+ child: TextField(
|
|
|
|
400
|
+ controller: controller,
|
|
|
|
401
|
+ textAlign: TextAlign.right,
|
|
|
|
402
|
+ textAlignVertical: TextAlignVertical.bottom,
|
|
|
|
403
|
+ maxLines: 1,
|
|
|
|
404
|
+ // //光标颜色
|
|
|
|
405
|
+ // cursorColor:
|
|
|
|
406
|
+ // widget.isSelect ? Colors.white : MyColours.color_199095,
|
|
|
|
407
|
+ //输入文本的样式
|
|
|
|
408
|
+ inputFormatters: title == '券名称'
|
|
|
|
409
|
+ ? [LengthLimitingTextInputFormatter(15)]
|
|
|
|
410
|
+ : title == '销售价'
|
|
|
|
411
|
+ ? [FilteringTextInputFormatter.digitsOnly]
|
|
|
|
412
|
+ : [],
|
|
|
|
413
|
+ style: TextStyle(
|
|
|
|
414
|
+ color: MyColours.color_515151,
|
|
|
|
415
|
+ fontSize: ScreenUtil().setSp(32),
|
|
|
|
416
|
+ ),
|
|
|
|
417
|
+ focusNode: focusNode,
|
|
|
|
418
|
+ decoration: InputDecoration(
|
|
|
|
419
|
+ border: OutlineInputBorder(borderSide: BorderSide.none),
|
|
|
|
420
|
+ hintText: hintText,
|
|
|
|
421
|
+ hintStyle: TextStyle(
|
|
|
|
422
|
+ color: MyColours.color_999999,
|
|
|
|
423
|
+ fontSize: ScreenUtil().setSp(32),
|
|
|
|
424
|
+ ),
|
|
|
|
425
|
+ enabledBorder: new UnderlineInputBorder(
|
|
|
|
426
|
+ borderSide: BorderSide.none,
|
|
|
|
427
|
+ ),
|
|
|
|
428
|
+ focusedBorder: new UnderlineInputBorder(
|
|
|
|
429
|
+ borderSide: BorderSide.none,
|
|
|
|
430
|
+ ),
|
|
|
|
431
|
+ ),
|
|
|
|
432
|
+ onChanged: (value) {},
|
|
|
|
433
|
+ onEditingComplete: () {
|
|
|
|
434
|
+ FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
435
|
+ },
|
|
|
|
436
|
+ keyboardType: textInputType),
|
|
|
|
437
|
+ ),
|
|
|
|
438
|
+ HEmptyView(32)
|
|
|
|
439
|
+ ],
|
|
|
|
440
|
+ ),
|
|
|
|
441
|
+ );
|
|
|
|
442
|
+ }
|
|
|
|
443
|
+
|
|
|
|
444
|
+ ///输入框
|
|
|
|
445
|
+ Widget _textfieldSelect(
|
|
|
|
446
|
+ String title,
|
|
|
|
447
|
+ String hintText,
|
|
|
|
448
|
+ TextEditingController controller,
|
|
|
|
449
|
+ FocusNode focusNode, {
|
|
|
|
450
|
+ TextInputType textInputType = TextInputType.text,
|
|
|
|
451
|
+ String subtitle = '',
|
|
|
|
452
|
+ }) {
|
|
|
|
453
|
+ return Container(
|
|
|
|
454
|
+ padding: EdgeInsets.only(left: w(20), right: (w(20))),
|
|
|
|
455
|
+ child: Row(
|
|
|
|
456
|
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
457
|
+ children: [
|
|
|
|
458
|
+ Container(
|
|
|
|
459
|
+ child: Text(
|
|
|
|
460
|
+ title,
|
|
|
|
461
|
+ style: TextStyle(
|
|
|
|
462
|
+ color: MyColours.color_515151,
|
|
|
|
463
|
+ fontSize: ScreenUtil().setSp(32)),
|
|
|
|
464
|
+ ),
|
|
|
|
465
|
+ ),
|
|
|
|
466
|
+ HEmptyView(40),
|
|
|
|
467
|
+ Expanded(
|
|
|
|
468
|
+ child: TextField(
|
|
|
|
469
|
+ controller: controller,
|
|
|
|
470
|
+ textAlign: TextAlign.right,
|
|
|
|
471
|
+ textAlignVertical: TextAlignVertical.bottom,
|
|
|
|
472
|
+ maxLines: 1,
|
|
|
|
473
|
+ // //光标颜色
|
|
|
|
474
|
+ // cursorColor:
|
|
|
|
475
|
+ // widget.isSelect ? Colors.white : MyColours.color_199095,
|
|
|
|
476
|
+ //输入文本的样式
|
|
|
|
477
|
+ style: TextStyle(
|
|
|
|
478
|
+ color: MyColours.color_515151,
|
|
|
|
479
|
+ fontSize: ScreenUtil().setSp(32),
|
|
|
|
480
|
+ ),
|
|
|
|
481
|
+ focusNode: focusNode,
|
|
|
|
482
|
+ decoration: InputDecoration(
|
|
|
|
483
|
+ isCollapsed: true,
|
|
|
|
484
|
+ border: OutlineInputBorder(borderSide: BorderSide.none),
|
|
|
|
485
|
+ hintText: hintText,
|
|
|
|
486
|
+ hintStyle: TextStyle(
|
|
|
|
487
|
+ color: MyColours.color_999999,
|
|
|
|
488
|
+ fontSize: ScreenUtil().setSp(32),
|
|
|
|
489
|
+ ),
|
|
|
|
490
|
+ enabledBorder: new UnderlineInputBorder(
|
|
|
|
491
|
+ borderSide: BorderSide.none,
|
|
|
|
492
|
+ ),
|
|
|
|
493
|
+ focusedBorder: new UnderlineInputBorder(
|
|
|
|
494
|
+ borderSide: BorderSide.none,
|
|
|
|
495
|
+ ),
|
|
|
|
496
|
+ ),
|
|
|
|
497
|
+ onChanged: (value) {},
|
|
|
|
498
|
+ onEditingComplete: () {
|
|
|
|
499
|
+ FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
500
|
+ },
|
|
|
|
501
|
+ keyboardType: textInputType),
|
|
|
|
502
|
+ ),
|
|
|
|
503
|
+ if (subtitle != '') HEmptyView(6),
|
|
|
|
504
|
+ Text(
|
|
|
|
505
|
+ subtitle,
|
|
|
|
506
|
+ style: TextStyle(
|
|
|
|
507
|
+ color: MyColours.color_515151,
|
|
|
|
508
|
+ fontSize: ScreenUtil().setSp(32)),
|
|
|
|
509
|
+ ),
|
|
|
|
510
|
+ ],
|
|
|
|
511
|
+ ),
|
|
|
|
512
|
+ );
|
|
|
|
513
|
+ }
|
|
|
|
514
|
+
|
|
|
|
515
|
+ ///时间选择
|
|
|
|
516
|
+ Widget _select(String title, String hintText, GestureTapCallback onTap) {
|
|
|
|
517
|
+ return InkWell(
|
|
|
|
518
|
+ onTap: onTap,
|
|
|
|
519
|
+ child: Container(
|
|
|
|
520
|
+ padding: EdgeInsets.symmetric(vertical: ScreenUtil().setWidth(28)),
|
|
|
|
521
|
+ child: Row(
|
|
|
|
522
|
+ crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
523
|
+ mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
524
|
+ children: [
|
|
|
|
525
|
+ Container(
|
|
|
|
526
|
+ // height: ScreenUtil().setWidth(40),
|
|
|
|
527
|
+ // color: Colors.red,
|
|
|
|
528
|
+ child: Text(
|
|
|
|
529
|
+ title,
|
|
|
|
530
|
+ style: TextStyle(
|
|
|
|
531
|
+ color: Color.fromRGBO(0, 0, 0, 0.9),
|
|
|
|
532
|
+ fontWeight: FontWeight.bold,
|
|
|
|
533
|
+ fontSize: ScreenUtil().setSp(32)),
|
|
|
|
534
|
+ ),
|
|
|
|
535
|
+ ),
|
|
|
|
536
|
+ HEmptyView(20),
|
|
|
|
537
|
+ Spacer(),
|
|
|
|
538
|
+ Text(hintText,
|
|
|
|
539
|
+ style: TextStyle(
|
|
|
|
540
|
+ color: hintText == '点击选择'
|
|
|
|
541
|
+ ? MyColours.color_999999
|
|
|
|
542
|
+ : MyColours.color_515151,
|
|
|
|
543
|
+ fontSize: ScreenUtil().setSp(32),
|
|
|
|
544
|
+ )),
|
|
|
|
545
|
+ HEmptyView(20),
|
|
|
|
546
|
+ Image.asset(
|
|
|
|
547
|
+ Utils.getImgPath('arrow_right_new'),
|
|
|
|
548
|
+ width: ScreenUtil().setWidth(20),
|
|
|
|
549
|
+ ),
|
|
|
|
550
|
+ HEmptyView(32),
|
|
|
|
551
|
+ ],
|
|
|
|
552
|
+ ),
|
|
|
|
553
|
+ ),
|
|
|
|
554
|
+ );
|
|
|
|
555
|
+ }
|
|
|
|
556
|
+
|
|
|
|
557
|
+ ///券说明
|
|
|
|
558
|
+ Widget _explain(String title, String hintText) {
|
|
|
|
559
|
+ return Container(
|
|
|
|
560
|
+ // height: ScreenUtil().setWidth(380),
|
|
|
|
561
|
+ padding: EdgeInsets.symmetric(vertical: ScreenUtil().setWidth(28)),
|
|
|
|
562
|
+ child: Column(
|
|
|
|
563
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
564
|
+ children: [
|
|
|
|
565
|
+ Align(
|
|
|
|
566
|
+ alignment: Alignment.centerLeft,
|
|
|
|
567
|
+ child: Text(
|
|
|
|
568
|
+ title,
|
|
|
|
569
|
+ textAlign: TextAlign.left,
|
|
|
|
570
|
+ style: TextStyle(
|
|
|
|
571
|
+ color: Color.fromRGBO(0, 0, 0, 0.9),
|
|
|
|
572
|
+ fontWeight: FontWeight.bold,
|
|
|
|
573
|
+ fontSize: ScreenUtil().setSp(32)),
|
|
|
|
574
|
+ )),
|
|
|
|
575
|
+ VEmptyView(26),
|
|
|
|
576
|
+ Container(
|
|
|
|
577
|
+ height: ScreenUtil().setWidth(2),
|
|
|
|
578
|
+ color: MyColours.color_E7E7E7,
|
|
|
|
579
|
+ ),
|
|
|
|
580
|
+ TextField(
|
|
|
|
581
|
+ controller: _couponExplainEditControl,
|
|
|
|
582
|
+ // keyboardType: TextInputType.number, //键盘类型,数字键盘
|
|
|
|
583
|
+ maxLines: 3,
|
|
|
|
584
|
+ maxLength: 50,
|
|
|
|
585
|
+
|
|
|
|
586
|
+ // maxLengthEnforced: true,
|
|
|
|
587
|
+ style: TextStyle(
|
|
|
|
588
|
+ fontSize: ScreenUtil().setSp(32),
|
|
|
|
589
|
+ color: MyColours.color_333333), //输入文本的样式
|
|
|
|
590
|
+ decoration: InputDecoration(
|
|
|
|
591
|
+ contentPadding: EdgeInsets.all(ScreenUtil().setWidth(30)),
|
|
|
|
592
|
+ hintText: hintText,
|
|
|
|
593
|
+ hintStyle: TextStyle(
|
|
|
|
594
|
+ color: MyColours.color_999999,
|
|
|
|
595
|
+ fontSize: ScreenUtil().setSp(32),
|
|
|
|
596
|
+ ),
|
|
|
|
597
|
+
|
|
|
|
598
|
+ border: OutlineInputBorder(borderSide: BorderSide.none),
|
|
|
|
599
|
+
|
|
|
|
600
|
+ enabledBorder: new UnderlineInputBorder(
|
|
|
|
601
|
+ borderSide: BorderSide.none,
|
|
|
|
602
|
+ ),
|
|
|
|
603
|
+ focusedBorder: new UnderlineInputBorder(
|
|
|
|
604
|
+ borderSide: BorderSide.none,
|
|
|
|
605
|
+ ),
|
|
|
|
606
|
+
|
|
|
|
607
|
+ // fillColor: MyColours.color_F9F9F9,
|
|
|
|
608
|
+ // // fillColor: Colors.red,
|
|
|
|
609
|
+ // filled: true,
|
|
|
|
610
|
+ // enabledBorder: OutlineInputBorder(
|
|
|
|
611
|
+ // //未选中时候的颜色
|
|
|
|
612
|
+ // borderRadius: BorderRadius.circular(ScreenUtil().setWidth(20)),
|
|
|
|
613
|
+ // borderSide: BorderSide(
|
|
|
|
614
|
+ // color: MyColours.color_cccccc,
|
|
|
|
615
|
+ // width: ScreenUtil().setWidth(2)),
|
|
|
|
616
|
+ // ),
|
|
|
|
617
|
+ // focusedBorder: OutlineInputBorder(
|
|
|
|
618
|
+ // //选中时外边框颜色
|
|
|
|
619
|
+ // borderRadius: BorderRadius.circular(ScreenUtil().setWidth(20)),
|
|
|
|
620
|
+ // borderSide: BorderSide(
|
|
|
|
621
|
+ // color: MyColours.app_main,
|
|
|
|
622
|
+ // ),
|
|
|
|
623
|
+ // ),
|
|
|
|
624
|
+ // border: OutlineInputBorder(
|
|
|
|
625
|
+ // borderRadius:
|
|
|
|
626
|
+ // BorderRadius.circular(ScreenUtil().setWidth(20)),
|
|
|
|
627
|
+ // borderSide: BorderSide(
|
|
|
|
628
|
+ // color: Colors.red, width: ScreenUtil().setWidth(2))),
|
|
|
|
629
|
+ ),
|
|
|
|
630
|
+ onChanged: (value) {},
|
|
|
|
631
|
+ ),
|
|
|
|
632
|
+ ],
|
|
|
|
633
|
+ ),
|
|
|
|
634
|
+ );
|
|
|
|
635
|
+ }
|
|
|
|
636
|
+
|
|
|
|
637
|
+ ///是否立即启用
|
|
|
|
638
|
+ Widget _canUse(String title, bool swich, GestureTapCallback onTap) {
|
|
|
|
639
|
+ return InkWell(
|
|
|
|
640
|
+ onTap: onTap,
|
|
|
|
641
|
+ child: Container(
|
|
|
|
642
|
+ padding: EdgeInsets.symmetric(vertical: ScreenUtil().setWidth(24)),
|
|
|
|
643
|
+ margin: EdgeInsets.only(right: ScreenUtil().setWidth(32)),
|
|
|
|
644
|
+ child: Row(
|
|
|
|
645
|
+ crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
646
|
+ mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
647
|
+ children: [
|
|
|
|
648
|
+ Container(
|
|
|
|
649
|
+ // height: ScreenUtil().setWidth(40),
|
|
|
|
650
|
+ // color: Colors.red,
|
|
|
|
651
|
+ child: Text(
|
|
|
|
652
|
+ title,
|
|
|
|
653
|
+ style: TextStyle(
|
|
|
|
654
|
+ color: Color.fromRGBO(0, 0, 0, 0.9),
|
|
|
|
655
|
+ fontWeight: FontWeight.bold,
|
|
|
|
656
|
+ fontSize: ScreenUtil().setSp(32)),
|
|
|
|
657
|
+ ),
|
|
|
|
658
|
+ ),
|
|
|
|
659
|
+ Spacer(),
|
|
|
|
660
|
+ Image.asset(
|
|
|
|
661
|
+ swich
|
|
|
|
662
|
+ ? Utils.getImgPath('swich_on')
|
|
|
|
663
|
+ : Utils.getImgPath('swich_off'),
|
|
|
|
664
|
+ width: ScreenUtil().setWidth(44 * 2),
|
|
|
|
665
|
+ )
|
|
|
|
666
|
+ ],
|
|
|
|
667
|
+ ),
|
|
|
|
668
|
+ ),
|
|
|
|
669
|
+ );
|
|
|
|
670
|
+ }
|
|
|
|
671
|
+
|
|
|
|
672
|
+ ///
|
|
|
|
673
|
+ Widget _item(String title, String subTitle) {
|
|
|
|
674
|
+ return Container(
|
|
|
|
675
|
+ padding: EdgeInsets.symmetric(vertical: ScreenUtil().setWidth(28)),
|
|
|
|
676
|
+ margin: EdgeInsets.only(right: ScreenUtil().setWidth(32)),
|
|
|
|
677
|
+ child: Row(
|
|
|
|
678
|
+ crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
679
|
+ mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
680
|
+ children: [
|
|
|
|
681
|
+ Container(
|
|
|
|
682
|
+ child: Text(
|
|
|
|
683
|
+ title,
|
|
|
|
684
|
+ style: TextStyle(
|
|
|
|
685
|
+ color: Color.fromRGBO(0, 0, 0, 0.9),
|
|
|
|
686
|
+ fontWeight: FontWeight.bold,
|
|
|
|
687
|
+ fontSize: ScreenUtil().setSp(32)),
|
|
|
|
688
|
+ ),
|
|
|
|
689
|
+ ),
|
|
|
|
690
|
+ HEmptyView(60),
|
|
|
|
691
|
+ Expanded(
|
|
|
|
692
|
+ child: Text(
|
|
|
|
693
|
+ subTitle,
|
|
|
|
694
|
+ maxLines: 20,
|
|
|
|
695
|
+ textAlign: TextAlign.right,
|
|
|
|
696
|
+ overflow: TextOverflow.ellipsis,
|
|
|
|
697
|
+ style: TextStyle(
|
|
|
|
698
|
+ color: Color.fromRGBO(0, 0, 0, 0.4),
|
|
|
|
699
|
+ fontSize: ScreenUtil().setSp(32),
|
|
|
|
700
|
+ ),
|
|
|
|
701
|
+ ))
|
|
|
|
702
|
+ ],
|
|
|
|
703
|
+ ),
|
|
|
|
704
|
+ );
|
|
|
|
705
|
+ }
|
|
|
|
706
|
+
|
|
|
|
707
|
+ _itemRadioWidget(bool select, String title, {GestureTapCallback? onTap}) {
|
|
|
|
708
|
+ return InkWell(
|
|
|
|
709
|
+ onTap: onTap,
|
|
|
|
710
|
+ child: Row(children: [
|
|
|
|
711
|
+ Image.asset(
|
|
|
|
712
|
+ Utils.getImgPath(
|
|
|
|
713
|
+ select ? 'plan_dish_select' : 'plan_dish_unselect'),
|
|
|
|
714
|
+ width: w(20),
|
|
|
|
715
|
+ ),
|
|
|
|
716
|
+ HEmptyView(6),
|
|
|
|
717
|
+ Text(
|
|
|
|
718
|
+ title,
|
|
|
|
719
|
+ style: TextStyle(
|
|
|
|
720
|
+ color: MyColours.color_515151,
|
|
|
|
721
|
+ fontSize: ScreenUtil().setSp(32)),
|
|
|
|
722
|
+ ),
|
|
|
|
723
|
+ ]));
|
|
|
|
724
|
+ }
|
|
|
|
725
|
+
|
|
|
|
726
|
+ ///时间选择
|
|
|
|
727
|
+ Widget _select1(String title, String hintText, GestureTapCallback onTap) {
|
|
|
|
728
|
+ return InkWell(
|
|
|
|
729
|
+ onTap: onTap,
|
|
|
|
730
|
+ child: Container(
|
|
|
|
731
|
+ padding: EdgeInsets.only(left: ScreenUtil().setWidth(32)),
|
|
|
|
732
|
+ child: Row(
|
|
|
|
733
|
+ crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
734
|
+ mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
735
|
+ children: [
|
|
|
|
736
|
+ Container(
|
|
|
|
737
|
+ // height: ScreenUtil().setWidth(40),
|
|
|
|
738
|
+ // color: Colors.red,
|
|
|
|
739
|
+ child: Text(
|
|
|
|
740
|
+ title,
|
|
|
|
741
|
+ style: TextStyle(
|
|
|
|
742
|
+ height: 1.5,
|
|
|
|
743
|
+ color: title == '点击设置可用日期'
|
|
|
|
744
|
+ ? MyColours.color_999999
|
|
|
|
745
|
+ : MyColours.color_515151,
|
|
|
|
746
|
+ fontSize: ScreenUtil().setSp(32)),
|
|
|
|
747
|
+ ),
|
|
|
|
748
|
+ ),
|
|
|
|
749
|
+ HEmptyView(20),
|
|
|
|
750
|
+ Spacer(),
|
|
|
|
751
|
+ Text(hintText,
|
|
|
|
752
|
+ style: TextStyle(
|
|
|
|
753
|
+ color: hintText == '点击设置开始日期' || hintText == '点击设置结束日期'
|
|
|
|
754
|
+ ? MyColours.color_999999
|
|
|
|
755
|
+ : MyColours.color_515151,
|
|
|
|
756
|
+ fontSize: ScreenUtil().setSp(32),
|
|
|
|
757
|
+ )),
|
|
|
|
758
|
+ HEmptyView(20),
|
|
|
|
759
|
+ Image.asset(
|
|
|
|
760
|
+ Utils.getImgPath('arrow_right_new'),
|
|
|
|
761
|
+ width: ScreenUtil().setWidth(18),
|
|
|
|
762
|
+ ),
|
|
|
|
763
|
+ HEmptyView(32),
|
|
|
|
764
|
+ ],
|
|
|
|
765
|
+ ),
|
|
|
|
766
|
+ ),
|
|
|
|
767
|
+ );
|
|
|
|
768
|
+ }
|
|
|
|
769
|
+
|
|
|
|
770
|
+ @override
|
|
|
|
771
|
+ Widget build(BuildContext context) {
|
|
|
|
772
|
+ couponProvider = Provider.of<CouponProvider>(context, listen: true);
|
|
|
|
773
|
+ _uploadImageProvider =
|
|
|
|
774
|
+ Provider.of<UploadImageProvider>(context, listen: true);
|
|
|
|
775
|
+ return Scaffold(
|
|
|
|
776
|
+ backgroundColor: MyColours.color_ffffff,
|
|
|
|
777
|
+ key: scaffoldKey,
|
|
|
|
778
|
+ appBar: SystemAppBar(
|
|
|
|
779
|
+ '优惠券详情',
|
|
|
|
780
|
+ onTap: () {
|
|
|
|
781
|
+ if (Navigator.canPop(context)) {
|
|
|
|
782
|
+ Navigator.pop(context, false);
|
|
|
|
783
|
+ }
|
|
|
|
784
|
+ },
|
|
|
|
785
|
+ ),
|
|
|
|
786
|
+ body: InkWell(
|
|
|
|
787
|
+ onTap: () {
|
|
|
|
788
|
+ FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
789
|
+ },
|
|
|
|
790
|
+ child: Container(
|
|
|
|
791
|
+ color: MyColours.color_ffffff,
|
|
|
|
792
|
+ child: Column(children: [
|
|
|
|
793
|
+ Expanded(
|
|
|
|
794
|
+ child: SingleChildScrollView(
|
|
|
|
795
|
+ controller: controller,
|
|
|
|
796
|
+ physics: BouncingScrollPhysics(),
|
|
|
|
797
|
+ child: Padding(
|
|
|
|
798
|
+ padding:
|
|
|
|
799
|
+ EdgeInsets.only(left: ScreenUtil().setWidth(32)),
|
|
|
|
800
|
+ child: Column(
|
|
|
|
801
|
+ children: [
|
|
|
|
802
|
+ VEmptyView(56),
|
|
|
|
803
|
+ _item('券类型', widget.isMine ? '我的优惠券' : '付费优惠券'),
|
|
|
|
804
|
+ Container(
|
|
|
|
805
|
+ height: ScreenUtil().setWidth(2),
|
|
|
|
806
|
+ color: MyColours.color_E7E7E7,
|
|
|
|
807
|
+ ),
|
|
|
|
808
|
+ VEmptyView(24),
|
|
|
|
809
|
+ // widget.isMine
|
|
|
|
810
|
+ // ? SizedBox()
|
|
|
|
811
|
+ // : _canUse('是否核销', swichHexiao, () {
|
|
|
|
812
|
+ // setState(() {
|
|
|
|
813
|
+ // swichHexiao = !swichHexiao;
|
|
|
|
814
|
+ // });
|
|
|
|
815
|
+ // }),
|
|
|
|
816
|
+ // widget.isMine
|
|
|
|
817
|
+ // ? SizedBox()
|
|
|
|
818
|
+ // : Container(
|
|
|
|
819
|
+ // height: ScreenUtil().setWidth(2),
|
|
|
|
820
|
+ // color: MyColours.color_E7E7E7,
|
|
|
|
821
|
+ // ),
|
|
|
|
822
|
+ // widget.isMine ? SizedBox() : VEmptyView(24),
|
|
|
|
823
|
+ _textfield('券名称', '例:9折券/200元代金券/菜品券',
|
|
|
|
824
|
+ _couponNameEditControl, _nameFocusNode),
|
|
|
|
825
|
+ Container(
|
|
|
|
826
|
+ height: ScreenUtil().setWidth(2),
|
|
|
|
827
|
+ color: MyColours.color_E7E7E7,
|
|
|
|
828
|
+ ),
|
|
|
|
829
|
+ VEmptyView(24),
|
|
|
|
830
|
+ if (!widget.isMine)
|
|
|
|
831
|
+ Column(
|
|
|
|
832
|
+ children: [
|
|
|
|
833
|
+ //销售价
|
|
|
|
834
|
+
|
|
|
|
835
|
+ _textfield('销售价', '请输入销售价', _priceControl,
|
|
|
|
836
|
+ _priceFocusNode,
|
|
|
|
837
|
+ textInputType:
|
|
|
|
838
|
+ TextInputType.numberWithOptions(
|
|
|
|
839
|
+ decimal: true)),
|
|
|
|
840
|
+
|
|
|
|
841
|
+ Container(
|
|
|
|
842
|
+ height: ScreenUtil().setWidth(2),
|
|
|
|
843
|
+ color: MyColours.color_E7E7E7,
|
|
|
|
844
|
+ ),
|
|
|
|
845
|
+ // VEmptyView(24),
|
|
|
|
846
|
+ //券用途
|
|
|
|
847
|
+ VEmptyView(56),
|
|
|
|
848
|
+ Container(
|
|
|
|
849
|
+ alignment: Alignment.centerLeft,
|
|
|
|
850
|
+ child: Text(
|
|
|
|
851
|
+ '券用途',
|
|
|
|
852
|
+ style: TextStyle(
|
|
|
|
853
|
+ color: Color.fromRGBO(0, 0, 0, 0.9),
|
|
|
|
854
|
+ fontWeight: FontWeight.bold,
|
|
|
|
855
|
+ fontSize: ScreenUtil().setSp(32)),
|
|
|
|
856
|
+ ),
|
|
|
|
857
|
+ ),
|
|
|
|
858
|
+ VEmptyView(40),
|
|
|
|
859
|
+ Row(
|
|
|
|
860
|
+ children: [
|
|
|
|
861
|
+ HEmptyView(30),
|
|
|
|
862
|
+ _itemRadioWidget(money, '代金券',
|
|
|
|
863
|
+ onTap: () {
|
|
|
|
864
|
+ if (!money) {
|
|
|
|
865
|
+ setState(() {
|
|
|
|
866
|
+ money = true;
|
|
|
|
867
|
+
|
|
|
|
868
|
+ dish = false;
|
|
|
|
869
|
+ discount = false;
|
|
|
|
870
|
+ });
|
|
|
|
871
|
+ }
|
|
|
|
872
|
+ }),
|
|
|
|
873
|
+ Spacer(),
|
|
|
|
874
|
+ _itemRadioWidget(discount, '折扣券',
|
|
|
|
875
|
+ onTap: () {
|
|
|
|
876
|
+ if (!discount) {
|
|
|
|
877
|
+ setState(() {
|
|
|
|
878
|
+ discount = true;
|
|
|
|
879
|
+
|
|
|
|
880
|
+ dish = false;
|
|
|
|
881
|
+ money = false;
|
|
|
|
882
|
+ });
|
|
|
|
883
|
+ }
|
|
|
|
884
|
+ }),
|
|
|
|
885
|
+ Spacer(),
|
|
|
|
886
|
+ _itemRadioWidget(dish, '菜品券',
|
|
|
|
887
|
+ onTap: () {
|
|
|
|
888
|
+ if (!dish) {
|
|
|
|
889
|
+ setState(() {
|
|
|
|
890
|
+ dish = true;
|
|
|
|
891
|
+ discount = false;
|
|
|
|
892
|
+ money = false;
|
|
|
|
893
|
+ });
|
|
|
|
894
|
+ }
|
|
|
|
895
|
+ }),
|
|
|
|
896
|
+ HEmptyView(30),
|
|
|
|
897
|
+ ],
|
|
|
|
898
|
+ ),
|
|
|
|
899
|
+ VEmptyView(30),
|
|
|
|
900
|
+
|
|
|
|
901
|
+ if (money)
|
|
|
|
902
|
+ _textfieldSelect('金额:', '点击输入代金券金额',
|
|
|
|
903
|
+ moneyControl, moneyFocusNode,
|
|
|
|
904
|
+ subtitle: '元',
|
|
|
|
905
|
+ textInputType: TextInputType
|
|
|
|
906
|
+ .numberWithOptions()),
|
|
|
|
907
|
+ if (discount)
|
|
|
|
908
|
+ _textfieldSelect('折扣率:', '点击输入折扣,如9折',
|
|
|
|
909
|
+ discountControl, dishFocusNode,
|
|
|
|
910
|
+ subtitle: '折',
|
|
|
|
911
|
+ textInputType: TextInputType
|
|
|
|
912
|
+ .numberWithOptions()),
|
|
|
|
913
|
+
|
|
|
|
914
|
+ if (dish)
|
|
|
|
915
|
+ Container(
|
|
|
|
916
|
+ padding: EdgeInsets.only(left: w(20)),
|
|
|
|
917
|
+ child: Column(
|
|
|
|
918
|
+ crossAxisAlignment:
|
|
|
|
919
|
+ CrossAxisAlignment.start,
|
|
|
|
920
|
+
|
|
|
|
921
|
+ // mainAxisAlignment:
|
|
|
|
922
|
+ // MainAxisAlignment.spaceBetween,
|
|
|
|
923
|
+ children: [
|
|
|
|
924
|
+ Container(
|
|
|
|
925
|
+ child: Text(
|
|
|
|
926
|
+ '菜品:',
|
|
|
|
927
|
+ style: TextStyle(
|
|
|
|
928
|
+ color:
|
|
|
|
929
|
+ MyColours.color_515151,
|
|
|
|
930
|
+ fontSize:
|
|
|
|
931
|
+ ScreenUtil().setSp(32)),
|
|
|
|
932
|
+ ),
|
|
|
|
933
|
+ ),
|
|
|
|
934
|
+ VEmptyView(24),
|
|
|
|
935
|
+ Container(
|
|
|
|
936
|
+ margin: EdgeInsets.only(
|
|
|
|
937
|
+ right: w(20),
|
|
|
|
938
|
+ ),
|
|
|
|
939
|
+ decoration: BoxDecoration(
|
|
|
|
940
|
+ borderRadius:
|
|
|
|
941
|
+ BorderRadius.circular(
|
|
|
|
942
|
+ r(10)),
|
|
|
|
943
|
+ border: Border.all(
|
|
|
|
944
|
+ width: w(1),
|
|
|
|
945
|
+ color: MyColours
|
|
|
|
946
|
+ .color_DBDBDB)),
|
|
|
|
947
|
+ padding: EdgeInsets.only(
|
|
|
|
948
|
+ left: w(8), right: (w(8))),
|
|
|
|
949
|
+ child: TextField(
|
|
|
|
950
|
+ controller: dishControl,
|
|
|
|
951
|
+ textAlign: TextAlign.left,
|
|
|
|
952
|
+ textAlignVertical:
|
|
|
|
953
|
+ TextAlignVertical
|
|
|
|
954
|
+ .bottom,
|
|
|
|
955
|
+ maxLines: 5,
|
|
|
|
956
|
+ maxLength: 500,
|
|
|
|
957
|
+ // //光标颜色
|
|
|
|
958
|
+ // cursorColor:
|
|
|
|
959
|
+ // widget.isSelect ? Colors.white : MyColours.color_199095,
|
|
|
|
960
|
+ //输入文本的样式
|
|
|
|
961
|
+ style: TextStyle(
|
|
|
|
962
|
+ color: MyColours
|
|
|
|
963
|
+ .color_515151,
|
|
|
|
964
|
+ fontSize: ScreenUtil()
|
|
|
|
965
|
+ .setSp(32),
|
|
|
|
966
|
+ ),
|
|
|
|
967
|
+ focusNode: dishFocusNode,
|
|
|
|
968
|
+ decoration: InputDecoration(
|
|
|
|
969
|
+ isCollapsed: true,
|
|
|
|
970
|
+ border:
|
|
|
|
971
|
+ OutlineInputBorder(
|
|
|
|
972
|
+ borderSide:
|
|
|
|
973
|
+ BorderSide
|
|
|
|
974
|
+ .none),
|
|
|
|
975
|
+ hintText: '点击输入赠送菜品名称',
|
|
|
|
976
|
+ hintStyle: TextStyle(
|
|
|
|
977
|
+ color: MyColours
|
|
|
|
978
|
+ .color_999999,
|
|
|
|
979
|
+ fontSize: ScreenUtil()
|
|
|
|
980
|
+ .setSp(32),
|
|
|
|
981
|
+ ),
|
|
|
|
982
|
+ enabledBorder:
|
|
|
|
983
|
+ new UnderlineInputBorder(
|
|
|
|
984
|
+ borderSide:
|
|
|
|
985
|
+ BorderSide.none,
|
|
|
|
986
|
+ ),
|
|
|
|
987
|
+ focusedBorder:
|
|
|
|
988
|
+ new UnderlineInputBorder(
|
|
|
|
989
|
+ borderSide:
|
|
|
|
990
|
+ BorderSide.none,
|
|
|
|
991
|
+ ),
|
|
|
|
992
|
+ ),
|
|
|
|
993
|
+ onChanged: (value) {},
|
|
|
|
994
|
+ onEditingComplete: () {
|
|
|
|
995
|
+ // FocusScope.of(context)
|
|
|
|
996
|
+ // .requestFocus(
|
|
|
|
997
|
+ // FocusNode()); //点击空白处隐藏键盘
|
|
|
|
998
|
+ },
|
|
|
|
999
|
+ keyboardType: TextInputType
|
|
|
|
1000
|
+ .multiline)),
|
|
|
|
1001
|
+ ],
|
|
|
|
1002
|
+ ),
|
|
|
|
1003
|
+ ),
|
|
|
|
1004
|
+
|
|
|
|
1005
|
+ // _textfieldSelect('', '',
|
|
|
|
1006
|
+ // , ,
|
|
|
|
1007
|
+ // textInputType: TextInputType.text),
|
|
|
|
1008
|
+ if (dish) VEmptyView(20),
|
|
|
|
1009
|
+
|
|
|
|
1010
|
+ if (dish)
|
|
|
|
1011
|
+ Padding(
|
|
|
|
1012
|
+ padding: EdgeInsets.only(
|
|
|
|
1013
|
+ left: w(20), right: w(15)),
|
|
|
|
1014
|
+ child: Consumer<UploadImageProvider>(
|
|
|
|
1015
|
+ builder: (context, model, _) {
|
|
|
|
1016
|
+ return ImgPickerWidget(
|
|
|
|
1017
|
+ scrollController: controller,
|
|
|
|
1018
|
+ model: _uploadImageProvider,
|
|
|
|
1019
|
+ maxImageNumber: 3,
|
|
|
|
1020
|
+ maxRemind: '三',
|
|
|
|
1021
|
+ imageList: img,
|
|
|
|
1022
|
+ uploadType:
|
|
|
|
1023
|
+ UploadType.CouponDishType,
|
|
|
|
1024
|
+ deleteCallback: (int index) {
|
|
|
|
1025
|
+ img.removeWhere((element) =>
|
|
|
|
1026
|
+ element == img[index]);
|
|
|
|
1027
|
+ setState(() {});
|
|
|
|
1028
|
+ },
|
|
|
|
1029
|
+ callback: () {
|
|
|
|
1030
|
+ imgAll.add(img.last.qiniuUrl!);
|
|
|
|
1031
|
+ print('完成');
|
|
|
|
1032
|
+ // for (UploadImgModel item
|
|
|
|
1033
|
+ // in _uploadImageProvider
|
|
|
|
1034
|
+ // .tableImageList) {
|
|
|
|
1035
|
+ // if (item.process < 1) {
|
|
|
|
1036
|
+ // Utils.showToast('正在上传图片,请稍等');
|
|
|
|
1037
|
+ // return;
|
|
|
|
1038
|
+ // }
|
|
|
|
1039
|
+ // }
|
|
|
|
1040
|
+ // //接口,和桌子绑定
|
|
|
|
1041
|
+ // List imageQiniuUrlList = [];
|
|
|
|
1042
|
+ // for (int i = 0;
|
|
|
|
1043
|
+ // i <
|
|
|
|
1044
|
+ // _uploadImageProvider
|
|
|
|
1045
|
+ // .tableImageList.length;
|
|
|
|
1046
|
+ // i++) {
|
|
|
|
1047
|
+ // if (!_uploadImageProvider
|
|
|
|
1048
|
+ // .tableImageList[i].isUpload) {
|
|
|
|
1049
|
+ // imageQiniuUrlList.add({
|
|
|
|
1050
|
+ // "url": _uploadImageProvider
|
|
|
|
1051
|
+ // .tableImageList[i].qiniuUrl
|
|
|
|
1052
|
+ // });
|
|
|
|
1053
|
+ // }
|
|
|
|
1054
|
+ // }
|
|
|
|
1055
|
+ // _setTablePhoto(
|
|
|
|
1056
|
+ // context, imageQiniuUrlList);
|
|
|
|
1057
|
+ },
|
|
|
|
1058
|
+ );
|
|
|
|
1059
|
+ })),
|
|
|
|
1060
|
+ VEmptyView(48),
|
|
|
|
1061
|
+ Container(
|
|
|
|
1062
|
+ height: ScreenUtil().setWidth(2),
|
|
|
|
1063
|
+ color: MyColours.color_E7E7E7,
|
|
|
|
1064
|
+ ),
|
|
|
|
1065
|
+ ],
|
|
|
|
1066
|
+ ),
|
|
|
|
1067
|
+ _textfield('券要求', '例:无门槛/满2000元',
|
|
|
|
1068
|
+ _couponRequireEditControl, _requireFocusNode),
|
|
|
|
1069
|
+ Container(
|
|
|
|
1070
|
+ height: ScreenUtil().setWidth(2),
|
|
|
|
1071
|
+ color: MyColours.color_E7E7E7,
|
|
|
|
1072
|
+ ),
|
|
|
|
1073
|
+ VEmptyView(24),
|
|
|
|
1074
|
+ _select('活动开始于', fromDate, () {
|
|
|
|
1075
|
+ FocusScope.of(context)
|
|
|
|
1076
|
+ .requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
1077
|
+ //弹出时间选择器
|
|
|
|
1078
|
+ // showPickerDateTime(context);
|
|
|
|
1079
|
+ showDateSelWidget = true;
|
|
|
|
1080
|
+ DialogUtil.showPickerDateTime24(
|
|
|
|
1081
|
+ context,
|
|
|
|
1082
|
+ scaffoldKey,
|
|
|
|
1083
|
+ (value) {
|
|
|
|
1084
|
+ // {'text': picker.adapter.text, 'select': selecteds}
|
|
|
|
1085
|
+ if (value != null) {
|
|
|
|
1086
|
+ setState(() {
|
|
|
|
1087
|
+ print(value);
|
|
|
|
1088
|
+ fromDate = DateUtil.formatDateStr(
|
|
|
|
1089
|
+ value,
|
|
|
|
1090
|
+ format: DateFormats.y_mo_d);
|
|
|
|
1091
|
+ });
|
|
|
|
1092
|
+ }
|
|
|
|
1093
|
+ showDateSelWidget = false;
|
|
|
|
1094
|
+ },
|
|
|
|
1095
|
+ dateTime: fromDate == '点击选择'
|
|
|
|
1096
|
+ ? null
|
|
|
|
1097
|
+ : DateUtil.getDateTime(fromDate),
|
|
|
|
1098
|
+ pickerDateTimeType: PickerDateTimeType.kYMD,
|
|
|
|
1099
|
+ onCancel: () {
|
|
|
|
1100
|
+ showDateSelWidget = false;
|
|
|
|
1101
|
+ });
|
|
|
|
1102
|
+ }),
|
|
|
|
1103
|
+ Container(
|
|
|
|
1104
|
+ height: ScreenUtil().setWidth(2),
|
|
|
|
1105
|
+ color: MyColours.color_E7E7E7,
|
|
|
|
1106
|
+ ),
|
|
|
|
1107
|
+ VEmptyView(24),
|
|
|
|
1108
|
+ _select('活动结束于', endDate, () {
|
|
|
|
1109
|
+ FocusScope.of(context)
|
|
|
|
1110
|
+ .requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
1111
|
+ //弹出时间选择器
|
|
|
|
1112
|
+ // showPickerDateTime(context);
|
|
|
|
1113
|
+ showDateSelWidget = true;
|
|
|
|
1114
|
+ DialogUtil.showPickerDateTime24(
|
|
|
|
1115
|
+ context,
|
|
|
|
1116
|
+ scaffoldKey,
|
|
|
|
1117
|
+ (value) {
|
|
|
|
1118
|
+ // {'text': picker.adapter.text, 'select': selecteds}
|
|
|
|
1119
|
+ if (value != null) {
|
|
|
|
1120
|
+ setState(() {
|
|
|
|
1121
|
+ print(value);
|
|
|
|
1122
|
+ endDate = DateUtil.formatDateStr(
|
|
|
|
1123
|
+ value,
|
|
|
|
1124
|
+ format: DateFormats.y_mo_d);
|
|
|
|
1125
|
+ });
|
|
|
|
1126
|
+ }
|
|
|
|
1127
|
+ showDateSelWidget = false;
|
|
|
|
1128
|
+ },
|
|
|
|
1129
|
+ dateTime: endDate == '点击选择'
|
|
|
|
1130
|
+ ? null
|
|
|
|
1131
|
+ : DateUtil.getDateTime(endDate),
|
|
|
|
1132
|
+ pickerDateTimeType: PickerDateTimeType.kYMD,
|
|
|
|
1133
|
+ onCancel: () {
|
|
|
|
1134
|
+ showDateSelWidget = false;
|
|
|
|
1135
|
+ });
|
|
|
|
1136
|
+ }),
|
|
|
|
1137
|
+ Container(
|
|
|
|
1138
|
+ height: ScreenUtil().setWidth(2),
|
|
|
|
1139
|
+ color: MyColours.color_E7E7E7,
|
|
|
|
1140
|
+ ),
|
|
|
|
1141
|
+ VEmptyView(24),
|
|
|
|
1142
|
+ if (!widget.isMine)
|
|
|
|
1143
|
+ Column(
|
|
|
|
1144
|
+ children: [
|
|
|
|
1145
|
+ //使用限制
|
|
|
|
1146
|
+ VEmptyView(24),
|
|
|
|
1147
|
+ Container(
|
|
|
|
1148
|
+ alignment: Alignment.centerLeft,
|
|
|
|
1149
|
+ child: Text(
|
|
|
|
1150
|
+ '使用限制',
|
|
|
|
1151
|
+ style: TextStyle(
|
|
|
|
1152
|
+ color: Color.fromRGBO(0, 0, 0, 0.9),
|
|
|
|
1153
|
+ fontWeight: FontWeight.bold,
|
|
|
|
1154
|
+ fontSize: ScreenUtil().setSp(32)),
|
|
|
|
1155
|
+ ),
|
|
|
|
1156
|
+ ),
|
|
|
|
1157
|
+ VEmptyView(40),
|
|
|
|
1158
|
+ Row(
|
|
|
|
1159
|
+ children: [
|
|
|
|
1160
|
+ HEmptyView(30),
|
|
|
|
1161
|
+ _itemRadioWidget(limitNone, '无',
|
|
|
|
1162
|
+ onTap: () {
|
|
|
|
1163
|
+ if (!limitNone) {
|
|
|
|
1164
|
+ setState(() {
|
|
|
|
1165
|
+ limitNone = true;
|
|
|
|
1166
|
+
|
|
|
|
1167
|
+ limitWeek = false;
|
|
|
|
1168
|
+ limitBirthday = false;
|
|
|
|
1169
|
+ });
|
|
|
|
1170
|
+ }
|
|
|
|
1171
|
+ }),
|
|
|
|
1172
|
+ Spacer(),
|
|
|
|
1173
|
+ _itemRadioWidget(limitWeek, '每周',
|
|
|
|
1174
|
+ onTap: () {
|
|
|
|
1175
|
+ if (!limitWeek) {
|
|
|
|
1176
|
+ setState(() {
|
|
|
|
1177
|
+ limitWeek = true;
|
|
|
|
1178
|
+
|
|
|
|
1179
|
+ limitNone = false;
|
|
|
|
1180
|
+ limitBirthday = false;
|
|
|
|
1181
|
+ });
|
|
|
|
1182
|
+ }
|
|
|
|
1183
|
+ }),
|
|
|
|
1184
|
+ Spacer(),
|
|
|
|
1185
|
+ _itemRadioWidget(
|
|
|
|
1186
|
+ limitBirthday, '会员生日当天', onTap: () {
|
|
|
|
1187
|
+ if (!limitBirthday) {
|
|
|
|
1188
|
+ setState(() {
|
|
|
|
1189
|
+ limitBirthday = true;
|
|
|
|
1190
|
+ limitNone = false;
|
|
|
|
1191
|
+ limitWeek = false;
|
|
|
|
1192
|
+ });
|
|
|
|
1193
|
+ }
|
|
|
|
1194
|
+ }),
|
|
|
|
1195
|
+ HEmptyView(30),
|
|
|
|
1196
|
+ ],
|
|
|
|
1197
|
+ ),
|
|
|
|
1198
|
+ if (limitWeek) VEmptyView(30),
|
|
|
|
1199
|
+
|
|
|
|
1200
|
+ if (limitWeek)
|
|
|
|
1201
|
+ _select1(weekShow, '', () async {
|
|
|
|
1202
|
+ FocusScope.of(context).requestFocus(
|
|
|
|
1203
|
+ FocusNode()); //点击空白处隐藏键盘
|
|
|
|
1204
|
+ //弹出时间选择器
|
|
|
|
1205
|
+ // showPickerDateTime(context);
|
|
|
|
1206
|
+ showDateSelWidget = false;
|
|
|
|
1207
|
+
|
|
|
|
1208
|
+ List<FilterBtnModel> data = await DialogUtil
|
|
|
|
1209
|
+ .openCoponsWeekSelectModalBottomSheet(
|
|
|
|
1210
|
+ context, weekData);
|
|
|
|
1211
|
+ if (data != null) {
|
|
|
|
1212
|
+ //改变了
|
|
|
|
1213
|
+ weekData = [];
|
|
|
|
1214
|
+ weekData.addAll(data);
|
|
|
|
1215
|
+ weekShow = '';
|
|
|
|
1216
|
+
|
|
|
|
1217
|
+ String noonStr = '午餐:';
|
|
|
|
1218
|
+ String nightStr = '晚餐:';
|
|
|
|
1219
|
+
|
|
|
|
1220
|
+ weekData.forEach((element) {
|
|
|
|
1221
|
+ if (element.selectNoon!) {
|
|
|
|
1222
|
+ noonStr += '${element.title} ';
|
|
|
|
1223
|
+ }
|
|
|
|
1224
|
+ if (element.selectNig!) {
|
|
|
|
1225
|
+ nightStr += '${element.title} ';
|
|
|
|
1226
|
+ }
|
|
|
|
1227
|
+ });
|
|
|
|
1228
|
+ if (noonStr.endsWith(' ')) {
|
|
|
|
1229
|
+ noonStr = noonStr.substring(
|
|
|
|
1230
|
+ 0, noonStr.length - 1);
|
|
|
|
1231
|
+ }
|
|
|
|
1232
|
+ if (nightStr.endsWith(' ')) {
|
|
|
|
1233
|
+ nightStr = nightStr.substring(
|
|
|
|
1234
|
+ 0, nightStr.length - 1);
|
|
|
|
1235
|
+ }
|
|
|
|
1236
|
+
|
|
|
|
1237
|
+ if (noonStr == '午餐:' &&
|
|
|
|
1238
|
+ nightStr == '晚餐:') {
|
|
|
|
1239
|
+ weekShow = '点击设置可用日期';
|
|
|
|
1240
|
+ } else {
|
|
|
|
1241
|
+ if (noonStr != '午餐:' &&
|
|
|
|
1242
|
+ nightStr != '晚餐:') {
|
|
|
|
1243
|
+ weekShow =
|
|
|
|
1244
|
+ noonStr + '\n' + nightStr;
|
|
|
|
1245
|
+ } else if (noonStr != '午餐:') {
|
|
|
|
1246
|
+ weekShow = noonStr;
|
|
|
|
1247
|
+ } else {
|
|
|
|
1248
|
+ weekShow = nightStr;
|
|
|
|
1249
|
+ }
|
|
|
|
1250
|
+ }
|
|
|
|
1251
|
+
|
|
|
|
1252
|
+ setState(() {});
|
|
|
|
1253
|
+ }
|
|
|
|
1254
|
+ }),
|
|
|
|
1255
|
+ limitWeek ? VEmptyView(22) : VEmptyView(48),
|
|
|
|
1256
|
+ Container(
|
|
|
|
1257
|
+ height: ScreenUtil().setWidth(2),
|
|
|
|
1258
|
+ color: MyColours.color_E7E7E7,
|
|
|
|
1259
|
+ ),
|
|
|
|
1260
|
+ VEmptyView(48),
|
|
|
|
1261
|
+ ],
|
|
|
|
1262
|
+ ),
|
|
|
|
1263
|
+ widget.isMine
|
|
|
|
1264
|
+ ? SizedBox()
|
|
|
|
1265
|
+ : _select('谁可以发放', '编辑', () async {
|
|
|
|
1266
|
+ Map temp = await NavigatorUtil
|
|
|
|
1267
|
+ .goCouponToPersonnalPage(
|
|
|
|
1268
|
+ context, uids);
|
|
|
|
1269
|
+ if (temp != null &&
|
|
|
|
1270
|
+ temp['object'] != null) {
|
|
|
|
1271
|
+ uids = temp['object'];
|
|
|
|
1272
|
+ }
|
|
|
|
1273
|
+ }),
|
|
|
|
1274
|
+ widget.isMine
|
|
|
|
1275
|
+ ? SizedBox()
|
|
|
|
1276
|
+ : Container(
|
|
|
|
1277
|
+ height: ScreenUtil().setWidth(2),
|
|
|
|
1278
|
+ color: MyColours.color_E7E7E7,
|
|
|
|
1279
|
+ ),
|
|
|
|
1280
|
+ widget.isMine ? SizedBox() : VEmptyView(24),
|
|
|
|
1281
|
+ widget.isMine
|
|
|
|
1282
|
+ ? SizedBox()
|
|
|
|
1283
|
+ : _textfield('发放总量限制', '点击输入总数量限制',
|
|
|
|
1284
|
+ _limitNumControl, _limitNumFocusNode,
|
|
|
|
1285
|
+ textInputType: TextInputType.number),
|
|
|
|
1286
|
+ widget.isMine
|
|
|
|
1287
|
+ ? SizedBox()
|
|
|
|
1288
|
+ : Container(
|
|
|
|
1289
|
+ height: ScreenUtil().setWidth(2),
|
|
|
|
1290
|
+ color: MyColours.color_E7E7E7,
|
|
|
|
1291
|
+ ),
|
|
|
|
1292
|
+ widget.isMine ? SizedBox() : VEmptyView(24),
|
|
|
|
1293
|
+ _explain('券说明', '例:可用包间,停车免费,不与店内其他活动共享等'),
|
|
|
|
1294
|
+ VEmptyView(20),
|
|
|
|
1295
|
+ _canUse('立即启用', swichState, () {
|
|
|
|
1296
|
+ setState(() {
|
|
|
|
1297
|
+ swichState = !swichState;
|
|
|
|
1298
|
+ });
|
|
|
|
1299
|
+ }),
|
|
|
|
1300
|
+ VEmptyView(30),
|
|
|
|
1301
|
+ ],
|
|
|
|
1302
|
+ ))),
|
|
|
|
1303
|
+ ),
|
|
|
|
1304
|
+ VEmptyView(20),
|
|
|
|
1305
|
+ RoundButton(
|
|
|
|
1306
|
+ onPressed: () {
|
|
|
|
1307
|
+ print(img);
|
|
|
|
1308
|
+ bool can = true;
|
|
|
|
1309
|
+ innerloop:
|
|
|
|
1310
|
+ for (UploadImgModel item in img) {
|
|
|
|
1311
|
+ if (item.process! < 1) {
|
|
|
|
1312
|
+ Utils.showToast('正在上传图片,请稍等');
|
|
|
|
1313
|
+ // return false;
|
|
|
|
1314
|
+ can = false;
|
|
|
|
1315
|
+ break innerloop;
|
|
|
|
1316
|
+ }
|
|
|
|
1317
|
+ }
|
|
|
|
1318
|
+ if (can) {
|
|
|
|
1319
|
+ if (_couponNameEditControl.text.trim().length == 0) {
|
|
|
|
1320
|
+ Utils.showToast('请输入券名称');
|
|
|
|
1321
|
+ return;
|
|
|
|
1322
|
+ }
|
|
|
|
1323
|
+ if (_priceControl.text.trim().length == 0 ||
|
|
|
|
1324
|
+ _priceControl.text.trim() == '0') {
|
|
|
|
1325
|
+ Utils.showToast('请输入销售价,且必须大于0');
|
|
|
|
1326
|
+ return;
|
|
|
|
1327
|
+ }
|
|
|
|
1328
|
+ if (!widget.isMine) {
|
|
|
|
1329
|
+ if (money && moneyControl.text.trim().length == 0) {
|
|
|
|
1330
|
+ Utils.showToast('请输入代金券金额!');
|
|
|
|
1331
|
+ return;
|
|
|
|
1332
|
+ }
|
|
|
|
1333
|
+ if (discount &&
|
|
|
|
1334
|
+ discountControl.text.trim().length == 0) {
|
|
|
|
1335
|
+ Utils.showToast('请输入折扣率!');
|
|
|
|
1336
|
+ return;
|
|
|
|
1337
|
+ }
|
|
|
|
1338
|
+ if (dish && dishControl.text.trim().length == 0) {
|
|
|
|
1339
|
+ Utils.showToast('请输入菜品!');
|
|
|
|
1340
|
+ return;
|
|
|
|
1341
|
+ }
|
|
|
|
1342
|
+
|
|
|
|
1343
|
+ if (limitWeek && weekShow == '点击设置可用日期') {
|
|
|
|
1344
|
+ Utils.showToast('请设置可用日期!');
|
|
|
|
1345
|
+ return;
|
|
|
|
1346
|
+ }
|
|
|
|
1347
|
+ if (uids == null || uids == '') {
|
|
|
|
1348
|
+ Utils.showToast('请设置发放人!');
|
|
|
|
1349
|
+ return;
|
|
|
|
1350
|
+ }
|
|
|
|
1351
|
+
|
|
|
|
1352
|
+ bool isNumber = Utils.isInteger(
|
|
|
|
1353
|
+ _limitNumControl.text.trim()); //判断输入的内容是否是数字
|
|
|
|
1354
|
+ if (!isNumber) {
|
|
|
|
1355
|
+ Utils.showToast('发放总量限制请输入数字');
|
|
|
|
1356
|
+ _limitNumControl.text = '';
|
|
|
|
1357
|
+ return;
|
|
|
|
1358
|
+ }
|
|
|
|
1359
|
+ }
|
|
|
|
1360
|
+ if (_couponRequireEditControl.text.trim().length == 0) {
|
|
|
|
1361
|
+ Utils.showToast('请填写券要求');
|
|
|
|
1362
|
+ return;
|
|
|
|
1363
|
+ }
|
|
|
|
1364
|
+ if (fromDate == '点击选择') {
|
|
|
|
1365
|
+ Utils.showToast('请选择有效期起始时间');
|
|
|
|
1366
|
+ return;
|
|
|
|
1367
|
+ }
|
|
|
|
1368
|
+ if (endDate == '点击选择') {
|
|
|
|
1369
|
+ Utils.showToast('请选择有效期结束时间');
|
|
|
|
1370
|
+ return;
|
|
|
|
1371
|
+ }
|
|
|
|
1372
|
+ if (DateUtil.getDateTime(endDate)
|
|
|
|
1373
|
+ .compareTo(DateUtil.getDateTime(fromDate)) <
|
|
|
|
1374
|
+ 0) {
|
|
|
|
1375
|
+ Utils.showToast('有效期结束时间不能早于起始时间');
|
|
|
|
1376
|
+ return;
|
|
|
|
1377
|
+ }
|
|
|
|
1378
|
+
|
|
|
|
1379
|
+ // ***参数***
|
|
|
|
1380
|
+ // _couponNameEditControl.text
|
|
|
|
1381
|
+ // _couponRequireEditControl.text
|
|
|
|
1382
|
+ // fromDate
|
|
|
|
1383
|
+ // endDate
|
|
|
|
1384
|
+ // _couponExplainEditControl.text
|
|
|
|
1385
|
+ // swichState
|
|
|
|
1386
|
+ _createNewCoupon();
|
|
|
|
1387
|
+ }
|
|
|
|
1388
|
+ },
|
|
|
|
1389
|
+ text: '立即创建',
|
|
|
|
1390
|
+ fontSize: 24,
|
|
|
|
1391
|
+ isBold: false,
|
|
|
|
1392
|
+ height: ScreenUtil().setWidth(37 * 2),
|
|
|
|
1393
|
+ width: ScreenUtil().setWidth(130 * 2),
|
|
|
|
1394
|
+ radius: ScreenUtil().setWidth(22),
|
|
|
|
1395
|
+ ),
|
|
|
|
1396
|
+ VEmptyView(32)
|
|
|
|
1397
|
+ ]))),
|
|
|
|
1398
|
+ );
|
|
|
|
1399
|
+ }
|
|
|
|
1400
|
+} |