72 lines
2.2 KiB
Dart
Executable File
72 lines
2.2 KiB
Dart
Executable File
|
||
import 'package:flutter/material.dart';
|
||
import 'package:get/get.dart';
|
||
import 'package:star_lock/login/login/entity/LoginData.dart';
|
||
import 'package:star_lock/login/selectCountryRegion/common/index.dart';
|
||
import 'package:star_lock/tools/storage.dart';
|
||
|
||
class PersonInfoEditAccountState {
|
||
|
||
PersonInfoEditAccountState() {
|
||
Map map = Get.arguments;
|
||
channel.value = map['isFrom'];
|
||
if (channel.value == '1') {
|
||
codeType.value = '3';
|
||
} else {
|
||
codeType.value = '6';
|
||
}
|
||
|
||
resetResend();
|
||
}
|
||
final TextEditingController accountController = TextEditingController();
|
||
final TextEditingController codeController = TextEditingController();
|
||
|
||
static int currentTimeMillis() {
|
||
return DateTime.now().millisecondsSinceEpoch;
|
||
}
|
||
|
||
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;
|
||
|
||
bool get accountIsOK => newAccountStr.value.isNotEmpty;
|
||
bool get codeIsOK => verificationCode.value.isNotEmpty;
|
||
|
||
RxBool canResend = false.obs;
|
||
RxString btnText = ''.obs;
|
||
int totalSeconds = 120;
|
||
int currentSecond = 120;
|
||
|
||
final Rx<LoginData> loginData = LoginData().obs;
|
||
|
||
///本地存储 登录信息
|
||
Future<void> saveLoginData(LoginData? data) async {
|
||
await Storage.setString(saveUserLoginData, jsonEncode(data));
|
||
loginData.value = data!;
|
||
}
|
||
|
||
///初始化本地数据
|
||
Future<void> initLoginData() async {
|
||
final String? data = await Storage.getString(saveUserLoginData);
|
||
if (data != null && data.isNotEmpty) {
|
||
loginData.value = LoginData.fromJson(jsonDecode(data));
|
||
}
|
||
}
|
||
|
||
void resetResend() {
|
||
canResend.value = totalSeconds == currentSecond;
|
||
btnText.value = !canResend.value
|
||
? '$currentSecond s'
|
||
: btnText.value = '获取验证码'.tr;
|
||
}
|
||
|
||
void onClose() {}
|
||
}
|