1,接入最新添加短信、邮件模版API并修改部分逻辑代码

2,接入最新获取默认模版API并修改部分逻辑代码
3,新建短信、邮件模版新增国内、国际模版选择
4,重构新建模版、编辑模版模块代码
5,梳理最新获取已有模版列表API修改
This commit is contained in:
“DaisyWu” 2024-07-09 16:04:56 +08:00
parent 3373b16d74
commit 7cd575009b
12 changed files with 339 additions and 232 deletions

View File

@ -114,7 +114,7 @@ class _ValueAddedServicesNoteAndEmailDetailPageState
onTap: () { onTap: () {
Navigator.pushNamed( Navigator.pushNamed(
context, Routers.customSMSTemplateListPage, context, Routers.customSMSTemplateListPage,
arguments: <String, int>{'type': type}); arguments: <String, int>{'channelType': type});
}, },
child: Row( child: Row(
children: <Widget>[ children: <Widget>[

View File

@ -1,5 +1,145 @@
import 'dart:convert'; import 'dart:convert';
class NewSMSTemplateEntity {
NewSMSTemplateEntity({
this.errorCode,
this.description,
this.errorMsg,
this.dataList,
});
NewSMSTemplateEntity.fromJson(Map<String, dynamic> json) {
errorCode = json['errorCode'];
description = json['description'];
errorMsg = json['errorMsg'];
if (json['data'] != null) {
dataList = <LangData>[];
json['data'].forEach((v) {
dataList!.add(LangData.fromJson(v));
});
}
}
int? errorCode;
String? description;
String? errorMsg;
List<LangData>? dataList;
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['errorCode'] = errorCode;
data['description'] = description;
data['errorMsg'] = errorMsg;
if (dataList != null) {
data['data'] = dataList!.map((v) => v.toJson()).toList();
}
return data;
}
}
class LangData {
LangData({
this.langType,
this.langName,
this.templates,
});
LangData.fromJson(Map<String, dynamic> json) {
langType = json['langType'];
langName = json['langName'];
if (json['templates'] != null) {
templates = <TemplateData>[];
json['templates'].forEach((v) {
templates!.add(TemplateData.fromJson(v));
});
}
}
int? langType;
String? langName;
List<TemplateData>? templates;
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['langType'] = langType;
data['langName'] = langName;
if (templates != null) {
data['templates'] = templates!.map((v) => v.toJson()).toList();
}
return data;
}
}
class TemplateData {
TemplateData({
this.langType,
this.langName,
this.templateType,
this.templateName,
this.template,
this.templatePreviewCode,
});
TemplateData.fromJson(Map<String, dynamic> json) {
langType = json['langType'];
langName = json['langName'];
templateType = json['templateType'];
templateName = json['templateName'];
template = json['template'];
templatePreviewCode = json['templatePreviewCode'] != null
? jsonEncode(json['templatePreviewCode'])
: null;
}
int? langType;
String? langName;
int? templateType;
String? templateName;
String? template;
String? fixedKey;
String? templatePreviewCode; // Changed to String
String? regards = '';
String? tips = '';
int? id;
String? name;
int? channelType;
bool? isUpdate = false;
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['langType'] = langType;
data['langName'] = langName;
data['templateType'] = templateType;
data['templateName'] = templateName;
data['template'] = template;
if (templatePreviewCode != null) {
data['templatePreviewCode'] = jsonDecode(templatePreviewCode!);
}
return data;
}
// New method to replace template variables with values from templatePreviewCode
String generatePreview() {
if (template == null || templatePreviewCode == null) {
return '';
}
// Decode the templatePreviewCode string back to a map
final Map<String, String> previewCodeMap =
Map<String, String>.from(jsonDecode(templatePreviewCode!));
String previewTemplate = template!;
previewCodeMap.forEach((String key, String value) {
previewTemplate = previewTemplate.replaceAll(
key, value + (value.length > 2 ? '\n' : ''));
});
return previewTemplate;
}
}
/*
class NewSMSTemplateEntity { class NewSMSTemplateEntity {
NewSMSTemplateEntity({ NewSMSTemplateEntity({
this.errorCode, this.errorCode,
@ -99,3 +239,4 @@ class SMSTemplateData {
return previewTemplate; return previewTemplate;
} }
} }
*/

View File

@ -14,14 +14,19 @@ class NewSMSTemplateLogic extends BaseGetXController {
//-- 1: 2: //-- 1: 2:
Future<void> getDefaultTemplate() async { Future<void> getDefaultTemplate() async {
final NewSMSTemplateEntity entity = await ApiRepository.to final NewSMSTemplateEntity entity =
.getDefaultTemplate(type: state.templateType.value); await ApiRepository.to.getDefaultTemplate();
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
state.templateList.value = entity.dataList ?? <SMSTemplateData>[]; state.langTemplateList.value = entity.dataList ?? <LangData>[];
state.templateList.value =
entity.dataList![state.selectedLangIndex.value].templates ??
<TemplateData>[];
if (state.templateList.isNotEmpty) { if (state.templateList.isNotEmpty) {
state.currentTemplate.value = state.templateList.firstWhere( state.currentTemplate.value = state.templateList.firstWhere(
(SMSTemplateData element) => (TemplateData element) =>
element.name == state.templateList[0].name, element.name ==
state.templateList[state.selectedTemplateIndex.value].name,
); );
state.currentTemplate.refresh(); state.currentTemplate.refresh();
} }
@ -35,12 +40,13 @@ class NewSMSTemplateLogic extends BaseGetXController {
return; return;
} }
final LoginEntity entity = await ApiRepository.to.addTemplateService( final LoginEntity entity = await ApiRepository.to.addTemplateService(
type: state.templateType.value, channelType: state.channelType.value,
name: state.templateNameTf.text, name: state.templateNameTf.text,
fixedKey: state.currentTemplate.value.fixedKey ?? '', langType: state.currentTemplate.value.langType ?? 0,
contentType: state.currentTemplate.value.contentType ?? 0, regards: state.templateOneTf.text,
regards: state.templateOneTf.text, tips: state.templateTwoTf.text,
tips: state.templateTwoTf.text); templateType: state.currentTemplate.value.templateType ?? 0,
);
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
showToast('添加成功'); showToast('添加成功');
Get.back(result: true); Get.back(result: true);
@ -75,15 +81,6 @@ class NewSMSTemplateLogic extends BaseGetXController {
// //
List<TextSpan> buildElectronicKeySpan({required bool isPreview}) { List<TextSpan> buildElectronicKeySpan({required bool isPreview}) {
//
if (state.templateType.value == 1) {
return _buildSMSElectronicKey(isPreview);
} else {
return _buildEmailElectronicKey(isPreview);
}
}
List<TextSpan> _buildSMSElectronicKey(bool isPreview) {
final List<TextSpan> textSpans = <TextSpan>[]; final List<TextSpan> textSpans = <TextSpan>[];
// //
if (isPreview) { if (isPreview) {
@ -110,6 +107,15 @@ class NewSMSTemplateLogic extends BaseGetXController {
textSpans.addAll(_buildDefaultTemplate(isPreview)); textSpans.addAll(_buildDefaultTemplate(isPreview));
} }
if (isPreview) {
textSpans.add(
TextSpan(
text: '\n${state.templateTwoTf.text}\n',
style: state.defaultStyle,
),
);
}
return textSpans; return textSpans;
} }
@ -150,70 +156,6 @@ class NewSMSTemplateLogic extends BaseGetXController {
} }
} }
if (isPreview) {
textSpans.add(
TextSpan(
text: '\n${state.templateTwoTf.text}',
style: state.defaultStyle,
),
);
}
return textSpans;
}
List<TextSpan> _buildEmailElectronicKey(bool isPreview) {
final List<TextSpan> textSpans = <TextSpan>[];
//
//
if (isPreview) {
textSpans.add(
TextSpan(
text: '${state.templateOneTf.text}\n',
style: state.defaultStyle,
),
);
} else {
String template = state.currentTemplate.value.template ?? '';
template = template.replaceAll('', '\n');
// ${}
final RegExp variableRegExp = RegExp(r'\{([^}]+)\}');
final Iterable<Match> matches = variableRegExp.allMatches(template);
int start = 0;
for (final Match match in matches) {
//
if (match.start > start) {
textSpans.add(
TextSpan(
text: template.substring(start, match.start),
style: state.defaultStyle,
),
);
}
//
textSpans.add(
TextSpan(
text: match.group(0),
style: state.highStyle,
),
);
start = match.end;
}
//
if (start < template.length) {
textSpans.add(
TextSpan(
text: template.substring(start),
style: state.defaultStyle,
),
);
}
}
return textSpans; return textSpans;
} }
@ -229,89 +171,85 @@ class NewSMSTemplateLogic extends BaseGetXController {
), ),
); );
} }
// if (isPreview) {
if ((state.templateType.value == 1) || if (state.currentTemplate.value.generatePreview().isNotEmpty) {
(state.templateType.value == 2 && isPreview == false)) {
if (isPreview) {
if (state.currentTemplate.value.generatePreview().isNotEmpty) {
textSpans.add(
TextSpan(
text: state.currentTemplate.value.generatePreview(),
style: state.defaultStyle,
),
);
//
if (isPreview) {
textSpans.add(
TextSpan(
text: '\n${state.templateTwoTf.text}',
style: state.defaultStyle,
),
);
}
}
return textSpans;
}
// ${}
final RegExp variableRegExp = RegExp(r'\$\{([^}]+)\}');
final String template = state.currentTemplate.value.template ?? '';
//
int startIndex = 0;
for (final Match match in variableRegExp.allMatches(template)) {
//
final String nonVariableText =
template.substring(startIndex, match.start);
//
final String replacedNonVariableText =
nonVariableText.replaceAllMapped(RegExp(r'|。'), (Match match) {
return '${match.group(0)}\n';
});
textSpans.add( textSpans.add(
TextSpan( TextSpan(
text: replacedNonVariableText, text: state.currentTemplate.value.generatePreview(),
style: state.defaultStyle, style: state.defaultStyle,
), ),
); );
// //
final String variableText = match.group(0) ?? ''; if (isPreview) {
textSpans.add( textSpans.add(
TextSpan( TextSpan(
text: variableText, text: '\n${state.templateTwoTf.text}',
style: state.highStyle, style: state.defaultStyle,
), ),
); );
}
//
startIndex = match.end;
} }
return textSpans;
}
// // ${}
final String remainingText = template.substring(startIndex); final RegExp variableRegExp = RegExp(r'\$\{([^}]+)\}');
final String template = state.currentTemplate.value.template ?? '';
//
int startIndex = 0;
for (final Match match in variableRegExp.allMatches(template)) {
//
final String nonVariableText =
template.substring(startIndex, match.start);
// //
final String replacedRemainingText = final String replacedNonVariableText =
remainingText.replaceAllMapped(RegExp(r'|。'), (Match match) { nonVariableText.replaceAllMapped(RegExp(r'|。'), (Match match) {
return '${match.group(0)}\n'; return '${match.group(0)}\n';
}); });
textSpans.add( textSpans.add(
TextSpan( TextSpan(
text: replacedRemainingText, text: replacedNonVariableText,
style: state.defaultStyle, style: state.defaultStyle,
), ),
); );
// //
if (isPreview) { final String variableText = match.group(0) ?? '';
textSpans.add( textSpans.add(
TextSpan( TextSpan(
text: '\n${state.templateTwoTf.text}', text: variableText,
style: state.defaultStyle, style: state.highStyle,
), ),
); );
}
//
startIndex = match.end;
}
//
final String remainingText = template.substring(startIndex);
//
final String replacedRemainingText =
remainingText.replaceAllMapped(RegExp(r'|。'), (Match match) {
return '${match.group(0)}\n';
});
textSpans.add(
TextSpan(
text: replacedRemainingText,
style: state.defaultStyle,
),
);
//
if (isPreview) {
textSpans.add(
TextSpan(
text: '\n${state.templateTwoTf.text}',
style: state.defaultStyle,
),
);
} }
return textSpans; return textSpans;

