1,自定义SMS模版页面新增上拉加载下拉刷新
2,新增删除模版API对接及逻辑处理
This commit is contained in:
parent
3035a53ff7
commit
5caa8a598f
@ -1,5 +1,6 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:star_lock/login/login/entity/LoginEntity.dart';
|
||||
import 'package:star_lock/mine/valueAddedServices/valueAddedServicesSMSTemplate/valueAddedServicesListSMSTemplate/customSMSTemplateList_entity.dart';
|
||||
import 'package:star_lock/mine/valueAddedServices/valueAddedServicesSMSTemplate/valueAddedServicesListSMSTemplate/customSMSTemplateList_state.dart';
|
||||
import 'package:star_lock/tools/regularExpression.dart';
|
||||
@ -12,9 +13,15 @@ class CustomSMSTemplateListLogic extends BaseGetXController {
|
||||
CustomSMSTemplateListState state = CustomSMSTemplateListState();
|
||||
|
||||
//获取短信模板列表
|
||||
Future<void> getSMSTemplateListRequest() async {
|
||||
Future<void> getSMSTemplateListRequest({required bool isRefresh}) async {
|
||||
// 如果是下拉刷新,清空已有数据
|
||||
if (isRefresh) {
|
||||
state.smsTemplateList.clear();
|
||||
pageNo = 1;
|
||||
}
|
||||
final CustomSMSTemplateListEntity entity = await ApiRepository.to
|
||||
.getSMSTemplateList(type: 1, pageNo: 1, pageSize: 20);
|
||||
.getSMSTemplateList(
|
||||
type: 1, pageNo: pageNo, pageSize: int.parse(pageSize));
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
state.smsTemplateList.value =
|
||||
entity.data?.list ?? <CustomSMSTemplateItem>[];
|
||||
@ -22,6 +29,15 @@ class CustomSMSTemplateListLogic extends BaseGetXController {
|
||||
}
|
||||
}
|
||||
|
||||
//删除短信模版
|
||||
Future<void> deleteSMSTemplateRequest({required int id}) async {
|
||||
final LoginEntity entity =
|
||||
await ApiRepository.to.deleteTemplateInfo(id: id);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
getSMSTemplateListRequest(isRefresh: true);
|
||||
}
|
||||
}
|
||||
|
||||
List<TextSpan> buildElectronicKeySpan(
|
||||
{required CustomSMSTemplateItem templateData}) {
|
||||
final List<TextSpan> textSpans = <TextSpan>[];
|
||||
|
||||
@ -1,11 +1,14 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:flutter_slidable/flutter_slidable.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/mine/valueAddedServices/valueAddedServicesSMSTemplate/valueAddedServicesAddSMSTemplate/newSMSTemplate_entity.dart';
|
||||
import 'package:star_lock/mine/valueAddedServices/valueAddedServicesSMSTemplate/valueAddedServicesListSMSTemplate/customSMSTemplateList_entity.dart';
|
||||
import 'package:star_lock/mine/valueAddedServices/valueAddedServicesSMSTemplate/valueAddedServicesListSMSTemplate/customSMSTemplateList_logic.dart';
|
||||
import 'package:star_lock/mine/valueAddedServices/valueAddedServicesSMSTemplate/valueAddedServicesListSMSTemplate/customSMSTemplateList_state.dart';
|
||||
import 'package:star_lock/tools/EasyRefreshTool.dart';
|
||||
import 'package:star_lock/tools/noData.dart';
|
||||
import 'package:star_lock/tools/showTipView.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
@ -30,7 +33,7 @@ class _CustomSMSTemplateListPageState extends State<CustomSMSTemplateListPage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
logic.getSMSTemplateListRequest();
|
||||
logic.getSMSTemplateListRequest(isRefresh: true);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -41,29 +44,37 @@ class _CustomSMSTemplateListPageState extends State<CustomSMSTemplateListPage> {
|
||||
barTitle: '自定义短信模版'.tr,
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: Column(
|
||||
children: <Widget>[
|
||||
Obx(() => Visibility(
|
||||
child: _topTipWidget(),
|
||||
visible: !state.isVip.value,
|
||||
)),
|
||||
Expanded(child: Obx(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: () async {
|
||||
final result = await Get.toNamed(Routers.newSMSTemplatePage);
|
||||
if (result != null) {
|
||||
logic.getSMSTemplateListRequest();
|
||||
}
|
||||
}),
|
||||
SizedBox(
|
||||
height: 40.h,
|
||||
)
|
||||
],
|
||||
body: EasyRefreshTool(
|
||||
onRefresh: () {
|
||||
logic.getSMSTemplateListRequest(isRefresh: true);
|
||||
},
|
||||
onLoad: () {
|
||||
logic.getSMSTemplateListRequest(isRefresh: false);
|
||||
},
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Obx(() => Visibility(
|
||||
child: _topTipWidget(),
|
||||
visible: !state.isVip.value,
|
||||
)),
|
||||
Expanded(child: Obx(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: () async {
|
||||
final result = await Get.toNamed(Routers.newSMSTemplatePage);
|
||||
if (result != null) {
|
||||
logic.getSMSTemplateListRequest(isRefresh: true);
|
||||
}
|
||||
}),
|
||||
SizedBox(
|
||||
height: 40.h,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -139,13 +150,36 @@ class _CustomSMSTemplateListPageState extends State<CustomSMSTemplateListPage> {
|
||||
|
||||
Widget buildMainUI() {
|
||||
return state.smsTemplateList.isNotEmpty
|
||||
? ListView.builder(
|
||||
itemCount: state.smsTemplateList.length,
|
||||
itemBuilder: (BuildContext c, int index) {
|
||||
final CustomSMSTemplateItem itemData =
|
||||
state.smsTemplateList[index];
|
||||
return _valueAddedServicesListSMSTemplateItem(itemData);
|
||||
})
|
||||
? SlidableAutoCloseBehavior(
|
||||
child: ListView.builder(
|
||||
itemCount: state.smsTemplateList.length,
|
||||
itemBuilder: (BuildContext c, int index) {
|
||||
final CustomSMSTemplateItem itemData =
|
||||
state.smsTemplateList[index];
|
||||
return Slidable(
|
||||
key: ValueKey(itemData.id),
|
||||
endActionPane: ActionPane(
|
||||
extentRatio: 0.2,
|
||||
motion: const ScrollMotion(),
|
||||
children: <Widget>[
|
||||
SlidableAction(
|
||||
onPressed: (BuildContext context) {
|
||||
ShowTipView()
|
||||
.showIosTipWithContentDialog('是否删除?'.tr, () {
|
||||
logic.deleteSMSTemplateRequest(
|
||||
id: itemData.id ?? 0);
|
||||
});
|
||||
},
|
||||
backgroundColor: Colors.red,
|
||||
foregroundColor: Colors.white,
|
||||
label: '删除'.tr,
|
||||
padding: EdgeInsets.only(left: 5.w, right: 5.w),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: _valueAddedServicesListSMSTemplateItem(itemData));
|
||||
}),
|
||||
)
|
||||
: NoData();
|
||||
}
|
||||
|
||||
@ -166,7 +200,7 @@ class _CustomSMSTemplateListPageState extends State<CustomSMSTemplateListPage> {
|
||||
'currentTemplate': templateData
|
||||
});
|
||||
if (result != null) {
|
||||
logic.getSMSTemplateListRequest();
|
||||
logic.getSMSTemplateListRequest(isRefresh: true);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
|
||||
@ -251,4 +251,5 @@ abstract class Api {
|
||||
final String addSMSTemplateURL = '/v2/service/addSmsTemplate'; //添加短信模板
|
||||
final String keydetail = ' /key/detail'; //获取钥匙详情
|
||||
final String updateTemplateInfoURL = '/v2/service/update'; //更新模板信息
|
||||
final String deleteTemplateURL = '/v2/service/delete'; //删除模板
|
||||
}
|
||||
|
||||
@ -2211,6 +2211,12 @@ class ApiProvider extends BaseProvider {
|
||||
}),
|
||||
isUnShowLoading: true,
|
||||
);
|
||||
|
||||
Future<Response<dynamic>> deleteTemplateInfo(int id) => post(
|
||||
deleteTemplateURL.toUrl,
|
||||
jsonEncode(<String, dynamic>{'id': id}),
|
||||
isUnShowLoading: true,
|
||||
);
|
||||
}
|
||||
|
||||
extension ExtensionString on String {
|
||||
|
||||
@ -2229,4 +2229,10 @@ class ApiRepository {
|
||||
await apiProvider.updateTemplateInfo(id, name, regards, tips);
|
||||
return LoginEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
// 删除模板
|
||||
Future<LoginEntity> deleteTemplateInfo({required int id}) async {
|
||||
final Response<dynamic> res = await apiProvider.deleteTemplateInfo(id);
|
||||
return LoginEntity.fromJson(res.body);
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,11 +79,11 @@ class ShowTipView {
|
||||
content: Text(contentStr),
|
||||
actions: <Widget>[
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.cancel!.tr),
|
||||
child: Text('取消', style: TextStyle(color: AppColors.mainColor)),
|
||||
onPressed: Get.back,
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.sure!.tr),
|
||||
child: Text('确定', style: TextStyle(color: AppColors.mainColor)),
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
sureClick();
|
||||
@ -96,7 +96,8 @@ class ShowTipView {
|
||||
}
|
||||
|
||||
void showTFViewAlertDialog(TextEditingController controller, String title,
|
||||
String tipTitle, Function sureClick, {List<TextInputFormatter>? inputFormatters}) {
|
||||
String tipTitle, Function sureClick,
|
||||
{List<TextInputFormatter>? inputFormatters}) {
|
||||
// 点击删除 开始扫描
|
||||
showDialog(
|
||||
context: Get.context!,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user