|
...
|
...
|
@@ -6,6 +6,7 @@ import 'package:flutter/services.dart'; |
|
|
|
// import 'package:flutter_picker_plus/flutter_picker_plus.dart';
|
|
|
|
import 'package:flutter_picker_plus/flutter_picker_plus.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:one_key/models/meal_day_date_model.dart';
|
|
|
|
|
|
|
|
import 'package:one_key/provider/coupon_provider.dart';
|
|
|
|
import 'package:one_key/provider/user_model.dart';
|
|
...
|
...
|
@@ -24,6 +25,7 @@ import 'package:provider/provider.dart'; |
|
|
|
import '../../models/coupon_model.dart';
|
|
|
|
import '../../models/filter_btn_model.dart';
|
|
|
|
import '../../models/upload_img_model.dart';
|
|
|
|
import '../../provider/store_base_info_provider.dart';
|
|
|
|
import '../../provider/upload_img_provider.dart';
|
|
|
|
import '../../utils/screen_util.dart';
|
|
|
|
import '../../utils/upload_image_util.dart';
|
|
...
|
...
|
@@ -94,10 +96,11 @@ class _CouponEidtPageState extends State<CouponEidtPage> { |
|
|
|
List<FilterBtnModel> weekData = [];
|
|
|
|
|
|
|
|
// morning == "00:00-00:00"
|
|
|
|
String? morning;
|
|
|
|
String? noon;
|
|
|
|
String? night;
|
|
|
|
|
|
|
|
// String morning = "00:00-00:00";
|
|
|
|
// String noon = "00:00-00:00";
|
|
|
|
// String night = "00:00-00:00";
|
|
|
|
// String meal1 = "00:00-00:00";
|
|
|
|
// String meal2 = "00:00-00:00";
|
|
|
|
UploadImageProvider? _uploadImageProvider;
|
|
|
|
List<UploadImgModel> img = [];
|
|
|
|
|
|
...
|
...
|
@@ -117,6 +120,8 @@ class _CouponEidtPageState extends State<CouponEidtPage> { |
|
|
|
bool isShareHave = true; //分享好友后继续拥有此券
|
|
|
|
// bool isCommission = true; //返佣金
|
|
|
|
|
|
|
|
late StoreBaseIndoProvider storeBaseIndoProvider;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
...
|
...
|
@@ -220,6 +225,7 @@ class _CouponEidtPageState extends State<CouponEidtPage> { |
|
|
|
swichState = widget.couponSunModel!.status == '1' ? true : false;
|
|
|
|
_priceControl.text = widget.couponSunModel!.price;
|
|
|
|
_limitDay.text = widget.couponSunModel!.aexpiration ?? '';
|
|
|
|
|
|
|
|
|
|
|
|
isSameDay = widget.couponSunModel!.arule!.isSameDay;
|
|
|
|
isAccumulation = widget.couponSunModel!.arule!.isAccumulation;
|
|
...
|
...
|
@@ -266,6 +272,7 @@ class _CouponEidtPageState extends State<CouponEidtPage> { |
|
|
|
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
// _couponNetworkData(0);
|
|
|
|
getMealSectionByDay();
|
|
|
|
if (weekData.length == 0) {
|
|
|
|
_initWeekData();
|
|
|
|
}
|
|
...
|
...
|
@@ -281,6 +288,16 @@ class _CouponEidtPageState extends State<CouponEidtPage> { |
|
|
|
_uploadImageProvider!.qiniuInfoSunModel!.token = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
getMealSectionByDay({bool showLoading = false}) async {
|
|
|
|
Map<String, String?> pramas = {
|
|
|
|
'sellerid': Provider.of<UserModel>(context, listen: false).user!.sellerid,
|
|
|
|
'day':
|
|
|
|
'${DateTime.now().year}-${Utils.addZeroNumber(DateTime.now().month)}-${Utils.addZeroNumber(DateTime.now().day)}'
|
|
|
|
};
|
|
|
|
await storeBaseIndoProvider.getMealSectionByDay(context, pramas,
|
|
|
|
showLoading: showLoading);
|
|
|
|
}
|
|
|
|
|
|
|
|
///获取七牛云token
|
|
|
|
///
|
|
|
|
_getQiniuInfo() async {
|
|
...
|
...
|
@@ -861,6 +878,9 @@ class _CouponEidtPageState extends State<CouponEidtPage> { |
|
|
|
couponProvider = Provider.of<CouponProvider>(context, listen: true);
|
|
|
|
_uploadImageProvider =
|
|
|
|
Provider.of<UploadImageProvider>(context, listen: true);
|
|
|
|
|
|
|
|
storeBaseIndoProvider =
|
|
|
|
Provider.of<StoreBaseIndoProvider>(context, listen: true);
|
|
|
|
return Scaffold(
|
|
|
|
backgroundColor: MyColours.color_ffffff,
|
|
|
|
key: scaffoldKey,
|
|
...
|
...
|
@@ -1242,51 +1262,185 @@ class _CouponEidtPageState extends State<CouponEidtPage> { |
|
|
|
VEmptyView(24),
|
|
|
|
|
|
|
|
_select('不可用日期', weekShow, () async {
|
|
|
|
if (storeBaseIndoProvider.dayDateData == null ||
|
|
|
|
storeBaseIndoProvider.dayDateData?.length ==
|
|
|
|
0) {
|
|
|
|
await getMealSectionByDay(showLoading: true);
|
|
|
|
}
|
|
|
|
FocusScope.of(context)
|
|
|
|
.requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
//弹出时间选择器
|
|
|
|
// showPickerDateTime(context);
|
|
|
|
showDateSelWidget = false;
|
|
|
|
|
|
|
|
List<FilterBtnModel> data = await DialogUtil
|
|
|
|
List<FilterBtnModel>? data = await DialogUtil
|
|
|
|
.openCoponsWeekSelectModalBottomSheet(
|
|
|
|
context, weekData);
|
|
|
|
context,
|
|
|
|
weekData,
|
|
|
|
storeBaseIndoProvider.dayDateData ??
|
|
|
|
[]);
|
|
|
|
if (data != null) {
|
|
|
|
//改变了
|
|
|
|
weekData = [];
|
|
|
|
weekData.addAll(data);
|
|
|
|
weekShow = '';
|
|
|
|
|
|
|
|
String noonStr = '午餐:';
|
|
|
|
String nightStr = '晚餐:';
|
|
|
|
if (weekData.every((e) =>
|
|
|
|
e.selectMor == false &&
|
|
|
|
e.selectNoon == false &&
|
|
|
|
e.selectNig == false &&
|
|
|
|
e.selectMeal1 == false &&
|
|
|
|
e.selectMeal2 == false)) {
|
|
|
|
weekShow = '无';
|
|
|
|
} else {
|
|
|
|
String? morStr;
|
|
|
|
if (weekData
|
|
|
|
.any((e) => e.selectMor == true)) {
|
|
|
|
//有选中的早餐
|
|
|
|
List<MealDayDateSunModel>? mortemp =
|
|
|
|
storeBaseIndoProvider.dayDateData
|
|
|
|
?.where((e) => e.ddateSolt == '1')
|
|
|
|
.toList();
|
|
|
|
|
|
|
|
morStr = (mortemp != null &&
|
|
|
|
mortemp.length > 0)
|
|
|
|
? '${mortemp[0].mname}:'
|
|
|
|
: '早餐:';
|
|
|
|
}
|
|
|
|
|
|
|
|
weekData.forEach((element) {
|
|
|
|
if (element.selectNoon!) {
|
|
|
|
noonStr += '${element.title} ';
|
|
|
|
String? noonStr;
|
|
|
|
if (weekData
|
|
|
|
.any((e) => e.selectNoon == true)) {
|
|
|
|
//有选中的午餐
|
|
|
|
List<MealDayDateSunModel>? mortemp =
|
|
|
|
storeBaseIndoProvider.dayDateData
|
|
|
|
?.where((e) => e.ddateSolt == '2')
|
|
|
|
.toList();
|
|
|
|
|
|
|
|
noonStr = (mortemp != null &&
|
|
|
|
mortemp.length > 0)
|
|
|
|
? '${mortemp[0].mname}:'
|
|
|
|
: '午餐:';
|
|
|
|
}
|
|
|
|
if (element.selectNig!) {
|
|
|
|
nightStr += '${element.title} ';
|
|
|
|
String? nigStr;
|
|
|
|
if (weekData
|
|
|
|
.any((e) => e.selectNig == true)) {
|
|
|
|
//有选中的晚餐
|
|
|
|
List<MealDayDateSunModel>? mortemp =
|
|
|
|
storeBaseIndoProvider.dayDateData
|
|
|
|
?.where((e) => e.ddateSolt == '3')
|
|
|
|
.toList();
|
|
|
|
|
|
|
|
nigStr = (mortemp != null &&
|
|
|
|
mortemp.length > 0)
|
|
|
|
? '${mortemp[0].mname}:'
|
|
|
|
: '晚餐:';
|
|
|
|
}
|
|
|
|
String? meal1Str;
|
|
|
|
if (weekData
|
|
|
|
.any((e) => e.selectMeal1 == true)) {
|
|
|
|
//有选中的晚餐1
|
|
|
|
List<MealDayDateSunModel>? mortemp =
|
|
|
|
storeBaseIndoProvider.dayDateData
|
|
|
|
?.where((e) => e.ddateSolt == '4')
|
|
|
|
.toList();
|
|
|
|
|
|
|
|
meal1Str = (mortemp != null &&
|
|
|
|
mortemp.length > 0)
|
|
|
|
? '${mortemp[0].mname}:'
|
|
|
|
: '晚餐1:';
|
|
|
|
}
|
|
|
|
String? meal2Str;
|
|
|
|
if (weekData
|
|
|
|
.any((e) => e.selectMeal2 == true)) {
|
|
|
|
//有选中的晚餐2
|
|
|
|
List<MealDayDateSunModel>? mortemp =
|
|
|
|
storeBaseIndoProvider.dayDateData
|
|
|
|
?.where((e) => e.ddateSolt == '5')
|
|
|
|
.toList();
|
|
|
|
|
|
|
|
meal2Str = (mortemp != null &&
|
|
|
|
mortemp.length > 0)
|
|
|
|
? '${mortemp[0].mname}:'
|
|
|
|
: '晚餐2:';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
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;
|
|
|
|
weekData.forEach((element) {
|
|
|
|
if (morStr != null &&
|
|
|
|
element.selectMor!) {
|
|
|
|
morStr = morStr! + '${element.title} ';
|
|
|
|
}
|
|
|
|
if (noonStr != null &&
|
|
|
|
element.selectNoon!) {
|
|
|
|
noonStr =
|
|
|
|
noonStr! + '${element.title} ';
|
|
|
|
}
|
|
|
|
if (nigStr != null &&
|
|
|
|
element.selectNig!) {
|
|
|
|
nigStr = nigStr! + '${element.title} ';
|
|
|
|
}
|
|
|
|
if (meal1Str != null &&
|
|
|
|
element.selectMeal1!) {
|
|
|
|
meal1Str =
|
|
|
|
meal1Str! + '${element.title} ';
|
|
|
|
}
|
|
|
|
if (meal2Str != null &&
|
|
|
|
element.selectMeal2!) {
|
|
|
|
meal2Str =
|
|
|
|
meal2Str! + '${element.title} ';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (morStr != null) {
|
|
|
|
if (morStr!.endsWith(' ')) {
|
|
|
|
morStr = morStr!
|
|
|
|
.substring(0, morStr!.length - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (noonStr != null) {
|
|
|
|
if (noonStr!.endsWith(' ')) {
|
|
|
|
noonStr = noonStr!
|
|
|
|
.substring(0, noonStr!.length - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (nigStr != null) {
|
|
|
|
if (nigStr!.endsWith(' ')) {
|
|
|
|
nigStr = nigStr!
|
|
|
|
.substring(0, nigStr!.length - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (meal1Str != null) {
|
|
|
|
if (meal1Str!.endsWith(' ')) {
|
|
|
|
meal1Str = meal1Str!
|
|
|
|
.substring(0, meal1Str!.length - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (meal2Str != null) {
|
|
|
|
if (meal2Str!.endsWith(' ')) {
|
|
|
|
meal2Str = meal2Str!
|
|
|
|
.substring(0, meal2Str!.length - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
String show = '';
|
|
|
|
|
|
|
|
if (morStr != null) {
|
|
|
|
show += morStr!;
|
|
|
|
}
|
|
|
|
if (noonStr != null) {
|
|
|
|
show += ('\n' + noonStr!);
|
|
|
|
}
|
|
|
|
if (nigStr != null) {
|
|
|
|
show += ('\n' + nigStr!);
|
|
|
|
}
|
|
|
|
if (meal1Str != null) {
|
|
|
|
show += ('\n' + meal1Str!);
|
|
|
|
}
|
|
|
|
if (meal2Str != null) {
|
|
|
|
show += ('\n' + meal2Str!);
|
|
|
|
}
|
|
|
|
|
|
|
|
weekShow = show;
|
|
|
|
}
|
|
|
|
|
|
|
|
setState(() {});
|
|
...
|
...
|
@@ -1608,7 +1762,7 @@ class _CouponEidtPageState extends State<CouponEidtPage> { |
|
|
|
return;
|
|
|
|
}
|
|
|
|
// 券开始早于活动开始 && 券结束大于活动结束
|
|
|
|
if (widget.from != null&& widget.from != 'null') {
|
|
|
|
if (widget.from != null && widget.from != 'null') {
|
|
|
|
if (DateUtil.getDateTime(fromDate)
|
|
|
|
.compareTo(DateUtil.getDateTime(widget.from!)) >
|
|
|
|
0) {
|
...
|
...
|
|