Browse Source

feat(设备绑定): 添加跳过设备绑定功能支持

- 在AppInfo模型中添加allowskipdevicebinding字段
- 在VersionUpdateService中缓存跳过设备绑定状态
- 修改PairingController使用新字段判断是否显示跳过按钮
- 新增getChannelApps API接口
newdev_shunjiawei
lxm 10 months ago
parent
commit
873b98f504
  1. 5
      lib/data/models/channel_app_model.dart
  2. 2
      lib/data/models/channel_app_model.g.dart
  3. 9
      lib/data/services/network/api.dart
  4. 12
      lib/data/services/version_update_service.dart
  5. 5
      lib/modules/pairing/controllers/pairing_controller.dart

5
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,
});

2
lib/data/models/channel_app_model.g.dart

@ -38,6 +38,7 @@ AppInfo _$AppInfoFromJson(Map<String, dynamic> 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<String, dynamic> _$AppInfoToJson(AppInfo instance) => <String, dynamic>{
'description': instance.description,
'version': instance.version,
'tourists': instance.tourists,
'allowskipsevicebinding': instance.allowskipdevicebinding,
'paychannels': instance.paychannels,
};

9
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(

12
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字段');
}

5
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; // 启用跳过按钮
}

Loading…
Cancel
Save