|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.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/utils.dart';
|
|
|
|
import 'package:one_key/widgets/h_empty_view.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/sai_you_yun_change_model.dart';
|
|
|
|
import '../../../models/sai_you_yun_model.dart';
|
|
|
|
import '../../../provider/marketing_center_provider.dart';
|
|
|
|
import '../../../utils/event_bus.dart';
|
|
|
|
import '../../../utils/screen_util.dart';
|
|
|
|
import '../../../widgets/round_button.dart';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 短信模版配置页面
|
|
|
|
*/
|
|
|
|
|
|
|
|
class SmsTemplateSettingPage extends StatefulWidget {
|
|
|
|
final String smsTemplate;
|
|
|
|
final String bookinginfo;
|
|
|
|
SmsTemplateSettingPage({Key key, this.smsTemplate, this.bookinginfo})
|
|
|
|
: super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
_SmsTemplateSettingPageState createState() => _SmsTemplateSettingPageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _SmsTemplateSettingPageState extends State<SmsTemplateSettingPage> {
|
|
|
|
String contentChangeStart = '';
|
|
|
|
|
|
|
|
TextEditingController controller = TextEditingController();
|
|
|
|
|
|
|
|
bool canChange = false; //选择了可变模版
|
|
|
|
|
|
|
|
List<String> btnData = ['店名', '仅包间名字', '小程序预订卡片'];
|
|
|
|
|
|
|
|
MarketingCenterProvider marketingCenterProvider;
|
|
|
|
|
|
|
|
String smsSelectValue = '';
|
|
|
|
|
|
|
|
int _cursorPosition = 0;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
// TODO: implement initState
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
smsSelectValue = widget.smsTemplate;
|
|
|
|
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
contentChangeStart =
|
|
|
|
'尊敬的贵宾,您好!诚挚感谢您选择${Provider.of<UserModel>(context, listen: false).user.sellername}用餐!\n';
|
|
|
|
_getSaiYouYunList();
|
|
|
|
// _getSaiYouYunChangeList();
|
|
|
|
// _getSmsChangeField();
|
|
|
|
_getData();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
///固定模版
|
|
|
|
_getSaiYouYunList() async {
|
|
|
|
await marketingCenterProvider.getSaiYouYunList(context);
|
|
|
|
if (widget.smsTemplate != null && widget.smsTemplate.length > 0) {
|
|
|
|
//默认选中
|
|
|
|
|
|
|
|
marketingCenterProvider.saiYouYunFixedData.forEach((element) {
|
|
|
|
if (element.temp == widget.smsTemplate) {
|
|
|
|
element.select = true;
|
|
|
|
controller.text = element.content;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
marketingCenterProvider.notifyListeners();
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<bool> _getSaiYouYunChangeList() async {
|
|
|
|
bool sucess = await marketingCenterProvider.getSaiYouYunChangeList(context);
|
|
|
|
if (sucess) {
|
|
|
|
if (widget.smsTemplate != null && widget.smsTemplate.length > 0) {
|
|
|
|
//默认选中
|
|
|
|
|
|
|
|
marketingCenterProvider.saiYouYunchangedData.forEach((element) {
|
|
|
|
if (element.temp == widget.smsTemplate) {
|
|
|
|
canChange = true;
|
|
|
|
element.select = true;
|
|
|
|
contentChangeStart = element.content.templateParam;
|
|
|
|
// controller.text = element.content;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
setState(() {});
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// marketingCenterProvider.notifyListeners();
|
|
|
|
}
|
|
|
|
|
|
|
|
_getData() async {
|
|
|
|
Future.wait<bool>([_getSmsChangeField(), _getSaiYouYunChangeList()])
|
|
|
|
.then((results) async {
|
|
|
|
print(results[0]);
|
|
|
|
if (results[0] && results[1]) {
|
|
|
|
//成功
|
|
|
|
String temp = widget.bookinginfo;
|
|
|
|
marketingCenterProvider.smsChangeFieldData.forEach((element) {
|
|
|
|
int count = widget.bookinginfo.split(element.code).length - 1;
|
|
|
|
|
|
|
|
element.times = count;
|
|
|
|
if (temp.contains(element.code)) {
|
|
|
|
temp = temp.replaceAll(element.code, element.show);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
// if (contentChangeStart.endsWith('\n')) {
|
|
|
|
// print(temp);
|
|
|
|
// String result = temp.substring(1, temp.length);
|
|
|
|
// print(result);
|
|
|
|
|
|
|
|
// controller.text =
|
|
|
|
// temp.startsWith('\n') ? temp.substring(1, temp.length) : temp;
|
|
|
|
// }
|
|
|
|
controller.text = temp;
|
|
|
|
print(controller.text);
|
|
|
|
setState(() {});
|
|
|
|
} else {
|
|
|
|
// if (!results[0]) {
|
|
|
|
// //没有优惠券
|
|
|
|
// } else {}
|
|
|
|
// if (!results[1]) {
|
|
|
|
// //没有营销中心数据
|
|
|
|
// } else {}
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
}).catchError((e) {
|
|
|
|
print(e);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/// 获取可变模板允许配置字段
|
|
|
|
Future<bool> _getSmsChangeField() async {
|
|
|
|
bool suceess = await marketingCenterProvider.getSmsChangeField(context);
|
|
|
|
if (suceess) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///设置店铺短信可变模版
|
|
|
|
Future<bool> _saveSaiYouYunChange(String text,
|
|
|
|
{bool isShowLoading = true}) async {
|
|
|
|
Map<String, String> params = {
|
|
|
|
'sid': Provider.of<UserModel>(context, listen: false).user.sellerid,
|
|
|
|
'sms_code': smsSelectValue,
|
|
|
|
// 'bookinginfo': smsSelectValue == 'tqNH3' || smsSelectValue == 'EZXsN2'
|
|
|
|
// ? text.startsWith('\n')
|
|
|
|
// ? text
|
|
|
|
// : '\n' + text
|
|
|
|
// : text,
|
|
|
|
'bookinginfo': text,
|
|
|
|
// 'bookinginfo': text.startsWith('\n') ? text : '\n' + text,
|
|
|
|
};
|
|
|
|
|
|
|
|
bool success = await marketingCenterProvider
|
|
|
|
.saveSaiYouYunChange(context, params, showLoading: isShowLoading);
|
|
|
|
// await _setTempleteSMS();
|
|
|
|
|
|
|
|
if (success) {
|
|
|
|
await _setTempleteSMS();
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///设置店铺短信固定模版
|
|
|
|
Future<bool> _setTempleteSMS({bool isShowLoading = true}) async {
|
|
|
|
Map<String, String> params = {
|
|
|
|
'sid': Provider.of<UserModel>(context, listen: false).user.sellerid,
|
|
|
|
'key': 'saiyouyun',
|
|
|
|
'value': smsSelectValue,
|
|
|
|
};
|
|
|
|
|
|
|
|
bool success = await marketingCenterProvider.setConfing(context, params,
|
|
|
|
needToast: false);
|
|
|
|
|
|
|
|
if (success) {
|
|
|
|
bus.emit('getDzSellerConf');
|
|
|
|
Utils.showToast('保存成功');
|
|
|
|
Navigator.pop(context);
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
List<Widget> templateWidgets(String title, List<SaiYouYunSunModel> temData) {
|
|
|
|
List<Widget> data = [];
|
|
|
|
for (var i = 0; i < temData.length; i++) {
|
|
|
|
data.add(btnItem(temData[i].temp, temData[i].select, onTap: () {
|
|
|
|
// if (title == '固定模版') {
|
|
|
|
canChange = false;
|
|
|
|
marketingCenterProvider.saiYouYunFixedData.forEach((element) {
|
|
|
|
element.select = false;
|
|
|
|
});
|
|
|
|
// i 的select = true;
|
|
|
|
temData[i].select = true;
|
|
|
|
smsSelectValue = temData[i].temp;
|
|
|
|
// controller.text = temData[i].content;
|
|
|
|
// controller.text = temData[i].content;
|
|
|
|
String temp = temData[i].content;
|
|
|
|
controller.text = temp;
|
|
|
|
// controller.text =
|
|
|
|
// temp.startsWith('\n') ? temp.substring(1, temp.length) : temp;
|
|
|
|
marketingCenterProvider.saiYouYunchangedData.forEach((element) {
|
|
|
|
element.select = false;
|
|
|
|
});
|
|
|
|
// } else {
|
|
|
|
// canChange = true;
|
|
|
|
// marketingCenterProvider.saiYouYunchangedData.forEach((element) {
|
|
|
|
// element.select = false;
|
|
|
|
// });
|
|
|
|
// // i 的select = true;
|
|
|
|
// temData[i].select = true;
|
|
|
|
// smsSelectValue = temData[i].temp;
|
|
|
|
// controller.text = temData[i].content;
|
|
|
|
// marketingCenterProvider.saiYouYunFixedData.forEach((element) {
|
|
|
|
// element.select = false;
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
setState(() {});
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
List<Widget> templateChangesWidgets(
|
|
|
|
String title, List<SaiYouYunChangeSunModel> temData) {
|
|
|
|
List<Widget> data = [];
|
|
|
|
for (var i = 0; i < temData.length; i++) {
|
|
|
|
data.add(btnItem(temData[i].temp, temData[i].select, onTap: () {
|
|
|
|
// if (!canChange) {
|
|
|
|
//从固定模版变更过来的,清空文本框内容
|
|
|
|
controller.text = temData[i].now == null
|
|
|
|
? ''
|
|
|
|
: temData[i].now.content == null
|
|
|
|
? ''
|
|
|
|
: temData[i].now.content;
|
|
|
|
|
|
|
|
// controller.text = temData[i].now == null
|
|
|
|
// ? ''
|
|
|
|
// : temData[i].now.content == null
|
|
|
|
// ? ''
|
|
|
|
// : temData[i].now.content.startsWith('\n')
|
|
|
|
// ? temData[i]
|
|
|
|
// .now
|
|
|
|
// .content
|
|
|
|
// .substring(1, temData[i].now.content.length)
|
|
|
|
// : temData[i].now.content;
|
|
|
|
// }
|
|
|
|
canChange = true;
|
|
|
|
marketingCenterProvider.saiYouYunchangedData.forEach((element) {
|
|
|
|
element.select = false;
|
|
|
|
});
|
|
|
|
// i 的select = true;
|
|
|
|
contentChangeStart = temData[i].content.templateParam;
|
|
|
|
temData[i].select = true;
|
|
|
|
smsSelectValue = temData[i].temp;
|
|
|
|
|
|
|
|
// controller.text = temData[i].content.templateCode;
|
|
|
|
marketingCenterProvider.saiYouYunFixedData.forEach((element) {
|
|
|
|
element.select = false;
|
|
|
|
});
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
List<Widget> btnWidgets() {
|
|
|
|
List<Widget> data = [];
|
|
|
|
for (var i = 0;
|
|
|
|
i < marketingCenterProvider.smsChangeFieldData.length;
|
|
|
|
i++) {
|
|
|
|
data.add(btnItem(marketingCenterProvider.smsChangeFieldData[i].name, true,
|
|
|
|
onTap: () {
|
|
|
|
marketingCenterProvider.smsChangeFieldData[i].times++;
|
|
|
|
print(controller.text);
|
|
|
|
|
|
|
|
// 获取当前光标位置
|
|
|
|
// int cursorPosition = _cursorPosition;
|
|
|
|
int cursorPosition = controller.selection.baseOffset;
|
|
|
|
if (cursorPosition != -1) {
|
|
|
|
// 插入文本
|
|
|
|
controller.text = controller.text.substring(0, cursorPosition) +
|
|
|
|
marketingCenterProvider.smsChangeFieldData[i].show +
|
|
|
|
controller.text.substring(cursorPosition);
|
|
|
|
|
|
|
|
print(controller.text);
|
|
|
|
|
|
|
|
// 设置新的光标位置
|
|
|
|
controller.selection = TextSelection.fromPosition(TextPosition(
|
|
|
|
offset: cursorPosition +
|
|
|
|
marketingCenterProvider.smsChangeFieldData[i].show.length,
|
|
|
|
affinity: TextAffinity.downstream));
|
|
|
|
setState(() {
|
|
|
|
_cursorPosition = controller.selection.baseOffset;
|
|
|
|
// cursorPosition = _cursorPosition;
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
controller.text += marketingCenterProvider.smsChangeFieldData[i].show;
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget btnItem(String title, bool select, {GestureTapCallback onTap}) {
|
|
|
|
return InkWell(
|
|
|
|
onTap: onTap,
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.all(w(3)),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: select ? MyColours.color_438E93 : MyColours.color_ffffff,
|
|
|
|
borderRadius: BorderRadius.circular(r(5)),
|
|
|
|
border: Border.all(width: w(1), color: MyColours.color_438E93)),
|
|
|
|
child: Text(title,
|
|
|
|
style: TextStyle(
|
|
|
|
color: select ? MyColours.color_ffffff : MyColours.color_438E93,
|
|
|
|
fontSize: font(12),
|
|
|
|
fontWeight: FontWeight.bold)),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _templeteWidget(
|
|
|
|
String title,
|
|
|
|
) {
|
|
|
|
return Container(
|
|
|
|
margin: EdgeInsets.symmetric(horizontal: w(16), vertical: w(5)),
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(fontSize: font(16), color: MyColours.color_515151),
|
|
|
|
),
|
|
|
|
HEmptyView(34),
|
|
|
|
Expanded(
|
|
|
|
child: Wrap(
|
|
|
|
spacing: w(5),
|
|
|
|
runSpacing: w(5),
|
|
|
|
children: title == '固定模版'
|
|
|
|
? templateWidgets(
|
|
|
|
title, marketingCenterProvider.saiYouYunFixedData)
|
|
|
|
: templateChangesWidgets(
|
|
|
|
title, marketingCenterProvider.saiYouYunchangedData),
|
|
|
|
))
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
marketingCenterProvider =
|
|
|
|
Provider.of<MarketingCenterProvider>(context, listen: true);
|
|
|
|
return Scaffold(
|
|
|
|
backgroundColor: MyColours.color_ffffff,
|
|
|
|
appBar: SystemAppBar('预订通知短信模版选择'),
|
|
|
|
body: Column(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
_templeteWidget('固定模版'),
|
|
|
|
_templeteWidget('可变模版'),
|
|
|
|
VEmptyView(10),
|
|
|
|
Container(
|
|
|
|
width: double.infinity,
|
|
|
|
padding: EdgeInsets.all(w(10)),
|
|
|
|
margin: EdgeInsets.symmetric(horizontal: w(16)),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border.all(
|
|
|
|
color: MyColours.color_DBDBDB, width: w(1)),
|
|
|
|
borderRadius: BorderRadius.circular(r(8))),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
if (canChange)
|
|
|
|
Text(
|
|
|
|
contentChangeStart,
|
|
|
|
style: TextStyle(
|
|
|
|
height: 1.5,
|
|
|
|
color: MyColours.color_66000000,
|
|
|
|
fontSize: font(14)),
|
|
|
|
),
|
|
|
|
TextField(
|
|
|
|
enabled: canChange,
|
|
|
|
controller: controller,
|
|
|
|
// textAlign: TextAlign.right,
|
|
|
|
// textAlignVertical: TextAlignVertical.bottom,
|
|
|
|
maxLines: 10,
|
|
|
|
|
|
|
|
// inputFormatters: title == '金额'
|
|
|
|
// ? [
|
|
|
|
// FilteringTextInputFormatter(RegExp("[0-9.]"),
|
|
|
|
// allow: true),
|
|
|
|
// MyNumberTextInputFormatter(digit: 2),
|
|
|
|
// ]
|
|
|
|
// : [],
|
|
|
|
|
|
|
|
// //光标颜色
|
|
|
|
// cursorColor:
|
|
|
|
// widget.isSelect ? Colors.white : MyColours.color_199095,
|
|
|
|
//输入文本的样式
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: ScreenUtil().setSp(28),
|
|
|
|
color: MyColours.color_515151),
|
|
|
|
// focusNode: focusNode,
|
|
|
|
decoration: InputDecoration(
|
|
|
|
border:
|
|
|
|
OutlineInputBorder(borderSide: BorderSide.none),
|
|
|
|
hintText:
|
|
|
|
canChange ? '以上内容为固定不可编辑,点击这里开始编辑短信内容' : '请选择模版',
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
color: MyColours.color_999999,
|
|
|
|
fontSize: ScreenUtil().setSp(28),
|
|
|
|
),
|
|
|
|
contentPadding: EdgeInsets.zero,
|
|
|
|
),
|
|
|
|
onChanged: (value) {
|
|
|
|
//添加的代码:光标一直在文本框后面
|
|
|
|
// controller.value = TextEditingValue(
|
|
|
|
// text: controller.text,
|
|
|
|
// selection:
|
|
|
|
// TextSelection.fromPosition(TextPosition(
|
|
|
|
// affinity: TextAffinity.downstream,
|
|
|
|
// offset: controller.text.length,
|
|
|
|
// )));
|
|
|
|
// setState(() {
|
|
|
|
// _cursorPosition = controller.selection.baseOffset;
|
|
|
|
// });
|
|
|
|
},
|
|
|
|
onEditingComplete: () {
|
|
|
|
FocusScope.of(context)
|
|
|
|
.requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
},
|
|
|
|
// keyboardType: inputType,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
VEmptyView(10),
|
|
|
|
if (canChange)
|
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: w(21)),
|
|
|
|
child: Wrap(
|
|
|
|
crossAxisAlignment: WrapCrossAlignment.start,
|
|
|
|
spacing: w(10),
|
|
|
|
runSpacing: w(10),
|
|
|
|
children: btnWidgets(),
|
|
|
|
))
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)),
|
|
|
|
Container(
|
|
|
|
height: ScreenUtil().setWidth(91 * 2),
|
|
|
|
width: double.infinity,
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
top: ScreenUtil().setWidth(16 * 2),
|
|
|
|
bottom: ScreenUtil().setWidth(35 * 2),
|
|
|
|
left: ScreenUtil().setWidth(23 * 2),
|
|
|
|
right: ScreenUtil().setWidth(23 * 2),
|
|
|
|
),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: MyColours.color_ffffff,
|
|
|
|
boxShadow: [
|
|
|
|
BoxShadow(
|
|
|
|
spreadRadius: ScreenUtil().setWidth(2),
|
|
|
|
color: Color.fromRGBO(0, 0, 0, 0.1),
|
|
|
|
offset: Offset(0, ScreenUtil().setWidth(-2)),
|
|
|
|
blurRadius: ScreenUtil().setWidth(8))
|
|
|
|
],
|
|
|
|
borderRadius: BorderRadius.all(
|
|
|
|
Radius.circular(ScreenUtil().setWidth(16)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
// RoundButton(
|
|
|
|
// text: '预览效果',
|
|
|
|
// width: w(100),
|
|
|
|
// height: ScreenUtil().setWidth(80),
|
|
|
|
// radius: ScreenUtil().setWidth(14),
|
|
|
|
// gradientStart: MyColours.color_ffffff,
|
|
|
|
// gradientEnd: MyColours.color_ffffff,
|
|
|
|
// borderColor: MyColours.color_438E93,
|
|
|
|
// textColor: MyColours.color_438E93,
|
|
|
|
// isBold: true,
|
|
|
|
// fontSize: 32,
|
|
|
|
// onPressed: () {
|
|
|
|
// DialogUtil.cupertinoAlertDialog(context,
|
|
|
|
// textAlign: TextAlign.left,
|
|
|
|
// showlTitle: false,
|
|
|
|
// content: canChange
|
|
|
|
// ? contentChangeStart + controller.text
|
|
|
|
// : controller.text);
|
|
|
|
// },
|
|
|
|
// ),
|
|
|
|
// HEmptyView(30),
|
|
|
|
Expanded(
|
|
|
|
child: RoundButton(
|
|
|
|
text: '保存',
|
|
|
|
height: ScreenUtil().setWidth(80),
|
|
|
|
radius: ScreenUtil().setWidth(14),
|
|
|
|
isBold: true,
|
|
|
|
fontSize: 32,
|
|
|
|
onPressed: () async {
|
|
|
|
if (smsSelectValue.length == 0) {
|
|
|
|
Utils.showToast('请选择模版类型');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (canChange) {
|
|
|
|
if (controller.text.trim().length == 0) {
|
|
|
|
Utils.showToast('请输入内容后保存');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// bool canRequest = marketingCenterProvider
|
|
|
|
// .smsChangeFieldData
|
|
|
|
// .every((element) {
|
|
|
|
// if (element.times > 0) {
|
|
|
|
// int count =
|
|
|
|
// controller.text.split(element.show).length -
|
|
|
|
// 1;
|
|
|
|
|
|
|
|
// if (count != element.times) {
|
|
|
|
// Utils.showToast('${element.show}不符合规范,请检查');
|
|
|
|
|
|
|
|
// return false;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// return true;
|
|
|
|
// });
|
|
|
|
|
|
|
|
// if (canRequest) {
|
|
|
|
String tempStr = controller.text;
|
|
|
|
marketingCenterProvider.smsChangeFieldData
|
|
|
|
.forEach((element) {
|
|
|
|
if (tempStr.contains(element.show)) {
|
|
|
|
tempStr = tempStr.replaceAll(
|
|
|
|
element.show, element.code);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
_saveSaiYouYunChange(tempStr);
|
|
|
|
// }
|
|
|
|
// print('fffff');
|
|
|
|
} else {
|
|
|
|
_setTempleteSMS();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|