统一修改发送验证码问题

This commit is contained in:
魏少阳 2024-04-03 16:50:42 +08:00
parent 0496bd9357
commit 84f7c6f1bb
25 changed files with 640 additions and 156 deletions

View File

@ -561,8 +561,10 @@ class BlueManage {
try {
// if(bluetoothConnectDevice != null && bluetoothConnectDevice!.connectionState == BluetoothConnectionState.connected){
connectDeviceMacAddress = "";
await bluetoothConnectDevice!.disconnect();
Get.log("断开连接成功");
if(bluetoothConnectionState == BluetoothConnectionState.connected){
await bluetoothConnectDevice!.disconnect();
Get.log("断开连接成功");
}
// }
} on Exception catch (e, _) {
Get.log("Error disconnecting from a device: $e");

View File

@ -45,7 +45,7 @@ class StarLockForgetPasswordLogic extends BaseGetXController {
}
void sendValidationCode() async {
var entity = await ApiRepository.to.sendValidationCode(
var entity = await ApiRepository.to.sendValidationCodeUnLogin(
// state.countryCode.value,
countryCode:state.countryCode.value,
account:state.phoneStr.value,

View File

@ -47,7 +47,7 @@ class StarLockRegisterLogic extends BaseGetXController {
}
void sendValidationCode() async {
var entity = await ApiRepository.to.sendValidationCode(
var entity = await ApiRepository.to.sendValidationCodeUnLogin(
// state.countryCode.value,
countryCode: state.countryCode.value.toString(),
account: state.phoneOrEmailStr.value,

View File

@ -158,7 +158,7 @@ class _StarLockRegisterPageState extends State<StarLockRegisterPage> {
children: [
SizedBox(width: 5.w),
Expanded(
child: Text(TranslationLoader.lanKeys!.countryAndRegion!.tr,
child: Text("你所在的${TranslationLoader.lanKeys!.countryAndRegion!.tr}",
style: TextStyle(
fontSize: 26.sp, color: AppColors.blackColor))),
SizedBox(width: 20.w),

View File

@ -110,14 +110,12 @@ class _LockDetailPageState extends State<LockDetailPage>
BlueManage().connectDeviceName =
state.keyInfos.value.bluetooth!.bluetoothDeviceName!;
List<int> publicKeyData =
state.keyInfos.value.bluetooth!.publicKey!.cast<int>();
List<int> publicKeyData = state.keyInfos.value.bluetooth!.publicKey!.cast<int>();
var saveStrList = changeIntListToStringList(publicKeyData);
Storage.setStringList(saveBluePublicKey, saveStrList);
//
List<int> privateKeyData =
state.keyInfos.value.bluetooth!.privateKey!.cast<int>();
List<int> privateKeyData = state.keyInfos.value.bluetooth!.privateKey!.cast<int>();
var savePrivateKeyList = changeIntListToStringList(privateKeyData);
Storage.setStringList(saveBluePrivateKey, savePrivateKeyList);

View File

@ -770,13 +770,13 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
print("lockSet===didPop");
logic.cancelBlueConnetctToastTimer();
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
if (state.deletWaitScanTimer != null) {
state.deletWaitScanTimer!.cancel();
}
if (state.deletWaitScanCompleter != null &&
!state.deletWaitScanCompleter!.isCompleted) {
state.deletWaitScanCompleter!.complete();
}
// if (state.deletWaitScanTimer != null) {
// state.deletWaitScanTimer!.cancel();
// }
// if (state.deletWaitScanCompleter != null &&
// !state.deletWaitScanCompleter!.isCompleted) {
// state.deletWaitScanCompleter!.complete();
// }
// BlueManage().stopScan();
state.ifCurrentScreen.value = false;
}
@ -797,13 +797,13 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
logic.cancelBlueConnetctToastTimer();
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
if (state.deletWaitScanTimer != null) {
state.deletWaitScanTimer!.cancel();
}
if (state.deletWaitScanCompleter != null &&
!state.deletWaitScanCompleter!.isCompleted) {
state.deletWaitScanCompleter!.complete();
}
// if (state.deletWaitScanTimer != null) {
// state.deletWaitScanTimer!.cancel();
// }
// if (state.deletWaitScanCompleter != null &&
// !state.deletWaitScanCompleter!.isCompleted) {
// state.deletWaitScanCompleter!.complete();
// }
// BlueManage().stopScan();
state.ifCurrentScreen.value = false;
}

View File

@ -31,8 +31,8 @@ class LockSetState {
var ifCurrentScreen = true.obs; // ,
var deleteAdministratorIsHaveAllData = false.obs; //
Completer? deletWaitScanCompleter;
Timer? deletWaitScanTimer;
// Completer? deletWaitScanCompleter;
// Timer? deletWaitScanTimer;
LockSetState() {
Map map = Get.arguments;

View File

@ -1,13 +1,105 @@
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/blue/io_type.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import '../../../blue/blue_manage.dart';
import '../../../blue/io_protocol/io_factoryDataReset.dart';
import '../../../blue/io_reply.dart';
import '../../../blue/io_tool/io_tool.dart';
import '../../../blue/io_tool/manager_event_bus.dart';
import '../../../blue/sender_manage.dart';
import '../../../common/XSConstantMacro/XSConstantMacro.dart';
import '../../../network/api_repository.dart';
import '../../../tools/dateTool.dart';
import '../../../tools/eventBusEventManage.dart';
import '../../../tools/showTFView.dart';
import '../../../tools/storage.dart';
import '../../../translations/trans_lib.dart';
import '../entity/lockListInfo_entity.dart';
import 'lockList_state.dart';
class LockListLogic extends BaseGetXController{
LockListState state = LockListState();
//
late StreamSubscription<Reply> _replySubscription;
void _initReplySubscription() {
_replySubscription =
EventBusManager().eventBus!.on<Reply>().listen((reply) async {
//
if (reply is FactoryDataResetReply) {
_replyFactoryDataResetKey(reply);
}
});
}
Future<void> _replyFactoryDataResetKey(Reply reply) async {
var token = reply.data.sublist(2, 6);
var saveStrList = changeIntListToStringList(token);
print("_replyFactoryDataResetKeyToken:$token");
Storage.setStringList(saveBlueToken, saveStrList);
int status = reply.data[6];
print("status:$status");
switch (status) {
case 0x00:
//
print("${reply.commandType!.typeValue} 数据解析成功");
dismissEasyLoading();
cancelBlueConnetctToastTimer();
deletLockInfoData();
break;
case 0x06:
//
print("${reply.commandType!.typeValue} 需要鉴权");
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
//
// var publicKey = await Storage.getStringList(saveBluePublicKey);
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
var token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = changeStringListToIntList(token!);
IoSenderManage.senderFactoryDataReset(
lockID: BlueManage().connectDeviceName,
userID: await Storage.getUid(),
keyID: "1",
needAuthor: 1,
publicKey: state.lockListInfoItemEntity.bluetooth!.publicKey!.cast<int>(),
privateKey: state.lockListInfoItemEntity.bluetooth!.privateKey!.cast<int>(),
token: getTokenList);
break;
case 0x07:
//
print("${reply.commandType!.typeValue} 用户无权限");
dismissEasyLoading();
showToast("用户无权限");
break;
case 0x09:
//
print("${reply.commandType!.typeValue} ");
dismissEasyLoading();
showToast("权限校验错误");
break;
default:
//
print("${reply.commandType!.typeValue} 失败");
dismissEasyLoading();
showToast("权限校验错误");
break;
}
}
String showElectricIcon (int electricnumber){
if(electricnumber >= 100){
return 'images/main/icon_lockElectricLevel_5.png';
@ -35,4 +127,270 @@ class LockListLogic extends BaseGetXController{
}
return "";
}
///
deleyLockLogicOfRoles(){
if (state.lockListInfoItemEntity.isLockOwner == 1) {
//
showDeletAlertDialog();
} else if (state.lockListInfoItemEntity.keyRight == 1){
//
showDeleteAdministratorIsHaveAllDataDialog();
} else{
//
deletKeyData();
}
}
//
void showDeletAlertDialog() {
showCupertinoDialog(
context: Get.context!,
builder: (context) {
return CupertinoAlertDialog(
title: const Text("提示"),
content: const Text('删除锁后,所有信息都会一起删除,确定删除锁吗?'),
actions: [
CupertinoDialogAction(
child: Text(TranslationLoader.lanKeys!.cancel!.tr),
onPressed: () {
Get.back();
},
),
CupertinoDialogAction(
child: Text(TranslationLoader.lanKeys!.sure!.tr),
onPressed: () {
Get.back();
showDeletPasswordAlertDialog(context);
},
),
],
);
},
);
}
void showDeletPasswordAlertDialog(BuildContext context) {
//
showDialog(
context: context,
builder: (BuildContext context) {
return ShowTFView(
title: "请输入登录密码",
tipTitle: "",
controller: state.passwordTF,
sureClick: () {
//
if (state.passwordTF.text.isEmpty) {
showToast("请输入登录密码");
return;
}
checkLoginPassword();
},
cancelClick: () {
//
// BlueManage().stopScan();
Get.back();
},
);
},
);
}
//
void showDeleteAdministratorIsHaveAllDataDialog() {
showDialog(
context: Get.context!,
builder: (BuildContext context) {
return CupertinoAlertDialog(
title: const Text("提示"),
content: Container(
height: 100.h,
child: Row(
children: [
GestureDetector(
onTap: () {
state.deleteAdministratorIsHaveAllData.value = !state.deleteAdministratorIsHaveAllData.value;
},
child: Obx(() => Image.asset(
state.deleteAdministratorIsHaveAllData.value
? 'images/icon_round_select.png'
: 'images/icon_round_unSelect.png',
width: 30.w,
height: 30.w,
))),
SizedBox(width: 15.w,),
Expanded(child: Text('同时删除其发送的所有钥匙,钥匙删除后不能恢复', maxLines: 2, textAlign: TextAlign.start, style: TextStyle(fontSize: 24.sp))),
],
),
),
actions: [
CupertinoDialogAction(
child: Text(TranslationLoader.lanKeys!.cancel!.tr),
onPressed: () {
Get.back();
},
),
CupertinoDialogAction(
child: Text(TranslationLoader.lanKeys!.delete!.tr),
onPressed: () {
Get.back();
deletKeyData();
},
),
],
);
},
);
}
//
void checkLoginPassword() async {
var entity = await ApiRepository.to.checkLoginPassword(
password: state.passwordTF.text,
);
if (entity.errorCode!.codeIsSuccessful) {
Get.back();
factoryDataResetAction();
}
}
//
void deletLockInfoData() async {
var entity = await ApiRepository.to.deletOwnerLockData(
lockId: state.lockListInfoItemEntity.lockId.toString(),
);
if (entity.errorCode!.codeIsSuccessful) {
BlueManage().connectDeviceMacAddress = "";
SchedulerBinding.instance.addPostFrameCallback((_) {
eventBus.fire(RefreshLockListInfoDataEvent());
});
}
}
//
void deletKeyData() async {
var entity = await ApiRepository.to.deletOwnerKeyData(
lockId: state.lockListInfoItemEntity.lockId.toString(),
keyId: state.lockListInfoItemEntity.keyId.toString(),
includeUnderlings: state.deleteAdministratorIsHaveAllData.value == true ? 1 : 0
);
if (entity.errorCode!.codeIsSuccessful) {
BlueManage().connectDeviceMacAddress = "";
SchedulerBinding.instance.addPostFrameCallback((_) {
eventBus.fire(RefreshLockListInfoDataEvent());
});
}
}
//
Future<void> factoryDataResetAction() async {
showEasyLoading();
showBlueConnetctToastTimer(isShowBlueConnetctToast: false, action: (){
dismissEasyLoading();
showDeletAlertTipDialog();
});
BlueManage().bludSendData(state.lockListInfoItemEntity.lockName!, (BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected) {
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
//
// var publicKey = await Storage.getStringList(saveBluePublicKey);
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
//
// var token = await Storage.getStringList(saveBlueToken);
// List<int> getTokenList = changeStringListToIntList(token!);
List<int> publicKeyData = state.lockListInfoItemEntity.bluetooth!.publicKey!.cast<int>();
var saveStrList = changeIntListToStringList(publicKeyData);
Storage.setStringList(saveBluePublicKey, saveStrList);
//
List<int> privateKeyData = state.lockListInfoItemEntity.bluetooth!.privateKey!.cast<int>();
var savePrivateKeyList = changeIntListToStringList(privateKeyData);
Storage.setStringList(saveBluePrivateKey, savePrivateKeyList);
// signKey
List<int> signKeyData = state.lockListInfoItemEntity.bluetooth!.signKey!.cast<int>();
var saveSignKeyList = changeIntListToStringList(signKeyData);
Storage.setStringList(saveBlueSignKey, saveSignKeyList);
var saveTokenList = changeIntListToStringList([0, 0, 0, 0]);
Storage.setStringList(saveBlueToken, saveTokenList);
IoSenderManage.senderFactoryDataReset(
lockID: BlueManage().connectDeviceName,
userID: await Storage.getUid(),
keyID: "1",
needAuthor: 1,
publicKey: state.lockListInfoItemEntity.bluetooth!.publicKey!.cast<int>(),
privateKey: state.lockListInfoItemEntity.bluetooth!.privateKey!.cast<int>(),
token: [0,0,0,0]);
} else if (connectionState == BluetoothConnectionState.disconnected) {
dismissEasyLoading();
cancelBlueConnetctToastTimer();
if(state.ifCurrentScreen.value == true){
showDeletAlertTipDialog();
}
}
});
}
void showDeletAlertTipDialog({String? showContent = ""}) {
// bool isContains = BlueManage().connectDeviceName!.contains("T9A");
var content = showContent!.isEmpty ? "删除设备失败,请确保在设备附近,设备未被连接,设备已打开${BlueManage().connectDeviceName!.contains("T9A") == true ? "。如果是全自动锁,请使屏幕变亮" : ""}" : showContent;
showCupertinoDialog(
context: Get.context!,
builder: (context) {
return CupertinoAlertDialog(
title: const Text("提示"),
content: Text(content),
// content: const Text('删除门锁后如需重新添加需要在门锁设置的"蓝牙功能"选项下先"清除配对",确定吗?'),
actions: [
// CupertinoDialogAction(
// child: Text(TranslationLoader.lanKeys!.cancel!.tr),
// onPressed: () {
// Navigator.pop(context);
// },
// ),
CupertinoDialogAction(
child: Text(TranslationLoader.lanKeys!.sure!.tr),
onPressed: () {
Navigator.pop(context);
// if (state.lockSetInfoData.value.lockBasicInfo!.isLockOwner == 1) {
// //
// deletLockInfoData();
// } else {
// //
// deletKeyData();
// }
},
),
],
);
},
);
}
@override
void onReady() {
// TODO: implement onReady
super.onReady();
_initReplySubscription();
}
@override
void onInit() {
// TODO: implement onInit
super.onInit();
}
@override
void onClose() {
// TODO: implement onClose
_replySubscription.cancel();
}
}

View File

@ -1,11 +1,13 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:get/get.dart';
import '../../../appRouters.dart';
import '../../../app_settings/app_colors.dart';
import '../../../common/XSConstantMacro/XSConstantMacro.dart';
import '../../../tools/appRouteObserver.dart';
import '../../../tools/dateTool.dart';
import '../entity/lockListInfo_entity.dart';
import 'lockListGroup_page.dart';
@ -20,7 +22,7 @@ class LockListPage extends StatefulWidget {
State<LockListPage> createState() => _LockListPageState();
}
class _LockListPageState extends State<LockListPage> {
class _LockListPageState extends State<LockListPage> with RouteAware {
final logic = Get.put(LockListLogic());
final state = Get.find<LockListLogic>().state;
@ -97,37 +99,65 @@ class _LockListPageState extends State<LockListPage> {
if (lockItemList.length == index+1){
isLast = true;
}
// print("lockItemList.length:${lockItemList.length} == ${index+1} $isLast");
return lockInfoListItem(keyInfo, isLast, () {
// if(DateTool().compareTimeIsOvertime(keyInfo.endDate!) && keyInfo.keyType == XSConstantMacro.keyTypeTime){
// logic.showToast("钥匙已过期");
// return;
// }
// var lockCount = 0;
// for(GroupList itemData in groupDataList){
// lockCount+=itemData.lockList!.length;
// }
return Slidable(
key:ValueKey(keyInfo.keyId),
endActionPane: ActionPane(
extentRatio: 0.2,
motion: const ScrollMotion(),
children: [
SlidableAction(
onPressed: (BuildContext context){
state.lockListInfoItemEntity = keyInfo;
logic.deleyLockLogicOfRoles();
},
backgroundColor: Colors.red,
foregroundColor: Colors.white,
label: '删除',
padding: EdgeInsets.only(left: 5.w, right: 5.w),
),
],
),
child: lockInfoListItem(keyInfo, isLast, () {
if((keyInfo.keyType == XSConstantMacro.keyTypeTime || keyInfo.keyType == XSConstantMacro.keyTypeLoop) && (keyInfo.keyStatus == XSConstantMacro.keyStatusWaitIneffective)){
logic.showToast("您的钥匙未生效");
return;
}
if((keyInfo.keyType == XSConstantMacro.keyTypeTime || keyInfo.keyType == XSConstantMacro.keyTypeLoop) && (keyInfo.keyStatus == XSConstantMacro.keyStatusFrozen)){
logic.showToast("您的钥匙已冻结");
return;
}
if((keyInfo.keyType == XSConstantMacro.keyTypeTime || keyInfo.keyType == XSConstantMacro.keyTypeLoop) && (keyInfo.keyStatus == XSConstantMacro.keyStatusExpired)){
logic.showToast("您的钥匙已过期");
return;
}
Get.toNamed(Routers.lockDetailMainPage, arguments: {
// "lockMainEntity": widget.lockMainEntity,
"keyInfo": keyInfo,
"isOnlyOneData": false,
});
}),
);
// || keyInfo.keyStatus == XSConstantMacro.keyStatusFrozen || keyInfo.keyStatus == XSConstantMacro.keyStatusExpired
if((keyInfo.keyType == XSConstantMacro.keyTypeTime || keyInfo.keyType == XSConstantMacro.keyTypeLoop) && (keyInfo.keyStatus == XSConstantMacro.keyStatusWaitIneffective)){
logic.showToast("您的钥匙未生效");
// return;
}
if((keyInfo.keyType == XSConstantMacro.keyTypeTime || keyInfo.keyType == XSConstantMacro.keyTypeLoop) && (keyInfo.keyStatus == XSConstantMacro.keyStatusFrozen)){
logic.showToast("您的钥匙已冻结");
// return;
}
if((keyInfo.keyType == XSConstantMacro.keyTypeTime || keyInfo.keyType == XSConstantMacro.keyTypeLoop) && (keyInfo.keyStatus == XSConstantMacro.keyStatusExpired)){
logic.showToast("您的钥匙已过期");
// return;
}
Get.toNamed(Routers.lockDetailMainPage, arguments: {
// "lockMainEntity": widget.lockMainEntity,
"keyInfo": keyInfo,
"isOnlyOneData": false,
});
});
// return lockInfoListItem(keyInfo, isLast, () {
// if((keyInfo.keyType == XSConstantMacro.keyTypeTime || keyInfo.keyType == XSConstantMacro.keyTypeLoop) && (keyInfo.keyStatus == XSConstantMacro.keyStatusWaitIneffective)){
// logic.showToast("您的钥匙未生效");
// // return;
// }
// if((keyInfo.keyType == XSConstantMacro.keyTypeTime || keyInfo.keyType == XSConstantMacro.keyTypeLoop) && (keyInfo.keyStatus == XSConstantMacro.keyStatusFrozen)){
// logic.showToast("您的钥匙已冻结");
// // return;
// }
// if((keyInfo.keyType == XSConstantMacro.keyTypeTime || keyInfo.keyType == XSConstantMacro.keyTypeLoop) && (keyInfo.keyStatus == XSConstantMacro.keyStatusExpired)){
// logic.showToast("您的钥匙已过期");
// // return;
// }
// Get.toNamed(Routers.lockDetailMainPage, arguments: {
// // "lockMainEntity": widget.lockMainEntity,
// "keyInfo": keyInfo,
// "isOnlyOneData": false,
// });
// });
}),
);
}
@ -250,4 +280,59 @@ class _LockListPageState extends State<LockListPage> {
);
}
@override
void didChangeDependencies() {
// TODO: implement didChangeDependencies
super.didChangeDependencies();
///
AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!);
}
@override
void dispose() {
// TODO: implement dispose
///
AppRouteObserver().routeObserver.unsubscribe(this);
super.dispose();
}
///
@override
void didPush() {
super.didPush();
print("lockSet===didPush");
state.ifCurrentScreen.value = true;
}
///
@override
void didPop() {
super.didPop();
print("lockSet===didPop");
logic.cancelBlueConnetctToastTimer();
// BlueManage().stopScan();
state.ifCurrentScreen.value = false;
}
///
@override
void didPopNext() {
super.didPopNext();
print("lockSet===didPopNext");
state.ifCurrentScreen.value = true;
}
///
@override
void didPushNext() {
super.didPushNext();
print("lockSet===didPushNext");
logic.cancelBlueConnetctToastTimer();
// BlueManage().stopScan();
state.ifCurrentScreen.value = false;
}
}

View File

@ -1,8 +1,15 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../entity/lockListInfo_entity.dart';
class LockListState{
var itemStatusIsEable = false.obs; // item是否能点击
LockListInfoItemEntity lockListInfoItemEntity = LockListInfoItemEntity(); // item
var passwordTF = TextEditingController();
var deleteAdministratorIsHaveAllData = false.obs; //
var ifCurrentScreen = true.obs; // ,
}

View File

@ -45,15 +45,16 @@ class LockMainLogic extends BaseGetXController {
if (connectResult == ConnectivityResult.mobile) {
// _netType = "4G";
state.networkConnectionStatus.value = 1;
// print("4G 4G 4G 4G 4G");
print("4G 4G 4G 4G 4G");
} else if (connectResult == ConnectivityResult.wifi) {
// _netType = "wifi";
state.networkConnectionStatus.value = 1;
// print("wifi wifi wifi wifi wifi");
print("wifi wifi wifi wifi wifi");
} else {
// _netType = "未连接";
state.networkConnectionStatus.value = 0;
// print("未连接 未连接 未连接 未连接 未连接");
print("未连接 未连接 未连接 未连接 未连接");
showToast("网络访问失败,请检查网络是否正常");
}
}

View File

@ -10,6 +10,10 @@ import 'package:star_lock/mine/mine/safeVerify/safeVerify_state.dart';
import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import '../../../login/login/entity/LoginData.dart';
import 'package:star_lock/login/selectCountryRegion/common/index.dart';
import 'package:star_lock/tools/storage.dart';
class SafeVerifyLogic extends BaseGetXController {
final SafeVerifyState state = SafeVerifyState();
@ -32,13 +36,12 @@ class SafeVerifyLogic extends BaseGetXController {
//
void sendValidationCode() async {
var entity = await ApiRepository.to.getValidationCodeAuth(
"",
'',
'1',
state.codeType.value,
"B748F838-94EE-4BDB-A0E6-7B2D16849792",
state.xWidth.value.toString());
var entity = await ApiRepository.to.sendValidationCodeAuth(
countryCode: "",
account: "",
channel: state.channel.value,
codeType: state.codeType.value,
xWidth: state.xWidth.value.toString());
if (entity.errorCode!.codeIsSuccessful) {
_startTimer();
} else {}
@ -70,6 +73,43 @@ class SafeVerifyLogic extends BaseGetXController {
state.canSub.value = state.codeIsOK;
}
///
void saveLoginData(LoginData? data) async {
print("saveLoginData:${data!.mobile}");
await Storage.setString(saveUserLoginData, jsonEncode(data));
state.loginData.value = data;
}
///
void initLoginData() async {
final data = await Storage.getString(saveUserLoginData);
// print("getLoginData:$data");
if (data != null && data.isNotEmpty) {
state.loginData.value = LoginData.fromJson(jsonDecode(data));
bool mobileIsNotEmpty = state.loginData.value.mobile != null && state.loginData.value.mobile!.isNotEmpty;
bool emailIsNotEmpty = state.loginData.value.email != null && state.loginData.value.email!.isNotEmpty;
//
if (mobileIsNotEmpty == true && emailIsNotEmpty == false) {
state.accountStr.value = state.loginData.value.mobile!;
state.channel.value = '1';
state.isToggle.value = false;
Get.log("1111111 mobileIsNotEmpty:$mobileIsNotEmpty emailIsNotEmpty:$emailIsNotEmpty");
} else if (mobileIsNotEmpty == true && emailIsNotEmpty == true) {
//
state.accountStr.value = state.loginData.value.mobile!;
state.channel.value = '1';
state.isToggle.value = true;
Get.log("22222222 mobileIsNotEmpty:$mobileIsNotEmpty emailIsNotEmpty:$emailIsNotEmpty");
} else if (mobileIsNotEmpty == false && emailIsNotEmpty == true) {
//
state.accountStr.value = state.loginData.value.email!;
state.channel.value = '2';
state.isToggle.value = false;
Get.log("33333333 mobileIsNotEmpty:$mobileIsNotEmpty emailIsNotEmpty:$emailIsNotEmpty");
}
}
}
@override
void onReady() {
super.onReady();
@ -78,7 +118,8 @@ class SafeVerifyLogic extends BaseGetXController {
@override
void onInit() {
super.onInit();
state.initLoginData();
initLoginData();
}
@override

View File

@ -57,7 +57,7 @@ class _SafeVerifyPageState extends State<SafeVerifyPage> {
decoration: InputDecoration(
contentPadding:
const EdgeInsets.only(left: 5, top: -8, bottom: 6),
hintText: TranslationLoader.lanKeys!.pleaseEnter!.tr,
hintText: '${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.verificationCode!.tr}',
hintStyle: TextStyle(fontSize: 22.sp, height: 1.0),
//线
border: const OutlineInputBorder(),

View File

@ -1,8 +1,6 @@
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';
import 'package:star_lock/translations/trans_lib.dart';
class SafeVerifyState {
@ -14,7 +12,7 @@ class SafeVerifyState {
var countryCode = '+86'.obs;
var countryId = '9'.obs;
var codeType = '5'.obs; //5
var codeType = '5'.obs; // //123456 7
var verificationCode = ''.obs;
var xWidth = ''.obs; //
var canSub = false.obs;
@ -22,6 +20,7 @@ class SafeVerifyState {
var accountStr = ''.obs;
var toggleStr = ''.obs; //
var isToggle = false.obs; //
var channel = '1'.obs; // 1 2
bool get codeIsOK => verificationCode.value.isNotEmpty;
@ -32,39 +31,6 @@ class SafeVerifyState {
final loginData = LoginData().obs;
///
void saveLoginData(LoginData? data) async {
print("saveLoginData:${data!.mobile}");
await Storage.setString(saveUserLoginData, jsonEncode(data));
loginData.value = data;
}
///
void initLoginData() async {
final data = await Storage.getString(saveUserLoginData);
// print("getLoginData:$data");
if (data != null && data.isNotEmpty) {
loginData.value = LoginData.fromJson(jsonDecode(data));
//
if (loginData.value.mobile!.isNotEmpty &&
loginData.value.email!.isEmpty) {
accountStr.value = loginData.value.mobile!;
isToggle.value = false;
} else if (loginData.value.mobile!.isNotEmpty &&
loginData.value.email!.isNotEmpty) {
//
accountStr.value = loginData.value.mobile!;
isToggle.value = true;
} else if (loginData.value.mobile!.isNotEmpty &&
loginData.value.email!.isNotEmpty) {
//
accountStr.value = loginData.value.email!;
isToggle.value = false;
}
}
}
SafeVerifyState() {
resetResend();
}

View File

@ -1,7 +1,10 @@
import 'dart:async';
import 'package:star_lock/login/login/entity/LoginEntity.dart';
import 'package:star_lock/network/api_repository.dart';
import '../../tools/baseGetXController.dart';
import '../../tools/eventBusEventManage.dart';
import '../../tools/storage.dart';
import 'starLockMine_state.dart';
@ -14,18 +17,16 @@ class StarLockMineLogic extends BaseGetXController {
if (entity.errorCode!.codeIsSuccessful) {}
}
@override
void onReady() {
print("ready home");
super.onReady();
///
StreamSubscription? _mineInfoChangeRefreshUIEvent;
void _mineInfoChangeRefreshUIAction() {
// eventBus
_mineInfoChangeRefreshUIEvent = eventBus.on<MineInfoChangeRefreshUI>().listen((event) {
getMineInfoData();
});
}
@override
Future<void> onInit() async {
print("init home");
super.onInit();
getMineInfoData() async {
final data = await Storage.getString(saveUserLoginData);
if (data != null && data.isNotEmpty) {
state.userNickName.value = (await Storage.getNickname())!;
@ -34,9 +35,26 @@ class StarLockMineLogic extends BaseGetXController {
}
}
@override
void onReady() {
print("ready home");
super.onReady();
_mineInfoChangeRefreshUIAction();
}
@override
Future<void> onInit() async {
print("init home");
super.onInit();
getMineInfoData();
}
@override
void onClose() {
print("close home");
super.onClose();
_mineInfoChangeRefreshUIEvent?.cancel();
}
}

View File

@ -55,7 +55,7 @@ class StarLockMinePageState extends State<StarLockMinePage> with BaseWidget {
height: 380.h,
fit: BoxFit.fill,
),
Obx(() => Center(
Center(
child: Column(
// crossAxisAlignment: CrossAxisAlignment.center,
children: [
@ -86,23 +86,23 @@ class StarLockMinePageState extends State<StarLockMinePage> with BaseWidget {
SizedBox(
height: 20.h,
),
Text(state.userNickName.value.isNotEmpty ? state.userNickName.value : (state.userMobile.value.isNotEmpty ? state.userMobile.value : state.userEmail.value),
Obx(() => Text(state.userNickName.value.isNotEmpty ? state.userNickName.value : (state.userMobile.value.isNotEmpty ? state.userMobile.value : state.userEmail.value),
style: TextStyle(
fontSize: 22.sp,
color: Colors.white,
)),
))),
SizedBox(
height: 10.h,
),
Text(
Obx(() => Text(
"${TranslationLoader.lanKeys!.accountNumber!.tr}:${state.userMobile.value.isNotEmpty ? state.userMobile.value : state.userEmail.value}",
style: TextStyle(
fontSize: 18.sp,
color: Colors.white,
fontWeight: FontWeight.w500)),
fontWeight: FontWeight.w500))),
],
),
)),
),
],
),
);

View File

@ -31,13 +31,12 @@ class MineUnbindPhoneOrEmailLogic extends BaseGetXController {
//
void sendValidationCode() async {
var entity = await ApiRepository.to.getValidationCodeAuth(
'',
'',
state.channel.value,
state.codeType.value,
state.uniqueid.value,
state.xWidth.value.toString());
var entity = await ApiRepository.to.sendValidationCodeAuth(
countryCode: '',
account: '',
channel:state.channel.value,
codeType: state.codeType.value,
xWidth: state.xWidth.value.toString());
if (entity.errorCode!.codeIsSuccessful) {
_startTimer();
} else {}

View File

@ -2,8 +2,10 @@ import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:star_lock/mine/minePersonInfo/minePersonInfoEditName/minePersonInfoEditName_state.dart';
import 'package:star_lock/tools/eventBusEventManage.dart';
import '../../../../network/api_repository.dart';
import '../../../../tools/baseGetXController.dart';
import '../../../tools/storage.dart';
class MinePersonInfoEditNameLogic extends BaseGetXController {
final MinePersonInfoEditNamePageState state =
@ -14,6 +16,10 @@ class MinePersonInfoEditNameLogic extends BaseGetXController {
await ApiRepository.to.updateUserInfo(state.inputNickName.value);
if (entity.errorCode!.codeIsSuccessful) {
showToast("操作成功");
final loginData = await Storage.getLoginData();
loginData!.nickname = state.inputNickName.value;
Storage.saveLoginData(loginData);
eventBus.fire(MineInfoChangeRefreshUI());
Get.back();
}
}

View File

@ -30,13 +30,12 @@ class MineBindPhoneOrEmailLogic extends BaseGetXController {
//
void sendValidationCode() async {
var entity = await ApiRepository.to.getValidationCodeAuth(
state.channel.value == '1' ? state.countryCode.value : '',
state.inputAccount.value,
state.channel.value,
state.codeType.value,
state.uniqueid.value,
state.xWidth.value.toString());
var entity = await ApiRepository.to.sendValidationCodeAuth(
countryCode: state.channel.value == '1' ? state.countryCode.value : '',
account: state.inputAccount.value,
channel: state.channel.value,
codeType: state.codeType.value,
xWidth: state.xWidth.value.toString());
if (entity.errorCode!.codeIsSuccessful) {
_startTimer();
}

View File

@ -122,9 +122,7 @@ class _MinePersonInfoPageState extends State<MinePersonInfoPage>
action: () {
// isFrom1 2
if (state.mineInfoData.value.mobile!.isNotEmpty) {
Navigator.pushNamed(
context, Routers.mineUnbindPhoneOrEmailPage,
arguments: {
Navigator.pushNamed(context, Routers.mineUnbindPhoneOrEmailPage, arguments: {
'mobile': state.mineInfoData.value.mobile!,
'isFrom': '1'
}).then((value) => logic.getUserInfoRequest());

View File

@ -1,6 +1,6 @@
abstract class Api {
//
final String getVerificationCodeUrl = '/user/sendValidationCode';
final String sendValidationCodeUrl = '/user/sendValidationCode';
final String registerUrl = '/user/register';
final String getSliderVerifyImgUrl = '/user/getSliderVerifyImg';
final String checkImgUrl = '/user/isSliderValid';
@ -161,7 +161,7 @@ abstract class Api {
final String userLogoutURL = '/user/logout'; //退
final String deleteAccountURL = '/user/delete'; //
final String getUserInfoURL = '/user/getUserInfo'; //
final String getValidationCodeAuthURL =
final String sendValidationCodeAuthURL =
'/user/sendValidationCodeAuth'; //使
final String updateUserInfoURL = '/user/updateUserInfo'; //-/
// final String changeAccountURL = '/user/changeAccount'; //

View File

@ -4,10 +4,10 @@ import 'package:get/get.dart';
import 'api_provider_base.dart';
class ApiProvider extends BaseProvider {
Future<Response> getVerificationCode(String countryCode, String account,
Future<Response> sendValidationCode(String countryCode, String account,
String channel, String codeType, String xWidth) =>
post(
getVerificationCodeUrl.toUrl,
sendValidationCodeUrl.toUrl,
jsonEncode({
'countryCode': countryCode,
'account': account,
@ -1528,16 +1528,15 @@ class ApiProvider extends BaseProvider {
post(keyboardPwdResetURL.toUrl, jsonEncode({'lockId': lockId}));
//使
Future<Response> getValidationCodeAuth(String countryCode, String account,
String channel, String codeType, String uniqueid, String xWidth) =>
Future<Response> sendValidationCodeAuth(String countryCode, String account,
String channel, String codeType, String xWidth) =>
post(
getValidationCodeAuthURL.toUrl,
sendValidationCodeAuthURL.toUrl,
jsonEncode({
'countryCode': countryCode,
'account': account,
"channel": channel,
'codeType': codeType,
"uniqueid": uniqueid,
'xWidth': xWidth,
}));

View File

@ -43,6 +43,7 @@ class BaseProvider extends GetConnect with Api {
// print('res.body======>${res.body}');
if (res.body == null) {
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
// EasyLoading.showToast("Network Error!", duration: 2000.milliseconds);
var rs = {
"errorMsg": "Network Error!",
"errorCode": -1,

View File

@ -60,14 +60,14 @@ class ApiRepository {
static ApiRepository get to => Get.find<ApiRepository>();
ApiRepository(this.apiProvider);
// 12345
Future<SendValidationCodeEntity> sendValidationCode(
// (使) 12
Future<SendValidationCodeEntity> sendValidationCodeUnLogin(
{required String countryCode,
required String account,
required String channel,
required String codeType,
required String xWidth}) async {
final res = await apiProvider.getVerificationCode(
final res = await apiProvider.sendValidationCode(
countryCode, account, channel, codeType, xWidth);
return SendValidationCodeEntity.fromJson(res.body);
}
@ -1566,15 +1566,16 @@ class ApiRepository {
}
// 2使 sendValidationCodeAuth 5
Future<SendValidationCodeEntity> getValidationCodeAuth(
String countryCode,
String account,
String channel,
String codeType,
String uniqueid,
String xWidth) async {
final res = await apiProvider.getValidationCodeAuth(
countryCode, account, channel, codeType, uniqueid, xWidth);
Future<SendValidationCodeEntity> sendValidationCodeAuth(
{
required String countryCode,
required String account,
required String channel,
required String codeType,
required String xWidth
}) async {
final res = await apiProvider.sendValidationCodeAuth(
countryCode, account, channel, codeType, xWidth);
return SendValidationCodeEntity.fromJson(res.body);
}

View File

@ -129,4 +129,9 @@ class LockUserManageListRefreshUI {
///
class AuthorizedAdministratorListPageRefreshUI {
AuthorizedAdministratorListPageRefreshUI();
}
///
class MineInfoChangeRefreshUI {
MineInfoChangeRefreshUI();
}