优化登录时个人信息本地持久化功能
This commit is contained in:
parent
6bdc2aae12
commit
dcabcfc392
@ -5,6 +5,7 @@ import 'package:star_lock/tools/baseGetXController.dart';
|
|||||||
|
|
||||||
import '../../mine/mine/starLockMine_logic.dart';
|
import '../../mine/mine/starLockMine_logic.dart';
|
||||||
import '../../network/api_repository.dart';
|
import '../../network/api_repository.dart';
|
||||||
|
import '../../tools/storage.dart';
|
||||||
import 'starLock_login_state.dart';
|
import 'starLock_login_state.dart';
|
||||||
|
|
||||||
class StarLockLoginLogic extends BaseGetXController {
|
class StarLockLoginLogic extends BaseGetXController {
|
||||||
@ -15,8 +16,7 @@ class StarLockLoginLogic extends BaseGetXController {
|
|||||||
var entity = await ApiRepository.to
|
var entity = await ApiRepository.to
|
||||||
.login("1", state.pwd.value, "+86", state.emailOrPhone.value);
|
.login("1", state.pwd.value, "+86", state.emailOrPhone.value);
|
||||||
if (entity.errorCode!.codeIsSuccessful) {
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
// await StoreService.to.saveLogInInfo(entity);
|
Storage.saveLoginData(entity.data);
|
||||||
stateMyLogic.saveLoginData(entity.data);
|
|
||||||
// Get.back();
|
// Get.back();
|
||||||
// Get.toNamed(Routers.starLockMain);
|
// Get.toNamed(Routers.starLockMain);
|
||||||
Get.offNamedUntil(Routers.starLockMain, (route) => false);
|
Get.offNamedUntil(Routers.starLockMain, (route) => false);
|
||||||
|
|||||||
@ -148,7 +148,7 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver, BaseWidget {
|
|||||||
|
|
||||||
//暂不使用DeviceID推送
|
//暂不使用DeviceID推送
|
||||||
_aliyunPush.getDeviceId().then((deviceId) async {
|
_aliyunPush.getDeviceId().then((deviceId) async {
|
||||||
final data = await Storage.getString('userLoginData');
|
final data = await Storage.getString(saveUserLoginData);
|
||||||
if (data!.isNotEmpty) {
|
if (data!.isNotEmpty) {
|
||||||
XSAliyunPushProvider()
|
XSAliyunPushProvider()
|
||||||
.pushBindDeviceID(deviceId, Platform.isAndroid ? 10 : 20);
|
.pushBindDeviceID(deviceId, Platform.isAndroid ? 10 : 20);
|
||||||
|
|||||||
@ -44,7 +44,7 @@ class _BasicInformationPageState extends State<BasicInformationPage> {
|
|||||||
CommonItem(
|
CommonItem(
|
||||||
leftTitel:
|
leftTitel:
|
||||||
TranslationLoader.lanKeys!.lockNumber!.tr,
|
TranslationLoader.lanKeys!.lockNumber!.tr,
|
||||||
rightTitle: state.lockBasicInfo.value.lockAlias,
|
rightTitle: state.lockBasicInfo.value.lockName,
|
||||||
allHeight: 70.h,
|
allHeight: 70.h,
|
||||||
isHaveLine: true),
|
isHaveLine: true),
|
||||||
CommonItem(
|
CommonItem(
|
||||||
|
|||||||
@ -24,7 +24,6 @@ import 'configuringWifi_state.dart';
|
|||||||
|
|
||||||
class ConfiguringWifiLogic extends BaseGetXController{
|
class ConfiguringWifiLogic extends BaseGetXController{
|
||||||
final ConfiguringWifiState state = ConfiguringWifiState();
|
final ConfiguringWifiState state = ConfiguringWifiState();
|
||||||
final StarLockMineState getInfostate = StarLockMineState();
|
|
||||||
|
|
||||||
Future<void> getWifiLockServiceIpAndPort() async {
|
Future<void> getWifiLockServiceIpAndPort() async {
|
||||||
var entity = await ApiRepository.to.getWifiLockServiceIpAndPort();
|
var entity = await ApiRepository.to.getWifiLockServiceIpAndPort();
|
||||||
@ -104,7 +103,7 @@ class ConfiguringWifiLogic extends BaseGetXController{
|
|||||||
serversList.add(type2);
|
serversList.add(type2);
|
||||||
}
|
}
|
||||||
|
|
||||||
var phoneList = [getInfostate.mobile()];
|
var uidList = [Storage.getUid().toString()];
|
||||||
IoSenderManage.senderConfiguringWifiCommand(
|
IoSenderManage.senderConfiguringWifiCommand(
|
||||||
keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
||||||
userID: await Storage.getUid(),
|
userID: await Storage.getUid(),
|
||||||
@ -112,8 +111,8 @@ class ConfiguringWifiLogic extends BaseGetXController{
|
|||||||
password: state.wifiPWDController.text,
|
password: state.wifiPWDController.text,
|
||||||
numberOfServers: state.configuringWifiEntity.value.data!.serviceNum,
|
numberOfServers: state.configuringWifiEntity.value.data!.serviceNum,
|
||||||
listOfServers: serversList,
|
listOfServers: serversList,
|
||||||
numberOfPhone: phoneList.length,
|
numberOfPhone: uidList.length,
|
||||||
listOfPhone: phoneList,
|
listOfPhone: uidList,
|
||||||
token: tokenData,
|
token: tokenData,
|
||||||
needAuthor: 1,
|
needAuthor: 1,
|
||||||
publicKey: publicKeyDataList,
|
publicKey: publicKeyDataList,
|
||||||
@ -192,14 +191,7 @@ class ConfiguringWifiLogic extends BaseGetXController{
|
|||||||
serversList.add(type2);
|
serversList.add(type2);
|
||||||
}
|
}
|
||||||
|
|
||||||
String? phone = '';
|
var uidList = [Storage.getUid().toString()];
|
||||||
final data = await Storage.getString('userLoginData');
|
|
||||||
if (data != null && data.isNotEmpty) {
|
|
||||||
phone = LoginData.fromJson(jsonDecode(data)).mobile;
|
|
||||||
}
|
|
||||||
var phoneList = [phone!];
|
|
||||||
print("phoneList:$phoneList");
|
|
||||||
|
|
||||||
IoSenderManage.senderConfiguringWifiCommand(
|
IoSenderManage.senderConfiguringWifiCommand(
|
||||||
keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
||||||
userID: await Storage.getUid(),
|
userID: await Storage.getUid(),
|
||||||
@ -207,8 +199,8 @@ class ConfiguringWifiLogic extends BaseGetXController{
|
|||||||
password: state.wifiPWDController.text,
|
password: state.wifiPWDController.text,
|
||||||
numberOfServers: state.configuringWifiEntity.value.data!.serviceNum,
|
numberOfServers: state.configuringWifiEntity.value.data!.serviceNum,
|
||||||
listOfServers: serversList,
|
listOfServers: serversList,
|
||||||
numberOfPhone: phoneList.length,
|
numberOfPhone: uidList.length,
|
||||||
listOfPhone: phoneList,
|
listOfPhone: uidList,
|
||||||
token: getTokenList,
|
token: getTokenList,
|
||||||
needAuthor: 1,
|
needAuthor: 1,
|
||||||
publicKey: publicKeyDataList,
|
publicKey: publicKeyDataList,
|
||||||
@ -266,6 +258,7 @@ class ConfiguringWifiLogic extends BaseGetXController{
|
|||||||
void onInit() {
|
void onInit() {
|
||||||
// TODO: implement onInit
|
// TODO: implement onInit
|
||||||
super.onInit();
|
super.onInit();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@ -115,6 +115,7 @@ class _ConfiguringWifiPageState extends State<ConfiguringWifiPage> with RouteAwa
|
|||||||
super.didPush();
|
super.didPush();
|
||||||
print("lockSet===didPush");
|
print("lockSet===didPush");
|
||||||
state.ifCurrentScreen.value = true;
|
state.ifCurrentScreen.value = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 返回上一个界面 当前界面即将消失
|
/// 返回上一个界面 当前界面即将消失
|
||||||
|
|||||||
@ -307,6 +307,7 @@ class LockBasicInfo {
|
|||||||
int? indate;
|
int? indate;
|
||||||
int? isLockOwner;
|
int? isLockOwner;
|
||||||
String? lockAlias;
|
String? lockAlias;
|
||||||
|
String? lockName;
|
||||||
int? groupId;
|
int? groupId;
|
||||||
List<GroupData>? groupData;
|
List<GroupData>? groupData;
|
||||||
String? adminPwd;
|
String? adminPwd;
|
||||||
@ -325,6 +326,7 @@ class LockBasicInfo {
|
|||||||
this.indate,
|
this.indate,
|
||||||
this.isLockOwner,
|
this.isLockOwner,
|
||||||
this.lockAlias,
|
this.lockAlias,
|
||||||
|
this.lockName,
|
||||||
this.groupId,
|
this.groupId,
|
||||||
this.groupData,
|
this.groupData,
|
||||||
this.adminPwd,
|
this.adminPwd,
|
||||||
@ -343,6 +345,7 @@ class LockBasicInfo {
|
|||||||
indate = json['indate'];
|
indate = json['indate'];
|
||||||
isLockOwner = json['isLockOwner'];
|
isLockOwner = json['isLockOwner'];
|
||||||
lockAlias = json['lockAlias'];
|
lockAlias = json['lockAlias'];
|
||||||
|
lockName = json['lockName'];
|
||||||
groupId = json['groupId'];
|
groupId = json['groupId'];
|
||||||
if (json['groupData'] != null) {
|
if (json['groupData'] != null) {
|
||||||
groupData = <GroupData>[];
|
groupData = <GroupData>[];
|
||||||
@ -368,6 +371,7 @@ class LockBasicInfo {
|
|||||||
data['indate'] = indate;
|
data['indate'] = indate;
|
||||||
data['isLockOwner'] = isLockOwner;
|
data['isLockOwner'] = isLockOwner;
|
||||||
data['lockAlias'] = lockAlias;
|
data['lockAlias'] = lockAlias;
|
||||||
|
data['lockName'] = lockName;
|
||||||
data['groupId'] = groupId;
|
data['groupId'] = groupId;
|
||||||
if (groupData != null) {
|
if (groupData != null) {
|
||||||
data['groupData'] = groupData!.map((v) => v.toJson()).toList();
|
data['groupData'] = groupData!.map((v) => v.toJson()).toList();
|
||||||
|
|||||||
@ -61,7 +61,7 @@ class LockMonitoringLogic extends BaseGetXController {
|
|||||||
subCommand: 30,
|
subCommand: 30,
|
||||||
lockID: UDPManage().lockId,
|
lockID: UDPManage().lockId,
|
||||||
lockIP: UDPManage().host,
|
lockIP: UDPManage().host,
|
||||||
userMobile: await state.userMobile,
|
userMobile: await state.userUid,
|
||||||
userMobileIP: await state.userMobileIP,
|
userMobileIP: await state.userMobileIP,
|
||||||
endData: []);
|
endData: []);
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ class LockMonitoringLogic extends BaseGetXController {
|
|||||||
subCommand: 6,
|
subCommand: 6,
|
||||||
lockID: UDPManage().lockId,
|
lockID: UDPManage().lockId,
|
||||||
lockIP: UDPManage().host,
|
lockIP: UDPManage().host,
|
||||||
userMobile: await state.userMobile,
|
userMobile: await state.userUid,
|
||||||
userMobileIP: await state.userMobileIP,
|
userMobileIP: await state.userMobileIP,
|
||||||
endData: []);
|
endData: []);
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ class LockMonitoringLogic extends BaseGetXController {
|
|||||||
subCommand: 30,
|
subCommand: 30,
|
||||||
lockID: UDPManage().lockId,
|
lockID: UDPManage().lockId,
|
||||||
lockIP: UDPManage().host,
|
lockIP: UDPManage().host,
|
||||||
userMobile: await state.userMobile,
|
userMobile: await state.userUid,
|
||||||
userMobileIP: await state.userMobileIP,
|
userMobileIP: await state.userMobileIP,
|
||||||
endData: []);
|
endData: []);
|
||||||
}
|
}
|
||||||
@ -108,7 +108,7 @@ class LockMonitoringLogic extends BaseGetXController {
|
|||||||
subCommand: 10,
|
subCommand: 10,
|
||||||
lockID: UDPManage().lockId,
|
lockID: UDPManage().lockId,
|
||||||
lockIP: UDPManage().host,
|
lockIP: UDPManage().host,
|
||||||
userMobile: await state.userMobile,
|
userMobile: await state.userUid,
|
||||||
userMobileIP: await state.userMobileIP,
|
userMobileIP: await state.userMobileIP,
|
||||||
endData: list);
|
endData: list);
|
||||||
Get.back();
|
Get.back();
|
||||||
@ -139,7 +139,7 @@ class LockMonitoringLogic extends BaseGetXController {
|
|||||||
// "udpSendDataFrameNumber": 0,
|
// "udpSendDataFrameNumber": 0,
|
||||||
"lockID": UDPManage().lockId,
|
"lockID": UDPManage().lockId,
|
||||||
"lockIP": UDPManage().host,
|
"lockIP": UDPManage().host,
|
||||||
"userMobile": await state.userMobile,
|
"userMobile": await state.userUid,
|
||||||
"userMobileIP": await state.userMobileIP,
|
"userMobileIP": await state.userMobileIP,
|
||||||
});
|
});
|
||||||
print(sublist);
|
print(sublist);
|
||||||
@ -162,7 +162,7 @@ class LockMonitoringLogic extends BaseGetXController {
|
|||||||
// "udpSendDataFrameNumber": 0,
|
// "udpSendDataFrameNumber": 0,
|
||||||
"lockID": UDPManage().lockId,
|
"lockID": UDPManage().lockId,
|
||||||
"lockIP": UDPManage().host,
|
"lockIP": UDPManage().host,
|
||||||
"userMobile": await state.userMobile,
|
"userMobile": await state.userUid,
|
||||||
"userMobileIP": await state.userMobileIP,
|
"userMobileIP": await state.userMobileIP,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,7 +14,7 @@ class LockMonitoringState {
|
|||||||
// var isSenderAudioData = false.obs;// 是否要发送音频数据
|
// var isSenderAudioData = false.obs;// 是否要发送音频数据
|
||||||
|
|
||||||
var userMobileIP = NetworkInfo().getWifiIP();
|
var userMobileIP = NetworkInfo().getWifiIP();
|
||||||
var userMobile = Storage.getMobile();
|
var userUid = Storage.getUid();
|
||||||
|
|
||||||
var udpStatus = 0.obs; //0:初始状态 1:等待监视 2: 3:监视中 4:呼叫成功 5:主角通话中 6:被叫通话 8:被叫通话中 9:长按说话
|
var udpStatus = 0.obs; //0:初始状态 1:等待监视 2: 3:监视中 4:呼叫成功 5:主角通话中 6:被叫通话 8:被叫通话中 9:长按说话
|
||||||
var passwordTF = TextEditingController();
|
var passwordTF = TextEditingController();
|
||||||
|
|||||||
@ -54,7 +54,7 @@ class RealTimePictureLogic extends BaseGetXController {
|
|||||||
subCommand: 1,
|
subCommand: 1,
|
||||||
lockID: state.getLockName.value,
|
lockID: state.getLockName.value,
|
||||||
lockIP: UDPManage().host,
|
lockIP: UDPManage().host,
|
||||||
userMobile: await state.userMobile,
|
userMobile: await state.userUid,
|
||||||
userMobileIP: await state.userMobileIP,
|
userMobileIP: await state.userMobileIP,
|
||||||
endData: []);
|
endData: []);
|
||||||
// print('得到lockName------${state.getLockName.value}');
|
// print('得到lockName------${state.getLockName.value}');
|
||||||
@ -68,7 +68,7 @@ class RealTimePictureLogic extends BaseGetXController {
|
|||||||
subCommand: 30,
|
subCommand: 30,
|
||||||
lockID: UDPManage().lockId,
|
lockID: UDPManage().lockId,
|
||||||
lockIP: UDPManage().host,
|
lockIP: UDPManage().host,
|
||||||
userMobile: await state.userMobile,
|
userMobile: await state.userUid,
|
||||||
userMobileIP: await state.userMobileIP,
|
userMobileIP: await state.userMobileIP,
|
||||||
endData: []);
|
endData: []);
|
||||||
}
|
}
|
||||||
@ -81,7 +81,7 @@ class RealTimePictureLogic extends BaseGetXController {
|
|||||||
subCommand: 10,
|
subCommand: 10,
|
||||||
lockID: UDPManage().lockId,
|
lockID: UDPManage().lockId,
|
||||||
lockIP: UDPManage().host,
|
lockIP: UDPManage().host,
|
||||||
userMobile: await state.userMobile,
|
userMobile: await state.userUid,
|
||||||
userMobileIP: await state.userMobileIP,
|
userMobileIP: await state.userMobileIP,
|
||||||
endData: list);
|
endData: list);
|
||||||
Get.back();
|
Get.back();
|
||||||
@ -112,7 +112,7 @@ class RealTimePictureLogic extends BaseGetXController {
|
|||||||
// "udpSendDataFrameNumber": 0,
|
// "udpSendDataFrameNumber": 0,
|
||||||
"lockID": UDPManage().lockId,
|
"lockID": UDPManage().lockId,
|
||||||
"lockIP": UDPManage().host,
|
"lockIP": UDPManage().host,
|
||||||
"userMobile": await state.userMobile,
|
"userMobile": await state.userUid,
|
||||||
"userMobileIP": await state.userMobileIP,
|
"userMobileIP": await state.userMobileIP,
|
||||||
});
|
});
|
||||||
print(sublist);
|
print(sublist);
|
||||||
@ -137,7 +137,7 @@ class RealTimePictureLogic extends BaseGetXController {
|
|||||||
// "udpSendDataFrameNumber": 0,
|
// "udpSendDataFrameNumber": 0,
|
||||||
"lockID": UDPManage().lockId,
|
"lockID": UDPManage().lockId,
|
||||||
"lockIP": UDPManage().host,
|
"lockIP": UDPManage().host,
|
||||||
"userMobile": await state.userMobile,
|
"userMobile": await state.userUid,
|
||||||
"userMobileIP": await state.userMobileIP,
|
"userMobileIP": await state.userMobileIP,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,7 +14,7 @@ class RealTimePictureState {
|
|||||||
// var isSenderAudioData = false.obs;// 是否要发送音频数据
|
// var isSenderAudioData = false.obs;// 是否要发送音频数据
|
||||||
|
|
||||||
var userMobileIP = NetworkInfo().getWifiIP();
|
var userMobileIP = NetworkInfo().getWifiIP();
|
||||||
var userMobile = Storage.getMobile();
|
var userUid = Storage.getUid();
|
||||||
|
|
||||||
var udpStatus =
|
var udpStatus =
|
||||||
0.obs; //0:初始状态 1:等待监视 2: 3:监视中 4:呼叫成功 5:主角通话中 6:被叫通话 8:被叫通话中 9:长按说话
|
0.obs; //0:初始状态 1:等待监视 2: 3:监视中 4:呼叫成功 5:主角通话中 6:被叫通话 8:被叫通话中 9:长按说话
|
||||||
|
|||||||
@ -203,9 +203,6 @@ class SaveLockLogic extends BaseGetXController {
|
|||||||
BlueManage().disconnect(BlueManage().connectDeviceMacAddress);
|
BlueManage().disconnect(BlueManage().connectDeviceMacAddress);
|
||||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||||
Get.close(state.isFromMap == 1 ? 5 : 6);
|
Get.close(state.isFromMap == 1 ? 5 : 6);
|
||||||
// Future.delayed(const Duration(milliseconds: 200), () {
|
|
||||||
// Get.offAllNamed(Routers.starLockMain);
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -35,13 +35,13 @@ class SafeVerifyState {
|
|||||||
///本地存储 登录信息
|
///本地存储 登录信息
|
||||||
void saveLoginData(LoginData? data) async {
|
void saveLoginData(LoginData? data) async {
|
||||||
print("saveLoginData:${data!.mobile}");
|
print("saveLoginData:${data!.mobile}");
|
||||||
await Storage.setString('userLoginData', jsonEncode(data));
|
await Storage.setString(saveUserLoginData, jsonEncode(data));
|
||||||
loginData.value = data;
|
loginData.value = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
///初始化本地数据
|
///初始化本地数据
|
||||||
void initLoginData() async {
|
void initLoginData() async {
|
||||||
final data = await Storage.getString('userLoginData');
|
final data = await Storage.getString(saveUserLoginData);
|
||||||
// print("getLoginData:$data");
|
// print("getLoginData:$data");
|
||||||
if (data != null && data.isNotEmpty) {
|
if (data != null && data.isNotEmpty) {
|
||||||
loginData.value = LoginData.fromJson(jsonDecode(data));
|
loginData.value = LoginData.fromJson(jsonDecode(data));
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import 'package:star_lock/login/login/entity/LoginEntity.dart';
|
|||||||
import 'package:star_lock/network/api_repository.dart';
|
import 'package:star_lock/network/api_repository.dart';
|
||||||
|
|
||||||
import '../../tools/baseGetXController.dart';
|
import '../../tools/baseGetXController.dart';
|
||||||
|
import '../../tools/storage.dart';
|
||||||
import 'starLockMine_state.dart';
|
import 'starLockMine_state.dart';
|
||||||
|
|
||||||
class StarLockMineLogic extends BaseGetXController {
|
class StarLockMineLogic extends BaseGetXController {
|
||||||
@ -14,17 +15,19 @@ class StarLockMineLogic extends BaseGetXController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onReady() {
|
Future<void> onReady() async {
|
||||||
print("ready home");
|
print("ready home");
|
||||||
|
|
||||||
super.onReady();
|
super.onReady();
|
||||||
|
|
||||||
|
state.userNickName.value = (await Storage.getNickname())!;
|
||||||
|
state.userMobile.value = (await Storage.getMobile())!;
|
||||||
|
state.userEmail.value = (await Storage.getEmail())!;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
print("init home");
|
print("init home");
|
||||||
super.onInit();
|
super.onInit();
|
||||||
state.initLoginData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@ -84,7 +84,7 @@ class _StarLockMinePageState extends State<StarLockMinePage> with BaseWidget {
|
|||||||
SizedBox(
|
SizedBox(
|
||||||
height: 20.h,
|
height: 20.h,
|
||||||
),
|
),
|
||||||
Text(state.nickname(),
|
Text(state.userNickName.value ?? "-",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 22.sp,
|
fontSize: 22.sp,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
@ -92,7 +92,7 @@ class _StarLockMinePageState extends State<StarLockMinePage> with BaseWidget {
|
|||||||
SizedBox(
|
SizedBox(
|
||||||
height: 10.h,
|
height: 10.h,
|
||||||
),
|
),
|
||||||
Text("${TranslationLoader.lanKeys!.accountNumber!.tr}:${state.mobile().isNotEmpty ? state.mobile() : state.email()}",
|
Text("${TranslationLoader.lanKeys!.accountNumber!.tr}:${state.userMobile.value.isNotEmpty ? state.userMobile.value : state.userEmail.value}",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 18.sp,
|
fontSize: 18.sp,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
|
|||||||
@ -7,52 +7,11 @@ import '../../login/login/entity/LoginEntity.dart';
|
|||||||
import '../../tools/storage.dart';
|
import '../../tools/storage.dart';
|
||||||
|
|
||||||
class StarLockMineState {
|
class StarLockMineState {
|
||||||
final loginData = LoginData().obs;
|
// final loginData = LoginData().obs;
|
||||||
|
|
||||||
///本地存储 登录信息
|
var userNickName = "".obs;
|
||||||
void saveLoginData(LoginData? data) async {
|
var userMobile = "".obs;
|
||||||
print("saveLoginData:${data!.mobile}");
|
var userEmail = "".obs;
|
||||||
await Storage.setString('userLoginData', jsonEncode(data));
|
|
||||||
loginData.value = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
///初始化本地数据
|
|
||||||
void initLoginData() async {
|
|
||||||
final data = await Storage.getString('userLoginData');
|
|
||||||
// print("getLoginData:$data");
|
|
||||||
if (data != null && data.isNotEmpty) {
|
|
||||||
loginData.value = LoginData.fromJson(jsonDecode(data));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
///退出登录
|
|
||||||
void logOut() async {
|
|
||||||
await Storage.setString('userLoginData', '');
|
|
||||||
loginData.value = LoginData();
|
|
||||||
}
|
|
||||||
|
|
||||||
///用户登录token
|
|
||||||
String token() {
|
|
||||||
return loginData.value.accessToken ?? '';
|
|
||||||
}
|
|
||||||
|
|
||||||
String mobile() {
|
|
||||||
return loginData.value.mobile ?? '';
|
|
||||||
}
|
|
||||||
|
|
||||||
String email() {
|
|
||||||
return loginData.value.email ?? '-';
|
|
||||||
}
|
|
||||||
|
|
||||||
String nickname() {
|
|
||||||
return loginData.value.nickname ?? '-';
|
|
||||||
}
|
|
||||||
|
|
||||||
///用户头像
|
|
||||||
String headUrl() {
|
|
||||||
return loginData.value.headUrl ?? '';
|
|
||||||
// return "https://img2.woyaogexing.com/2022/04/14/156cdbabd5bc496abee2cd0fca527434!400x400.jpeg";
|
|
||||||
}
|
|
||||||
|
|
||||||
void onClose() {}
|
void onClose() {}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,13 +37,13 @@ class PersonInfoEditAccountState {
|
|||||||
///本地存储 登录信息
|
///本地存储 登录信息
|
||||||
void saveLoginData(LoginData? data) async {
|
void saveLoginData(LoginData? data) async {
|
||||||
print("saveLoginData:${data!.mobile}");
|
print("saveLoginData:${data!.mobile}");
|
||||||
await Storage.setString('userLoginData', jsonEncode(data));
|
await Storage.setString(saveUserLoginData, jsonEncode(data));
|
||||||
loginData.value = data;
|
loginData.value = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
///初始化本地数据
|
///初始化本地数据
|
||||||
void initLoginData() async {
|
void initLoginData() async {
|
||||||
final data = await Storage.getString('userLoginData');
|
final data = await Storage.getString(saveUserLoginData);
|
||||||
// print("getLoginData:$data");
|
// print("getLoginData:$data");
|
||||||
if (data != null && data.isNotEmpty) {
|
if (data != null && data.isNotEmpty) {
|
||||||
loginData.value = LoginData.fromJson(jsonDecode(data));
|
loginData.value = LoginData.fromJson(jsonDecode(data));
|
||||||
|
|||||||
@ -63,7 +63,6 @@ class MineSetLogic extends BaseGetXController {
|
|||||||
///退出登录
|
///退出登录
|
||||||
void logOut() async {
|
void logOut() async {
|
||||||
Storage.clearAll();
|
Storage.clearAll();
|
||||||
// await Storage.setString('userLoginData', '');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//更新触摸开锁
|
//更新触摸开锁
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
abstract class Api {
|
abstract class Api {
|
||||||
static String baseAddress = "https://pre.lock.star-lock.cn:8093"; //预发布环境
|
// static String baseAddress = "https://pre.lock.star-lock.cn:8093"; //预发布环境
|
||||||
// static String baseAddress = "http://192.168.56.101:8099"; //联调环境
|
static String baseAddress = "http://192.168.56.101:8099"; //联调环境
|
||||||
// static String baseAddress = "http://192.168.1.15:8022"; //谢总本地
|
// static String baseAddress = "http://192.168.1.15:8022"; //谢总本地
|
||||||
|
|
||||||
final String baseUrl = "$baseAddress/api";
|
final String baseUrl = "$baseAddress/api";
|
||||||
|
|||||||
@ -18,7 +18,7 @@ FutureOr<Request> requestInterceptor(Request request) async {
|
|||||||
// request.headers['token'] = StoreService.to.userToken!;
|
// request.headers['token'] = StoreService.to.userToken!;
|
||||||
// print("11111${StoreService.to.userToken}");
|
// print("11111${StoreService.to.userToken}");
|
||||||
String? xToken = '';
|
String? xToken = '';
|
||||||
final data = await Storage.getString('userLoginData');
|
final data = await Storage.getString(saveUserLoginData);
|
||||||
if (data != null && data.isNotEmpty) {
|
if (data != null && data.isNotEmpty) {
|
||||||
xToken = LoginData.fromJson(jsonDecode(data)).accessToken;
|
xToken = LoginData.fromJson(jsonDecode(data)).accessToken;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,10 +41,10 @@ class UdpHelp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var mobile = await Storage.getMobile();
|
var uid = await Storage.getUid();
|
||||||
udpHeartTimer = Timer.periodic(1.seconds, (timer) async {
|
udpHeartTimer = Timer.periodic(1.seconds, (timer) async {
|
||||||
UDPSenderManage.sendHeart(
|
UDPSenderManage.sendHeart(
|
||||||
userName: mobile,
|
userName: uid,
|
||||||
ipList: serversList,
|
ipList: serversList,
|
||||||
tokenStr: "b989fa15f75c2ac02718b7c9bb64f80e",
|
tokenStr: "b989fa15f75c2ac02718b7c9bb64f80e",
|
||||||
);
|
);
|
||||||
|
|||||||
@ -16,6 +16,8 @@ const currentConnectionLockId = "CurrentConnectionLockId";
|
|||||||
const currentConnectionMacAddress = "CurrentConnectionMacAddress";
|
const currentConnectionMacAddress = "CurrentConnectionMacAddress";
|
||||||
const ifIsDemoModeOrNot = "IfIsDemoModeOrNot";
|
const ifIsDemoModeOrNot = "IfIsDemoModeOrNot";
|
||||||
|
|
||||||
|
const saveUserLoginData = "userLoginData";
|
||||||
|
|
||||||
class Storage {
|
class Storage {
|
||||||
Storage._internal();
|
Storage._internal();
|
||||||
|
|
||||||
@ -136,28 +138,40 @@ class Storage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Future<String?> getUid() async {
|
static Future<String?> getUid() async {
|
||||||
String? uid = '';
|
LoginData? loginData = await getLoginData();
|
||||||
final data = await Storage.getString('userLoginData');
|
String? uid = loginData!.uid.toString();
|
||||||
if (data != null && data.isNotEmpty) {
|
|
||||||
uid = LoginData.fromJson(jsonDecode(data)).uid.toString();
|
|
||||||
}
|
|
||||||
// print("pubUid:$uid");
|
// print("pubUid:$uid");
|
||||||
return uid;
|
return uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Future<String?> getUserid() async {
|
||||||
|
LoginData? loginData = await getLoginData();
|
||||||
|
String? userid = loginData!.userid.toString();
|
||||||
|
// print("pubUid:$uid");
|
||||||
|
return userid;
|
||||||
|
}
|
||||||
|
|
||||||
static Future<String?> getMobile() async {
|
static Future<String?> getMobile() async {
|
||||||
String? mobile = '';
|
LoginData? loginData = await getLoginData();
|
||||||
final data = await Storage.getString('userLoginData');
|
String? mobile = loginData!.mobile;
|
||||||
if (data != null && data.isNotEmpty) {
|
|
||||||
mobile = LoginData.fromJson(jsonDecode(data)).mobile.toString();
|
|
||||||
}
|
|
||||||
// print("mobile:$mobile");
|
|
||||||
return mobile;
|
return mobile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Future<String?> getEmail() async {
|
||||||
|
LoginData? loginData = await getLoginData();
|
||||||
|
String? email = loginData!.email;
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<String?> getNickname() async {
|
||||||
|
LoginData? loginData = await getLoginData();
|
||||||
|
String? nickname = loginData!.nickname;
|
||||||
|
return nickname;
|
||||||
|
}
|
||||||
|
|
||||||
static Future<LoginData?> getLoginData() async {
|
static Future<LoginData?> getLoginData() async {
|
||||||
LoginData? loginData;
|
LoginData? loginData;
|
||||||
final data = await Storage.getString('userLoginData');
|
final data = await Storage.getString(saveUserLoginData);
|
||||||
if (data != null && data.isNotEmpty) {
|
if (data != null && data.isNotEmpty) {
|
||||||
loginData = LoginData.fromJson(jsonDecode(data));
|
loginData = LoginData.fromJson(jsonDecode(data));
|
||||||
}
|
}
|
||||||
@ -165,5 +179,8 @@ class Storage {
|
|||||||
return loginData;
|
return loginData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Future<void> saveLoginData(LoginData? data) async {
|
||||||
|
await Storage.setString(saveUserLoginData, jsonEncode(data));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user