2024-08-21 14:12:15 +08:00
|
|
|
|
|
2023-10-09 18:45:10 +08:00
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
import 'package:get/get.dart';
|
|
|
|
|
|
import 'package:star_lock/login/login/entity/LoginData.dart';
|
2024-01-23 17:48:06 +08:00
|
|
|
|
import 'package:star_lock/login/selectCountryRegion/common/index.dart';
|
2023-10-09 18:45:10 +08:00
|
|
|
|
import 'package:star_lock/tools/storage.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class PersonInfoEditAccountState {
|
2024-08-21 14:12:15 +08:00
|
|
|
|
|
|
|
|
|
|
PersonInfoEditAccountState() {
|
|
|
|
|
|
Map map = Get.arguments;
|
|
|
|
|
|
channel.value = map['isFrom'];
|
|
|
|
|
|
if (channel.value == '1') {
|
|
|
|
|
|
codeType.value = '3';
|
|
|
|
|
|
} else {
|
|
|
|
|
|
codeType.value = '6';
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
resetResend();
|
|
|
|
|
|
}
|
2023-10-09 18:45:10 +08:00
|
|
|
|
final TextEditingController accountController = TextEditingController();
|
|
|
|
|
|
final TextEditingController codeController = TextEditingController();
|
|
|
|
|
|
|
|
|
|
|
|
static int currentTimeMillis() {
|
|
|
|
|
|
return DateTime.now().millisecondsSinceEpoch;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-01 18:54:32 +08:00
|
|
|
|
RxString countryCode = '+86'.obs;
|
|
|
|
|
|
RxString countryId = '9'.obs;
|
|
|
|
|
|
RxString codeType = '3'.obs; ////1注册,2找回密码,3绑定手机号,4解绑手机(换绑),5删除账号,6 绑定邮箱,7解绑邮箱(换绑)
|
|
|
|
|
|
RxString channel = '1'.obs; //短信通道 1 短信,2 邮箱
|
|
|
|
|
|
RxString uniqueid = 'B748F838-94EE-4BDB-A0E6-7B2D16849792'.obs;
|
|
|
|
|
|
RxString newAccountStr = ''.obs;
|
|
|
|
|
|
RxString verificationCode = ''.obs;
|
|
|
|
|
|
RxString xWidth = ''.obs; // 滑动验证码滑动位置
|
|
|
|
|
|
RxBool canSub = false.obs;
|
|
|
|
|
|
RxString date = currentTimeMillis().toString().obs;
|
2023-10-09 18:45:10 +08:00
|
|
|
|
|
|
|
|
|
|
bool get accountIsOK => newAccountStr.value.isNotEmpty;
|
|
|
|
|
|
bool get codeIsOK => verificationCode.value.isNotEmpty;
|
|
|
|
|
|
|
2024-08-01 18:54:32 +08:00
|
|
|
|
RxBool canResend = false.obs;
|
|
|
|
|
|
RxString btnText = ''.obs;
|
|
|
|
|
|
int totalSeconds = 120;
|
|
|
|
|
|
int currentSecond = 120;
|
2023-10-09 18:45:10 +08:00
|
|
|
|
|
2024-08-01 18:54:32 +08:00
|
|
|
|
final Rx<LoginData> loginData = LoginData().obs;
|
2023-10-09 18:45:10 +08:00
|
|
|
|
|
|
|
|
|
|
///本地存储 登录信息
|
2024-08-21 14:12:15 +08:00
|
|
|
|
Future<void> saveLoginData(LoginData? data) async {
|
2024-01-16 15:13:43 +08:00
|
|
|
|
await Storage.setString(saveUserLoginData, jsonEncode(data));
|
2024-04-26 15:38:59 +08:00
|
|
|
|
loginData.value = data!;
|
2023-10-09 18:45:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///初始化本地数据
|
2024-08-21 14:12:15 +08:00
|
|
|
|
Future<void> initLoginData() async {
|
2024-08-01 18:54:32 +08:00
|
|
|
|
final String? data = await Storage.getString(saveUserLoginData);
|
2023-10-09 18:45:10 +08:00
|
|
|
|
if (data != null && data.isNotEmpty) {
|
|
|
|
|
|
loginData.value = LoginData.fromJson(jsonDecode(data));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void resetResend() {
|
|
|
|
|
|
canResend.value = totalSeconds == currentSecond;
|
|
|
|
|
|
btnText.value = !canResend.value
|
|
|
|
|
|
? '$currentSecond s'
|
2024-08-01 18:54:32 +08:00
|
|
|
|
: btnText.value = '获取验证码'.tr;
|
2023-10-09 18:45:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void onClose() {}
|
|
|
|
|
|
}
|