排除接口

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

@ -1,22 +1,44 @@
import 'package:json_annotation/json_annotation.dart'; import 'package:json_annotation/json_annotation.dart';
import 'package:equatable/equatable.dart'; import 'package:equatable/equatable.dart';
part 'exclude_phone_model.g.dart';
part 'exclude_phone_model.g.dart';
@JsonSerializable() @JsonSerializable()
class ExcludePhoneModel extends Equatable{ class ExcludePhoneModel extends Equatable {
final int id; final int id;
final String phone; final String phone;
final String remark; final String remark;
factory ExcludePhoneModel.fromJson(Map<String, dynamic> json) =>_$ExcludePhoneModelFromJson(json); final String address;
Map<String,dynamic> toJson()=> _$ExcludePhoneModelToJson(this);
factory ExcludePhoneModel.fromJson(Map<String, dynamic> json) =>
_$ExcludePhoneModelFromJson(json);
Map<String, dynamic> toJson() => _$ExcludePhoneModelToJson(this);
const ExcludePhoneModel({ const ExcludePhoneModel({
required this.id, required this.id,
required this.phone, required this.phone,
required this.remark, required this.remark,
required this.address,
}); });
@override @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, id: json['id'] as int,
phone: json['phone'] as String, phone: json['phone'] as String,
remark: json['remark'] as String, remark: json['remark'] as String,
address: json['address'] as String,
); );
Map<String, dynamic> _$ExcludePhoneModelToJson(ExcludePhoneModel instance) => <String, dynamic>{ Map<String, dynamic> _$ExcludePhoneModelToJson(ExcludePhoneModel instance) => <String, dynamic>{
'id': instance.id, 'id': instance.id,
'phone': instance.phone, 'phone': instance.phone,
'remark': instance.remark, '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:get/get.dart';
import 'package:project_telephony/ui/widget/scaffold_theme_widget.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 { class ExcludeContactsPage extends StatefulWidget {
const ExcludeContactsPage({Key? key}) : super(key: key); const ExcludeContactsPage({Key? key}) : super(key: key);
@ -17,7 +22,6 @@ class _ExcludeContactsPageState extends State<ExcludeContactsPage> {
List<String> numbers = []; List<String> numbers = [];
List<bool> status = []; List<bool> status = [];
var flag = true; var flag = true;
bool _permissionDenied = false;
@override @override
void initState() { void initState() {
@ -83,11 +87,20 @@ class _ExcludeContactsPageState extends State<ExcludeContactsPage> {
return ScaffoldThemeWidget( return ScaffoldThemeWidget(
title: "从通讯录添加", title: "从通讯录添加",
bottom: "添加", 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)) { if (status.contains(true)) {
// BotToast.showText(text: ""); BaseModel res = await apiClient
.request(API.exclude.add, data: {'exclude': excludeList});
Get.back(); if (res.code == 0) {
Get.back();
}
} else { } else {
BotToast.showText(text: "还未选中手机号"); BotToast.showText(text: "还未选中手机号");
} }

Loading…
Cancel
Save