Files
platforms/apps/user_app/lib/domain/models/shipping_address.dart
czl231 3ef33b531d 已完成用户APP首期功能开发
交付用户端首期页面、配套接口、后台资源及测试文档。用户APP构建、静态分析和三个管理后台构建通过;完整测试仍有2项失败,后端模型注释检查未通过,详见交付记录。
2026-09-13 00:57:32 +08:00

41 lines
1.4 KiB
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 功能描述:用户收货地址模型,列表脱敏展示、编辑使用本人完整数据。
// 版本1.0.0。
class ShippingAddress {
const ShippingAddress({
this.identity = '',
required this.address,
required this.contactName,
required this.contactPhone,
this.longitude = '',
this.latitude = '',
this.isDefault = false,
});
final String identity, address, contactName, contactPhone, longitude, latitude;
final bool isDefault;
/// 从兼容地址响应读取字段;历史空联系人在编辑时要求补齐。
factory ShippingAddress.fromJson(Map<String, Object?> json) => ShippingAddress(
identity: json['identity'] as String? ?? '',
address: json['address'] as String? ?? '',
contactName: json['contact_name'] as String? ?? '',
contactPhone: json['contact_phone'] as String? ?? '',
longitude: json['longitude'] as String? ?? '',
latitude: json['latitude'] as String? ?? '',
isDefault: json['is_default'] == true,
);
String get maskedPhone => contactPhone.length == 11
? '${contactPhone.substring(0, 3)}****${contactPhone.substring(7)}'
: contactPhone;
/// 保存地址的完整字段;不接收内部账户编号。
Map<String, Object?> toJson() => {
'address': address,
'contact_name': contactName,
'contact_phone': contactPhone,
'longitude': longitude,
'latitude': latitude,
'is_default': isDefault,
};
}