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

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) {
state.smsCost.value = calculateSmsCost(template);
}
int calculateSmsCost(String template) {
final int smsCount = template.length;
int calculateSmsCost() {
final String smsText =
'${state.templateOneTf.text}\n${state.currentTemplate.value.template}\n${state.templateTwoTf.text}';
final int smsCount = smsText.length;
if (smsCount <= 70) {
return 1;
} else {

View File

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

View File

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