对接用户信息用户资料接口

hmxc
小赖 4 years ago
parent 2c20751260
commit 37b9334fda

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

@ -12,6 +12,7 @@ class API {
static const int networkTimeOut = 10000;
static _Auth auth = _Auth();
static _User user = _User();
}
class _Auth {
@ -21,3 +22,11 @@ class _Auth {
////退app
String get login => '/login/loginSMSUser';
}
class _User {
///
String get profile => '/user/personalData/findPersonalData';
///
String get info => '/user/personalData/getUserDetail';
}

@ -0,0 +1,27 @@
class ImgModel {
String url;
String size;
int longs;
int paragraph;
int sort;
ImgModel({this.url, this.size, this.longs, this.paragraph, this.sort});
ImgModel.fromJson(Map<String, dynamic> json) {
url = json['url'];
size = json['size'];
longs = json['longs'];
paragraph = json['paragraph'];
sort = json['sort'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['url'] = this.url;
data['size'] = this.size;
data['longs'] = this.longs;
data['paragraph'] = this.paragraph;
data['sort'] = this.sort;
return data;
}
}

@ -0,0 +1,124 @@
class UserInfoModel {
int id;
String userName;
String pwd;
String actualName;
String tel;
int sex;
String userCode;
String birthday;
String email;
String idCard;
int organizationId;
String organizationIdPath;
int positionId;
String roleId;
int status;
int isDelete;
int createId;
String createDate;
int modifyId;
String modifyDate;
String lastLoginIp;
String lastLoginDate;
String nickName;
String code;
String codeSendDate;
int remake;
int reportTo;
String entryDate;
UserInfoModel(
{this.id,
this.userName,
this.pwd,
this.actualName,
this.tel,
this.sex,
this.userCode,
this.birthday,
this.email,
this.idCard,
this.organizationId,
this.organizationIdPath,
this.positionId,
this.roleId,
this.status,
this.isDelete,
this.createId,
this.createDate,
this.modifyId,
this.modifyDate,
this.lastLoginIp,
this.lastLoginDate,
this.nickName,
this.code,
this.codeSendDate,
this.remake,
this.reportTo,
this.entryDate});
UserInfoModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
userName = json['userName'];
pwd = json['pwd'];
actualName = json['actualName'];
tel = json['tel'];
sex = json['sex'];
userCode = json['userCode'];
birthday = json['birthday'];
email = json['email'];
idCard = json['idCard'];
organizationId = json['organizationId'];
organizationIdPath = json['organizationIdPath'];
positionId = json['positionId'];
roleId = json['roleId'];
status = json['status'];
isDelete = json['isDelete'];
createId = json['createId'];
createDate = json['createDate'];
modifyId = json['modifyId'];
modifyDate = json['modifyDate'];
lastLoginIp = json['lastLoginIp'];
lastLoginDate = json['lastLoginDate'];
nickName = json['nickName'];
code = json['code'];
codeSendDate = json['codeSendDate'];
remake = json['remake'];
reportTo = json['reportTo'];
entryDate = json['entryDate'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['userName'] = this.userName;
data['pwd'] = this.pwd;
data['actualName'] = this.actualName;
data['tel'] = this.tel;
data['sex'] = this.sex;
data['userCode'] = this.userCode;
data['birthday'] = this.birthday;
data['email'] = this.email;
data['idCard'] = this.idCard;
data['organizationId'] = this.organizationId;
data['organizationIdPath'] = this.organizationIdPath;
data['positionId'] = this.positionId;
data['roleId'] = this.roleId;
data['status'] = this.status;
data['isDelete'] = this.isDelete;
data['createId'] = this.createId;
data['createDate'] = this.createDate;
data['modifyId'] = this.modifyId;
data['modifyDate'] = this.modifyDate;
data['lastLoginIp'] = this.lastLoginIp;
data['lastLoginDate'] = this.lastLoginDate;
data['nickName'] = this.nickName;
data['code'] = this.code;
data['codeSendDate'] = this.codeSendDate;
data['remake'] = this.remake;
data['reportTo'] = this.reportTo;
data['entryDate'] = this.entryDate;
return data;
}
}

@ -0,0 +1,41 @@
import 'package:aku_community_manager/models/common/img_model.dart';
class UserProfileModel {
int id;
List<ImgModel> imgUrls;
String nickName;
String tel;
UserProfileModel({this.id, this.imgUrls, this.nickName, this.tel});
ImgModel get firstImg {
if (imgUrls.isEmpty)
return null;
else
return imgUrls.first;
}
UserProfileModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
if (json['imgUrls'] != null) {
imgUrls = new List<ImgModel>();
json['imgUrls'].forEach((v) {
imgUrls.add(new ImgModel.fromJson(v));
});
}
nickName = json['nickName'];
tel = json['tel'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
if (this.imgUrls != null) {
data['imgUrls'] = this.imgUrls.map((v) => v.toJson()).toList();
} else
imgUrls = [];
data['nickName'] = this.nickName;
data['tel'] = this.tel;
return data;
}
}

@ -1,8 +1,13 @@
import 'dart:io';
import 'package:aku_community_manager/const/api.dart';
import 'package:aku_community_manager/mock_models/users/user_info_model.dart';
import 'package:aku_community_manager/models/user/user_profile_model.dart';
import 'package:aku_community_manager/utils/hive_store.dart';
import 'package:aku_community_manager/utils/network/base_model.dart';
import 'package:aku_community_manager/utils/network/net_util.dart';
import 'package:aku_community_manager/models/user/user_info_model.dart'
as USER_INFO;
import 'package:flutter/material.dart';
//
@ -11,19 +16,46 @@ class UserProvider extends ChangeNotifier {
bool get isLogin => _isLogin;
///
Future setLogin(int token) async {
_isLogin = true;
NetUtil().dio.options.headers.putIfAbsent('App-Admin-Token', () => token);
NetUtil()
.dio
.options
.headers
.putIfAbsent('butlerApp-admin-token', () => token);
HiveStore.appBox.put('token', token);
HiveStore.appBox.put('login', true);
// await updateProfile();
// await updateUserDetail();
_profileModel = await updateProfile();
_infoModel = await updateUserInfo();
// await setCurrentHouse((_userDetailModel?.estateNames?.isEmpty ?? true)
// ? ''
// : _userDetailModel?.estateNames?.first);
notifyListeners();
}
UserProfileModel _profileModel;
UserProfileModel get profileModel => _profileModel;
USER_INFO.UserInfoModel _infoModel;
USER_INFO.UserInfoModel get infoModel => _infoModel;
///profile
Future<UserProfileModel> updateProfile() async {
BaseModel model = await NetUtil().get(API.user.profile);
if (model == null)
return null;
else
return UserProfileModel.fromJson(model.data);
}
Future<USER_INFO.UserInfoModel> updateUserInfo() async {
BaseModel model = await NetUtil().get(API.user.info);
if (model == null)
return null;
else
return USER_INFO.UserInfoModel.fromJson(model.data);
}
bool _isSigned = false;
///

@ -1,3 +1,4 @@
import 'package:aku_community_manager/const/api.dart';
import 'package:aku_community_manager/const/resource.dart';
import 'package:aku_community_manager/provider/anouncement_provider.dart';
import 'package:aku_community_manager/mock_models/all_model.dart';
@ -15,6 +16,7 @@ import 'package:aku_community_manager/ui/home/application/applications_page.dart
import 'package:aku_community_manager/ui/home/personal_draw.dart';
import 'package:aku_community_manager/ui/home/search_workorder_page.dart';
import 'package:aku_community_manager/ui/login/login_page.dart';
import 'package:aku_community_manager/ui/settings/user_info_page.dart';
import 'package:aku_community_manager/ui/sub_pages/business_and_fix/business_fix_card.dart';
import 'package:aku_community_manager/ui/sub_pages/decoration_manager/decoration_manager_card.dart';
import 'package:aku_community_manager/ui/sub_pages/visitor_manager/visitor_manager_page.dart';
@ -48,7 +50,7 @@ class _HomePageState extends State<HomePage> {
onPressed: () {
final userProvider =
Provider.of<UserProvider>(context, listen: false);
if (userProvider.isSigned) {
if (userProvider.isLogin) {
Get.to(page);
if (text != '全部应用')
appProvider.addRecentApp(AppApplication(text, assetPath, page));
@ -173,6 +175,11 @@ class _HomePageState extends State<HomePage> {
margin: EdgeInsets.only(top: 8.w, bottom: 8.w),
width: 72.w,
height: 72.w,
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(36.w),
),
//
child: Builder(
builder: (BuildContext context) {
@ -180,20 +187,14 @@ class _HomePageState extends State<HomePage> {
onTap: () {
Scaffold.of(context).openDrawer();
},
child: CircleAvatar(
radius: 36.w,
backgroundImage:
userProvider.userInfoModel.avatar == null
? null
: FileImage(
userProvider.userInfoModel.avatar),
backgroundColor: Colors.white,
child: userProvider.isSigned
? userProvider.userInfoModel.avatar == null
? Icon(Icons.person_outline)
: null
: Icon(Icons.person),
),
child: userProvider.isLogin
? FadeInImage.assetNetwork(
placeholder: R.ASSETS_PLACEHOLDER_WEBP,
image: API.image(userProvider
.profileModel.firstImg?.url ??
''),
)
: Icon(Icons.person),
);
},
),
@ -270,7 +271,7 @@ class _HomePageState extends State<HomePage> {
//
height: double.infinity,
onPressed: () {
if (userProvider.isSigned)
if (userProvider.isLogin)
Get.to(Message());
else
Get.to(LoginPage());
@ -297,7 +298,10 @@ class _HomePageState extends State<HomePage> {
SizedBox(height: 24.w),
GestureDetector(
onTap: () {
if (!userProvider.isSigned) Get.to(LoginPage());
if (!userProvider.isLogin)
Get.to(LoginPage());
else
Get.to(UserInfoPage());
},
child: Container(
margin: EdgeInsets.only(
@ -305,8 +309,8 @@ class _HomePageState extends State<HomePage> {
),
height: 67.w,
child: Text(
userProvider.isSigned
? 'HI${userProvider.userInfoModel.nickName}'
userProvider.isLogin
? 'HI${userProvider.infoModel.nickName}'
: '登录/注册',
style: TextStyle(
color: AppStyle.primaryTextColor,

@ -1,3 +1,4 @@
import 'package:aku_community_manager/const/api.dart';
import 'package:aku_community_manager/const/resource.dart';
import 'package:aku_community_manager/provider/user_provider.dart';
import 'package:aku_community_manager/style/app_style.dart';
@ -61,7 +62,7 @@ class _PersonalDrawState extends State<PersonalDraw> {
//leading
InkWell(
onTap: () {
userProvider.isSigned
userProvider.isLogin
? Get.to(UserInfoPage())
: Get.to(LoginPage());
},
@ -75,17 +76,19 @@ class _PersonalDrawState extends State<PersonalDraw> {
AkuRoundButton(
height: 72.w,
onPressed: () {},
child: CircleAvatar(
radius: 36.w,
backgroundImage:
userProvider.userInfoModel.avatar == null
? null
: FileImage(userProvider.userInfoModel.avatar),
backgroundColor: Colors.white,
child: userProvider.isSigned
? userProvider.userInfoModel.avatar == null
? Icon(Icons.person_outline)
: null
child: Material(
borderRadius: BorderRadius.circular(36.w),
clipBehavior: Clip.antiAlias,
color: Colors.grey,
child: userProvider.isLogin
? FadeInImage.assetNetwork(
placeholder: R.ASSETS_PLACEHOLDER_WEBP,
image: API.image(
userProvider.profileModel.firstImg?.url ?? '',
),
height: 72.w,
width: 72.w,
)
: Icon(Icons.person),
),
),

@ -117,7 +117,8 @@ class _LoginSMSPageState extends State<LoginSMSPage> {
data: {'tel': widget.phone, 'code': text},
);
if (response.data['status'] == true) {
userProvider.setLogin(response.data['token']);
await userProvider.setLogin(response.data['token']);
Get.offAll(HomePage());
} else {
_textEditingController.clear();
BotToast.showText(text: '登陆失败');

Loading…
Cancel
Save