# Conflicts:
#	lib/model/exclude_phone_model.dart
#	lib/model/exclude_phone_model.g.dart
master
王亚玲 2 years ago
commit 8a2b0bd307

@ -1,16 +1,19 @@
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{
class ExcludePhoneModel extends Equatable {
final int id;
final String phone;
final String remark;
final String address;
factory ExcludePhoneModel.fromJson(Map<String, dynamic> json) =>_$ExcludePhoneModelFromJson(json);
Map<String,dynamic> toJson()=> _$ExcludePhoneModelToJson(this);
final String address;
factory ExcludePhoneModel.fromJson(Map<String, dynamic> json) =>
_$ExcludePhoneModelFromJson(json);
Map<String, dynamic> toJson() => _$ExcludePhoneModelToJson(this);
const ExcludePhoneModel({
required this.id,
@ -20,5 +23,22 @@ class ExcludePhoneModel extends Equatable{
});
@override
List<Object?> get props => [id,phone,remark,address];
}
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,
});
}

@ -6,18 +6,27 @@ part of 'exclude_phone_model.dart';
// JsonSerializableGenerator
// **************************************************************************
ExcludePhoneModel _$ExcludePhoneModelFromJson(Map<String, dynamic> json) =>
ExcludePhoneModel(
ExcludePhoneModel _$ExcludePhoneModelFromJson(Map<String, dynamic> json) => ExcludePhoneModel(
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>{
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: "");
Get.back();
BaseModel res = await apiClient
.request(API.exclude.add, data: {'exclude': excludeList});
if (res.code == 0) {
Get.back();
}
} else {
BotToast.showText(text: "还未选中手机号");
}

Loading…
Cancel
Save