登录接口调试
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:cashier_reserve/common/push/push.dart';
|
||||
import 'package:cashier_reserve/datas/login/login_result.dart';
|
||||
import 'package:cashier_reserve/login/login_view.dart';
|
||||
|
||||
import '../base/ui.dart';
|
||||
@@ -40,14 +41,6 @@ class AppManager {
|
||||
}
|
||||
|
||||
YJPush.presentWidget(globalContext!, const LoginView());
|
||||
|
||||
// showDialog(
|
||||
// context: globalContext!,
|
||||
// barrierDismissible: false,
|
||||
// builder: (BuildContext context) {
|
||||
// return WillPopScope(
|
||||
// onWillPop: () => Future.value(false), child: const LoginView());
|
||||
// });
|
||||
}
|
||||
|
||||
static void disposeLoginWidget() {
|
||||
@@ -61,4 +54,15 @@ class AppManager {
|
||||
static String getUserToken() {
|
||||
return HiveManager.getUserToken();
|
||||
}
|
||||
|
||||
static void loginSuccess(LoginResult? r) {
|
||||
HiveManager.setUserToken(r?.token ?? '');
|
||||
HiveManager.setShopId((r?.shopId ?? '').toString());
|
||||
HiveManager.setShopName(r?.shopName ?? '');
|
||||
HiveManager.setShopLogo(r?.logo ?? '');
|
||||
HiveManager.setUserInfo(r?.user?.toString() ?? '');
|
||||
|
||||
disposeLoginWidget();
|
||||
Navigator.of(globalContext!).pop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,51 @@ class HiveManager {
|
||||
_userInfoBox = Hive.box();
|
||||
}
|
||||
|
||||
static void clearLoginInfo() {
|
||||
_userInfoBox?.delete('token');
|
||||
_userInfoBox?.delete('shopId');
|
||||
_userInfoBox?.delete('shopName');
|
||||
_userInfoBox?.delete('shopLogo');
|
||||
_userInfoBox?.delete('userInfo');
|
||||
}
|
||||
|
||||
static void setUserToken(String token) {
|
||||
_userInfoBox?.put('token', token);
|
||||
}
|
||||
|
||||
static String getUserToken() {
|
||||
return _userInfoBox?.get('token') ?? '';
|
||||
}
|
||||
|
||||
static void setShopId(String shopId) {
|
||||
_userInfoBox?.put('shopId', shopId);
|
||||
}
|
||||
|
||||
static String getShopId() {
|
||||
return _userInfoBox?.get('shopId') ?? '';
|
||||
}
|
||||
|
||||
static void setShopName(String shopName) {
|
||||
_userInfoBox?.put('shopName', shopName);
|
||||
}
|
||||
|
||||
static String getShopName() {
|
||||
return _userInfoBox?.get('shopName') ?? '';
|
||||
}
|
||||
|
||||
static void setShopLogo(String shopLogo) {
|
||||
_userInfoBox?.put('shopLogo', shopLogo);
|
||||
}
|
||||
|
||||
static String getShopLogo() {
|
||||
return _userInfoBox?.get('shopLogo') ?? '';
|
||||
}
|
||||
|
||||
static void setUserInfo(String userInfo) {
|
||||
_userInfoBox?.put('userInfo', userInfo);
|
||||
}
|
||||
|
||||
static String getUserInfo() {
|
||||
return _userInfoBox?.get('userInfo') ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user