Commit 7d417b0451b36a787cb66be9e1bf1c7cc5d9fe1d
1 parent
60c14061
feat:fix用户vip到期日问题
Showing
2 changed files
with
17 additions
and
1 deletions
lib/models/user_entity.dart
... | ... | @@ -68,6 +68,22 @@ class UserEntity { |
68 | 68 | return valid ?? false; |
69 | 69 | } |
70 | 70 | |
71 | + // 计算用户vip到期日 | |
72 | + String? getEffectiveDate() { | |
73 | + if (effectiveDate == null) { | |
74 | + return null; | |
75 | + } | |
76 | + DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(int.parse(effectiveDate!)); | |
77 | + // 获取年、月、日 | |
78 | + String year = dateTime.year.toString(); | |
79 | + String month = dateTime.month.toString().padLeft(2, '0'); // 如果月份是个位数,则在前面加上0,使其两位数 | |
80 | + String day = dateTime.day.toString().padLeft(2, '0'); // 如果日期是个位数,则在前面加上0,使其两位数 | |
81 | + | |
82 | + // 拼接成日期字符串 | |
83 | + String formattedDate = '$year-$month-$day'; | |
84 | + return formattedDate; | |
85 | + } | |
86 | + | |
71 | 87 | UserEntity copyWith({ |
72 | 88 | int? id, |
73 | 89 | String? name, | ... | ... |
lib/pages/user/user_page.dart