更新短信条数不准确问题修复

This commit is contained in:
“DaisyWu” 2024-07-09 16:34:45 +08:00
parent f9738cdcf7
commit 5c0e5deba2
3 changed files with 6 additions and 11 deletions

View File

@ -66,12 +66,10 @@ class NewSMSTemplateLogic extends BaseGetXController {
} }
// //
void updateSmsCost(String template) { int calculateSmsCost() {
state.smsCost.value = calculateSmsCost(template); final String smsText =
} '${state.templateOneTf.text}\n${state.currentTemplate.value.template}\n${state.templateTwoTf.text}';
final int smsCount = smsText.length;
int calculateSmsCost(String template) {
final int smsCount = template.length;
if (smsCount <= 70) { if (smsCount <= 70) {
return 1; return 1;
} else { } else {

View File

@ -184,7 +184,7 @@ class _NewSMSTemplatePageState extends State<NewSMSTemplatePage> {
bottom: 25.h, bottom: 25.h,
), ),
child: Text( child: Text(
'预计产生短信条数:${state.smsCost.value}', '预计产生短信条数:${logic.calculateSmsCost()}',
style: TextStyle( style: TextStyle(
color: Colors.grey, color: Colors.grey,
fontSize: 20.sp, fontSize: 20.sp,
@ -234,9 +234,7 @@ class _NewSMSTemplatePageState extends State<NewSMSTemplatePage> {
), ),
), ),
onChanged: (String value) { onChanged: (String value) {
setState(() { setState(logic.calculateSmsCost);
logic.updateSmsCost(controller.text); //
});
}, },
); );
} }

View File

@ -37,7 +37,6 @@ class NewSMSTemplateState {
RxInt selectedTemplateIndex = 0.obs; // RxInt selectedTemplateIndex = 0.obs; //
RxBool isShowDate = false.obs; // RxBool isShowDate = false.obs; //
RxInt channelType = 0.obs; //1 2 RxInt channelType = 0.obs; //1 2
RxInt smsCost = 0.obs; //
RxString preContent = ''.obs; // RxString preContent = ''.obs; //
RxBool isUpdate = false.obs; // RxBool isUpdate = false.obs; //
} }