From 1e43a0090a5d0c789b7a8d942869fb1b2719b1bd Mon Sep 17 00:00:00 2001 From: wylyl22 <2373073266@qq.com> Date: Tue, 13 Sep 2022 18:05:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=BF=AE=E6=94=B9=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../home/set/func/exclude_contacts_func.dart | 36 +++++++++++++------ lib/ui/home/set/specify_phone_page.dart | 29 ++++++++++----- 2 files changed, 47 insertions(+), 18 deletions(-) diff --git a/lib/ui/home/set/func/exclude_contacts_func.dart b/lib/ui/home/set/func/exclude_contacts_func.dart index af34370..2c472c2 100644 --- a/lib/ui/home/set/func/exclude_contacts_func.dart +++ b/lib/ui/home/set/func/exclude_contacts_func.dart @@ -10,24 +10,40 @@ import '../../../../utils/toast/cloud_toast.dart'; class ExcludeFunc { // 查看手机号码 static Future> getContacts() async { - BaseListModel res=await apiClient.requestList(API.exclude.find,); - if(res.code==0){ - return res.nullSafetyList.map((e) => ExcludePhoneModel.fromJson(e)).toList(); - }else{ - CloudToast.show(res.msg); - return []; + BaseListModel res = await apiClient.requestList( + API.exclude.find, + ); + if (res.code == 0) { + return res.nullSafetyList + .map((e) => ExcludePhoneModel.fromJson(e)) + .toList(); + } else { + CloudToast.show(res.msg); + return []; } } + //添加手机号码 -static Future getContactsList(List numList) async{ - BaseModel res=await apiClient.request(API.exclude.add,data: {"exclude":numList}); + static Future getContactsList(List numList) async { + BaseModel res = + await apiClient.request(API.exclude.add, data: {"exclude": numList}); + if (res.code == 0) { + return true; + } else { + CloudToast.show(res.msg); + return false; + } + } + + static Future getUpdate(int id, String phone, String remark) async { + BaseModel res = await apiClient.request(API.exclude.update, + data: {"id": id, "phone": phone, "remark": remark}); if(res.code==0){ return true; }else{ CloudToast.show(res.msg); return false; } + } - -} } diff --git a/lib/ui/home/set/specify_phone_page.dart b/lib/ui/home/set/specify_phone_page.dart index 6356fd9..819cd45 100644 --- a/lib/ui/home/set/specify_phone_page.dart +++ b/lib/ui/home/set/specify_phone_page.dart @@ -27,7 +27,8 @@ class SpecifyPhonePage extends StatefulWidget { class _SpecifyPhonePageState extends State { final EasyRefreshController _refreshController = EasyRefreshController(); List findList = []; - + String name=""; + String phone=""; @override void dispose() { _refreshController.dispose(); @@ -136,13 +137,13 @@ class _SpecifyPhonePageState extends State { _getNum() { return ListView.builder( itemBuilder: (context, index) { - return _getNumContant(findList[index]); + return _getNumContant(findList[index],findList[index].id); }, itemCount: findList.length, ); } - _getNumContant(ExcludePhoneModel item) { + _getNumContant(ExcludePhoneModel item,int id) { return Container( margin: EdgeInsets.symmetric(horizontal: 16.w), child: ListTile( @@ -181,7 +182,10 @@ class _SpecifyPhonePageState extends State { placeholderStyle: const TextStyle(color: BaseStyle.color333333), placeholder: item.remark, - onChanged: (value) {}, + onChanged: (value) { + name=value; + setState(() {}); + }, ), 20.hb, Text( @@ -202,7 +206,10 @@ class _SpecifyPhonePageState extends State { // ), color: const Color(0xFFF9F9F9)), placeholder: item.phone, - onChanged: (value) {}, + onChanged: (value) { + phone=value; + setState(() {}); + }, ), 82.hb, // _getUpdate("爸爸", "123123123"), @@ -211,7 +218,12 @@ class _SpecifyPhonePageState extends State { border: true, color1: const Color(0xFF1890FF), color2: const Color(0xFF74BCFF), - onTap: () {}, + onTap: () async{ + Navigator.pop(context); + var res=await ExcludeFunc.getUpdate(id, phone, item.remark.isEmpty?name:item.remark); + _refreshController.callRefresh(); + print(res); + }, text: "保存", ) ], @@ -222,7 +234,7 @@ class _SpecifyPhonePageState extends State { }); }, title: Text( - item.phone, + item.remark.isEmpty? item.phone:item.remark, style: TextStyle( fontSize: 32.sp, color: BaseStyle.color333333, @@ -236,8 +248,9 @@ class _SpecifyPhonePageState extends State { side: MaterialStateProperty.all( BorderSide(width: 2.w, color: const Color(0xFFE8E8E8)))), onPressed: () async { + print(id); var res = - await apiClient.request(API.exclude.find, data: {item.id}); + await apiClient.request(API.exclude.delete, data: {"id":id}); if (res.code == 0) { _refreshController.callRefresh(); CloudToast.show(res.msg);