推送配置,测试

This commit is contained in:
2025-12-31 17:22:13 +08:00
parent 6629c8047f
commit 295b71c819
15 changed files with 557 additions and 76 deletions

View File

@@ -1,12 +1,14 @@
import 'package:aliyun_push_flutter/aliyun_push_flutter.dart';
import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';
import 'package:getx_scaffold/common/utils/log_util.dart';
import 'package:ln_jq_app/common/model/vehicle_info.dart';
/// 定义登录渠道的枚举类型
enum LoginChannel {
station, // 站点
driver, // 司机
none, // 未登录或未知
driver, // 司机
none, // 未登录或未知
}
class StorageService extends GetxService {
@@ -22,10 +24,10 @@ class StorageService extends GetxService {
static const String _vehicleInfoKey = 'vehicle_info';
static const String _stationAccountKey = 'station_account';
static const String _stationPasswordKey = 'station_password';
// 新增:用于标记“绑定车辆”弹窗是否已在本会话中显示过
static const String _bindDialogShownKey = 'bind_vehicle_dialog_shown';
static StorageService get to => Get.find();
Future<StorageService> init() async {
@@ -33,22 +35,28 @@ class StorageService extends GetxService {
return this;
}
// --- Getters ---
// --- Getters ---
bool get isLoggedIn => _box.read<String?>(_tokenKey)?.isNotEmpty ?? false;
String? get token => _box.read<String?>(_tokenKey);
String? get userId => _box.read<String?>(_userIdKey);
String? get name => _box.read<String?>(_nameKey);
String? get phone => _box.read<String?>(_phoneKey);
String? get idCard => _box.read<String?>(_idCardKey);
bool get hasVehicleInfo => _box.hasData(_vehicleInfoKey);
String? get stationAccount => _box.read<String?>(_stationAccountKey);
String? get stationPassword => _box.read<String?>(_stationPasswordKey);
// 新增:获取“绑定车辆”弹窗是否已显示的标志
bool get hasShownBindVehicleDialog => _box.read<bool>(_bindDialogShownKey) ?? false;
VehicleInfo? get vehicleInfo {
final vehicleJson = _box.read<String?>(_vehicleInfoKey);
if (vehicleJson != null) {
@@ -98,7 +106,6 @@ class StorageService extends GetxService {
await _box.write(_bindDialogShownKey, true);
}
Future<void> clearVehicleInfo() async {
await _box.remove(_vehicleInfoKey);
}
@@ -118,5 +125,22 @@ class StorageService extends GetxService {
await clearVehicleInfo();
// 登出时,清除“绑定车辆”弹窗的显示记录,以便下次登录时可以再次弹出
await _box.remove(_bindDialogShownKey);
delAlias();
}
final _aliyunPush = AliyunPushFlutter();
void delAlias() async {
String phoen = StorageService.to.phone ?? "";
var result = await _aliyunPush.removeAlias(phoen);
var code = result['code'];
if (code == kAliyunPushSuccessCode) {
Logger.d('删除别名$phoen成功');
} else {
var errorCode = result['code'];
var errorMsg = result['errorMsg'];
Logger.d('删除别名$phoen失败: $errorCode - $errorMsg');
}
}
}