master
王亚玲 2 years ago
parent 7e97d5064d
commit 099b478f11

@ -0,0 +1,19 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:equatable/equatable.dart';
part 'exclude_pn_model.g.dart';
@JsonSerializable()
class ExcludePnModel extends Equatable{
final String? phone;
final String? remark;
factory ExcludePnModel.fromJson(Map<String, dynamic> json) =>_$ExcludePnModelFromJson(json);
const ExcludePnModel({
required this.phone,
required this.remark,
});
@override
List<Object?> get props => [phone,remark];
}

@ -0,0 +1,13 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'exclude_pn_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
ExcludePnModel _$ExcludePnModelFromJson(Map<String, dynamic> json) =>
ExcludePnModel(
phone: json['phone'] as String,
remark: json['remark'] as String,
);

@ -32,6 +32,7 @@ class _ExcludeSinglePageState extends State<ExcludeSinglePage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ScaffoldThemeWidget( return ScaffoldThemeWidget(
wid: 110,
title: '添加单个或批量号码', title: '添加单个或批量号码',
bottom: "添加", bottom: "添加",
onTap: () {}, onTap: () {},
@ -57,6 +58,7 @@ class _ExcludeSinglePageState extends State<ExcludeSinglePage> {
color: Colors.black38, color: Colors.black38,
), ),
), ),
TextSpan( TextSpan(
text: "如输入000*可屏蔽所有000开头的号码", text: "如输入000*可屏蔽所有000开头的号码",
style: TextStyle( style: TextStyle(
@ -78,10 +80,10 @@ class _ExcludeSinglePageState extends State<ExcludeSinglePage> {
children: [ children: [
Text( Text(
title, title,
style: const TextStyle( style: TextStyle(
fontSize: 16, fontSize: 28.sp,
color: Color(0xFF999999), color: const Color(0xFF999999),
fontWeight: FontWeight.w600, fontWeight: FontWeight.w500,
), ),
), ),
15.heightBox, 15.heightBox,
@ -93,10 +95,10 @@ class _ExcludeSinglePageState extends State<ExcludeSinglePage> {
decoration: InputDecoration( decoration: InputDecoration(
contentPadding: EdgeInsets.all(30.w), contentPadding: EdgeInsets.all(30.w),
hintText: content, hintText: content,
hintStyle: const TextStyle( hintStyle: TextStyle(
fontSize: 16, fontSize: 28.sp,
fontWeight: FontWeight.w600, // fontWeight: FontWeight.w600,
color: Color(0xFF999999), color: const Color(0xFF999999),
), ),
fillColor: const Color(0xFFF9F9F9), fillColor: const Color(0xFFF9F9F9),
filled: true, filled: true,

@ -1,8 +1,10 @@
import 'package:project_telephony/constants/api.dart'; import 'package:project_telephony/constants/api.dart';
import 'package:project_telephony/model/network/api_client.dart'; import 'package:project_telephony/model/network/api_client.dart';
import 'package:project_telephony/model/network/base_model.dart';
import 'package:project_telephony/utils/inner_model/base_list_model.dart'; import 'package:project_telephony/utils/inner_model/base_list_model.dart';
import '../../../../model/exclude_phone_model.dart'; import '../../../../model/exclude_phone_model.dart';
import '../../../../model/exclude_pn_model.dart';
import '../../../../utils/toast/cloud_toast.dart'; import '../../../../utils/toast/cloud_toast.dart';
class ExcludeFunc { class ExcludeFunc {
@ -17,5 +19,15 @@ class ExcludeFunc {
} }
} }
// //
// static Future<bool> static Future<bool> 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;
}
}
} }

@ -5,8 +5,10 @@ import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:project_telephony/base/base_style.dart'; import 'package:project_telephony/base/base_style.dart';
import 'package:project_telephony/constants/api.dart'; import 'package:project_telephony/constants/api.dart';
import 'package:project_telephony/model/network/api_client.dart'; import 'package:project_telephony/model/network/api_client.dart';
import 'package:project_telephony/ui/home/set/func/exclude_contacts_func.dart';
import 'package:project_telephony/utils/headers.dart'; import 'package:project_telephony/utils/headers.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import '../../../../model/exclude_pn_model.dart';
import '../../../../model/phone_num_model.dart'; import '../../../../model/phone_num_model.dart';
import '../../../../utils/toast/cloud_toast.dart'; import '../../../../utils/toast/cloud_toast.dart';
import '../../../widget/scaffold_theme_widget.dart'; import '../../../widget/scaffold_theme_widget.dart';
@ -21,13 +23,17 @@ class CallRecordsList extends StatefulWidget {
class _CallRecordsListState extends State<CallRecordsList> { class _CallRecordsListState extends State<CallRecordsList> {
List<PhoneNumModel> phoneNum = []; List<PhoneNumModel> phoneNum = [];
List<PhoneNumModel> phoneNum2 = []; List<PhoneNumModel> phoneNum2 = [];
List<String> phoneNum3 = []; // List<ExcludePnModel> phoneNum3 = [];
List phoneNum3=[];
// Map<String, String> get phoneNum3 => {};
final EasyRefreshController _easyRefreshController = EasyRefreshController(); final EasyRefreshController _easyRefreshController = EasyRefreshController();
late bool notifications; late bool notifications;
late bool trackHistory; late bool trackHistory;
late bool instantOrders; late bool instantOrders;
late SharedPreferences prefs; late SharedPreferences prefs;
List<String> numList = []; List<String> numList = [];
// List<String> =[] // List<String> =[]
@override @override
void initState() { void initState() {
@ -56,7 +62,7 @@ class _CallRecordsListState extends State<CallRecordsList> {
)); ));
} }
} }
for(int i=0;i<phoneNum.length;i++){ for (int i = 0; i < phoneNum.length; i++) {
phoneNum2.add(PhoneNumModel( phoneNum2.add(PhoneNumModel(
num: phoneNum[i].num, num: phoneNum[i].num,
time: phoneNum[i].time, time: phoneNum[i].time,
@ -85,13 +91,13 @@ class _CallRecordsListState extends State<CallRecordsList> {
title: '从通话记录添加', title: '从通话记录添加',
isBorder: true, isBorder: true,
isOpacity: phoneNum3.isNotEmpty, isOpacity: phoneNum3.isNotEmpty,
onTap: () async{ onTap: () async {
if(phoneNum3.isEmpty){ if (phoneNum3.isEmpty) {
CloudToast.show('请选择手机号'); CloudToast.show('请选择手机号');
}else{ } else {
var res=await apiClient.request(API.exclude.add,data: {});
print(phoneNum3); print(phoneNum3);
var res = await ExcludeFunc.getContactsList(phoneNum3);
print(res);
} }
// _easyRefreshController.callRefresh(); // _easyRefreshController.callRefresh();
// phoneNum3.clear(); // phoneNum3.clear();
@ -104,10 +110,9 @@ class _CallRecordsListState extends State<CallRecordsList> {
getList(); getList();
setState(() {}); setState(() {});
}, },
child: child: ListView.builder(
ListView.builder(
itemBuilder: (context, index) { itemBuilder: (context, index) {
return _getBox(phoneNum2[index],phoneNum2[index].num!); return _getBox(phoneNum2[index], phoneNum2[index].num!,phoneNum2[index].name?? "");
}, },
itemCount: phoneNum2.length, itemCount: phoneNum2.length,
), ),
@ -158,15 +163,18 @@ class _CallRecordsListState extends State<CallRecordsList> {
// ); // );
} }
_getBox(PhoneNumModel item, String index) { _getBox(PhoneNumModel item, String num,String name) {
return CheckboxListTile( return CheckboxListTile(
onChanged: (bool? value) { onChanged: (bool? value) {
setState(() { setState(() {
item.state = value!; item.state = value!;
if(item.state){ if (item.state) {
phoneNum3.add(index); phoneNum3.add({"phone":num,"remark":name});
}else{ // phoneNum3.add((phone: num, remark: name));
phoneNum3.remove(index);
} else {
phoneNum3.remove({"phone":num,"remark":name});
// phoneNum3.remove(ExcludePnModel(phone: num, remark: name)) ;
} }
}); });
}, },

@ -17,6 +17,7 @@ import '../../../model/exclude_phone_model.dart';
import '../../widget/scaffold_theme_widget.dart'; import '../../widget/scaffold_theme_widget.dart';
import 'func/exclude_contacts_func.dart';
class SpecifyPhonePage extends StatefulWidget { class SpecifyPhonePage extends StatefulWidget {
const SpecifyPhonePage({Key? key}) : super(key: key); const SpecifyPhonePage({Key? key}) : super(key: key);
@ -28,7 +29,7 @@ class SpecifyPhonePage extends StatefulWidget {
class _SpecifyPhonePageState extends State<SpecifyPhonePage> { class _SpecifyPhonePageState extends State<SpecifyPhonePage> {
final EasyRefreshController _refreshController = EasyRefreshController(); final EasyRefreshController _refreshController = EasyRefreshController();
List<ExcludePhoneModel> findList = [ List<ExcludePhoneModel> findList = [
const ExcludePhoneModel(id: 0, phone: '123123123123', remark: '好的')
]; ];
@override @override
@ -40,6 +41,7 @@ class _SpecifyPhonePageState extends State<SpecifyPhonePage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ScaffoldThemeWidget( return ScaffoldThemeWidget(
wid: 196,
title: "指定号码", title: "指定号码",
bottom: '添加', bottom: '添加',
onTap: () { onTap: () {
@ -118,7 +120,7 @@ class _SpecifyPhonePageState extends State<SpecifyPhonePage> {
header: MaterialHeader(), header: MaterialHeader(),
// footer: MaterialFooter(), // footer: MaterialFooter(),
onRefresh: () async { onRefresh: () async {
// findList = await ExcludeFunc.getContacts(); findList = await ExcludeFunc.getContacts();
// await userProvider.updateUserInfo(); // await userProvider.updateUserInfo();
setState(() {}); setState(() {});

Loading…
Cancel
Save