feat: 完成代码
Build Android APK / 编译 libcore.aar (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 / 编译 libcore (Windows) (push) Has been cancelled
Build Windows / build (push) Has been cancelled
Build Android APK / 编译 Android APK (release) (push) Has been cancelled
Build Android APK / 编译 libcore.aar (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 / 编译 libcore (Windows) (push) Has been cancelled
Build Windows / build (push) Has been cancelled
Build Android APK / 编译 Android APK (release) (push) Has been cancelled
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
abstract class Api {
|
||||
/// 游客登录查看是否已经注册
|
||||
static const String kr_isRegister = "/v1/app/auth/check";
|
||||
/// 判断邮箱和当前设备是否已存在订阅
|
||||
static const String kr_checkSubscription = "/v1/public/user/subscribe_status";
|
||||
|
||||
/// 注册
|
||||
// static const String kr_register = "/v1/auth/register";
|
||||
@@ -21,7 +23,7 @@ abstract class Api {
|
||||
static const String kr_deviceLogin = "/v1/auth/login/device";
|
||||
|
||||
/// 删除账号
|
||||
static const String kr_deleteAccount = "/v1/app/user/account";
|
||||
static const String kr_deleteAccount = "/v1/public/user/delete_account";
|
||||
|
||||
/// 忘记密码-设置新密码
|
||||
static const String kr_setNewPsdByForgetPsd = "/v1/app/auth/reset_password";
|
||||
|
||||
@@ -8,6 +8,7 @@ import 'package:kaer_with_panels/app/mixins/kr_app_bar_opacity_mixin.dart';
|
||||
import 'package:kaer_with_panels/app/services/api_service/api.dart';
|
||||
import 'package:kaer_with_panels/app/model/enum/kr_request_type.dart';
|
||||
import 'package:kaer_with_panels/app/model/response/kr_is_register.dart';
|
||||
import 'package:kaer_with_panels/app/model/response/kr_check_subscription.dart';
|
||||
import 'package:kaer_with_panels/app/model/response/kr_login_data.dart';
|
||||
import 'package:kaer_with_panels/app/network/base_response.dart';
|
||||
import 'package:kaer_with_panels/app/network/http_error.dart';
|
||||
@@ -43,6 +44,36 @@ class KRAuthApi {
|
||||
return right(baseResponse.model.kr_isRegister);
|
||||
}
|
||||
|
||||
/// 检查账号和邮箱是否都已经有订阅(只有两者都订阅才返回 true)
|
||||
Future<Either<HttpError, bool>> kr_checkSubscription(String email) async {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['email'] = email;
|
||||
|
||||
// 获取当前设备 ID
|
||||
final deviceId = KRDeviceInfoService().deviceId ?? 'unknown';
|
||||
KRLogUtil.kr_i('设备ID: $deviceId', tag: 'KRAuthApi');
|
||||
data["identifier"] = deviceId;
|
||||
|
||||
// 发起请求
|
||||
BaseResponse<KRCheckSubscription> baseResponse = await HttpUtil.getInstance()
|
||||
.request<KRCheckSubscription>(
|
||||
Api.kr_checkSubscription,
|
||||
data,
|
||||
method: HttpMethod.POST,
|
||||
isShowLoading: true,
|
||||
);
|
||||
|
||||
// 请求失败
|
||||
if (!baseResponse.isSuccess) {
|
||||
return left(HttpError(msg: baseResponse.retMsg, code: baseResponse.retCode));
|
||||
}
|
||||
|
||||
final subscription = baseResponse.model;
|
||||
|
||||
// 只有设备和邮箱都已订阅才返回 true
|
||||
return right(subscription.isFullySubscribed);
|
||||
}
|
||||
|
||||
/// 注册(仅支持邮箱+密码,验证码和邀请码可选)
|
||||
Future<Either<HttpError, String>> kr_register(
|
||||
String email,
|
||||
@@ -139,8 +170,9 @@ class KRAuthApi {
|
||||
}
|
||||
|
||||
/// 删除账号
|
||||
Future<Either<HttpError, String>> kr_deleteAccount(String code) async {
|
||||
Future<Either<HttpError, String>> kr_deleteAccount(String email, String code) async {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['email'] = email;
|
||||
data['code'] = code;
|
||||
|
||||
BaseResponse<dynamic> baseResponse = await HttpUtil.getInstance()
|
||||
|
||||
Reference in New Issue
Block a user