排除接口

master
戴余标 2 years ago
parent 61e62e1e62
commit 3f59e7d3f1

@ -1,22 +1,44 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:equatable/equatable.dart';
part 'exclude_phone_model.g.dart';
part 'exclude_phone_model.g.dart';
@JsonSerializable()
class ExcludePhoneModel extends Equatable {
final int id;
final String phone;
final String remark;
factory ExcludePhoneModel.fromJson(Map<String, dynamic> json) =>_$ExcludePhoneModelFromJson(json);
final String address;
factory ExcludePhoneModel.fromJson(Map<String, dynamic> json) =>
_$ExcludePhoneModelFromJson(json);
Map<String, dynamic> toJson() => _$ExcludePhoneModelToJson(this);
const ExcludePhoneModel({
required this.id,
required this.phone,
required this.remark,
required this.address,
});
@override
List<Object?> get props => [id,phone,remark];
List<Object?> get props => [id, phone, remark, address];
}
@JsonSerializable()
class Exclude extends Equatable {
final String phone;
final String remark;
factory Exclude.fromJson(Map<String, dynamic> json) =>
_$ExcludeFromJson(json);
Map<String, dynamic> toJson() => _$ExcludeToJson(this);
@override
List<Object?> get props => [phone, remark];
const Exclude({
required this.phone,
required this.remark,
});
}

@ -10,10 +10,23 @@ ExcludePhoneModel _$ExcludePhoneModelFromJson(Map<String, dynamic> json) => Excl
id: json['id'] as int,
phone: json['phone'] as String,
remark: json['remark'] as String,
address: json['address'] as String,
);
Map<String, dynamic> _$ExcludePhoneModelToJson(ExcludePhoneModel instance) => <String, dynamic>{
'id': instance.id,
'phone': instance.phone,
'remark': instance.remark,
'address': instance.address,
};
Exclude _$ExcludeFromJson(Map<String, dynamic> json) => Exclude(
phone: json['phone'] as String,
remark: json['remark'] as String,
);
Map<String, dynamic> _$ExcludeToJson(Exclude instance) => <String, dynamic>{
'phone': instance.phone,
'remark': instance.remark,
};

@ -5,6 +5,11 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:project_telephony/ui/widget/scaffold_theme_widget.dart';
import '../../constants/api.dart';
import '../../model/exclude_phone_model.dart';
import '../../model/network/api_client.dart';
import '../../model/network/base_model.dart';
class ExcludeContactsPage extends StatefulWidget {
const ExcludeContactsPage({Key? key}) : super(key: key);
@ -17,7 +22,6 @@ class _ExcludeContactsPageState extends State<ExcludeContactsPage> {
List<String> numbers = [];
List<bool> status = [];
var flag = true;
bool _permissionDenied = false;
@override
void initState() {
@ -83,11 +87,20 @@ class _ExcludeContactsPageState extends State<ExcludeContactsPage> {
return ScaffoldThemeWidget(
title: "从通讯录添加",
bottom: "添加",
onTap: () {
onTap: () async {
List<Exclude> excludeList = [];
for (int i = 0; i < status.length; i++) {
if (status[i] == true) {
excludeList.add(
Exclude(phone: numbers[i], remark: contacts![i].displayName));
}
}
if (status.contains(true)) {
// BotToast.showText(text: "");
BaseModel res = await apiClient
.request(API.exclude.add, data: {'exclude': excludeList});
if (res.code == 0) {
Get.back();
}
} else {
BotToast.showText(text: "还未选中手机号");
}

Loading…
Cancel
Save