|
|
|
import 'dart:convert';
|
|
|
|
|
|
|
|
import 'package:common_utils/common_utils.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:flutter_picker_plus/picker.dart';
|
|
|
|
// import 'package:flutter_picker/flutter_picker.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:fluttertoast/fluttertoast.dart';
|
|
|
|
import 'package:one_key/constant/constant.dart';
|
|
|
|
import 'package:one_key/provider/coupon_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/event_bus.dart';
|
|
|
|
import 'package:one_key/route/navigator_util.dart';
|
|
|
|
import 'package:one_key/utils/utils.dart';
|
|
|
|
import 'package:one_key/widgets/MyDivider.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';
|
|
|
|
|
|
|
|
import '../../models/coupon_model.dart';
|
|
|
|
import '../../models/filter_btn_model.dart';
|
|
|
|
import '../../models/upload_img_model.dart';
|
|
|
|
import '../../provider/upload_img_provider.dart';
|
|
|
|
import '../../utils/screen_util.dart';
|
|
|
|
import '../../utils/upload_image_util.dart';
|
|
|
|
import '../online_check/img_picker_widget.dart';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 新建券
|
|
|
|
*/
|
|
|
|
|
|
|
|
class CouponEidtPayPage extends StatefulWidget {
|
|
|
|
final bool isMine;
|
|
|
|
final CouponSunModel? couponSunModel;
|
|
|
|
CouponEidtPayPage({Key? key, this.isMine = true, this.couponSunModel})
|
|
|
|
: super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
_CouponEidtPayPageState createState() => _CouponEidtPayPageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _CouponEidtPayPageState extends State<CouponEidtPayPage> {
|
|
|
|
ScrollController controller = ScrollController();
|
|
|
|
TextEditingController _couponNameEditControl = TextEditingController();
|
|
|
|
TextEditingController _couponRequireEditControl = TextEditingController();
|
|
|
|
TextEditingController _couponExplainEditControl = TextEditingController();
|
|
|
|
TextEditingController _limitNumControl = TextEditingController();
|
|
|
|
FocusNode _limitNumFocusNode = FocusNode();
|
|
|
|
final heightCell = ScreenUtil().setWidth(48 * 2);
|
|
|
|
bool swichState = true; //默认启用 开关状态
|
|
|
|
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
|
|
|
|
String fromDate = '点击选择'; //有效期开始时间
|
|
|
|
String endDate = '点击选择'; //有效期结束时间
|
|
|
|
FocusNode _nameFocusNode = FocusNode();
|
|
|
|
FocusNode _requireFocusNode = FocusNode();
|
|
|
|
bool showDateSelWidget = false;
|
|
|
|
CouponProvider? couponProvider;
|
|
|
|
// bool swichHexiao = true; //默认启用 核销状态
|
|
|
|
String uids = '';
|
|
|
|
TextEditingController _priceControl = TextEditingController();
|
|
|
|
FocusNode _priceFocusNode = FocusNode();
|
|
|
|
|
|
|
|
bool money = true;
|
|
|
|
bool discount = false;
|
|
|
|
bool dish = false;
|
|
|
|
|
|
|
|
TextEditingController moneyControl = TextEditingController();
|
|
|
|
TextEditingController discountControl = TextEditingController();
|
|
|
|
TextEditingController dishControl = TextEditingController();
|
|
|
|
|
|
|
|
FocusNode moneyFocusNode = FocusNode();
|
|
|
|
FocusNode discountFocusNode = FocusNode();
|
|
|
|
FocusNode dishFocusNode = FocusNode();
|
|
|
|
|
|
|
|
bool limitNone = true;
|
|
|
|
bool limitWeek = false;
|
|
|
|
bool limitBirthday = false;
|
|
|
|
String weekShow = '点击设置可用日期';
|
|
|
|
List<FilterBtnModel> weekData = [];
|
|
|
|
|
|
|
|
// morning == "00:00-00:00"
|
|
|
|
String? morning;
|
|
|
|
String? noon;
|
|
|
|
String? night;
|
|
|
|
|
|
|
|
UploadImageProvider? _uploadImageProvider;
|
|
|
|
List<UploadImgModel> img = [];
|
|
|
|
|
|
|
|
List<String> imgAll = [];
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
_nameFocusNode.addListener(() {
|
|
|
|
if (_nameFocusNode.hasFocus) {
|
|
|
|
//有焦点
|
|
|
|
if (showDateSelWidget) {
|
|
|
|
if (Navigator.canPop(context)) {
|
|
|
|
Navigator.pop(context);
|
|
|
|
}
|
|
|
|
showDateSelWidget = false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//失去焦点
|
|
|
|
// _editingController.text = '';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
_requireFocusNode.addListener(() {
|
|
|
|
if (_requireFocusNode.hasFocus) {
|
|
|
|
//有焦点
|
|
|
|
if (showDateSelWidget) {
|
|
|
|
if (Navigator.canPop(context)) {
|
|
|
|
Navigator.pop(context);
|
|
|
|
}
|
|
|
|
showDateSelWidget = false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//失去焦点
|
|
|
|
// _editingController.text = '';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
_priceFocusNode.addListener(() {
|
|
|
|
if (_priceFocusNode.hasFocus) {
|
|
|
|
//有焦点
|
|
|
|
if (showDateSelWidget) {
|
|
|
|
if (Navigator.canPop(context)) {
|
|
|
|
Navigator.pop(context);
|
|
|
|
}
|
|
|
|
showDateSelWidget = false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//失去焦点
|
|
|
|
// _editingController.text = '';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
moneyFocusNode.addListener(() {
|
|
|
|
if (moneyFocusNode.hasFocus) {
|
|
|
|
//有焦点
|
|
|
|
if (showDateSelWidget) {
|
|
|
|
if (Navigator.canPop(context)) {
|
|
|
|
Navigator.pop(context);
|
|
|
|
}
|
|
|
|
showDateSelWidget = false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//失去焦点
|
|
|
|
// _editingController.text = '';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
discountFocusNode.addListener(() {
|
|
|
|
if (discountFocusNode.hasFocus) {
|
|
|
|
//有焦点
|
|
|
|
if (showDateSelWidget) {
|
|
|
|
if (Navigator.canPop(context)) {
|
|
|
|
Navigator.pop(context);
|
|
|
|
}
|
|
|
|
showDateSelWidget = false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//失去焦点
|
|
|
|
// _editingController.text = '';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
dishFocusNode.addListener(() {
|
|
|
|
if (dishFocusNode.hasFocus) {
|
|
|
|
//有焦点
|
|
|
|
if (showDateSelWidget) {
|
|
|
|
if (Navigator.canPop(context)) {
|
|
|
|
Navigator.pop(context);
|
|
|
|
}
|
|
|
|
showDateSelWidget = false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//失去焦点
|
|
|
|
// _editingController.text = '';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
if (widget.couponSunModel != null) {
|
|
|
|
_couponNameEditControl.text = widget.couponSunModel!.aname ?? '';
|
|
|
|
_couponRequireEditControl.text = widget.couponSunModel!.desc ?? '';
|
|
|
|
_couponExplainEditControl.text = widget.couponSunModel!.explain ?? '';
|
|
|
|
DateTime dateTimes = DateTime.fromMillisecondsSinceEpoch(
|
|
|
|
int.parse(widget.couponSunModel!.stime.toString()) * 1000);
|
|
|
|
fromDate = DateUtil.formatDate(dateTimes, format: DateFormats.y_mo_d);
|
|
|
|
DateTime dateTimee = DateTime.fromMillisecondsSinceEpoch(
|
|
|
|
int.parse(widget.couponSunModel!.etime.toString()) * 1000);
|
|
|
|
endDate = DateUtil.formatDate(dateTimee, format: DateFormats.y_mo_d);
|
|
|
|
|
|
|
|
swichState = widget.couponSunModel!.status == '1' ? true : false;
|
|
|
|
|
|
|
|
if (widget.isMine) {
|
|
|
|
//我的优惠券
|
|
|
|
} else {
|
|
|
|
//店铺
|
|
|
|
// swichHexiao = widget.couponSunModel!.isExamine == '1' ? true : false;
|
|
|
|
_priceControl.text = widget.couponSunModel!.price ?? '';
|
|
|
|
|
|
|
|
money = widget.couponSunModel!.use!.isCash;
|
|
|
|
dish = widget.couponSunModel!.use!.isDish;
|
|
|
|
discount = widget.couponSunModel!.use!.isDiscount;
|
|
|
|
moneyControl.text = widget.couponSunModel!.use!.cash ?? '';
|
|
|
|
discountControl.text = widget.couponSunModel!.use!.discount ?? '';
|
|
|
|
dishControl.text = widget.couponSunModel!.use!.dish ?? '';
|
|
|
|
|
|
|
|
if (widget.couponSunModel!.use!.images.length > 0) {
|
|
|
|
widget.couponSunModel!.use!.images.forEach((element) {
|
|
|
|
UploadImgModel uploadImgModel = UploadImgModel();
|
|
|
|
uploadImgModel.qiniuUrl = element;
|
|
|
|
uploadImgModel.process = 1;
|
|
|
|
img.add(uploadImgModel);
|
|
|
|
imgAll.add(element); //初始化数据,同步数据库数据
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
limitNone = widget.couponSunModel!.expDate!.isNone ? true : false;
|
|
|
|
limitBirthday =
|
|
|
|
widget.couponSunModel!.expDate!.isBirthday ? true : false;
|
|
|
|
limitWeek = widget.couponSunModel!.expDate!.isWeek ? true : false;
|
|
|
|
|
|
|
|
weekShow = widget.couponSunModel!.expDate!.weekShow ?? '点击设置可用日期';
|
|
|
|
weekData = widget.couponSunModel!.expDate!.weekData ?? [];
|
|
|
|
uids = widget.couponSunModel!.uidList ?? '';
|
|
|
|
_limitNumControl.text = widget.couponSunModel!.grantNum ?? '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
// _couponNetworkData(0);
|
|
|
|
if (weekData.length == 0) {
|
|
|
|
_initWeekData();
|
|
|
|
}
|
|
|
|
|
|
|
|
_getQiniuInfo();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
super.dispose();
|
|
|
|
|
|
|
|
_uploadImageProvider!.qiniuInfoSunModel!.token = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
///获取七牛云token
|
|
|
|
///
|
|
|
|
_getQiniuInfo() async {
|
|
|
|
await _uploadImageProvider!.getQiniuInfo(context, {});
|
|
|
|
}
|
|
|
|
|
|
|
|
// //初始化时间
|
|
|
|
// initWeekData() async {
|
|
|
|
// // UserModel userModel = Provider.of<UserModel>(context, listen: false);
|
|
|
|
|
|
|
|
// // morning =
|
|
|
|
// // userModel.user.morning.isEmpty ? "00:00-00:00" : userModel.user.morning;
|
|
|
|
// // noon = userModel.user.noon.isEmpty ? "00:00-00:00" : userModel.user.noon;
|
|
|
|
// // night = userModel.user.night.isEmpty ? "00:00-00:00" : userModel.user.night;
|
|
|
|
// // if (morning != "00:00-00:00") {
|
|
|
|
// // //开通早餐
|
|
|
|
// // }
|
|
|
|
// // if (morning != "00:00-00:00") {
|
|
|
|
// // //开通午餐
|
|
|
|
// // }
|
|
|
|
// // if (morning != "00:00-00:00") {
|
|
|
|
// // //开通晚餐
|
|
|
|
// // }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
_initWeekData() {
|
|
|
|
FilterBtnModel filterBtnModel = FilterBtnModel();
|
|
|
|
filterBtnModel.selectNoon = false;
|
|
|
|
filterBtnModel.selectNig = false;
|
|
|
|
filterBtnModel.title = '周日';
|
|
|
|
weekData.add(filterBtnModel);
|
|
|
|
for (int i = 1; i < 7; i++) {
|
|
|
|
FilterBtnModel filterBtnModel = FilterBtnModel();
|
|
|
|
filterBtnModel.selectNoon = false;
|
|
|
|
filterBtnModel.selectNig = false;
|
|
|
|
filterBtnModel.title = '周${Utils.formatWeekDayNum(i)}';
|
|
|
|
weekData.add(filterBtnModel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//创建新券 客户经理创建活动
|
|
|
|
_createNewCoupon() async {
|
|
|
|
FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
|
|
|
|
String from = fromDate + ' 00:00:00';
|
|
|
|
String end = endDate + ' 23:59:59';
|
|
|
|
Map<String, String> params = {
|
|
|
|
"uid": Provider.of<UserModel>(context, listen: false).user!.openid!,
|
|
|
|
"aname": _couponNameEditControl.text.trim(),
|
|
|
|
"desc": _couponRequireEditControl.text.trim(),
|
|
|
|
"stime": fromDate == '点击选择'
|
|
|
|
? ""
|
|
|
|
: '${(DateUtil.getDateMsByTimeStr(from)! / 1000).floor()}',
|
|
|
|
"etime": endDate == '点击选择'
|
|
|
|
? ''
|
|
|
|
: '${(DateUtil.getDateMsByTimeStr(end)! / 1000).floor()}',
|
|
|
|
"explain": _couponExplainEditControl.text,
|
|
|
|
"is_open": swichState ? "1" : "0",
|
|
|
|
"status": swichState ? "1" : "0",
|
|
|
|
'is_type': widget.isMine ? "2" : "1"
|
|
|
|
};
|
|
|
|
List<String> images = [];
|
|
|
|
if (!widget.isMine) {
|
|
|
|
params['is_examine'] = "1";
|
|
|
|
params['uid_list'] = uids;
|
|
|
|
params['price'] =
|
|
|
|
_priceControl.text.trim().length == 0 ? '0' : _priceControl.text;
|
|
|
|
|
|
|
|
if (img.length > 0) {
|
|
|
|
img.forEach((value) {
|
|
|
|
images.add(value.qiniuUrl!);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
Map use = {
|
|
|
|
'is_cash': money ? '1' : '0',
|
|
|
|
'is_discount': discount ? '1' : '0',
|
|
|
|
'is_dish': dish ? '1' : '0',
|
|
|
|
'cash': moneyControl.text,
|
|
|
|
'discount': discountControl.text,
|
|
|
|
'dish': dishControl.text,
|
|
|
|
'images': json.encode(images)
|
|
|
|
};
|
|
|
|
params['use'] = jsonEncode(use);
|
|
|
|
|
|
|
|
Map expDate = {
|
|
|
|
'is_none': limitNone ? '1' : '0',
|
|
|
|
'is_week': limitWeek ? '1' : '0',
|
|
|
|
'is_birthday': limitBirthday ? '1' : '0',
|
|
|
|
'week_show': weekShow,
|
|
|
|
'week_data': weekData
|
|
|
|
};
|
|
|
|
params['exp_date'] = jsonEncode(expDate);
|
|
|
|
|
|
|
|
if (_limitNumControl.text.trim().length == 0) {
|
|
|
|
params['grant_num'] = '1000';
|
|
|
|
} else {
|
|
|
|
params['grant_num'] = _limitNumControl.text;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool isSuccess =
|
|
|
|
await couponProvider!.createCustomerActivity(context, params);
|
|
|
|
if (isSuccess) {
|
|
|
|
if (!widget.isMine) {
|
|
|
|
// imgAll和images 比较,挑出不一样的,删除七牛云
|
|
|
|
Set<String> difference = Set.from(imgAll)..removeAll(images);
|
|
|
|
List<String> differenceList = difference.toList(); //需要删除的图片
|
|
|
|
if (differenceList.length > 0) {
|
|
|
|
String delImgs = Utils.listToStringEnglish(differenceList);
|
|
|
|
|
|
|
|
_uploadImageProvider!.deleteImg(context, delImgs, needToast: false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//成功之后跳回前一个页面
|
|
|
|
// bus.emit('refresh_coupon_list');
|
|
|
|
EventBus().emit('refresh_coupon_invitation');
|
|
|
|
bus.emit('refresh_coupon_list_f');
|
|
|
|
// bus.emit('refresh_marketting_page');
|
|
|
|
|
|
|
|
bus.emit('refresh_table_m_coupon');
|
|
|
|
bus.emit('refresh_wine_msg');
|
|
|
|
if (Navigator.canPop(context)) {
|
|
|
|
Navigator.pop(context, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///输入框
|
|
|
|
Widget _textfield(String title, String hintText,
|
|
|
|
TextEditingController controller, FocusNode focusNode,
|
|
|
|
{TextInputType textInputType = TextInputType.text}) {
|
|
|
|
return Container(
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
child: Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Color.fromRGBO(0, 0, 0, 0.9),
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
HEmptyView(80),
|
|
|
|
Expanded(
|
|
|
|
// width: ScreenUtil().setWidth(231 * 2),
|
|
|
|
child: TextField(
|
|
|
|
controller: controller,
|
|
|
|
textAlign: TextAlign.right,
|
|
|
|
textAlignVertical: TextAlignVertical.bottom,
|
|
|
|
maxLines: 1,
|
|
|
|
// //光标颜色
|
|
|
|
// cursorColor:
|
|
|
|
// widget.isSelect ? Colors.white : MyColours.color_199095,
|
|
|
|
//输入文本的样式
|
|
|
|
inputFormatters: title == '券名称'
|
|
|
|
? [LengthLimitingTextInputFormatter(15)]
|
|
|
|
: title == '销售价'
|
|
|
|
? [FilteringTextInputFormatter.digitsOnly]
|
|
|
|
: [],
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_515151,
|
|
|
|
fontSize: ScreenUtil().setSp(32),
|
|
|
|
),
|
|
|
|
focusNode: focusNode,
|
|
|
|
decoration: InputDecoration(
|
|
|
|
border: OutlineInputBorder(borderSide: BorderSide.none),
|
|
|
|
hintText: hintText,
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
color: MyColours.color_999999,
|
|
|
|
fontSize: ScreenUtil().setSp(32),
|
|
|
|
),
|
|
|
|
enabledBorder: new UnderlineInputBorder(
|
|
|
|
borderSide: BorderSide.none,
|
|
|
|
),
|
|
|
|
focusedBorder: new UnderlineInputBorder(
|
|
|
|
borderSide: BorderSide.none,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
onChanged: (value) {},
|
|
|
|
onEditingComplete: () {
|
|
|
|
FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
},
|
|
|
|
keyboardType: textInputType),
|
|
|
|
),
|
|
|
|
HEmptyView(32)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
///输入框
|
|
|
|
Widget _textfieldSelect(
|
|
|
|
String title,
|
|
|
|
String hintText,
|
|
|
|
TextEditingController controller,
|
|
|
|
FocusNode focusNode, {
|
|
|
|
TextInputType textInputType = TextInputType.text,
|
|
|
|
String subtitle = '',
|
|
|
|
}) {
|
|
|
|
return Container(
|
|
|
|
padding: EdgeInsets.only(left: w(20), right: (w(20))),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
child: Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_515151,
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
HEmptyView(40),
|
|
|
|
Expanded(
|
|
|
|
child: TextField(
|
|
|
|
controller: controller,
|
|
|
|
textAlign: TextAlign.right,
|
|
|
|
textAlignVertical: TextAlignVertical.bottom,
|
|
|
|
maxLines: 1,
|
|
|
|
// //光标颜色
|
|
|
|
// cursorColor:
|
|
|
|
// widget.isSelect ? Colors.white : MyColours.color_199095,
|
|
|
|
//输入文本的样式
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_515151,
|
|
|
|
fontSize: ScreenUtil().setSp(32),
|
|
|
|
),
|
|
|
|
focusNode: focusNode,
|
|
|
|
decoration: InputDecoration(
|
|
|
|
isCollapsed: true,
|
|
|
|
border: OutlineInputBorder(borderSide: BorderSide.none),
|
|
|
|
hintText: hintText,
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
color: MyColours.color_999999,
|
|
|
|
fontSize: ScreenUtil().setSp(32),
|
|
|
|
),
|
|
|
|
enabledBorder: new UnderlineInputBorder(
|
|
|
|
borderSide: BorderSide.none,
|
|
|
|
),
|
|
|
|
focusedBorder: new UnderlineInputBorder(
|
|
|
|
borderSide: BorderSide.none,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
onChanged: (value) {},
|
|
|
|
onEditingComplete: () {
|
|
|
|
FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
},
|
|
|
|
keyboardType: textInputType),
|
|
|
|
),
|
|
|
|
if (subtitle != '') HEmptyView(6),
|
|
|
|
Text(
|
|
|
|
subtitle,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_515151,
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
///时间选择
|
|
|
|
Widget _select(String title, String hintText, GestureTapCallback onTap) {
|
|
|
|
return InkWell(
|
|
|
|
onTap: onTap,
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.symmetric(vertical: ScreenUtil().setWidth(28)),
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
// height: ScreenUtil().setWidth(40),
|
|
|
|
// color: Colors.red,
|
|
|
|
child: Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Color.fromRGBO(0, 0, 0, 0.9),
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
HEmptyView(20),
|
|
|
|
Spacer(),
|
|
|
|
Text(hintText,
|
|
|
|
style: TextStyle(
|
|
|
|
color: hintText == '点击选择'
|
|
|
|
? MyColours.color_999999
|
|
|
|
: MyColours.color_515151,
|
|
|
|
fontSize: ScreenUtil().setSp(32),
|
|
|
|
)),
|
|
|
|
HEmptyView(20),
|
|
|
|
Image.asset(
|
|
|
|
Utils.getImgPath('arrow_right_new'),
|
|
|
|
width: ScreenUtil().setWidth(20),
|
|
|
|
),
|
|
|
|
HEmptyView(32),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
///券说明
|
|
|
|
Widget _explain(String title, String hintText) {
|
|
|
|
return Container(
|
|
|
|
// height: ScreenUtil().setWidth(380),
|
|
|
|
padding: EdgeInsets.symmetric(vertical: ScreenUtil().setWidth(28)),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Align(
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Text(
|
|
|
|
title,
|
|
|
|
textAlign: TextAlign.left,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Color.fromRGBO(0, 0, 0, 0.9),
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
)),
|
|
|
|
VEmptyView(26),
|
|
|
|
Container(
|
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
TextField(
|
|
|
|
controller: _couponExplainEditControl,
|
|
|
|
// keyboardType: TextInputType.number, //键盘类型,数字键盘
|
|
|
|
maxLines: 3,
|
|
|
|
maxLength: 50,
|
|
|
|
|
|
|
|
// maxLengthEnforced: true,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: ScreenUtil().setSp(32),
|
|
|
|
color: MyColours.color_333333), //输入文本的样式
|
|
|
|
decoration: InputDecoration(
|
|
|
|
contentPadding: EdgeInsets.all(ScreenUtil().setWidth(30)),
|
|
|
|
hintText: hintText,
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
color: MyColours.color_999999,
|
|
|
|
fontSize: ScreenUtil().setSp(32),
|
|
|
|
),
|
|
|
|
|
|
|
|
border: OutlineInputBorder(borderSide: BorderSide.none),
|
|
|
|
|
|
|
|
enabledBorder: new UnderlineInputBorder(
|
|
|
|
borderSide: BorderSide.none,
|
|
|
|
),
|
|
|
|
focusedBorder: new UnderlineInputBorder(
|
|
|
|
borderSide: BorderSide.none,
|
|
|
|
),
|
|
|
|
|
|
|
|
// fillColor: MyColours.color_F9F9F9,
|
|
|
|
// // fillColor: Colors.red,
|
|
|
|
// filled: true,
|
|
|
|
// enabledBorder: OutlineInputBorder(
|
|
|
|
// //未选中时候的颜色
|
|
|
|
// borderRadius: BorderRadius.circular(ScreenUtil().setWidth(20)),
|
|
|
|
// borderSide: BorderSide(
|
|
|
|
// color: MyColours.color_cccccc,
|
|
|
|
// width: ScreenUtil().setWidth(2)),
|
|
|
|
// ),
|
|
|
|
// focusedBorder: OutlineInputBorder(
|
|
|
|
// //选中时外边框颜色
|
|
|
|
// borderRadius: BorderRadius.circular(ScreenUtil().setWidth(20)),
|
|
|
|
// borderSide: BorderSide(
|
|
|
|
// color: MyColours.app_main,
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// border: OutlineInputBorder(
|
|
|
|
// borderRadius:
|
|
|
|
// BorderRadius.circular(ScreenUtil().setWidth(20)),
|
|
|
|
// borderSide: BorderSide(
|
|
|
|
// color: Colors.red, width: ScreenUtil().setWidth(2))),
|
|
|
|
),
|
|
|
|
onChanged: (value) {},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
///是否立即启用
|
|
|
|
Widget _canUse(String title, bool swich, GestureTapCallback onTap) {
|
|
|
|
return InkWell(
|
|
|
|
onTap: onTap,
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.symmetric(vertical: ScreenUtil().setWidth(24)),
|
|
|
|
margin: EdgeInsets.only(right: ScreenUtil().setWidth(32)),
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
// height: ScreenUtil().setWidth(40),
|
|
|
|
// color: Colors.red,
|
|
|
|
child: Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Color.fromRGBO(0, 0, 0, 0.9),
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Spacer(),
|
|
|
|
Image.asset(
|
|
|
|
swich
|
|
|
|
? Utils.getImgPath('swich_on')
|
|
|
|
: Utils.getImgPath('swich_off'),
|
|
|
|
width: ScreenUtil().setWidth(44 * 2),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
///
|
|
|
|
Widget _item(String title, String subTitle) {
|
|
|
|
return Container(
|
|
|
|
padding: EdgeInsets.symmetric(vertical: ScreenUtil().setWidth(28)),
|
|
|
|
margin: EdgeInsets.only(right: ScreenUtil().setWidth(32)),
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
child: Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Color.fromRGBO(0, 0, 0, 0.9),
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
HEmptyView(60),
|
|
|
|
Expanded(
|
|
|
|
child: Text(
|
|
|
|
subTitle,
|
|
|
|
maxLines: 20,
|
|
|
|
textAlign: TextAlign.right,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Color.fromRGBO(0, 0, 0, 0.4),
|
|
|
|
fontSize: ScreenUtil().setSp(32),
|
|
|
|
),
|
|
|
|
))
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
_itemRadioWidget(bool select, String title, {GestureTapCallback? onTap}) {
|
|
|
|
return InkWell(
|
|
|
|
onTap: onTap,
|
|
|
|
child: Row(children: [
|
|
|
|
Image.asset(
|
|
|
|
Utils.getImgPath(
|
|
|
|
select ? 'plan_dish_select' : 'plan_dish_unselect'),
|
|
|
|
width: w(20),
|
|
|
|
),
|
|
|
|
HEmptyView(6),
|
|
|
|
Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_515151,
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
),
|
|
|
|
]));
|
|
|
|
}
|
|
|
|
|
|
|
|
///时间选择
|
|
|
|
Widget _select1(String title, String hintText, GestureTapCallback onTap) {
|
|
|
|
return InkWell(
|
|
|
|
onTap: onTap,
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.only(left: ScreenUtil().setWidth(32)),
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
// height: ScreenUtil().setWidth(40),
|
|
|
|
// color: Colors.red,
|
|
|
|
child: Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(
|
|
|
|
height: 1.5,
|
|
|
|
color: title == '点击设置可用日期'
|
|
|
|
? MyColours.color_999999
|
|
|
|
: MyColours.color_515151,
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
HEmptyView(20),
|
|
|
|
Spacer(),
|
|
|
|
Text(hintText,
|
|
|
|
style: TextStyle(
|
|
|
|
color: hintText == '点击设置开始日期' || hintText == '点击设置结束日期'
|
|
|
|
? MyColours.color_999999
|
|
|
|
: MyColours.color_515151,
|
|
|
|
fontSize: ScreenUtil().setSp(32),
|
|
|
|
)),
|
|
|
|
HEmptyView(20),
|
|
|
|
Image.asset(
|
|
|
|
Utils.getImgPath('arrow_right_new'),
|
|
|
|
width: ScreenUtil().setWidth(18),
|
|
|
|
),
|
|
|
|
HEmptyView(32),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
couponProvider = Provider.of<CouponProvider>(context, listen: true);
|
|
|
|
_uploadImageProvider =
|
|
|
|
Provider.of<UploadImageProvider>(context, listen: true);
|
|
|
|
return Scaffold(
|
|
|
|
backgroundColor: MyColours.color_ffffff,
|
|
|
|
key: scaffoldKey,
|
|
|
|
appBar: SystemAppBar(
|
|
|
|
'优惠券详情',
|
|
|
|
onTap: () {
|
|
|
|
if (Navigator.canPop(context)) {
|
|
|
|
Navigator.pop(context, false);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
|
|
|
body: InkWell(
|
|
|
|
onTap: () {
|
|
|
|
FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
color: MyColours.color_ffffff,
|
|
|
|
child: Column(children: [
|
|
|
|
Expanded(
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
controller: controller,
|
|
|
|
physics: BouncingScrollPhysics(),
|
|
|
|
child: Padding(
|
|
|
|
padding:
|
|
|
|
EdgeInsets.only(left: ScreenUtil().setWidth(32)),
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
VEmptyView(56),
|
|
|
|
_item('券类型', widget.isMine ? '我的优惠券' : '付费优惠券'),
|
|
|
|
Container(
|
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
VEmptyView(24),
|
|
|
|
// widget.isMine
|
|
|
|
// ? SizedBox()
|
|
|
|
// : _canUse('是否核销', swichHexiao, () {
|
|
|
|
// setState(() {
|
|
|
|
// swichHexiao = !swichHexiao;
|
|
|
|
// });
|
|
|
|
// }),
|
|
|
|
// widget.isMine
|
|
|
|
// ? SizedBox()
|
|
|
|
// : Container(
|
|
|
|
// height: ScreenUtil().setWidth(2),
|
|
|
|
// color: MyColours.color_E7E7E7,
|
|
|
|
// ),
|
|
|
|
// widget.isMine ? SizedBox() : VEmptyView(24),
|
|
|
|
_textfield('券名称', '例:9折券/200元代金券/菜品券',
|
|
|
|
_couponNameEditControl, _nameFocusNode),
|
|
|
|
Container(
|
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
VEmptyView(24),
|
|
|
|
if (!widget.isMine)
|
|
|
|
Column(
|
|
|
|
children: [
|
|
|
|
//销售价
|
|
|
|
|
|
|
|
_textfield('销售价', '请输入销售价', _priceControl,
|
|
|
|
_priceFocusNode,
|
|
|
|
textInputType:
|
|
|
|
TextInputType.numberWithOptions(
|
|
|
|
decimal: true)),
|
|
|
|
|
|
|
|
Container(
|
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
// VEmptyView(24),
|
|
|
|
//券用途
|
|
|
|
VEmptyView(56),
|
|
|
|
Container(
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Text(
|
|
|
|
'券用途',
|
|
|
|
style: TextStyle(
|
|
|
|
color: Color.fromRGBO(0, 0, 0, 0.9),
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
VEmptyView(40),
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
HEmptyView(30),
|
|
|
|
_itemRadioWidget(money, '代金券',
|
|
|
|
onTap: () {
|
|
|
|
if (!money) {
|
|
|
|
setState(() {
|
|
|
|
money = true;
|
|
|
|
|
|
|
|
dish = false;
|
|
|
|
discount = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
Spacer(),
|
|
|
|
_itemRadioWidget(discount, '折扣券',
|
|
|
|
onTap: () {
|
|
|
|
if (!discount) {
|
|
|
|
setState(() {
|
|
|
|
discount = true;
|
|
|
|
|
|
|
|
dish = false;
|
|
|
|
money = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
Spacer(),
|
|
|
|
_itemRadioWidget(dish, '菜品券',
|
|
|
|
onTap: () {
|
|
|
|
if (!dish) {
|
|
|
|
setState(() {
|
|
|
|
dish = true;
|
|
|
|
discount = false;
|
|
|
|
money = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
HEmptyView(30),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
VEmptyView(30),
|
|
|
|
|
|
|
|
if (money)
|
|
|
|
_textfieldSelect('金额:', '点击输入代金券金额',
|
|
|
|
moneyControl, moneyFocusNode,
|
|
|
|
subtitle: '元',
|
|
|
|
textInputType: TextInputType
|
|
|
|
.numberWithOptions()),
|
|
|
|
if (discount)
|
|
|
|
_textfieldSelect('折扣率:', '点击输入折扣,如9折',
|
|
|
|
discountControl, dishFocusNode,
|
|
|
|
subtitle: '折',
|
|
|
|
textInputType: TextInputType
|
|
|
|
.numberWithOptions()),
|
|
|
|
|
|
|
|
if (dish)
|
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.only(left: w(20)),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment:
|
|
|
|
CrossAxisAlignment.start,
|
|
|
|
|
|
|
|
// mainAxisAlignment:
|
|
|
|
// MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
child: Text(
|
|
|
|
'菜品:',
|
|
|
|
style: TextStyle(
|
|
|
|
color:
|
|
|
|
MyColours.color_515151,
|
|
|
|
fontSize:
|
|
|
|
ScreenUtil().setSp(32)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
VEmptyView(24),
|
|
|
|
Container(
|
|
|
|
margin: EdgeInsets.only(
|
|
|
|
right: w(20),
|
|
|
|
),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius:
|
|
|
|
BorderRadius.circular(
|
|
|
|
r(10)),
|
|
|
|
border: Border.all(
|
|
|
|
width: w(1),
|
|
|
|
color: MyColours
|
|
|
|
.color_DBDBDB)),
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
left: w(8), right: (w(8))),
|
|
|
|
child: TextField(
|
|
|
|
controller: dishControl,
|
|
|
|
textAlign: TextAlign.left,
|
|
|
|
textAlignVertical:
|
|
|
|
TextAlignVertical
|
|
|
|
.bottom,
|
|
|
|
maxLines: 5,
|
|
|
|
maxLength: 500,
|
|
|
|
// //光标颜色
|
|
|
|
// cursorColor:
|
|
|
|
// widget.isSelect ? Colors.white : MyColours.color_199095,
|
|
|
|
//输入文本的样式
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours
|
|
|
|
.color_515151,
|
|
|
|
fontSize: ScreenUtil()
|
|
|
|
.setSp(32),
|
|
|
|
),
|
|
|
|
focusNode: dishFocusNode,
|
|
|
|
decoration: InputDecoration(
|
|
|
|
isCollapsed: true,
|
|
|
|
border:
|
|
|
|
OutlineInputBorder(
|
|
|
|
borderSide:
|
|
|
|
BorderSide
|
|
|
|
.none),
|
|
|
|
hintText: '点击输入赠送菜品名称',
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
color: MyColours
|
|
|
|
.color_999999,
|
|
|
|
fontSize: ScreenUtil()
|
|
|
|
.setSp(32),
|
|
|
|
),
|
|
|
|
enabledBorder:
|
|
|
|
new UnderlineInputBorder(
|
|
|
|
borderSide:
|
|
|
|
BorderSide.none,
|
|
|
|
),
|
|
|
|
focusedBorder:
|
|
|
|
new UnderlineInputBorder(
|
|
|
|
borderSide:
|
|
|
|
BorderSide.none,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
onChanged: (value) {},
|
|
|
|
onEditingComplete: () {
|
|
|
|
// FocusScope.of(context)
|
|
|
|
// .requestFocus(
|
|
|
|
// FocusNode()); //点击空白处隐藏键盘
|
|
|
|
},
|
|
|
|
keyboardType: TextInputType
|
|
|
|
.multiline)),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
// _textfieldSelect('', '',
|
|
|
|
// , ,
|
|
|
|
// textInputType: TextInputType.text),
|
|
|
|
if (dish) VEmptyView(20),
|
|
|
|
|
|
|
|
if (dish)
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
left: w(20), right: w(15)),
|
|
|
|
child: Consumer<UploadImageProvider>(
|
|
|
|
builder: (context, model, _) {
|
|
|
|
return ImgPickerWidget(
|
|
|
|
scrollController: controller,
|
|
|
|
model: _uploadImageProvider,
|
|
|
|
maxImageNumber: 3,
|
|
|
|
maxRemind: '三',
|
|
|
|
imageList: img,
|
|
|
|
uploadType:
|
|
|
|
UploadType.CouponDishType,
|
|
|
|
deleteCallback: (int index) {
|
|
|
|
img.removeWhere((element) =>
|
|
|
|
element == img[index]);
|
|
|
|
setState(() {});
|
|
|
|
},
|
|
|
|
callback: () {
|
|
|
|
imgAll.add(img.last.qiniuUrl!);
|
|
|
|
print('完成');
|
|
|
|
// for (UploadImgModel item
|
|
|
|
// in _uploadImageProvider
|
|
|
|
// .tableImageList) {
|
|
|
|
// if (item.process < 1) {
|
|
|
|
// Utils.showToast('正在上传图片,请稍等');
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// //接口,和桌子绑定
|
|
|
|
// List imageQiniuUrlList = [];
|
|
|
|
// for (int i = 0;
|
|
|
|
// i <
|
|
|
|
// _uploadImageProvider
|
|
|
|
// .tableImageList.length;
|
|
|
|
// i++) {
|
|
|
|
// if (!_uploadImageProvider
|
|
|
|
// .tableImageList[i].isUpload) {
|
|
|
|
// imageQiniuUrlList.add({
|
|
|
|
// "url": _uploadImageProvider
|
|
|
|
// .tableImageList[i].qiniuUrl
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// _setTablePhoto(
|
|
|
|
// context, imageQiniuUrlList);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
})),
|
|
|
|
VEmptyView(48),
|
|
|
|
Container(
|
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
_textfield('券要求', '例:无门槛/满2000元',
|
|
|
|
_couponRequireEditControl, _requireFocusNode),
|
|
|
|
Container(
|
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
VEmptyView(24),
|
|
|
|
_select('活动开始于', fromDate, () {
|
|
|
|
FocusScope.of(context)
|
|
|
|
.requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
//弹出时间选择器
|
|
|
|
// showPickerDateTime(context);
|
|
|
|
showDateSelWidget = true;
|
|
|
|
DialogUtil.showPickerDateTime24(
|
|
|
|
context,
|
|
|
|
scaffoldKey,
|
|
|
|
(value) {
|
|
|
|
// {'text': picker.adapter.text, 'select': selecteds}
|
|
|
|
if (value != null) {
|
|
|
|
setState(() {
|
|
|
|
print(value);
|
|
|
|
fromDate = DateUtil.formatDateStr(
|
|
|
|
value,
|
|
|
|
format: DateFormats.y_mo_d);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
showDateSelWidget = false;
|
|
|
|
},
|
|
|
|
dateTime: fromDate == '点击选择'
|
|
|
|
? null
|
|
|
|
: DateUtil.getDateTime(fromDate),
|
|
|
|
pickerDateTimeType: PickerDateTimeType.kYMD,
|
|
|
|
onCancel: () {
|
|
|
|
showDateSelWidget = false;
|
|
|
|
});
|
|
|
|
}),
|
|
|
|
Container(
|
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
VEmptyView(24),
|
|
|
|
_select('活动结束于', endDate, () {
|
|
|
|
FocusScope.of(context)
|
|
|
|
.requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
//弹出时间选择器
|
|
|
|
// showPickerDateTime(context);
|
|
|
|
showDateSelWidget = true;
|
|
|
|
DialogUtil.showPickerDateTime24(
|
|
|
|
context,
|
|
|
|
scaffoldKey,
|
|
|
|
(value) {
|
|
|
|
// {'text': picker.adapter.text, 'select': selecteds}
|
|
|
|
if (value != null) {
|
|
|
|
setState(() {
|
|
|
|
print(value);
|
|
|
|
endDate = DateUtil.formatDateStr(
|
|
|
|
value,
|
|
|
|
format: DateFormats.y_mo_d);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
showDateSelWidget = false;
|
|
|
|
},
|
|
|
|
dateTime: endDate == '点击选择'
|
|
|
|
? null
|
|
|
|
: DateUtil.getDateTime(endDate),
|
|
|
|
pickerDateTimeType: PickerDateTimeType.kYMD,
|
|
|
|
onCancel: () {
|
|
|
|
showDateSelWidget = false;
|
|
|
|
});
|
|
|
|
}),
|
|
|
|
Container(
|
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
VEmptyView(24),
|
|
|
|
if (!widget.isMine)
|
|
|
|
Column(
|
|
|
|
children: [
|
|
|
|
//使用限制
|
|
|
|
VEmptyView(24),
|
|
|
|
Container(
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Text(
|
|
|
|
'使用限制',
|
|
|
|
style: TextStyle(
|
|
|
|
color: Color.fromRGBO(0, 0, 0, 0.9),
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
VEmptyView(40),
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
HEmptyView(30),
|
|
|
|
_itemRadioWidget(limitNone, '无',
|
|
|
|
onTap: () {
|
|
|
|
if (!limitNone) {
|
|
|
|
setState(() {
|
|
|
|
limitNone = true;
|
|
|
|
|
|
|
|
limitWeek = false;
|
|
|
|
limitBirthday = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
Spacer(),
|
|
|
|
_itemRadioWidget(limitWeek, '每周',
|
|
|
|
onTap: () {
|
|
|
|
if (!limitWeek) {
|
|
|
|
setState(() {
|
|
|
|
limitWeek = true;
|
|
|
|
|
|
|
|
limitNone = false;
|
|
|
|
limitBirthday = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
Spacer(),
|
|
|
|
_itemRadioWidget(
|
|
|
|
limitBirthday, '会员生日当天', onTap: () {
|
|
|
|
if (!limitBirthday) {
|
|
|
|
setState(() {
|
|
|
|
limitBirthday = true;
|
|
|
|
limitNone = false;
|
|
|
|
limitWeek = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
HEmptyView(30),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
if (limitWeek) VEmptyView(30),
|
|
|
|
|
|
|
|
if (limitWeek)
|
|
|
|
_select1(weekShow, '', () async {
|
|
|
|
FocusScope.of(context).requestFocus(
|
|
|
|
FocusNode()); //点击空白处隐藏键盘
|
|
|
|
//弹出时间选择器
|
|
|
|
// showPickerDateTime(context);
|
|
|
|
showDateSelWidget = false;
|
|
|
|
|
|
|
|
List<FilterBtnModel> data = await DialogUtil
|
|
|
|
.openCoponsWeekSelectModalBottomSheet(
|
|
|
|
context, weekData);
|
|
|
|
if (data != null) {
|
|
|
|
//改变了
|
|
|
|
weekData = [];
|
|
|
|
weekData.addAll(data);
|
|
|
|
weekShow = '';
|
|
|
|
|
|
|
|
String noonStr = '午餐:';
|
|
|
|
String nightStr = '晚餐:';
|
|
|
|
|
|
|
|
weekData.forEach((element) {
|
|
|
|
if (element.selectNoon!) {
|
|
|
|
noonStr += '${element.title} ';
|
|
|
|
}
|
|
|
|
if (element.selectNig!) {
|
|
|
|
nightStr += '${element.title} ';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (noonStr.endsWith(' ')) {
|
|
|
|
noonStr = noonStr.substring(
|
|
|
|
0, noonStr.length - 1);
|
|
|
|
}
|
|
|
|
if (nightStr.endsWith(' ')) {
|
|
|
|
nightStr = nightStr.substring(
|
|
|
|
0, nightStr.length - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (noonStr == '午餐:' &&
|
|
|
|
nightStr == '晚餐:') {
|
|
|
|
weekShow = '点击设置可用日期';
|
|
|
|
} else {
|
|
|
|
if (noonStr != '午餐:' &&
|
|
|
|
nightStr != '晚餐:') {
|
|
|
|
weekShow =
|
|
|
|
noonStr + '\n' + nightStr;
|
|
|
|
} else if (noonStr != '午餐:') {
|
|
|
|
weekShow = noonStr;
|
|
|
|
} else {
|
|
|
|
weekShow = nightStr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
limitWeek ? VEmptyView(22) : VEmptyView(48),
|
|
|
|
Container(
|
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
VEmptyView(48),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
widget.isMine
|
|
|
|
? SizedBox()
|
|
|
|
: _select('谁可以发放', '编辑', () async {
|
|
|
|
Map temp = await NavigatorUtil
|
|
|
|
.goCouponToPersonnalPage(
|
|
|
|
context, uids);
|
|
|
|
if (temp != null &&
|
|
|
|
temp['object'] != null) {
|
|
|
|
uids = temp['object'];
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
widget.isMine
|
|
|
|
? SizedBox()
|
|
|
|
: Container(
|
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
widget.isMine ? SizedBox() : VEmptyView(24),
|
|
|
|
widget.isMine
|
|
|
|
? SizedBox()
|
|
|
|
: _textfield('发放总量限制', '点击输入总数量限制',
|
|
|
|
_limitNumControl, _limitNumFocusNode,
|
|
|
|
textInputType: TextInputType.number),
|
|
|
|
widget.isMine
|
|
|
|
? SizedBox()
|
|
|
|
: Container(
|
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
widget.isMine ? SizedBox() : VEmptyView(24),
|
|
|
|
_explain('券说明', '例:可用包间,停车免费,不与店内其他活动共享等'),
|
|
|
|
VEmptyView(20),
|
|
|
|
_canUse('立即启用', swichState, () {
|
|
|
|
setState(() {
|
|
|
|
swichState = !swichState;
|
|
|
|
});
|
|
|
|
}),
|
|
|
|
VEmptyView(30),
|
|
|
|
],
|
|
|
|
))),
|
|
|
|
),
|
|
|
|
VEmptyView(20),
|
|
|
|
RoundButton(
|
|
|
|
onPressed: () {
|
|
|
|
print(img);
|
|
|
|
bool can = true;
|
|
|
|
innerloop:
|
|
|
|
for (UploadImgModel item in img) {
|
|
|
|
if (item.process! < 1) {
|
|
|
|
Utils.showToast('正在上传图片,请稍等');
|
|
|
|
// return false;
|
|
|
|
can = false;
|
|
|
|
break innerloop;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (can) {
|
|
|
|
if (_couponNameEditControl.text.trim().length == 0) {
|
|
|
|
Utils.showToast('请输入券名称');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (_priceControl.text.trim().length == 0 ||
|
|
|
|
_priceControl.text.trim() == '0') {
|
|
|
|
Utils.showToast('请输入销售价,且必须大于0');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!widget.isMine) {
|
|
|
|
if (money && moneyControl.text.trim().length == 0) {
|
|
|
|
Utils.showToast('请输入代金券金额!');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (discount &&
|
|
|
|
discountControl.text.trim().length == 0) {
|
|
|
|
Utils.showToast('请输入折扣率!');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (dish && dishControl.text.trim().length == 0) {
|
|
|
|
Utils.showToast('请输入菜品!');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (limitWeek && weekShow == '点击设置可用日期') {
|
|
|
|
Utils.showToast('请设置可用日期!');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (uids == null || uids == '') {
|
|
|
|
Utils.showToast('请设置发放人!');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isNumber = Utils.isInteger(
|
|
|
|
_limitNumControl.text.trim()); //判断输入的内容是否是数字
|
|
|
|
if (!isNumber) {
|
|
|
|
Utils.showToast('发放总量限制请输入数字');
|
|
|
|
_limitNumControl.text = '';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (_couponRequireEditControl.text.trim().length == 0) {
|
|
|
|
Utils.showToast('请填写券要求');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (fromDate == '点击选择') {
|
|
|
|
Utils.showToast('请选择有效期起始时间');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (endDate == '点击选择') {
|
|
|
|
Utils.showToast('请选择有效期结束时间');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (DateUtil.getDateTime(endDate)
|
|
|
|
.compareTo(DateUtil.getDateTime(fromDate)) <
|
|
|
|
0) {
|
|
|
|
Utils.showToast('有效期结束时间不能早于起始时间');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ***参数***
|
|
|
|
// _couponNameEditControl.text
|
|
|
|
// _couponRequireEditControl.text
|
|
|
|
// fromDate
|
|
|
|
// endDate
|
|
|
|
// _couponExplainEditControl.text
|
|
|
|
// swichState
|
|
|
|
_createNewCoupon();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
text: '立即创建',
|
|
|
|
fontSize: 24,
|
|
|
|
isBold: false,
|
|
|
|
height: ScreenUtil().setWidth(37 * 2),
|
|
|
|
width: ScreenUtil().setWidth(130 * 2),
|
|
|
|
radius: ScreenUtil().setWidth(22),
|
|
|
|
),
|
|
|
|
VEmptyView(32)
|
|
|
|
]))),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|