通话记录展示
This commit is contained in:
86
lib/common/channel/call_log_model.dart
Normal file
86
lib/common/channel/call_log_model.dart
Normal file
@@ -0,0 +1,86 @@
|
||||
import 'dart:convert';
|
||||
|
||||
/// number : "18092171236"
|
||||
/// date : "2024-11-21 09:32:27"
|
||||
/// duration : 0
|
||||
/// type : 5
|
||||
/// name : gong
|
||||
|
||||
CallLogModel callLogModelFromJson(String str) =>
|
||||
CallLogModel.fromJson(json.decode(str));
|
||||
|
||||
String callLogModelToJson(CallLogModel data) => json.encode(data.toJson());
|
||||
|
||||
class CallLogModel {
|
||||
CallLogModel({
|
||||
String? number,
|
||||
String? date,
|
||||
num? duration,
|
||||
num? type,
|
||||
String? name,
|
||||
String? time,
|
||||
}) {
|
||||
_number = number;
|
||||
_date = date;
|
||||
_duration = duration;
|
||||
_type = type;
|
||||
_name = name;
|
||||
_time = time;
|
||||
}
|
||||
|
||||
CallLogModel.fromJson(dynamic json) {
|
||||
_number = json['number'];
|
||||
_date = json['date'];
|
||||
_duration = json['duration'];
|
||||
_type = json['type'];
|
||||
_name = json['name'];
|
||||
_time = json['time'];
|
||||
}
|
||||
|
||||
String? _number;
|
||||
String? _date;
|
||||
num? _duration;
|
||||
num? _type;
|
||||
String? _name;
|
||||
String? _time;
|
||||
|
||||
CallLogModel copyWith({
|
||||
String? number,
|
||||
String? date,
|
||||
num? duration,
|
||||
num? type,
|
||||
String? name,
|
||||
String? time,
|
||||
}) =>
|
||||
CallLogModel(
|
||||
number: number ?? _number,
|
||||
date: date ?? _date,
|
||||
duration: duration ?? _duration,
|
||||
type: type ?? _type,
|
||||
name: name ?? _name,
|
||||
time: time ?? _time,
|
||||
);
|
||||
|
||||
String? get number => _number;
|
||||
|
||||
String? get date => _date;
|
||||
|
||||
num? get duration => _duration;
|
||||
|
||||
num? get type => _type;
|
||||
|
||||
String? get name => _name;
|
||||
|
||||
String? get time => _time;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['number'] = _number;
|
||||
map['date'] = _date;
|
||||
map['duration'] = _duration;
|
||||
map['type'] = _type;
|
||||
map['name'] = _name;
|
||||
map['time'] = _time;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,10 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:cashier_reserve/common/print/print.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../manager/event_manager.dart';
|
||||
import 'call_log_model.dart';
|
||||
import 'names.dart';
|
||||
|
||||
class MyEventChannel {
|
||||
@@ -13,13 +17,19 @@ class MyEventChannel {
|
||||
channel.receiveBroadcastStream().listen((Object? o) {
|
||||
yjPrint("onGetCallLogResult");
|
||||
yjPrint(o);
|
||||
// AlipayPayResultEvent event = AlipayPayResultEvent();
|
||||
// if (o is int) {
|
||||
// event.resultStatus = o;
|
||||
// } else {
|
||||
// event.resultStatus = int.parse(o as String);
|
||||
// }
|
||||
// EventManager.postEvent(event);
|
||||
GetCallLogEvent event = GetCallLogEvent();
|
||||
if (o is String) {
|
||||
event.isSuccess = true;
|
||||
List<dynamic> list = json.decode(o);
|
||||
List<CallLogModel> callLogs = [];
|
||||
for (var item in list) {
|
||||
callLogs.add(CallLogModel.fromJson(item));
|
||||
}
|
||||
event.callLogs = callLogs.reversed.toList();
|
||||
} else {
|
||||
event.isSuccess = false;
|
||||
}
|
||||
EventManager.postEvent(event);
|
||||
}, onError: (Object error) {
|
||||
yjPrint("onGetCallLogResult error");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user