diff --git a/lib/appRouters.dart b/lib/appRouters.dart index 47b83b66..907c13f0 100755 --- a/lib/appRouters.dart +++ b/lib/appRouters.dart @@ -186,8 +186,6 @@ import 'mine/mineSet/lockUserManage/lockUserManageList/lockUserManageList_page.d import 'mine/mineSet/lockUserManage/ownedKeyList/ownedKeyList_page.dart'; import 'mine/supportStaff/supportStaff_page.dart'; import 'mine/valueAddedServices/valueAddedServicesBuy/valueAddedServicesBuy_page.dart'; -import 'mine/valueAddedServices/valueAddedServicesEmailTemplate/valueAddedServicesAddEmailTemplate/valueAddedServicesAddEmailTemplate_page.dart'; -import 'mine/valueAddedServices/valueAddedServicesEmailTemplate/valueAddedServicesListEmailTemplate/valueAddedServicesListEmailTemplate_page.dart'; import 'mine/valueAddedServices/valueAddedServicesHighFunction/valueAddedServicesHighFunction_page.dart'; import 'mine/valueAddedServices/valueAddedServicesList/valueAddedServicesList_page.dart'; import 'mine/valueAddedServices/valueAddedServicesNoteAndEmailDetail/valueAddedServicesNoteAndEmailDetail_page.dart'; @@ -364,8 +362,6 @@ abstract class Routers { '/NewSMSTemplatePage'; // 增值服务-自定义短信模版 static const String valueAddedServicesListEmailTemplatePage = '/ValueAddedServicesListEmailTemplatePage'; // 增值服务-邮箱模版列表 - static const String valueAddedServicesAddEmailTemplatePage = - '/ValueAddedServicesAddEmailTemplatePage'; // 增值服务-自定义邮箱模版 static const String valueAddedServicesBuyAndUseRecordManagePage = '/ValueAddedServicesBuyAndUseRecordManagePage'; // 增值服务-购买使用记录 @@ -886,14 +882,6 @@ abstract class AppRouters { name: Routers.newSMSTemplatePage, page: () => const NewSMSTemplatePage(), ), - GetPage( - name: Routers.valueAddedServicesListEmailTemplatePage, - page: () => const ValueAddedServicesListEmailTemplatePage(), - ), - GetPage( - name: Routers.valueAddedServicesAddEmailTemplatePage, - page: () => const ValueAddedServicesAddEmailTemplatePage(), - ), GetPage( name: Routers.lockScreenPage, page: () => const LockScreenPage(), diff --git a/lib/mine/valueAddedServices/valueAddedServicesEmailTemplate/valueAddedServicesAddEmailTemplate/valueAddedServicesAddEmailTemplate_page.dart b/lib/mine/valueAddedServices/valueAddedServicesEmailTemplate/valueAddedServicesAddEmailTemplate/valueAddedServicesAddEmailTemplate_page.dart deleted file mode 100755 index 1102058a..00000000 --- a/lib/mine/valueAddedServices/valueAddedServicesEmailTemplate/valueAddedServicesAddEmailTemplate/valueAddedServicesAddEmailTemplate_page.dart +++ /dev/null @@ -1,329 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:get/get.dart'; - -import '../../../../app_settings/app_colors.dart'; -import '../../../../tools/commonItem.dart'; -import '../../../../tools/showBottomSheetTool.dart'; -import '../../../../tools/submitBtn.dart'; -import '../../../../tools/titleAppBar.dart'; -import '../../../../translations/trans_lib.dart'; - -//高亮样式 -final TextStyle highStyle = - TextStyle(color: const Color(0xFFEEDFA8), fontSize: 20.sp); - -//默认样式 -final TextStyle defaultStyle = TextStyle(color: Colors.black, fontSize: 20.sp); - -//预览样式封装-密码 -InlineSpan emailPasswardSpan = TextSpan(children: [ - TextSpan( - text: - '${TranslationLoader.lanKeys!.hello!.tr},${TranslationLoader.lanKeys!.yourRoomIs!.tr}:', - style: defaultStyle), - TextSpan( - text: '{${TranslationLoader.lanKeys!.roomName!.tr}', style: highStyle), - TextSpan( - text: ',${TranslationLoader.lanKeys!.theCodeToOpenTheDoorIs!.tr}:', - style: defaultStyle), - TextSpan( - text: '{${TranslationLoader.lanKeys!.password!.tr}}', style: highStyle), - TextSpan( - text: '。${TranslationLoader.lanKeys!.periodValidity!.tr}:', - style: defaultStyle), - TextSpan( - text: '{${TranslationLoader.lanKeys!.periodValidity!.tr}}', - style: highStyle), - TextSpan( - text: '。${TranslationLoader.lanKeys!.templateTip1!.tr}。', - style: defaultStyle), -]); - -//预览样式封装-密码提示 -InlineSpan emailPasswardTipSpan = TextSpan(children: [ - TextSpan( - text: TranslationLoader.lanKeys!.templateTip4!.tr, style: defaultStyle), - TextSpan( - text: '{${TranslationLoader.lanKeys!.roomName!.tr}}', style: highStyle), - TextSpan(text: '、', style: defaultStyle), - TextSpan( - text: '{${TranslationLoader.lanKeys!.password!.tr}}', style: highStyle), - TextSpan(text: TranslationLoader.lanKeys!.and!.tr, style: defaultStyle), - TextSpan( - text: '{${TranslationLoader.lanKeys!.periodValidity!.tr}}', - style: highStyle), - TextSpan( - text: TranslationLoader.lanKeys!.willBeReplacedWithTheActualValue!.tr, - style: defaultStyle), -]); - -String emaiPasswardStr = - "${TranslationLoader.lanKeys!.hello!.tr},${TranslationLoader.lanKeys!.yourRoomIs!.tr}:{${TranslationLoader.lanKeys!.roomName!.tr}},${TranslationLoader.lanKeys!.theCodeToOpenTheDoorIs!.tr}:{${TranslationLoader.lanKeys!.password!.tr}}。${TranslationLoader.lanKeys!.periodValidity!.tr}:{${TranslationLoader.lanKeys!.periodValidity!.tr}}。${TranslationLoader.lanKeys!.templateTip1!.tr}"; - -//预览样式封装-电子钥匙 -InlineSpan emailElectronicKeySpan = TextSpan(children: [ - TextSpan( - text: TranslationLoader.lanKeys!.templateTip2!.tr, style: defaultStyle), - TextSpan(text: 'https://abc.com/bcd', style: highStyle) -]); - -//预览样式封装-电子钥匙提示 -InlineSpan emailElectronicKeyTipSpan = TextSpan(children: [ - TextSpan( - text: TranslationLoader.lanKeys!.templateTip4!.tr, style: defaultStyle), - TextSpan( - text: '{${TranslationLoader.lanKeys!.downloadLink!.tr}', - style: highStyle), - TextSpan( - text: TranslationLoader.lanKeys!.willBeReplacedWithTheActualValue!.tr, - style: defaultStyle), -]); - -String emailElectronicKeyStr = - "${TranslationLoader.lanKeys!.templateTip2!.tr}\n{${TranslationLoader.lanKeys!.downloadLink!.tr}}"; - -class ValueAddedServicesAddEmailTemplatePage extends StatefulWidget { - const ValueAddedServicesAddEmailTemplatePage({Key? key}) : super(key: key); - - @override - State createState() => - _ValueAddedServicesAddEmailTemplatePageState(); -} - -class _ValueAddedServicesAddEmailTemplatePageState - extends State { - final _templateOneTf = TextEditingController(); - final _templateNameTf = TextEditingController(); - - @override - void initState() { - super.initState(); - } - - @override - Widget build(BuildContext context) { - _templateOneTf.text = emailElectronicKeyStr; - - return Scaffold( - backgroundColor: AppColors.mainBackgroundColor, - appBar: TitleAppBar( - barTitle: TranslationLoader.lanKeys!.customMailTemplate!.tr, - haveBack: true, - backgroundColor: AppColors.mainColor), - body: ListView( - children: [ - _buildEditTopInfo(), - SizedBox( - height: 10.h, - ), - _buildEditTemplate(), - SizedBox( - height: 10.h, - ), - _buildpreview(), - SizedBox(height: 42.h), - SubmitBtn( - btnName: TranslationLoader.lanKeys!.save!.tr, - borderRadius: 10.w, - margin: EdgeInsets.only( - left: 30.w, right: 30.w, top: 30.w, bottom: 30.w), - padding: EdgeInsets.only(top: 25.w, bottom: 25.w), - onClick: () { - // Navigator.pushNamed(context, Routers.sendElectronicKeyManagePage); - }), - ], - )); - } - - Widget _buildEditTopInfo() { - return Column( - children: [ - CommonItem( - leftTitel: TranslationLoader.lanKeys!.name!.tr, - rightTitle: "", - isHaveLine: true, - isHaveRightWidget: true, - rightWidget: getTFWidget( - _templateNameTf, TranslationLoader.lanKeys!.pleaseEnter!.tr)), - CommonItem( - leftTitel: TranslationLoader.lanKeys!.type!.tr, - rightTitle: TranslationLoader.lanKeys!.password!.tr, - isHaveLine: false, - action: () { - _showSelectTemplateType(); - }), - ], - ); - } - - Widget _buildEditTemplate() { - return Container( - color: Colors.white, - child: Column( - children: [ - Row( - children: [ - Padding( - padding: EdgeInsets.only( - left: 25.w, top: 25.h, bottom: 25.h, right: 25.w), - child: Text( - TranslationLoader.lanKeys!.templateContent!.tr, - style: - TextStyle(fontSize: 28.sp, fontWeight: FontWeight.w600), - ), - ), - ], - ), - Container( - margin: EdgeInsets.only(left: 25.w, right: 25.w, bottom: 25.h), - height: 100, - child: TextField( - maxLines: 8, - // maxLength:1000, - textAlign: TextAlign.start, - controller: _templateOneTf, - style: TextStyle( - color: Colors.black, - fontSize: 28.sp, - ), - decoration: InputDecoration( - contentPadding: EdgeInsets.only( - top: 20.h, left: 20.w, right: 20.w, bottom: 20.h), - border: OutlineInputBorder( - ///设置边框四个角的弧度 - borderRadius: BorderRadius.all(Radius.circular(20.h)), - - ///用来配置边框的样式 - borderSide: const BorderSide( - ///设置边框的颜色 - color: Color(0xffB2B2B2), - - ///设置边框的粗细 - width: 0.5, - ), - ), - - ///用来配置输入框获取焦点时的颜色 - focusedBorder: OutlineInputBorder( - ///设置边框四个角的弧度 - borderRadius: BorderRadius.all(Radius.circular(20.h)), - - ///用来配置边框的样式 - borderSide: const BorderSide( - ///设置边框的颜色 - color: Color(0xffB2B2B2), - - ///设置边框的粗细 - width: 1, - ), - ), - ), - ), - ), - Container( - padding: EdgeInsets.only( - top: 20.h, left: 20.w, right: 20.w, bottom: 20.h), - margin: EdgeInsets.only(left: 15.w, right: 15.w, bottom: 15.h), - decoration: BoxDecoration( - color: const Color(0xFFFbF9EC), - borderRadius: BorderRadius.circular(10.h)), - child: RichText(text: emailElectronicKeyTipSpan), - ) - ], - ), - ); - } - - Widget _buildpreview() { - return Column( - // mainAxisAlignment: MainAxisAlignment.start, - children: [ - Container( - color: Colors.white, - margin: EdgeInsets.only(bottom: 20.h), - child: Column( - children: [ - Column( - children: [ - Row( - children: [ - Padding( - padding: EdgeInsets.only( - left: 25.w, - top: 25.h, - bottom: 25.h, - right: 25.w), - child: Text( - TranslationLoader.lanKeys!.preview!.tr, - style: TextStyle(fontSize: 20.sp), - ), - ), - ], - ), - Container( - margin: EdgeInsets.only( - left: 25.w, right: 25.w, bottom: 20.h), - padding: EdgeInsets.only( - left: 20.w, top: 20.h, right: 20.w, bottom: 20.h), - decoration: BoxDecoration( - color: const Color(0xFFF5F5F5), - borderRadius: BorderRadius.circular(10.h), - ), - child: RichText(text: emailElectronicKeySpan), - ) - ], - ), - ], - )) - ]); - } - - Widget getTFWidget(TextEditingController tfController, String tfStr) { - return Container( - height: 50.h, - width: 500.w, - child: Row( - children: [ - Expanded( - child: TextField( - //输入框一行 - maxLines: 1, - controller: tfController, - autofocus: false, - textAlign: TextAlign.end, - decoration: InputDecoration( - //输入里面输入文字内边距设置 - contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0), - hintText: tfStr, - //不需要输入框下划线 - border: InputBorder.none, - ), - ), - ), - ], - ), - ); - } - - void _showSelectTemplateType() { - var list = [ - TranslationLoader.lanKeys!.electronicKey!.tr, - TranslationLoader.lanKeys!.password!.tr - ]; - ShowBottomSheetTool().showSingleRowPicker( - //上下文 - context, - //默认的索引 - normalIndex: 0, - title: TranslationLoader.lanKeys!.type!.tr, - cancelTitle: TranslationLoader.lanKeys!.cancel!.tr, - sureTitle: TranslationLoader.lanKeys!.sure!.tr, - //要显示的列表 - //可自定义数据适配器 - //adapter: PickerAdapter(), - data: list, - //选择事件的回调 - clickCallBack: (int index, var str) {}); - } -} diff --git a/lib/mine/valueAddedServices/valueAddedServicesEmailTemplate/valueAddedServicesListEmailTemplate/valueAddedServicesListEmailTemplate_page.dart b/lib/mine/valueAddedServices/valueAddedServicesEmailTemplate/valueAddedServicesListEmailTemplate/valueAddedServicesListEmailTemplate_page.dart deleted file mode 100755 index 52db8831..00000000 --- a/lib/mine/valueAddedServices/valueAddedServicesEmailTemplate/valueAddedServicesListEmailTemplate/valueAddedServicesListEmailTemplate_page.dart +++ /dev/null @@ -1,164 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:get/get.dart'; - -import '../../../../appRouters.dart'; -import '../../../../app_settings/app_colors.dart'; -import '../../../../tools/submitBtn.dart'; -import '../../../../tools/titleAppBar.dart'; -import '../../../../translations/trans_lib.dart'; -import '../valueAddedServicesAddEmailTemplate/valueAddedServicesAddEmailTemplate_page.dart'; - -class ValueAddedServicesListEmailTemplatePage extends StatefulWidget { - const ValueAddedServicesListEmailTemplatePage({Key? key}) : super(key: key); - - @override - State createState() => - _ValueAddedServicesListEmailTemplatePageState(); -} - -class _ValueAddedServicesListEmailTemplatePageState - extends State { - @override - Widget build(BuildContext context) { - return Scaffold( - backgroundColor: AppColors.mainBackgroundColor, - appBar: TitleAppBar( - barTitle: '自定义邮件模版'.tr, - haveBack: true, - backgroundColor: AppColors.mainColor), - body: Column( - children: [ - _topTipWidget(), - Expanded(child: _buildMainUI()), - SubmitBtn( - btnName: TranslationLoader.lanKeys!.creatingANewTemplate!.tr, - borderRadius: 20.w, - margin: EdgeInsets.only( - left: 30.w, right: 30.w, top: 30.w, bottom: 30.w), - padding: EdgeInsets.only(top: 25.w, bottom: 25.w), - onClick: () { - Navigator.pushNamed( - context, Routers.valueAddedServicesAddEmailTemplatePage); - }), - SizedBox( - height: 64.h, - ) - ], - ), - ); - } - - Widget _topTipWidget() { - return Container( - margin: EdgeInsets.only(top: 20.w, left: 20.w, right: 20.w), - padding: - EdgeInsets.only(top: 20.h, left: 20.w, right: 20.w, bottom: 20.h), - decoration: BoxDecoration( - color: Colors.white, borderRadius: BorderRadius.circular(5)), - child: Column( - children: [ - Text(TranslationLoader.lanKeys!.customTemplatesTip!.tr), - SizedBox( - height: 15.h, - ), - Container( - padding: EdgeInsets.only( - top: 15.h, left: 15.w, right: 15.w, bottom: 15.h), - decoration: BoxDecoration( - color: const Color(0xFFFbF9EC), - borderRadius: BorderRadius.circular(10.h)), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - width: 1.sw - 15.w * 2 - 40.w * 2 - 140.w, - // margin: EdgeInsets.only(top:15.h, left: 15.w, right: 15.w, bottom: 15.h), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "${TranslationLoader.lanKeys!.currentState!.tr}:${TranslationLoader.lanKeys!.onTrial!.tr}", - style: TextStyle( - fontSize: 20.sp, fontWeight: FontWeight.w600), - ), - Text(TranslationLoader.lanKeys!.unHaveOpenedTip2!.tr, - style: TextStyle( - fontSize: 20.sp, fontWeight: FontWeight.w600)) - ], - ), - ), - GestureDetector( - onTap: () { - Navigator.pushNamed( - context, Routers.valueAddedServicesHighFunctionPage); - }, - child: Container( - width: 100.w, - height: 50.h, - decoration: BoxDecoration( - color: const Color(0xFFCAB68D), - borderRadius: BorderRadius.circular(35.h)), - child: Center( - child: Text( - TranslationLoader.lanKeys!.goToTheOpen!.tr, - textAlign: TextAlign.center, - style: TextStyle( - color: Colors.white, fontSize: 20.sp)))), - ), - ], - ), - ) - ], - )); - } - - Widget _buildMainUI() { - return ListView.builder( - itemCount: 10, - itemBuilder: (c, index) { - return _valueAddedServicesListSMSTemplateItem( - 'images/icon_lock.png', "张三", () { - // Navigator.pushNamed(context, Routers.valueAddedServicesAddSMSTemplatePage); - }); - }); - } - - Widget _valueAddedServicesListSMSTemplateItem( - String title, String content, Function() action) { - return GestureDetector( - onTap: action, - child: Container( - // height: 100.h, - margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(10.w), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only(left: 30.h, top: 30.h, bottom: 20.h), - child: Text( - "101", - style: TextStyle(fontSize: 32.sp, fontWeight: FontWeight.w500), - ), - ), - Container( - margin: EdgeInsets.only(left: 25.w, right: 25.w, bottom: 25.h), - decoration: BoxDecoration( - color: const Color(0xFFF5F5F5), - borderRadius: BorderRadius.circular(10.h), - ), - child: Padding( - padding: EdgeInsets.only( - left: 20.w, top: 20.h, right: 20.w, bottom: 20.h), - child: RichText(text: emailElectronicKeySpan)), - ), - ], - ), - ), - ); - } -} diff --git a/lib/mine/valueAddedServices/valueAddedServicesSMSTemplate/valueAddedServicesAddSMSTemplate/newSMSTemplate_entity.dart b/lib/mine/valueAddedServices/valueAddedServicesSMSTemplate/valueAddedServicesAddSMSTemplate/newSMSTemplate_entity.dart index 780f4f2f..cce845be 100644 --- a/lib/mine/valueAddedServices/valueAddedServicesSMSTemplate/valueAddedServicesAddSMSTemplate/newSMSTemplate_entity.dart +++ b/lib/mine/valueAddedServices/valueAddedServicesSMSTemplate/valueAddedServicesAddSMSTemplate/newSMSTemplate_entity.dart @@ -1,6 +1,13 @@ +import 'dart:convert'; + class NewSMSTemplateEntity { - NewSMSTemplateEntity( - {this.errorCode, this.description, this.errorMsg, this.dataList}); + NewSMSTemplateEntity({ + this.errorCode, + this.description, + this.errorMsg, + this.dataList, + }); + NewSMSTemplateEntity.fromJson(Map json) { errorCode = json['errorCode']; description = json['description']; @@ -12,6 +19,7 @@ class NewSMSTemplateEntity { }); } } + int? errorCode; String? description; String? errorMsg; @@ -30,18 +38,29 @@ class NewSMSTemplateEntity { } class SMSTemplateData { - SMSTemplateData( - {this.contentType, this.typeName, this.template, this.fixedKey}); + SMSTemplateData({ + this.contentType, + this.typeName, + this.template, + this.fixedKey, + this.templatePreviewCode, + }); + SMSTemplateData.fromJson(Map json) { contentType = json['content_type']; typeName = json['typeName']; template = json['template']; fixedKey = json['fixed_key']; + templatePreviewCode = json['template_preview_code'] != null + ? jsonEncode(json['template_preview_code']) + : null; } + int? contentType; String? typeName; String? template; String? fixedKey; + String? templatePreviewCode; // Changed to String String? regards = ''; String? tips = ''; int? id; @@ -55,6 +74,28 @@ class SMSTemplateData { data['typeName'] = typeName; data['template'] = template; data['fixed_key'] = fixedKey; + if (templatePreviewCode != null) { + data['template_preview_code'] = 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 previewCodeMap = + Map.from(jsonDecode(templatePreviewCode!)); + + String previewTemplate = template!; + previewCodeMap.forEach((String key, String value) { + previewTemplate = previewTemplate.replaceAll( + key, value + (value.length > 2 ? '\n' : '')); + }); + + return previewTemplate; + } } diff --git a/lib/mine/valueAddedServices/valueAddedServicesSMSTemplate/valueAddedServicesAddSMSTemplate/newSMSTemplate_logic.dart b/lib/mine/valueAddedServices/valueAddedServicesSMSTemplate/valueAddedServicesAddSMSTemplate/newSMSTemplate_logic.dart index 0c149a5d..3c6d67ee 100644 --- a/lib/mine/valueAddedServices/valueAddedServicesSMSTemplate/valueAddedServicesAddSMSTemplate/newSMSTemplate_logic.dart +++ b/lib/mine/valueAddedServices/valueAddedServicesSMSTemplate/valueAddedServicesAddSMSTemplate/newSMSTemplate_logic.dart @@ -94,6 +94,27 @@ class NewSMSTemplateLogic extends BaseGetXController { ), ); } + + if (isPreview) { + if (state.currentTemplate.value.generatePreview().isNotEmpty) { + textSpans.add( + TextSpan( + text: state.currentTemplate.value.generatePreview(), + style: state.defaultStyle, + ), + ); + } else { + textSpans.addAll(_buildDefaultTemplate(isPreview)); + } + } else { + textSpans.addAll(_buildDefaultTemplate(isPreview)); + } + + return textSpans; + } + + List _buildDefaultTemplate(bool isPreview) { + final List textSpans = []; // 将模板分割为文本片段 final List textFragments = state.currentTemplate.value.template ?.split(RegularExpression.urlRegExp) ?? @@ -129,7 +150,6 @@ class NewSMSTemplateLogic extends BaseGetXController { } } - // 如果是预览模式,添加预览模板的文本 if (isPreview) { textSpans.add( TextSpan( @@ -209,10 +229,30 @@ class NewSMSTemplateLogic extends BaseGetXController { ), ); } - //短信模版才需要加默认模版 - if (state.templateType == 1 || - (state.templateType == 2 && isPreview == false)) { + if ((state.templateType.value == 1) || + (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'\$\{([^}]+)\}'); @@ -281,8 +321,8 @@ class NewSMSTemplateLogic extends BaseGetXController { Future onReady() async { super.onReady(); - if (state.currentTemplate.value.isUpdate == false) { - getDefaultTemplate(); - } + // if (state.currentTemplate.value.isUpdate == false) { + getDefaultTemplate(); + // } } } diff --git a/lib/mine/valueAddedServices/valueAddedServicesSMSTemplate/valueAddedServicesAddSMSTemplate/newSMSTemplate_page.dart b/lib/mine/valueAddedServices/valueAddedServicesSMSTemplate/valueAddedServicesAddSMSTemplate/newSMSTemplate_page.dart index 9435ffa9..965f3419 100755 --- a/lib/mine/valueAddedServices/valueAddedServicesSMSTemplate/valueAddedServicesAddSMSTemplate/newSMSTemplate_page.dart +++ b/lib/mine/valueAddedServices/valueAddedServicesSMSTemplate/valueAddedServicesAddSMSTemplate/newSMSTemplate_page.dart @@ -29,7 +29,13 @@ class _NewSMSTemplatePageState extends State { return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( - barTitle: state.templateType.value == 1 ? '新建短信模版'.tr : '新建邮件模版'.tr, + barTitle: state.isUpdate.value == false + ? state.templateType.value == 1 + ? '新建短信模版'.tr + : '新建邮件模版'.tr + : state.templateType.value == 1 + ? '编辑短信模版'.tr + : '编辑邮件模版'.tr, haveBack: true, backgroundColor: AppColors.mainColor, ), @@ -75,15 +81,15 @@ class _NewSMSTemplatePageState extends State { TranslationLoader.lanKeys!.pleaseEnter!.tr, ), ), - Obx( - () => CommonItem( - leftTitel: TranslationLoader.lanKeys!.type!.tr, - rightTitle: state.currentTemplate.value.typeName ?? '', - isHaveLine: false, - isHaveDirection: true, - action: _showSelectTemplateType, - ), - ), + Obx(() => state.isUpdate.value == false + ? CommonItem( + leftTitel: TranslationLoader.lanKeys!.type!.tr, + rightTitle: state.currentTemplate.value.typeName ?? '', + isHaveLine: false, + isHaveDirection: true, + action: _showSelectTemplateType, + ) + : Container()), ], ); } @@ -113,6 +119,7 @@ class _NewSMSTemplatePageState extends State { Obx(() => Container( width: 1.sw - 50.w, margin: EdgeInsets.only(left: 25.w, right: 25.w), + padding: EdgeInsets.only(bottom: 20.h), child: _buildTemplateWithType(isPreview: false), )), SizedBox(height: 10.h), @@ -152,6 +159,8 @@ class _NewSMSTemplatePageState extends State { ), Obx(() => Container( width: 1.sw - 50.w, + // margin: EdgeInsets.only(left: 25.w, right: 25.w, bottom: 20.h), + // padding: EdgeInsets.only(left: 20.w, right: 20.w, bottom: 20.h), margin: EdgeInsets.only(left: 25.w, right: 25.w), padding: EdgeInsets.only(left: 20.w, right: 20.w, top: 10.h), decoration: BoxDecoration( @@ -160,20 +169,25 @@ class _NewSMSTemplatePageState extends State { ), child: _buildTemplateWithType(isPreview: true), )), - Padding( - padding: EdgeInsets.only( - left: 25.w, - top: 25.h, - bottom: 25.h, - ), - child: Text( - '预计产生短信条数:${state.smsCost.value}', - style: TextStyle( - color: Colors.grey, - fontSize: 20.sp, + if (state.templateType.value == 1) + Padding( + padding: EdgeInsets.only( + left: 25.w, + top: 25.h, + bottom: 25.h, ), - ), - ), + child: Text( + '预计产生短信条数:${state.smsCost.value}', + style: TextStyle( + color: Colors.grey, + fontSize: 20.sp, + ), + ), + ) + else + SizedBox( + height: 20.h, + ) ], ), ); diff --git a/lib/mine/valueAddedServices/valueAddedServicesSMSTemplate/valueAddedServicesAddSMSTemplate/newSMSTemplate_state.dart b/lib/mine/valueAddedServices/valueAddedServicesSMSTemplate/valueAddedServicesAddSMSTemplate/newSMSTemplate_state.dart index d2b540d2..daf04ccc 100644 --- a/lib/mine/valueAddedServices/valueAddedServicesSMSTemplate/valueAddedServicesAddSMSTemplate/newSMSTemplate_state.dart +++ b/lib/mine/valueAddedServices/valueAddedServicesSMSTemplate/valueAddedServicesAddSMSTemplate/newSMSTemplate_state.dart @@ -13,6 +13,7 @@ class NewSMSTemplateState { templateOneTf.text = currentTemplate.value.regards ?? ''; templateTwoTf.text = currentTemplate.value.tips ?? ''; templateType.value = currentTemplate.value.type ?? 0; + isUpdate.value = map['isUpdate']; } } @@ -34,4 +35,6 @@ class NewSMSTemplateState { RxBool isShowDate = false.obs; //是否显示日期 RxInt templateType = 0.obs; //1:短信 2:邮件 RxInt smsCost = 0.obs; //短信条数 + RxString preContent = ''.obs; //预览内容 + RxBool isUpdate = false.obs; //是否是修改模板 } diff --git a/lib/mine/valueAddedServices/valueAddedServicesSMSTemplate/valueAddedServicesListSMSTemplate/customSMSTemplateList_page.dart b/lib/mine/valueAddedServices/valueAddedServicesSMSTemplate/valueAddedServicesListSMSTemplate/customSMSTemplateList_page.dart index a6842aec..ebea82b7 100755 --- a/lib/mine/valueAddedServices/valueAddedServicesSMSTemplate/valueAddedServicesListSMSTemplate/customSMSTemplateList_page.dart +++ b/lib/mine/valueAddedServices/valueAddedServicesSMSTemplate/valueAddedServicesListSMSTemplate/customSMSTemplateList_page.dart @@ -72,8 +72,9 @@ class _CustomSMSTemplateListPageState extends State { templateData.typeName = templateData.contentType == 1 ? '电子钥匙' : '密码'; final result = await Get.toNamed(Routers.newSMSTemplatePage, - arguments: { - 'currentTemplate': templateData + arguments: { + 'currentTemplate': templateData, + 'isUpdate': false }); if (result != null) { logic.getSMSTemplateListRequest(isRefresh: true); @@ -207,9 +208,7 @@ class _CustomSMSTemplateListPageState extends State { templateData.type = itemData.type; templateData.isUpdate = true; final result = await Get.toNamed(Routers.newSMSTemplatePage, - arguments: { - 'currentTemplate': templateData - }); + arguments: {'currentTemplate': templateData, 'isUpdate': true}); if (result != null) { logic.getSMSTemplateListRequest(isRefresh: true); }