View File

@ -30,10 +30,10 @@ class _NewSMSTemplatePageState extends State<NewSMSTemplatePage> {
backgroundColor: AppColors.mainBackgroundColor, backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar( appBar: TitleAppBar(
barTitle: state.isUpdate.value == false barTitle: state.isUpdate.value == false
? state.templateType.value == 1 ? state.channelType.value == 1
? '新建短信模版'.tr ? '新建短信模版'.tr
: '新建邮件模版'.tr : '新建邮件模版'.tr
: state.templateType.value == 1 : state.channelType.value == 1
? '编辑短信模版'.tr ? '编辑短信模版'.tr
: '编辑邮件模版'.tr, : '编辑邮件模版'.tr,
haveBack: true, haveBack: true,
@ -84,12 +84,21 @@ class _NewSMSTemplatePageState extends State<NewSMSTemplatePage> {
Obx(() => state.isUpdate.value == false Obx(() => state.isUpdate.value == false
? CommonItem( ? CommonItem(
leftTitel: TranslationLoader.lanKeys!.type!.tr, leftTitel: TranslationLoader.lanKeys!.type!.tr,
rightTitle: state.currentTemplate.value.typeName ?? '', rightTitle: state.currentTemplate.value.templateName ?? '',
isHaveLine: false, isHaveLine: true,
isHaveDirection: true, isHaveDirection: true,
action: _showSelectTemplateType, action: _showSelectTemplateType,
) )
: Container()), : Container()),
Obx(() => state.isUpdate.value == false
? CommonItem(
leftTitel: '模版类型',
rightTitle: state.currentTemplate.value.langName ?? '',
isHaveLine: false,
isHaveDirection: true,
action: _showSelectLangType,
)
: Container()),
], ],
); );
} }
@ -123,18 +132,16 @@ class _NewSMSTemplatePageState extends State<NewSMSTemplatePage> {
child: _buildTemplateWithType(isPreview: false), child: _buildTemplateWithType(isPreview: false),
)), )),
SizedBox(height: 10.h), SizedBox(height: 10.h),
Obx(() => Visibility( Container(
visible: state.templateType.value == 1, margin: EdgeInsets.symmetric(horizontal: 25.w, vertical: 25.h),
child: Container( height: 100,
margin: EdgeInsets.symmetric(horizontal: 25.w, vertical: 25.h), child: Stack(
height: 100, alignment: Alignment.bottomRight,
child: Stack( children: <Widget>[
alignment: Alignment.bottomRight, _buildTextField(state.templateTwoTf),
children: <Widget>[ ],
_buildTextField(state.templateTwoTf), ),
], )
),
))),
], ],
), ),
); );
@ -169,7 +176,7 @@ class _NewSMSTemplatePageState extends State<NewSMSTemplatePage> {
), ),
child: _buildTemplateWithType(isPreview: true), child: _buildTemplateWithType(isPreview: true),
)), )),
if (state.templateType.value == 1) if (state.channelType.value == 1)
Padding( Padding(
padding: EdgeInsets.only( padding: EdgeInsets.only(
left: 25.w, left: 25.w,
@ -201,7 +208,7 @@ class _NewSMSTemplatePageState extends State<NewSMSTemplatePage> {
} else { } else {
return RichText( return RichText(
text: TextSpan( text: TextSpan(
children: state.currentTemplate.value.typeName == '电子钥匙' children: state.currentTemplate.value.templateName == '电子钥匙'
? logic.buildElectronicKeySpan(isPreview: isPreview) ? logic.buildElectronicKeySpan(isPreview: isPreview)
: logic.buildPasswordSpan(isPreview: isPreview), : logic.buildPasswordSpan(isPreview: isPreview),
), ),
@ -228,8 +235,7 @@ class _NewSMSTemplatePageState extends State<NewSMSTemplatePage> {
), ),
onChanged: (String value) { onChanged: (String value) {
setState(() { setState(() {
controller.text = value; logic.updateSmsCost(controller.text); //
logic.updateSmsCost(value); //
}); });
}, },
); );
@ -269,7 +275,7 @@ class _NewSMSTemplatePageState extends State<NewSMSTemplatePage> {
void _showSelectTemplateType() { void _showSelectTemplateType() {
final List<String> titleList = state.templateList final List<String> titleList = state.templateList
.map((SMSTemplateData template) => template.typeName ?? '') .map((TemplateData template) => template.templateName ?? '')
.toList(); .toList();
ShowBottomSheetTool().showSingleRowPicker( ShowBottomSheetTool().showSingleRowPicker(
context, context,
@ -279,8 +285,35 @@ class _NewSMSTemplatePageState extends State<NewSMSTemplatePage> {
sureTitle: TranslationLoader.lanKeys!.sure!.tr, sureTitle: TranslationLoader.lanKeys!.sure!.tr,
data: titleList, data: titleList,
clickCallBack: (int index, Object str) { clickCallBack: (int index, Object str) {
state.selectedTemplateIndex.value = index;
state.currentTemplate.value = state.templateList[index]; state.currentTemplate.value = state.templateList[index];
state.currentTemplate.value.typeName = str.toString(); state.currentTemplate.value.templateName = str.toString();
state.selectedTemplateIndex.refresh();
state.currentTemplate.refresh();
},
);
}
void _showSelectLangType() {
// langName
final List<String> langNames = state.langTemplateList
.map((LangData langData) => langData.langName ?? '')
.toList();
ShowBottomSheetTool().showSingleRowPicker(
context,
normalIndex: 0,
title: TranslationLoader.lanKeys!.type!.tr,
cancelTitle: TranslationLoader.lanKeys!.cancel!.tr,
sureTitle: TranslationLoader.lanKeys!.sure!.tr,
data: langNames,
clickCallBack: (int index, Object str) {
state.selectedLangIndex.value = index;
state.currentTemplate.value = state
.langTemplateList[state.selectedLangIndex.value]
.templates![state.selectedTemplateIndex.value];
state.currentTemplate.value.langName = str.toString();
state.selectedLangIndex.refresh();
state.currentTemplate.refresh(); state.currentTemplate.refresh();
}, },
); );

View File

@ -12,7 +12,7 @@ class NewSMSTemplateState {
templateNameTf.text = currentTemplate.value.name ?? ''; templateNameTf.text = currentTemplate.value.name ?? '';
templateOneTf.text = currentTemplate.value.regards ?? ''; templateOneTf.text = currentTemplate.value.regards ?? '';
templateTwoTf.text = currentTemplate.value.tips ?? ''; templateTwoTf.text = currentTemplate.value.tips ?? '';
templateType.value = currentTemplate.value.type ?? 0; channelType.value = currentTemplate.value.channelType ?? 0;
isUpdate.value = map['isUpdate']; isUpdate.value = map['isUpdate'];
} }
} }
@ -30,10 +30,13 @@ class NewSMSTemplateState {
final TextEditingController templateNameTf = TextEditingController(); final TextEditingController templateNameTf = TextEditingController();
RxBool isVip = false.obs; RxBool isVip = false.obs;
RxList<SMSTemplateData> templateList = <SMSTemplateData>[].obs; RxList<TemplateData> templateList = <TemplateData>[].obs;
Rx<SMSTemplateData> currentTemplate = SMSTemplateData().obs; // Rx<TemplateData> currentTemplate = TemplateData().obs; //
RxList<LangData> langTemplateList = <LangData>[].obs; //
RxInt selectedLangIndex = 0.obs; //
RxInt selectedTemplateIndex = 0.obs; //
RxBool isShowDate = false.obs; // RxBool isShowDate = false.obs; //
RxInt templateType = 0.obs; //1 2 RxInt channelType = 0.obs; //1 2
RxInt smsCost = 0.obs; // RxInt smsCost = 0.obs; //
RxString preContent = ''.obs; // RxString preContent = ''.obs; //
RxBool isUpdate = false.obs; // RxBool isUpdate = false.obs; //

View File

@ -29,7 +29,7 @@ class CustomSMSTemplateListEntity {
class CustomSMSTemplateListData { class CustomSMSTemplateListData {
CustomSMSTemplateListData( CustomSMSTemplateListData(
{this.type, {this.channelType,
this.list, this.list,
this.pageNo, this.pageNo,
this.pageSize, this.pageSize,
@ -37,7 +37,7 @@ class CustomSMSTemplateListData {
this.total}); this.total});
CustomSMSTemplateListData.fromJson(Map<String, dynamic> json) { CustomSMSTemplateListData.fromJson(Map<String, dynamic> json) {
type = json['type']; channelType = json['channelType'];
if (json['list'] != null) { if (json['list'] != null) {
list = <CustomSMSTemplateItem>[]; list = <CustomSMSTemplateItem>[];
json['list'].forEach((v) { json['list'].forEach((v) {
@ -49,7 +49,7 @@ class CustomSMSTemplateListData {
pages = json['pages']; pages = json['pages'];
total = json['total']; total = json['total'];
} }
int? type; int? channelType;
List<CustomSMSTemplateItem>? list; List<CustomSMSTemplateItem>? list;
int? pageNo; int? pageNo;
int? pageSize; int? pageSize;
@ -58,7 +58,7 @@ class CustomSMSTemplateListData {
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{}; final Map<String, dynamic> data = <String, dynamic>{};
data['type'] = type; data['channelType'] = channelType;
if (list != null) { if (list != null) {
data['list'] = list!.map((v) => v.toJson()).toList(); data['list'] = list!.map((v) => v.toJson()).toList();
} }
@ -73,58 +73,51 @@ class CustomSMSTemplateListData {
class CustomSMSTemplateItem { class CustomSMSTemplateItem {
CustomSMSTemplateItem( CustomSMSTemplateItem(
{this.id, {this.id,
this.userId, this.channelType,
this.type, this.templateType,
this.contentType,
this.name, this.name,
this.regards, this.regards,
this.tips, this.tips,
this.fixedKey,
this.createdAt, this.createdAt,
this.updatedAt, this.updatedAt,
this.template, this.langType,
this.fixedTemplate}); this.template});
CustomSMSTemplateItem.fromJson(Map<String, dynamic> json) { CustomSMSTemplateItem.fromJson(Map<String, dynamic> json) {
id = json['id']; id = json['id'];
userId = json['user_id']; channelType = json['channelType'];
type = json['type']; templateType = json['templateType'];
contentType = json['content_type'];
name = json['name']; name = json['name'];
regards = json['regards']; regards = json['regards'];
tips = json['tips']; tips = json['tips'];
fixedKey = json['fixed_key'];
createdAt = json['created_at']; createdAt = json['created_at'];
updatedAt = json['updated_at']; updatedAt = json['updated_at'];
langType = json['langType'];
template = json['template']; template = json['template'];
fixedTemplate = json['fixed_template'];
} }
int? id; int? id;
int? userId; int? channelType;
int? type; int? templateType;
int? contentType;
String? name; String? name;
String? regards; String? regards;
String? tips; String? tips;
String? fixedKey;
String? createdAt; String? createdAt;
String? updatedAt; String? updatedAt;
int? langType;
String? template; String? template;
String? fixedTemplate;
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{}; final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id; data['id'] = id;
data['user_id'] = userId; data['channelType'] = channelType;
data['type'] = type; data['templateType'] = templateType;
data['content_type'] = contentType;
data['name'] = name; data['name'] = name;
data['regards'] = regards; data['regards'] = regards;
data['tips'] = tips; data['tips'] = tips;
data['fixed_key'] = fixedKey;
data['created_at'] = createdAt; data['created_at'] = createdAt;
data['updated_at'] = updatedAt; data['updated_at'] = updatedAt;
data['langType'] = langType;
data['template'] = template; data['template'] = template;
data['fixed_template'] = fixedTemplate;
return data; return data;
} }
} }

View File

@ -20,7 +20,7 @@ class CustomSMSTemplateListLogic extends BaseGetXController {
} }
final CustomSMSTemplateListEntity entity = await ApiRepository.to final CustomSMSTemplateListEntity entity = await ApiRepository.to
.getSMSTemplateList( .getSMSTemplateList(
channelType: state.type.value, channelType: state.channelType.value,
pageNo: pageNo, pageNo: pageNo,
pageSize: int.parse(pageSize)); pageSize: int.parse(pageSize));
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {

View File

@ -42,7 +42,7 @@ class _CustomSMSTemplateListPageState extends State<CustomSMSTemplateListPage> {
return Scaffold( return Scaffold(
backgroundColor: AppColors.mainBackgroundColor, backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar( appBar: TitleAppBar(
barTitle: state.type.value == 1 ? '自定义短信模版'.tr : '自定义邮件模版'.tr, barTitle: state.channelType.value == 1 ? '自定义短信模版'.tr : '自定义邮件模版'.tr,
haveBack: true, haveBack: true,
backgroundColor: AppColors.mainColor), backgroundColor: AppColors.mainColor),
body: EasyRefreshTool( body: EasyRefreshTool(
@ -66,11 +66,11 @@ class _CustomSMSTemplateListPageState extends State<CustomSMSTemplateListPage> {
left: 30.w, right: 30.w, top: 30.w, bottom: 30.w), left: 30.w, right: 30.w, top: 30.w, bottom: 30.w),
padding: EdgeInsets.only(top: 25.w, bottom: 25.w), padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
onClick: () async { onClick: () async {
final SMSTemplateData templateData = SMSTemplateData(); final TemplateData templateData = TemplateData();
templateData.type = state.type.value; templateData.channelType = state.channelType.value;
templateData.isUpdate = false; templateData.isUpdate = false;
templateData.typeName = templateData.templateName =
templateData.contentType == 1 ? '电子钥匙' : '密码'; templateData.templateType == 1 ? '电子钥匙' : '密码';
final result = await Get.toNamed(Routers.newSMSTemplatePage, final result = await Get.toNamed(Routers.newSMSTemplatePage,
arguments: { arguments: {
'currentTemplate': templateData, 'currentTemplate': templateData,
@ -197,15 +197,16 @@ class _CustomSMSTemplateListPageState extends State<CustomSMSTemplateListPage> {
CustomSMSTemplateItem itemData) { CustomSMSTemplateItem itemData) {
return GestureDetector( return GestureDetector(
onTap: () async { onTap: () async {
final SMSTemplateData templateData = SMSTemplateData(); final TemplateData templateData = TemplateData();
templateData.name = itemData.name; templateData.name = itemData.name;
templateData.regards = itemData.regards; templateData.regards = itemData.regards;
templateData.tips = itemData.tips; templateData.tips = itemData.tips;
templateData.id = itemData.id; templateData.id = itemData.id;
templateData.template = itemData.template; templateData.template = itemData.template;
templateData.contentType = itemData.contentType; templateData.templateType = itemData.templateType;
templateData.typeName = templateData.contentType == 1 ? '电子钥匙' : '密码'; templateData.templateName =
templateData.type = itemData.type; templateData.templateName == 1 ? '电子钥匙' : '密码';
templateData.channelType = itemData.channelType;
templateData.isUpdate = true; templateData.isUpdate = true;
final result = await Get.toNamed(Routers.newSMSTemplatePage, final result = await Get.toNamed(Routers.newSMSTemplatePage,
arguments: {'currentTemplate': templateData, 'isUpdate': true}); arguments: {'currentTemplate': templateData, 'isUpdate': true});
@ -240,7 +241,7 @@ class _CustomSMSTemplateListPageState extends State<CustomSMSTemplateListPage> {
padding: EdgeInsets.only(left: 20.w, top: 20.h, bottom: 20.h), padding: EdgeInsets.only(left: 20.w, top: 20.h, bottom: 20.h),
child: RichText( child: RichText(
text: TextSpan( text: TextSpan(
children: itemData.contentType == 1 children: itemData.templateType == 1
? logic.buildElectronicKeySpan(templateData: itemData) ? logic.buildElectronicKeySpan(templateData: itemData)
: logic.buildPasswordSpan(templateData: itemData), : logic.buildPasswordSpan(templateData: itemData),
), ),

View File

@ -6,7 +6,7 @@ import 'package:star_lock/mine/valueAddedServices/valueAddedServicesSMSTemplate/
class CustomSMSTemplateListState { class CustomSMSTemplateListState {
CustomSMSTemplateListState() { CustomSMSTemplateListState() {
if (Get.arguments != null) { if (Get.arguments != null) {
type.value = Get.arguments['type']; channelType.value = Get.arguments['channelType'];
} }
} }
// //
@ -19,5 +19,5 @@ class CustomSMSTemplateListState {
RxBool isVip = false.obs; RxBool isVip = false.obs;
RxList<CustomSMSTemplateItem> smsTemplateList = <CustomSMSTemplateItem>[].obs; RxList<CustomSMSTemplateItem> smsTemplateList = <CustomSMSTemplateItem>[].obs;
RxInt type = 0.obs; RxInt channelType = 0.obs;
} }

View File

@ -243,9 +243,7 @@ abstract class Api {
final String getNoticeTemplateURL = '/key/getNoticeTemplate'; // final String getNoticeTemplateURL = '/key/getNoticeTemplate'; //
final String appGetAppInfoURL = '/app/getAppInfo'; //APP基本信息 final String appGetAppInfoURL = '/app/getAppInfo'; //APP基本信息
final String appGetFwVersionURL = '/app/getFwVersion'; // final String appGetFwVersionURL = '/app/getFwVersion'; //
final String smsTemplateListURL = '/v2/service/listTemplate'; // final String haveTemplateListURL = '/v2/service/listTemplate'; //
final String emailTemplateListURL =
'/v2/service/listEmailTemplate'; //
final String getDefaultTemplateURL = final String getDefaultTemplateURL =
'/v2/service/getDefaultTemplate'; // '/v2/service/getDefaultTemplate'; //
final String addTemplateServiceURL = '/v2/service/addTemplate'; // final String addTemplateServiceURL = '/v2/service/addTemplate'; //

View File

@ -2191,9 +2191,9 @@ class ApiProvider extends BaseProvider {
); );
// //
Future<Response<dynamic>> getDefaultTemplate(int type) => post( Future<Response<dynamic>> getDefaultTemplate() => post(
getDefaultTemplateURL.toUrl, getDefaultTemplateURL.toUrl,
jsonEncode(<String, dynamic>{'type': type}), jsonEncode(<String, dynamic>{}),
isUnShowLoading: true, isUnShowLoading: true,
); );
@ -2201,7 +2201,7 @@ class ApiProvider extends BaseProvider {
Future<Response<dynamic>> getSMSTemplateList( Future<Response<dynamic>> getSMSTemplateList(
int channelType, int pageNo, int pageSize) => int channelType, int pageNo, int pageSize) =>
post( post(
smsTemplateListURL.toUrl, haveTemplateListURL.toUrl,
jsonEncode(<String, dynamic>{ jsonEncode(<String, dynamic>{
'channelType': channelType, 'channelType': channelType,
'pageNo': pageNo, 'pageNo': pageNo,
@ -2211,17 +2211,17 @@ class ApiProvider extends BaseProvider {
); );
// //
Future<Response<dynamic>> addTemplateService(int type, String name, Future<Response<dynamic>> addTemplateService(int channelType, String name,
int contentType, String regards, String tips, String fixedKey) => int langType, String regards, String tips, int templateType) =>
post( post(
addTemplateServiceURL.toUrl, addTemplateServiceURL.toUrl,
jsonEncode(<String, dynamic>{ jsonEncode(<String, dynamic>{
'type': type, 'channelType': channelType,
'name': name, 'name': name,
'content_type': contentType, 'langType': langType,
'regards': regards, 'regards': regards,
'tips': tips, 'tips': tips,
'fixed_key': fixedKey 'templateType': templateType
}), }),
isUnShowLoading: true, isUnShowLoading: true,
); );

View File

@ -2217,8 +2217,8 @@ class ApiRepository {
} }
// //
Future<NewSMSTemplateEntity> getDefaultTemplate({required int type}) async { Future<NewSMSTemplateEntity> getDefaultTemplate() async {
final Response<dynamic> res = await apiProvider.getDefaultTemplate(type); final Response<dynamic> res = await apiProvider.getDefaultTemplate();
return NewSMSTemplateEntity.fromJson(res.body); return NewSMSTemplateEntity.fromJson(res.body);
} }
@ -2234,14 +2234,14 @@ class ApiRepository {
// //
Future<LoginEntity> addTemplateService( Future<LoginEntity> addTemplateService(
{required int type, {required int channelType,
required String name, required String name,
required int contentType, required int langType,
required String regards, required String regards,
required String tips, required String tips,
required String fixedKey}) async { required int templateType}) async {
final Response<dynamic> res = await apiProvider.addTemplateService( final Response<dynamic> res = await apiProvider.addTemplateService(
type, name, contentType, regards, tips, fixedKey); channelType, name, langType, regards, tips, templateType);
return LoginEntity.fromJson(res.body); return LoginEntity.fromJson(res.body);
} }