feat: 尚未购买的弹窗
This commit is contained in:
@@ -6,6 +6,7 @@ import 'package:get/get.dart';
|
||||
import 'package:kaer_with_panels/app/modules/hi_menu/controllers/hi_menu_controller.dart';
|
||||
import 'package:kaer_with_panels/app/routes/app_pages.dart';
|
||||
import 'package:kaer_with_panels/app/widgets/kr_local_image.dart';
|
||||
import 'package:kaer_with_panels/app/widgets/kr_subscription_expiry_text.dart';
|
||||
|
||||
/// 用户信息展示卡片 Widget
|
||||
///
|
||||
@@ -67,51 +68,10 @@ class UserInfoCard extends StatelessWidget {
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Obx(() {
|
||||
final currentSubscribe =
|
||||
controller.kr_subscribeService.kr_currentSubscribe.value;
|
||||
String expiryText;
|
||||
|
||||
if (currentSubscribe == null) {
|
||||
expiryText = '尚未购买套餐';
|
||||
} else {
|
||||
final now = DateTime.now();
|
||||
DateTime? expireDateTime;
|
||||
try {
|
||||
expireDateTime =
|
||||
DateTime.parse(currentSubscribe.expireTime);
|
||||
} catch (e) {
|
||||
expireDateTime = null;
|
||||
}
|
||||
|
||||
if (expireDateTime == null) {
|
||||
expiryText = '套餐信息无效';
|
||||
} else if (expireDateTime.isBefore(now)) {
|
||||
final formattedExpireDate =
|
||||
'${expireDateTime.year}/${expireDateTime.month.toString().padLeft(2, '0')}/${expireDateTime.day.toString().padLeft(2, '0')}';
|
||||
expiryText = '已于 $formattedExpireDate 到期';
|
||||
} else {
|
||||
final year = expireDateTime.year;
|
||||
final month = expireDateTime.month.toString().padLeft(2, '0');
|
||||
final day = expireDateTime.day.toString().padLeft(2, '0');
|
||||
final hour = expireDateTime.hour.toString().padLeft(2, '0');
|
||||
final minute = expireDateTime.minute.toString().padLeft(2, '0');
|
||||
final second = expireDateTime.second.toString().padLeft(2, '0');
|
||||
|
||||
// 2. 拼接成最终的字符串
|
||||
final formattedDateTime = '$year/$month/$day $hour:$minute:$second';
|
||||
|
||||
expiryText = '到期时间:$formattedDateTime';
|
||||
}
|
||||
}
|
||||
return Text(
|
||||
expiryText,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 12.sp,
|
||||
),
|
||||
);
|
||||
}),
|
||||
KRSubscriptionExpiryText(
|
||||
expireTimeProvider: () => controller.kr_subscribeService
|
||||
.kr_currentSubscribe.value?.expireTime,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user