From 37b9334fda1e296b835ea9d01971f5ae1d72bee5 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Fri, 19 Feb 2021 15:47:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E7=94=A8=E6=88=B7=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E7=94=A8=E6=88=B7=E8=B5=84=E6=96=99=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/placeholder.webp | Bin 0 -> 10322 bytes lib/const/api.dart | 9 ++ lib/models/common/img_model.dart | 27 ++++++ lib/models/user/user_info_model.dart | 124 ++++++++++++++++++++++++ lib/models/user/user_profile_model.dart | 41 ++++++++ lib/provider/user_provider.dart | 38 +++++++- lib/ui/home/home_page.dart | 42 ++++---- lib/ui/home/personal_draw.dart | 27 +++--- lib/ui/login/login_sms_page.dart | 3 +- 9 files changed, 276 insertions(+), 35 deletions(-) create mode 100644 assets/placeholder.webp create mode 100644 lib/models/common/img_model.dart create mode 100644 lib/models/user/user_info_model.dart create mode 100644 lib/models/user/user_profile_model.dart diff --git a/assets/placeholder.webp b/assets/placeholder.webp new file mode 100644 index 0000000000000000000000000000000000000000..0b27014f2ff1113ea93f06a97431196f1272d4a5 GIT binary patch literal 10322 zcmeHsWl&wsw(SNs?h;&sySr;}ci32PcXx*nG`PD<@ZjzQcXtg=aQ6Gok9SY*JLjvq z|6aXUr>nbbb=6#}y62j6j4`WKWu&BJX#fB%Nik(jWgcw=004mY*Qf>lql?NbOXvKx zg20&uN5Z99t(8p6noJM1=aN4QL+DsP#epCH@Ag2jeL3o1`z8&i1^`(0A+jOp>VS1X zAv~loF*2YqJ2Vhr%*ePE91oj2C)^U*HqQpu4cG>|UNpQ;J;aR|T6rJ%*o?(eY!Saa z96QLq%)HJ$fkh05x>Ew`-lv|RPiq^lARh7+wXP<~0@m)--c!TDv)$)DkO7R~52su2 zM`;0Tf>OQ4;-;7r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ginSMSUser'; } + +class _User { + ///个人资料:查询个人资料信息 + String get profile => '/user/personalData/findPersonalData'; + + ///个人资料:获取用户信息 + String get info => '/user/personalData/getUserDetail'; +} diff --git a/lib/models/common/img_model.dart b/lib/models/common/img_model.dart new file mode 100644 index 0000000..e8a9dd2 --- /dev/null +++ b/lib/models/common/img_model.dart @@ -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 json) { + url = json['url']; + size = json['size']; + longs = json['longs']; + paragraph = json['paragraph']; + sort = json['sort']; + } + + Map toJson() { + final Map data = new Map(); + data['url'] = this.url; + data['size'] = this.size; + data['longs'] = this.longs; + data['paragraph'] = this.paragraph; + data['sort'] = this.sort; + return data; + } +} diff --git a/lib/models/user/user_info_model.dart b/lib/models/user/user_info_model.dart new file mode 100644 index 0000000..c248d15 --- /dev/null +++ b/lib/models/user/user_info_model.dart @@ -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 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 toJson() { + final Map data = new Map(); + 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; + } +} diff --git a/lib/models/user/user_profile_model.dart b/lib/models/user/user_profile_model.dart new file mode 100644 index 0000000..686a5da --- /dev/null +++ b/lib/models/user/user_profile_model.dart @@ -0,0 +1,41 @@ +import 'package:aku_community_manager/models/common/img_model.dart'; + +class UserProfileModel { + int id; + List 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 json) { + id = json['id']; + if (json['imgUrls'] != null) { + imgUrls = new List(); + json['imgUrls'].forEach((v) { + imgUrls.add(new ImgModel.fromJson(v)); + }); + } + nickName = json['nickName']; + tel = json['tel']; + } + + Map toJson() { + final Map data = new Map(); + 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; + } +} diff --git a/lib/provider/user_provider.dart b/lib/provider/user_provider.dart index 52dfd4b..91a4348 100644 --- a/lib/provider/user_provider.dart +++ b/lib/provider/user_provider.dart @@ -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 updateProfile() async { + BaseModel model = await NetUtil().get(API.user.profile); + if (model == null) + return null; + else + return UserProfileModel.fromJson(model.data); + } + + Future 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; ///用户是否登陆 diff --git a/lib/ui/home/home_page.dart b/lib/ui/home/home_page.dart index ade220d..a00db6c 100644 --- a/lib/ui/home/home_page.dart +++ b/lib/ui/home/home_page.dart @@ -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 { onPressed: () { final userProvider = Provider.of(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 { 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 { 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 { //消息按钮 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 { 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 { ), height: 67.w, child: Text( - userProvider.isSigned - ? 'HI,${userProvider.userInfoModel.nickName}' + userProvider.isLogin + ? 'HI,${userProvider.infoModel.nickName}' : '登录/注册', style: TextStyle( color: AppStyle.primaryTextColor, diff --git a/lib/ui/home/personal_draw.dart b/lib/ui/home/personal_draw.dart index b9e0ffa..94d208e 100644 --- a/lib/ui/home/personal_draw.dart +++ b/lib/ui/home/personal_draw.dart @@ -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 { //leading InkWell( onTap: () { - userProvider.isSigned + userProvider.isLogin ? Get.to(UserInfoPage()) : Get.to(LoginPage()); }, @@ -75,17 +76,19 @@ class _PersonalDrawState extends State { 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), ), ), diff --git a/lib/ui/login/login_sms_page.dart b/lib/ui/login/login_sms_page.dart index a79279f..6f97343 100644 --- a/lib/ui/login/login_sms_page.dart +++ b/lib/ui/login/login_sms_page.dart @@ -117,7 +117,8 @@ class _LoginSMSPageState extends State { 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: '登陆失败');