@@ -0,0 +1,44 @@ | |||||
/// | |||||
/// 用户信息类 | |||||
/// | |||||
class UserInfoModel { | |||||
String token; | |||||
String mobile; | |||||
String userId; | |||||
String username; | |||||
List<String> perms; | |||||
String registerInviteCodeEnable; | |||||
UserInfoModel( | |||||
{this.token, | |||||
this.userId, | |||||
this.username, | |||||
this.perms, | |||||
this.registerInviteCodeEnable}); | |||||
UserInfoModel.fromJson(Map<String, dynamic> json) { | |||||
token = json['token']; | |||||
userId = json['user_id']; | |||||
username = json['username']; | |||||
mobile = json['mobile']; | |||||
perms = json['perms']?.cast<String>(); | |||||
registerInviteCodeEnable = json['register_invite_code_enable']; | |||||
} | |||||
Map<String, dynamic> toJson() { | |||||
final Map<String, dynamic> data = new Map<String, dynamic>(); | |||||
data['token'] = this.token; | |||||
data['user_id'] = this.userId; | |||||
data['username'] = this.username; | |||||
data['perms'] = this.perms; | |||||
data['mobile'] = this.mobile; | |||||
data['register_invite_code_enable'] = this.registerInviteCodeEnable; | |||||
return data; | |||||
} | |||||
@override | |||||
String toString() { | |||||
return 'LoginUser{token: $token, userId: $userId, username: $username, perms: $perms, registerInviteCodeEnable: $registerInviteCodeEnable}'; | |||||
} | |||||
} |
@@ -0,0 +1,35 @@ | |||||
import 'package:flutter/material.dart'; | |||||
import 'package:zhiying_comm/models/user/user_info_model.dart'; | |||||
/// | |||||
/// 用户信息 | |||||
/// | |||||
class UserInfoNotifier with ChangeNotifier { | |||||
UserInfoModel _userInfo; | |||||
/// 初始化,是否需要读取缓存信息? | |||||
UserInfoNotifier(); | |||||
/// 更新用户数据 | |||||
void setUserInfo(UserInfoModel loginUser) async { | |||||
print('${loginUser.toString()}'); | |||||
this._userInfo = loginUser; | |||||
// 缓存数据 TODO | |||||
/// token | |||||
} | |||||
/// 退出登陆 | |||||
void unLogin() { | |||||
this._userInfo = null; | |||||
// 清除缓存数据 TODO | |||||
} | |||||
/// 获取登陆数据 | |||||
UserInfoModel getUserInfoModel() { | |||||
if (null != _userInfo) { | |||||
return _userInfo; | |||||
} | |||||
// TODO 需要读取缓存的数据? | |||||
return null; | |||||
} | |||||
} |
@@ -86,7 +86,7 @@ class NetUtil { | |||||
/// 同步请求 | /// 同步请求 | ||||
static Future<dynamic> post(String path, | static Future<dynamic> post(String path, | ||||
{Map<String, dynamic> params, NetMethod method = NetMethod.POST, bool cache = true}) async { | |||||
{Map<String, dynamic> params, NetMethod method = NetMethod.POST, bool cache = false}) async { | |||||
if (params == null) { | if (params == null) { | ||||
params = {}; | params = {}; | ||||
} | } | ||||
@@ -15,6 +15,11 @@ export 'util/page_factory.dart'; | |||||
export 'util/widget_factory.dart'; | export 'util/widget_factory.dart'; | ||||
export 'util/router_util.dart'; | export 'util/router_util.dart'; | ||||
export 'util/log/let_log.dart'; | export 'util/log/let_log.dart'; | ||||
export 'util/empty_util.dart'; | |||||
// 用户信息 | |||||
export 'models/user/user_info_model.dart'; | |||||
export 'models/user/user_info_model_notifier.dart'; | |||||
// 屏幕适配 | // 屏幕适配 | ||||
export 'package:flutter_screenutil/flutter_screenutil.dart'; | export 'package:flutter_screenutil/flutter_screenutil.dart'; | ||||
@@ -12,10 +12,11 @@ dependencies: | |||||
sdk: flutter | sdk: flutter | ||||
dio: ^3.0.9 | dio: ^3.0.9 | ||||
provider: ^4.0.0 | |||||
package_info: ^0.4.0+17 | package_info: ^0.4.0+17 | ||||
device_info: ^0.4.0+1 | device_info: ^0.4.0+1 | ||||
flutter_native_image: ^0.0.5 | flutter_native_image: ^0.0.5 | ||||
fluttertoast: ^7.0.4 | |||||
fluttertoast: 4.0.1 | |||||
cached_network_image: ^2.2.0+1 | cached_network_image: ^2.2.0+1 | ||||
equatable: ^1.2.0 | equatable: ^1.2.0 | ||||
json_serializable: ^3.3.0 | json_serializable: ^3.3.0 | ||||
@@ -26,6 +27,7 @@ dependencies: | |||||
shared_preferences: ^0.5.10 | shared_preferences: ^0.5.10 | ||||
dev_dependencies: | dev_dependencies: | ||||
flutter_test: | flutter_test: | ||||
sdk: flutter | sdk: flutter | ||||