匿名登录逻辑优化
This commit is contained in:
parent
620f5067d6
commit
7052764dc8
|
|
@ -21,4 +21,9 @@ class AppConfig {
|
|||
static const paddingLeft = 20.0;
|
||||
static const paddingRight = 20.0;
|
||||
static const paddingbottom = 20.0;
|
||||
|
||||
// 正常登录
|
||||
static const NORMAL_LOGIN = "normal_login";
|
||||
// 匿名登录
|
||||
static const ANONYMOUS_LOGIN = "anonymous_login";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@ enum AppStorageKey {
|
|||
token(value: 'TOKEN', label: "登录用户的token"),
|
||||
userInfo(value: 'USERINFO', label: "登录用户的基本信息"),
|
||||
account(value: 'ACCOUNT', label: "用户名"),
|
||||
pwd(value: 'PWD', label: "密码");
|
||||
pwd(value: 'PWD', label: "密码"),
|
||||
loginType(value: 'LOGINTYPE', label: "登录类型");
|
||||
|
||||
final String label;
|
||||
final String value;
|
||||
|
|
|
|||
|
|
@ -14,10 +14,14 @@ class UserStore extends GetxController with RequestToolMixin {
|
|||
/// 是否登录
|
||||
String? token;
|
||||
|
||||
/// 登录类型
|
||||
String? loginType;
|
||||
|
||||
/// 用户信息
|
||||
Rx<UserInfoEntity?> userInfoEntity = Rx(null);
|
||||
|
||||
UserStore init() {
|
||||
loginType = StorageService.to.read(AppStorageKey.loginType.value);
|
||||
token = StorageService.to.read(AppStorageKey.token.value);
|
||||
try {
|
||||
var userDetail = StorageService.to.read(AppStorageKey.userInfo.value);
|
||||
|
|
@ -41,6 +45,12 @@ class UserStore extends GetxController with RequestToolMixin {
|
|||
StorageService.to.write(AppStorageKey.token.value, token);
|
||||
}
|
||||
|
||||
/// 保存登录类型
|
||||
void setLoginType(String loginType) {
|
||||
this.loginType = loginType;
|
||||
StorageService.to.write(AppStorageKey.loginType.value, loginType);
|
||||
}
|
||||
|
||||
/// 保存用户信息
|
||||
void setUserDetailInfo(UserInfoEntity info) {
|
||||
userInfoEntity.value = info;
|
||||
|
|
@ -51,6 +61,7 @@ class UserStore extends GetxController with RequestToolMixin {
|
|||
void erase() {
|
||||
userInfoEntity.value = null;
|
||||
token = null;
|
||||
loginType = null;
|
||||
|
||||
StorageService.to.erase();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import 'package:wgshare/utils/package_info_util.dart';
|
|||
import 'package:wgshare/utils/storage.dart';
|
||||
import 'package:wgshare/utils/utils.dart';
|
||||
|
||||
import 'common/config/app_config.dart';
|
||||
import 'common/config/colorUtils.dart';
|
||||
import 'routes/app_pages.dart';
|
||||
import 'routes/app_routes.dart';
|
||||
|
|
@ -79,7 +80,9 @@ class MyApp extends StatelessWidget {
|
|||
//默认专场动画
|
||||
defaultTransition: Transition.fade,
|
||||
//初始化路由页面
|
||||
initialRoute: (UserStore.to.token?.isNotEmpty ?? false) && UserStore.to.userInfoEntity.value != null ? Routes.startPage : Routes.loginPage,
|
||||
initialRoute: (UserStore.to.token?.isNotEmpty ?? false) && UserStore.to.userInfoEntity.value != null && UserStore.to.loginType != null && UserStore.to.loginType == AppConfig.NORMAL_LOGIN
|
||||
? Routes.startPage
|
||||
: Routes.loginPage,
|
||||
|
||||
/// 路由表
|
||||
getPages: AppPages.pages,
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import 'package:get/get.dart';
|
|||
import 'package:signalr_core/signalr_core.dart';
|
||||
import 'package:wgshare/common/models/common/base_structure_result.dart';
|
||||
import 'package:wgshare/common/mixins/request_tool_mixin.dart';
|
||||
import 'package:wgshare/common/store/user_store.dart';
|
||||
|
||||
import '../../common/models/meeting_room_item.dart';
|
||||
import '../../utils/toast_utils.dart';
|
||||
|
|
@ -24,8 +25,9 @@ class HomeLogic extends GetxController with RequestToolMixin {
|
|||
state.refreshController.dispose();
|
||||
}
|
||||
|
||||
/// 直接进入会议(匿名登录)
|
||||
/// 获取会议列表
|
||||
Future<void> doHttpGetMeetingRoomList(int pageIndex, int pageSize) async {
|
||||
debugPrint("wgs输出===:token:${UserStore.to.token}");
|
||||
BaseStructureResult<MeetingRoomItem> res = await getClient().getMeetingRoomList(pageIndex,pageSize);
|
||||
if(null != res.data){
|
||||
if(state.pageIndex == 1){
|
||||
|
|
|
|||
|
|
@ -212,174 +212,6 @@ class HomePageState extends State<HomePage> with AutomaticKeepAliveClientMixin {
|
|||
);
|
||||
}
|
||||
|
||||
/*@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
surfaceTintColor: Colors.white,
|
||||
elevation: 0,
|
||||
toolbarHeight: 0,
|
||||
systemOverlayStyle: const SystemUiOverlayStyle(
|
||||
statusBarColor: Colors.transparent,
|
||||
systemNavigationBarColor: Color(0xFF000000),
|
||||
systemNavigationBarIconBrightness: Brightness.light,
|
||||
statusBarIconBrightness: Brightness.dark,
|
||||
statusBarBrightness: Brightness.light,
|
||||
),
|
||||
backgroundColor: Colors.white,
|
||||
),
|
||||
body: Obx(() => Column(
|
||||
children: [
|
||||
Container(
|
||||
width: double.infinity,
|
||||
height: 44.h,
|
||||
alignment: Alignment.center,
|
||||
color: Colors.white,
|
||||
child: Text(
|
||||
'会议列表',
|
||||
style: TextStyle(
|
||||
fontSize: 16.sp,
|
||||
color: ColorUtil.Color_51_51_51,
|
||||
fontWeight: FontWeight.w500),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
color: ColorUtil.Color_244_244_244,
|
||||
child: SmartRefresher(
|
||||
enablePullUp: true,
|
||||
controller: state.refreshController,
|
||||
onRefresh: logic.onRefresh,
|
||||
onLoading: logic.onLoading,
|
||||
child: ListView.builder(
|
||||
itemBuilder: (context, index) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
decoration: const BoxDecoration(
|
||||
borderRadius:
|
||||
BorderRadius.all(Radius.circular(6)),
|
||||
color: Colors.white,
|
||||
),
|
||||
margin: EdgeInsets.only(
|
||||
top: index == 0 ? 20 : 12,
|
||||
bottom: index == 19 ? 20 : 0,
|
||||
left: 16,
|
||||
right: 16),
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
state.meetingRooms.value[index].roomName,
|
||||
style: TextStyle(
|
||||
fontSize: 14.sp,
|
||||
color: ColorUtil.Color_89_88_88,
|
||||
fontWeight: FontWeight.w500),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Image.asset(
|
||||
'assets/images/index_persons.png',
|
||||
width: 16.w,
|
||||
height: 16.h,
|
||||
),
|
||||
Text(
|
||||
'${state.meetingRooms.value[index].onlineUserCount}人',
|
||||
style: TextStyle(
|
||||
fontSize: 12.sp,
|
||||
color: ColorUtil.Color_177_177_177,
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
SizedBox(height: 20.h),
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
state.meetingRooms.value[index]
|
||||
.roomNum,
|
||||
style: TextStyle(
|
||||
fontSize: 12.sp,
|
||||
color: ColorUtil.Color_177_177_177,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 6.w),
|
||||
GestureDetector(
|
||||
child: Image.asset(
|
||||
'assets/images/index_copy.png',
|
||||
width: 16.w,
|
||||
height: 16.h,
|
||||
),
|
||||
onTap: () {
|
||||
Clipboard.setData(ClipboardData(
|
||||
text: state.meetingRooms
|
||||
.value[index].roomNum));
|
||||
ToastUtils.showSuccess("复制成功");
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
GestureDetector(
|
||||
child: Container(
|
||||
width: 78.w,
|
||||
height: 30.h,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.all(
|
||||
Radius.circular(6)),
|
||||
color: ColorUtil.Color_85_117_242,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'进入',
|
||||
style: TextStyle(
|
||||
fontSize: 12.sp,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
Image.asset(
|
||||
'assets/images/index_right.png',
|
||||
width: 16.w,
|
||||
height: 16.h,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
Get.toNamed(Routes.meetingMainPage,
|
||||
arguments: {
|
||||
"roomNumber": state.meetingRooms
|
||||
.value[index].roomNum
|
||||
});
|
||||
},
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
itemCount: state.meetingRooms.value.length,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
)));
|
||||
}*/
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_timer?.cancel();
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import 'package:wgshare/common/mixins/request_tool_mixin.dart';
|
|||
import 'package:wgshare/utils/device_info.dart';
|
||||
import 'package:wgshare/utils/toast_utils.dart';
|
||||
|
||||
import '../../common/config/app_config.dart';
|
||||
import '../../common/models/common/base_structure_result.dart';
|
||||
import '../../common/models/user_info_entity.dart';
|
||||
import '../../common/store/app_storage_key.dart';
|
||||
|
|
@ -50,8 +51,13 @@ class LoginLogic extends GetxController with RequestToolMixin {
|
|||
if (null != res.data) {
|
||||
UserStore.to.setToken(res.data!.token);
|
||||
UserStore.to.setUserDetailInfo(res.data!);
|
||||
// Get.toNamed(Routes.startPage);
|
||||
UserStore.to.setLoginType(AppConfig.NORMAL_LOGIN);
|
||||
Get.offAllNamed(Routes.startPage);
|
||||
state.userNameController.text = "";
|
||||
state.passwordController.text = "";
|
||||
state.meetingCodeController.text = "";
|
||||
state.nickNameCodeController.text = "";
|
||||
state.checkAgreementBool.value = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -71,8 +77,13 @@ class LoginLogic extends GetxController with RequestToolMixin {
|
|||
if (null != res.data) {
|
||||
UserStore.to.setToken(res.data!.token);
|
||||
UserStore.to.setUserDetailInfo(res.data!);
|
||||
// Get.toNamed(Routes.meetingMainPage, arguments: {"roomNumber": state.meetingCodeController.text});
|
||||
Get.offAllNamed(Routes.meetingMainPage, arguments: {"roomNumber": state.meetingCodeController.text});
|
||||
UserStore.to.setLoginType(AppConfig.ANONYMOUS_LOGIN);
|
||||
Get.toNamed(Routes.meetingMainPage, arguments: {"roomNumber": state.meetingCodeController.text});
|
||||
state.userNameController.text = "";
|
||||
state.passwordController.text = "";
|
||||
state.meetingCodeController.text = "";
|
||||
state.nickNameCodeController.text = "";
|
||||
state.checkAgreementBool.value = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|||
import 'package:get/get.dart';
|
||||
import 'package:liquid_progress_indicator_v2/liquid_progress_indicator.dart';
|
||||
import 'package:preload_page_view/preload_page_view.dart';
|
||||
import 'package:wgshare/common/config/app_config.dart';
|
||||
import 'package:wgshare/common/store/user_store.dart';
|
||||
import 'package:wgshare/utils/toast_utils.dart';
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue