|
|
|
import 'dart:convert';
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:one_key/widgets/system_app_bar.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
import '../../../models/coupon_model.dart';
|
|
|
|
import '../../../models/recharge_list_model.dart';
|
|
|
|
import '../../../provider/coupon_provider.dart';
|
|
|
|
import '../../../provider/marketing_center_provider.dart';
|
|
|
|
import '../../../provider/user_model.dart';
|
|
|
|
import '../../../res/colors.dart';
|
|
|
|
import '../../../route/navigator_util.dart';
|
|
|
|
import '../../../utils/screen_util.dart';
|
|
|
|
import '../../../utils/utils.dart';
|
|
|
|
import '../../../widgets/h_empty_view.dart';
|
|
|
|
import '../../../widgets/round_button.dart';
|
|
|
|
import '../../../widgets/v_empty_view.dart';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 优惠券设置页面
|
|
|
|
* */
|
|
|
|
|
|
|
|
class CommentsSettingPage extends StatefulWidget {
|
|
|
|
CommentsSettingPage({Key key}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
_CommentsSettingPageState createState() => _CommentsSettingPageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _CommentsSettingPageState extends State<CommentsSettingPage> {
|
|
|
|
ScrollController controller = ScrollController();
|
|
|
|
CouponProvider couponProvider;
|
|
|
|
MarketingCenterProvider marketingCenterProvider;
|
|
|
|
bool isTranspond = false; //转发邀请函
|
|
|
|
bool isArrival = false; //确认到店
|
|
|
|
bool isOnlineBook = false; //在线预订
|
|
|
|
bool isOrder = false; //提前点餐
|
|
|
|
bool isLink = false; //充值优惠活动链接
|
|
|
|
bool isCoupon = false; // 代金券
|
|
|
|
bool isRecharge = false; //充值券
|
|
|
|
String welcome = '';
|
|
|
|
String qiniuUrl = '';
|
|
|
|
|
|
|
|
RechargeListSunModel rechargeData;
|
|
|
|
String rechargeContent = '';
|
|
|
|
|
|
|
|
List<CouponSunModel> couponDataList = [];
|
|
|
|
bool isComments = false; //启用评价设置
|
|
|
|
bool isCommentsCoupon = false; //启用评价送券
|
|
|
|
List<CouponSunModel> couponDataListComments = [];
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
|
|
|
_couponNetworkData();
|
|
|
|
getSellerTemplateConf();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
getSellerTemplateConf() async {
|
|
|
|
bool success = await marketingCenterProvider.getSellerTemplateConf(context);
|
|
|
|
if (success && marketingCenterProvider.markDataModel.marketing != null) {
|
|
|
|
isTranspond =
|
|
|
|
marketingCenterProvider.markDataModel.marketing.isTranspond == '1'
|
|
|
|
? true
|
|
|
|
: false;
|
|
|
|
|
|
|
|
isArrival =
|
|
|
|
marketingCenterProvider.markDataModel.marketing.isArrival == '1'
|
|
|
|
? true
|
|
|
|
: false;
|
|
|
|
isOnlineBook =
|
|
|
|
marketingCenterProvider.markDataModel.marketing.isOnlineBook == '1'
|
|
|
|
? true
|
|
|
|
: false;
|
|
|
|
isOrder = marketingCenterProvider.markDataModel.marketing.isOrder == '1'
|
|
|
|
? true
|
|
|
|
: false;
|
|
|
|
isLink = marketingCenterProvider.markDataModel.marketing.isLink == '1'
|
|
|
|
? true
|
|
|
|
: false;
|
|
|
|
|
|
|
|
isCoupon = marketingCenterProvider.markDataModel.marketing.isCoupon == '1'
|
|
|
|
? true
|
|
|
|
: false;
|
|
|
|
|
|
|
|
isRecharge =
|
|
|
|
marketingCenterProvider.markDataModel.marketing.isRecharge == '1'
|
|
|
|
? true
|
|
|
|
: false;
|
|
|
|
|
|
|
|
rechargeData =
|
|
|
|
marketingCenterProvider.markDataModel.marketing.rechargeData;
|
|
|
|
couponDataList =
|
|
|
|
marketingCenterProvider.markDataModel.marketing.couponDataList ?? [];
|
|
|
|
|
|
|
|
couponDataListComments = marketingCenterProvider
|
|
|
|
.markDataModel.marketing.couponDataListComments ??
|
|
|
|
[];
|
|
|
|
|
|
|
|
isCommentsCoupon =
|
|
|
|
marketingCenterProvider.markDataModel.marketing.isCommentsCoupon ==
|
|
|
|
'1'
|
|
|
|
? true
|
|
|
|
: false;
|
|
|
|
isComments =
|
|
|
|
marketingCenterProvider.markDataModel.marketing.isComments == '1'
|
|
|
|
? true
|
|
|
|
: false;
|
|
|
|
|
|
|
|
qiniuUrl = marketingCenterProvider.markDataModel.marketing.logo ?? null;
|
|
|
|
|
|
|
|
welcome = marketingCenterProvider.markDataModel.marketing.wecomle;
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///优惠券设置
|
|
|
|
|
|
|
|
_setCouponShow() async {
|
|
|
|
//接口
|
|
|
|
Map marketingData = {
|
|
|
|
// 'isTranspond': isTranspond ? '1' : '0', //转发同行客人
|
|
|
|
'is_transpond': '1', //转发同行客人
|
|
|
|
'is_arrival': isArrival ? '1' : '0', //确认到店
|
|
|
|
'is_online_book': isOnlineBook ? '1' : '0', //在线预订
|
|
|
|
'is_order': isOrder ? '1' : '0', //去点餐
|
|
|
|
'is_coupon': isCoupon ? '1' : '0', //代金券暂时
|
|
|
|
'is_recharge': isRecharge ? '1' : '0', //充值券暂时
|
|
|
|
'is_link': isLink ? '1' : '0',
|
|
|
|
'wecomle': welcome ?? '',
|
|
|
|
'logo': qiniuUrl,
|
|
|
|
'recharge_data': rechargeData,
|
|
|
|
'coupon_data': json.encode(couponDataList),
|
|
|
|
'is_comments': isComments ? '1' : '0',
|
|
|
|
'is_comments_coupon': isCommentsCoupon ? '1' : '0',
|
|
|
|
'coupon_data_comments': json.encode(couponDataListComments),
|
|
|
|
};
|
|
|
|
Map<String, String> params = {
|
|
|
|
'sid': Provider.of<UserModel>(context, listen: false).user.sellerid,
|
|
|
|
'marketing': json.encode(marketingData)
|
|
|
|
};
|
|
|
|
|
|
|
|
bool success = await marketingCenterProvider
|
|
|
|
.setSellerTemplateConf(context, params, showLoading: true);
|
|
|
|
if (success) {
|
|
|
|
// bus.emit('refresh_coupon_list_f');
|
|
|
|
Utils.showToast('保存成功');
|
|
|
|
Navigator.pop(context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///获取优惠券列表数据(status == 1)
|
|
|
|
|
|
|
|
_couponNetworkData({bool isShowLoading = true}) async {
|
|
|
|
Map<String, String> params = {
|
|
|
|
"uid": Provider.of<UserModel>(context, listen: false).user.openid,
|
|
|
|
};
|
|
|
|
params['status'] = '1';
|
|
|
|
|
|
|
|
await couponProvider.getCustomerSelectActivityMarking(context, params,
|
|
|
|
isShowLoading: isShowLoading);
|
|
|
|
if (couponDataListComments == null || couponDataListComments.length == 0) {
|
|
|
|
if (couponProvider.couponListSelect != null &&
|
|
|
|
couponProvider.couponListSelect.length > 0) {
|
|
|
|
couponDataListComments.add(couponProvider.couponListSelect[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
|
|
|
|
///标题
|
|
|
|
Widget _headItem(String title) {
|
|
|
|
return Container(
|
|
|
|
width: double.infinity,
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border(
|
|
|
|
bottom:
|
|
|
|
BorderSide(color: MyColours.color_E7E7E7, width: w(0.5)))),
|
|
|
|
margin: EdgeInsets.only(left: w(16)),
|
|
|
|
padding: EdgeInsets.only(top: w(12), bottom: w(12), right: w(16)),
|
|
|
|
child: Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_515151, fontSize: ScreenUtil().setWidth(32)),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
///优惠券
|
|
|
|
Widget _markingCupon({
|
|
|
|
VoidCallback onPressed,
|
|
|
|
bool select = false,
|
|
|
|
VoidCallback onPressedSelect,
|
|
|
|
}) {
|
|
|
|
return Container(
|
|
|
|
margin: EdgeInsets.only(left: w(21), top: w(12), right: w(21)),
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
InkWell(
|
|
|
|
onTap: onPressedSelect,
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Image.asset(
|
|
|
|
Utils.getImgPath(select ? 'f_select' : 'f_select_not'),
|
|
|
|
width: w(20),
|
|
|
|
),
|
|
|
|
HEmptyView(20),
|
|
|
|
Text(
|
|
|
|
'顾客点评后赠送优惠券',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: font(14), color: MyColours.color_515151),
|
|
|
|
),
|
|
|
|
Spacer(),
|
|
|
|
RoundButton(
|
|
|
|
text: '选择活动',
|
|
|
|
width: w(72),
|
|
|
|
height: w(22),
|
|
|
|
gradientStart: MyColours.color_ffffff,
|
|
|
|
gradientEnd: MyColours.color_ffffff,
|
|
|
|
borderColor: MyColours.color_438E93,
|
|
|
|
textColor: MyColours.color_438E93,
|
|
|
|
radius: r(11),
|
|
|
|
fontSize: 24,
|
|
|
|
isBold: true,
|
|
|
|
onPressed: onPressed,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
VEmptyView(20),
|
|
|
|
ListView.builder(
|
|
|
|
shrinkWrap: true,
|
|
|
|
controller: controller,
|
|
|
|
itemCount: couponDataListComments.length,
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
CouponSunModel couponData = couponDataListComments[index];
|
|
|
|
return _markingCuponItem(
|
|
|
|
couponData.aname,
|
|
|
|
_getCouponsDesc(couponData),
|
|
|
|
couponData.price ?? '',
|
|
|
|
couponData.use != null && couponData.use.isCash
|
|
|
|
? '${(double.parse(couponData.price) / double.parse(couponData.use.cash)) * 10}折'
|
|
|
|
: '',
|
|
|
|
'切换活动',
|
|
|
|
select: isCommentsCoupon, onPressedSelect: () {
|
|
|
|
setState(() {
|
|
|
|
isCommentsCoupon = !isCommentsCoupon;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
})
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
String _getCouponsDesc(couponData) {
|
|
|
|
String couponsDesc = '';
|
|
|
|
if (couponData != null) {
|
|
|
|
if (couponData.expDate == null) {
|
|
|
|
couponsDesc = couponData.desc;
|
|
|
|
} else {
|
|
|
|
if (couponData.expDate.isNone) {
|
|
|
|
couponsDesc = '无限制,' + couponData.desc ?? '';
|
|
|
|
} else if (couponData.expDate.isBirthday) {
|
|
|
|
couponsDesc = '会员生日当天可用,' + couponData.desc ?? '';
|
|
|
|
} else if (couponData.expDate.isWeek) {
|
|
|
|
couponsDesc =
|
|
|
|
'${couponData.expDate.weekShow},' + couponData.desc ?? '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return couponsDesc;
|
|
|
|
}
|
|
|
|
|
|
|
|
///优惠券
|
|
|
|
Widget _markingCuponItem(
|
|
|
|
String title,
|
|
|
|
String content,
|
|
|
|
String subtile,
|
|
|
|
String discount,
|
|
|
|
String btnTitle, {
|
|
|
|
VoidCallback onPressed,
|
|
|
|
bool select = false,
|
|
|
|
VoidCallback onPressedSelect,
|
|
|
|
}) {
|
|
|
|
return Container(
|
|
|
|
margin: EdgeInsets.only(left: w(21), top: w(12), right: w(21)),
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.all(w(12)),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadiusDirectional.circular(r(8)),
|
|
|
|
border: Border.all(width: w(1), color: MyColours.color_DBDBDB)),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
constraints: BoxConstraints(maxWidth: w(150)),
|
|
|
|
child: Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: font(14),
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: MyColours.color_515151),
|
|
|
|
)),
|
|
|
|
HEmptyView(20),
|
|
|
|
subtile != ''
|
|
|
|
? Text(
|
|
|
|
'¥${subtile}',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: font(7),
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: MyColours.color_E34D59),
|
|
|
|
)
|
|
|
|
: SizedBox(),
|
|
|
|
HEmptyView(10),
|
|
|
|
discount != ''
|
|
|
|
? Container(
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: w(3), vertical: w(2)),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.circular(r(3)),
|
|
|
|
border: Border.all(
|
|
|
|
width: w(0.5),
|
|
|
|
color: MyColours.color_E34D59)),
|
|
|
|
child: Text(
|
|
|
|
discount,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_E34D59,
|
|
|
|
fontSize: font(7)),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
: SizedBox(),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
if (content != '') VEmptyView(20),
|
|
|
|
if (content != '')
|
|
|
|
Text(
|
|
|
|
content,
|
|
|
|
style: TextStyle(
|
|
|
|
height: 1.2,
|
|
|
|
fontSize: font(10),
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: MyColours.color_515151),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
///营销推广
|
|
|
|
Widget _markingItem(
|
|
|
|
String selectTitle,
|
|
|
|
String title, {
|
|
|
|
bool select = false,
|
|
|
|
VoidCallback onPressedSelect,
|
|
|
|
}) {
|
|
|
|
return Container(
|
|
|
|
margin: EdgeInsets.only(left: w(18), top: w(12), right: w(18)),
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
InkWell(
|
|
|
|
onTap: onPressedSelect,
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Image.asset(
|
|
|
|
Utils.getImgPath(select ? 'f_select' : 'f_select_not'),
|
|
|
|
width: w(20),
|
|
|
|
),
|
|
|
|
HEmptyView(20),
|
|
|
|
Text(
|
|
|
|
selectTitle,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: font(14), color: MyColours.color_515151),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
VEmptyView(20),
|
|
|
|
Container(
|
|
|
|
height: w(76),
|
|
|
|
padding: EdgeInsets.all(w(12)),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadiusDirectional.circular(r(8)),
|
|
|
|
border:
|
|
|
|
Border.all(width: w(1), color: MyColours.color_DBDBDB)),
|
|
|
|
child: Text(
|
|
|
|
title,
|
|
|
|
maxLines: 2,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: font(14),
|
|
|
|
// fontWeight: FontWeight.bold,
|
|
|
|
color: MyColours.color_515151),
|
|
|
|
))
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
couponProvider = Provider.of<CouponProvider>(context, listen: false);
|
|
|
|
|
|
|
|
marketingCenterProvider =
|
|
|
|
Provider.of<MarketingCenterProvider>(context, listen: false);
|
|
|
|
return Scaffold(
|
|
|
|
backgroundColor: MyColours.color_ffffff,
|
|
|
|
appBar: SystemAppBar('用户评价设置'),
|
|
|
|
body: Column(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
controller: controller,
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
// _headItem('预订安排启用顾客反馈评价功能'),
|
|
|
|
InkWell(
|
|
|
|
onTap: () {
|
|
|
|
setState(() {
|
|
|
|
isComments = !isComments;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
left: w(16),
|
|
|
|
top: w(12),
|
|
|
|
bottom: w(12),
|
|
|
|
right: w(12)),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment:
|
|
|
|
MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
'预订安排启用顾客反馈评价功能',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_515151,
|
|
|
|
fontSize: font(16)),
|
|
|
|
),
|
|
|
|
Spacer(),
|
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: w(7), vertical: w(4)),
|
|
|
|
child: Image.asset(
|
|
|
|
Utils.getImgPath(isComments
|
|
|
|
? 'swich_on'
|
|
|
|
: 'swich_off'),
|
|
|
|
width: w(44),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
// RoundButton(
|
|
|
|
// text: '预览',
|
|
|
|
// gradientStart: MyColours.color_ffffff,
|
|
|
|
// gradientEnd: MyColours.color_ffffff,
|
|
|
|
// borderColor: MyColours.color_438E93,
|
|
|
|
// textColor: MyColours.color_438E93,
|
|
|
|
// radius: ScreenUtil().setWidth(22),
|
|
|
|
// fontSize: 24,
|
|
|
|
// width: w(72),
|
|
|
|
// height: ScreenUtil().setWidth(44),
|
|
|
|
// isBold: true,
|
|
|
|
// onPressed: () {
|
|
|
|
// NavigatorUtil.goMarkingPreviewPage(context);
|
|
|
|
// },
|
|
|
|
// ),
|
|
|
|
]))),
|
|
|
|
VEmptyView(24),
|
|
|
|
couponProvider.couponListSelect != null &&
|
|
|
|
couponProvider.couponListSelect.length > 0
|
|
|
|
? _markingCupon(
|
|
|
|
select: isCommentsCoupon,
|
|
|
|
onPressedSelect: () {
|
|
|
|
setState(() {
|
|
|
|
isCommentsCoupon = !isCommentsCoupon;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onPressed: () async {
|
|
|
|
//切换活动
|
|
|
|
|
|
|
|
Map temp =
|
|
|
|
await NavigatorUtil.goMarkingCouponSelectPage(
|
|
|
|
context,
|
|
|
|
{'object': couponDataListComments},
|
|
|
|
mulSelect: false);
|
|
|
|
// Map temp = await NavigatorUtil.goCouponSelectPage(
|
|
|
|
// context,
|
|
|
|
// from: 'statistics',
|
|
|
|
// hasModify: false);
|
|
|
|
if (temp!= null && temp['coupon'] != null) {
|
|
|
|
couponDataListComments = temp['coupon'];
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
})
|
|
|
|
: (couponProvider.couponListSelect == null ||
|
|
|
|
couponProvider.couponListSelect.length == 0)
|
|
|
|
? _markingItem(
|
|
|
|
'顾客点评后赠送优惠券',
|
|
|
|
'当前没有可用优惠券,请创建优惠券后再来尝试。',
|
|
|
|
select: false,
|
|
|
|
)
|
|
|
|
: SizedBox(),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
color: MyColours.color_ffffff,
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
left: w(45), right: w(45), top: w(12), bottom: w(25)),
|
|
|
|
child: RoundButton(
|
|
|
|
text: '保存',
|
|
|
|
gradientStart: MyColours.color_199095,
|
|
|
|
gradientEnd: MyColours.color_199095,
|
|
|
|
// borderColor: MyColours.color_999999,
|
|
|
|
radius: r(5),
|
|
|
|
fontSize: 34,
|
|
|
|
height: w(40),
|
|
|
|
isBold: true,
|
|
|
|
onPressed: () async {
|
|
|
|
_setCouponShow();
|
|
|
|
},
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
));
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|