From 873b98f50491214ec572c9bbc9f66b6876677a20 Mon Sep 17 00:00:00 2001 From: lxm <1274844347@qq.com> Date: Thu, 4 Dec 2025 16:46:11 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E8=AE=BE=E5=A4=87=E7=BB=91=E5=AE=9A):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=B7=B3=E8=BF=87=E8=AE=BE=E5=A4=87=E7=BB=91?= =?UTF-8?q?=E5=AE=9A=E5=8A=9F=E8=83=BD=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在AppInfo模型中添加allowskipdevicebinding字段 - 在VersionUpdateService中缓存跳过设备绑定状态 - 修改PairingController使用新字段判断是否显示跳过按钮 - 新增getChannelApps API接口 --- lib/data/models/channel_app_model.dart | 5 +++++ lib/data/models/channel_app_model.g.dart | 2 ++ lib/data/services/network/api.dart | 9 +++++++++ lib/data/services/version_update_service.dart | 12 +++++++++++- .../pairing/controllers/pairing_controller.dart | 5 +++-- 5 files changed, 30 insertions(+), 3 deletions(-) diff --git a/lib/data/models/channel_app_model.dart b/lib/data/models/channel_app_model.dart index 269dd9f5b..f4a117fe3 100644 --- a/lib/data/models/channel_app_model.dart +++ b/lib/data/models/channel_app_model.dart @@ -69,6 +69,10 @@ class AppInfo { @JsonKey(name: 'tourists') final bool tourists; + /// 是否允许跳过设备绑定 + @JsonKey(name: 'allowskipdevicebinding') + final bool allowskipdevicebinding; + /// 支付渠道列表 @JsonKey(name: 'Paychannels') final String? paychannels; @@ -79,6 +83,7 @@ class AppInfo { required this.description, required this.version, this.tourists = false, + this.allowskipdevicebinding = false, required this.paychannels, }); diff --git a/lib/data/models/channel_app_model.g.dart b/lib/data/models/channel_app_model.g.dart index fa2bd07e5..720e9cc33 100644 --- a/lib/data/models/channel_app_model.g.dart +++ b/lib/data/models/channel_app_model.g.dart @@ -38,6 +38,7 @@ AppInfo _$AppInfoFromJson(Map json) => AppInfo( description: json['description'] as String, version: json['version'] as String, tourists: json['tourists'] as bool? ?? false, + allowskipdevicebinding: json['allowskipdevicebinding'] as bool? ?? false, paychannels: json['paychannels'] as String?, ); @@ -47,5 +48,6 @@ Map _$AppInfoToJson(AppInfo instance) => { 'description': instance.description, 'version': instance.version, 'tourists': instance.tourists, + 'allowskipsevicebinding': instance.allowskipdevicebinding, 'paychannels': instance.paychannels, }; diff --git a/lib/data/services/network/api.dart b/lib/data/services/network/api.dart index a1c93e5b4..d5a1747ce 100644 --- a/lib/data/services/network/api.dart +++ b/lib/data/services/network/api.dart @@ -136,6 +136,15 @@ class Api { ); } + //获取所有渠道包信息 + static getChannelApps() { + return DioManager().request( + NWMethod.post, + '/api/home/user_getchannelapps', + //params: params, + ); + } + //绑定设备 static binddevice([params]) { return DioManager().request( diff --git a/lib/data/services/version_update_service.dart b/lib/data/services/version_update_service.dart index b8bf1da1f..4c37e851f 100644 --- a/lib/data/services/version_update_service.dart +++ b/lib/data/services/version_update_service.dart @@ -26,6 +26,7 @@ class VersionUpdateService extends GetxService { static String? _updateUrl = ""; //更新链接 static AppInfo? _appInfo; //应用信息 static bool? _isShowTourists = false; //是否显示游客登录 + static bool? _allowSkipDeviceBinding = false; //是否允许跳过设备绑定 static DateTime? _lastCheckTime; //上次检查时间 static const int _cacheIntervalMinutes = 10; // 可配置化 static final String? _countryCode = Get.deviceLocale?.countryCode; //国家地区编码 @@ -73,6 +74,9 @@ class VersionUpdateService extends GetxService { /// 获取缓存的游客登录状态 bool get cachedShowTourists => _isShowTourists ?? false; + /// 获取缓存的是否允许跳过设备绑定 + bool get cachedAllowSkipDeviceBinding => _allowSkipDeviceBinding ?? false; + /// 获取上次检查时间 DateTime? get lastCheckTime => _lastCheckTime; @@ -123,6 +127,7 @@ class VersionUpdateService extends GetxService { // 调用后端接口获取最新版本信息 final response = await Api.getChannelApp({'channel': platformInfo.channel.value}); + // final response = await Api.getChannelApps(); _logger.d('lxm--获取渠道包信息:$response'); @@ -147,6 +152,8 @@ class VersionUpdateService extends GetxService { // 设置游客登录显示状态(先用当前渠道结果作为回退,再用.env渠道覆盖以保持一致) _isShowTourists = appInfo.tourists; + _allowSkipDeviceBinding = appInfo.allowskipdevicebinding; + //print('lxm--_isShowTourists: $_isShowTourists'); if (Platform.isAndroid && _channel != platformInfo.channel) { //[4]当前渠道与.env渠道不同,需要从.env渠道获取游客登录配置 @@ -300,11 +307,14 @@ class VersionUpdateService extends GetxService { final envChannel = UserChannel.fromName(envChannelName); final resp = await Api.getChannelApp({'channel': envChannel.value}); + // _logger.d('lxm--获取渠道包信息:$resp'); if (resp != null && resp.containsKey('app')) { final envAppInfo = AppInfo.fromJson(resp['app']); + // print('lxm--envAppInfo: ${envAppInfo.toJson()}'); _isShowTourists = envAppInfo.tourists; + _allowSkipDeviceBinding = envAppInfo.allowskipdevicebinding; _logger.d( - 'lxm--游客登录配置已按.env渠道同步: ${envAppInfo.tourists} (channel=$envChannelName),_isShowTourists: $_isShowTourists'); + 'lxm--游客登录配置已按.env${envChannel.value}渠道同步: ${envAppInfo.tourists} (channel=$envChannelName),_isShowTourists: $_isShowTourists,_allowSkipDeviceBinding: $_allowSkipDeviceBinding'); } else { _logger.w('按.env渠道获取游客配置失败:响应为空或不含app字段'); } diff --git a/lib/modules/pairing/controllers/pairing_controller.dart b/lib/modules/pairing/controllers/pairing_controller.dart index f804348de..39ca7fa67 100644 --- a/lib/modules/pairing/controllers/pairing_controller.dart +++ b/lib/modules/pairing/controllers/pairing_controller.dart @@ -137,10 +137,11 @@ class PairingController extends GetxController with WidgetsBindingObserver { _startInitialCheck(); }); - final app_authcode_jump = AppConfig.env('APP_AUTHCODE_JUMP') ?? ""; + // final app_authcode_jump = AppConfig.env('APP_AUTHCODE_JUMP') ?? ""; //print('app_authcode_jump: $app_authcode_jump'); // 如果APP_AUTHCODE_JUMP为true,或者用户已登录且有绑定设备,启用跳过按钮 - if (app_authcode_jump == "true" || + final allowSkipDeviceBinding = versionService.cachedAllowSkipDeviceBinding; + if (allowSkipDeviceBinding || (User.isLoggedIn() && User.instance.devices.isNotEmpty)) { isShowSkipButton = true; // 启用跳过按钮 }