|
|
|
import 'dart:convert';
|
|
|
|
|
|
|
|
import 'package:common_utils/common_utils.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_picker/Picker.dart';
|
|
...
|
...
|
@@ -61,6 +63,8 @@ class _RechargeEditPageState extends State<RechargeEditPage> { |
|
|
|
bool giveScoreSwich = false;
|
|
|
|
bool giveCouponsSwich = false;
|
|
|
|
|
|
|
|
List<CouponSunModel> couponsData = [];
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
...
|
...
|
@@ -636,12 +640,15 @@ class _RechargeEditPageState extends State<RechargeEditPage> { |
|
|
|
object['couponsid'] != null) {
|
|
|
|
List<CouponSunModel> data =
|
|
|
|
object['couponsdata'];
|
|
|
|
|
|
|
|
couponsData = [];
|
|
|
|
//
|
|
|
|
selectIDs = object['couponsid'];
|
|
|
|
coupons = [];
|
|
|
|
data.forEach((element) {
|
|
|
|
if (element.isCheck) {
|
|
|
|
coupons.add(element.aname);
|
|
|
|
couponsData.add(element);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
setState(() {});
|
|
...
|
...
|
@@ -871,6 +878,74 @@ class _RechargeEditPageState extends State<RechargeEditPage> { |
|
|
|
isBold: false,
|
|
|
|
fontSize: 28,
|
|
|
|
onPressed: () async {
|
|
|
|
//优惠活动
|
|
|
|
if (givePriceSwich && givePriceC.text.trim().length == 0) {
|
|
|
|
Utils.showToast('请输入赠送金额!');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (giveScoreSwich && giveScoreC.text.trim().length == 0) {
|
|
|
|
Utils.showToast('请输入赠送积分!');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (giveCouponsSwich && couponsData.length == 0) {
|
|
|
|
Utils.showToast('请选择赠送的优惠券!');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//有效期
|
|
|
|
|
|
|
|
if (fixdate) {
|
|
|
|
//固定时间段
|
|
|
|
|
|
|
|
if (fromDate == '点击设置开始日期') {
|
|
|
|
Utils.showToast('请设置开始日期!');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (endDate == '点击设置结束日期') {
|
|
|
|
Utils.showToast('请设置结束日期!');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (DateUtil.getDateTime(endDate)
|
|
|
|
.compareTo(DateUtil.getDateTime(fromDate)) <
|
|
|
|
0) {
|
|
|
|
Utils.showToast('有效期结束日期不能早于开始日期!');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (weekly && weekShow == '点击设置可用日期') {
|
|
|
|
Utils.showToast('请设置可用日期!');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Map discounts = {
|
|
|
|
'is_price': givePriceSwich ? '1' : '0', //优惠活动,赠送金额
|
|
|
|
'is_score': giveScoreSwich ? '1' : '0', //赠送积分
|
|
|
|
'is_coupons': giveCouponsSwich ? '1' : '0', //赠送优惠券
|
|
|
|
'price': givePriceC.text,
|
|
|
|
'score': giveScoreC.text,
|
|
|
|
'coupons': couponsData,
|
|
|
|
'coupons_ids': selectIDs,
|
|
|
|
'coupons_names': coupons
|
|
|
|
};
|
|
|
|
|
|
|
|
String discountsStr = json.encode(discounts);
|
|
|
|
print(discountsStr);
|
|
|
|
|
|
|
|
Map date = {
|
|
|
|
'is_fix': fixdate ? '1' : '0',
|
|
|
|
'is_week': weekly ? '1' : '0',
|
|
|
|
'is_birthday': birthday ? '1' : '0',
|
|
|
|
'fix_sdate': fixdate ? fromDate : '', // 开始时间
|
|
|
|
'fix_edate': fixdate ? endDate : '', //结束时间
|
|
|
|
'week_date_show': weekly ? weekShow : '',
|
|
|
|
'week_date_data': weekly ? weekData : ''
|
|
|
|
};
|
|
|
|
|
|
|
|
String dateStr = json.encode(date);
|
|
|
|
print(dateStr);
|
|
|
|
|
|
|
|
// "stime": fromDate == '点击选择'
|
|
|
|
// ? ""
|
|
|
|
// : '${DateUtil.getDateMsByTimeStr(fromDate) / 1000}',
|
...
|
...
|
|