hi-client/lib/app/utils/kr_subscribe_navigation_util.dart
Rust f1e8e7f530
Some checks failed
Build Android APK / 编译 libcore.aar (push) Has been cancelled
Build Android APK / 编译 Android APK (release) (push) Has been cancelled
Build Android APK / 创建 GitHub Release (push) Has been cancelled
Build Multi-Platform / 编译 libcore (iOS/tvOS) (push) Has been cancelled
Build Multi-Platform / 编译 libcore (Android) (push) Has been cancelled
Build Multi-Platform / 编译 libcore (Windows) (push) Has been cancelled
Build Multi-Platform / 编译 libcore (macOS) (push) Has been cancelled
Build Multi-Platform / 编译 libcore (Linux) (push) Has been cancelled
Build Multi-Platform / 构建 Android APK (push) Has been cancelled
Build Multi-Platform / 构建 Windows (push) Has been cancelled
Build Multi-Platform / 构建 macOS (push) Has been cancelled
Build Multi-Platform / 构建 Linux (push) Has been cancelled
Build Multi-Platform / 构建 iOS (push) Has been cancelled
Build Multi-Platform / 创建 Release (push) Has been cancelled
Build Windows / build (push) Has been cancelled
Build Windows / 编译 libcore (Windows) (push) Has been cancelled
1. 订阅卡片 - 移除 ScreenUtil,内容可见
2.  连接选项 - 移除 ScreenUtil,"国家/地区"可见
  3.  连接信息卡片 - 移除 ScreenUtil
  4.  试用卡片 - 移除 ScreenUtil
  5.  最后一天卡片 - 移除 ScreenUtil
  6.  底部面板 - 移除 ScreenUtil
  7.  购买页面 - 移除 ScreenUtil,点击订阅不再卡死

(cherry picked from commit 1b059c57f55d65a737d5713754486a9cf576b210)
2025-11-02 01:06:45 -08:00

62 lines
2.4 KiB
Dart

import 'package:get/get.dart';
import 'package:kaer_with_panels/app/common/app_run_data.dart';
import 'package:kaer_with_panels/app/widgets/dialogs/kr_dialog.dart';
import 'package:kaer_with_panels/app/routes/app_pages.dart';
import 'package:kaer_with_panels/app/utils/kr_log_util.dart';
import 'package:kaer_with_panels/app/localization/app_translations.dart';
/// 订阅导航工具类
/// 用于统一处理订阅相关的导航逻辑
class KRSubscribeNavigationUtil {
/// 导航到购买会员页面
/// 如果是设备登录用户,会先提示需要绑定账号,然后跳转到登录页面
/// 如果是普通用户,直接跳转到购买会员页面
///
/// [tag] 调用来源标签,用于日志记录
static void navigateToPurchase({String tag = 'Subscribe'}) {
final appRunData = KRAppRunData.getInstance();
final isDeviceLogin = appRunData.isDeviceLogin();
final account = appRunData.kr_account.value;
KRLogUtil.kr_i('=== 订阅按钮点击 ===', tag: tag);
KRLogUtil.kr_i('账号: $account', tag: tag);
KRLogUtil.kr_i('是否设备登录: $isDeviceLogin', tag: tag);
if (isDeviceLogin) {
// 设备登录用户需要绑定账号
KRLogUtil.kr_i('检测到设备登录,显示绑定提示', tag: tag);
KRDialog.show(
title: AppTranslations.kr_dialog.deviceLoginBindingTitle,
message: AppTranslations.kr_dialog.deviceLoginBindingMessage,
confirmText: AppTranslations.kr_dialog.kr_ok,
cancelText: AppTranslations.kr_dialog.kr_cancel,
onConfirm: () {
Get.back(); // 关闭对话框
// 等待对话框完全关闭后再跳转到登录页面
Future.delayed(const Duration(milliseconds: 300), () {
Get.toNamed(Routes.MR_LOGIN);
});
},
onCancel: () => Get.back(),
);
} else {
// 正常流程 - 跳转到购买页面
KRLogUtil.kr_i('普通用户,跳转到购买页面', tag: tag);
try {
// 🔧 添加加载保护,避免页面跳转时卡死
Get.toNamed(Routes.KR_PURCHASE_MEMBERSHIP);
} catch (e) {
KRLogUtil.kr_e('跳转购买页面失败: $e', tag: tag);
// 如果跳转失败,显示错误提示
KRDialog.show(
title: AppTranslations.kr_dialog.error,
message: AppTranslations.kr_home.checkNetwork,
confirmText: AppTranslations.kr_dialog.kr_ok,
onConfirm: () => Get.back(),
);
}
}
}
}