add user detail

update visitor access
hmxc
张萌 4 years ago
parent c2cf7e7f6f
commit a82fc92958

@ -31,6 +31,9 @@ class _User {
/// ///
String get userProfile => '/user/personalData/findPersonalData'; String get userProfile => '/user/personalData/findPersonalData';
///
String get userDetail => '/user/personalData/getUserDetail';
/// ///
String get setSex => '/user/personalData/updateSex'; String get setSex => '/user/personalData/updateSex';
@ -57,4 +60,6 @@ class _Manager {
/// ///
String get fixedSubmit => '/user/reportRepair/list'; String get fixedSubmit => '/user/reportRepair/list';
///访
String get insertVisitorInfo => 'user/visitorAccess/insertVisitorInfo';
} }

@ -0,0 +1,72 @@
class UserDetailModel {
int id;
String name;
int type;
String tel;
int idType;
String idNumber;
String pwd;
String confuse;
String email;
int createId;
String createDate;
String identity;
int roomStatus;
String nickName;
List<String> estateNames;
UserDetailModel(
{this.id,
this.name,
this.type,
this.tel,
this.idType,
this.idNumber,
this.pwd,
this.confuse,
this.email,
this.createId,
this.createDate,
this.identity,
this.roomStatus,
this.nickName,
this.estateNames});
UserDetailModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
type = json['type'];
tel = json['tel'];
idType = json['idType'];
idNumber = json['idNumber'];
pwd = json['pwd'];
confuse = json['confuse'];
email = json['email'];
createId = json['createId'];
createDate = json['createDate'];
identity = json['identity'];
roomStatus = json['roomStatus'];
nickName = json['nickName'];
estateNames = json['estateNames'].cast<String>();
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['name'] = this.name;
data['type'] = this.type;
data['tel'] = this.tel;
data['idType'] = this.idType;
data['idNumber'] = this.idNumber;
data['pwd'] = this.pwd;
data['confuse'] = this.confuse;
data['email'] = this.email;
data['createId'] = this.createId;
data['createDate'] = this.createDate;
data['identity'] = this.identity;
data['roomStatus'] = this.roomStatus;
data['nickName'] = this.nickName;
data['estateNames'] = this.estateNames;
return data;
}
}

@ -0,0 +1,21 @@
import 'package:akuCommunity/constants/api.dart';
import 'package:akuCommunity/utils/network/base_model.dart';
import 'package:akuCommunity/utils/network/net_util.dart';
class ManagerFunc {
static insertVisitorInfo(int id, int type, String name, int sex, String tel,
String carNum, DateTime expectedVisitDate) async {
BaseModel baseModel = await NetUtil().post(API.manager.insertVisitorInfo,
params: {
'buildingUnitEstateId': id,
'type': type,
'name': name,
'sex': sex,
'tel': tel,
'carNum': carNum,
'expectedVisitDate': expectedVisitDate.toIso8601String(),
},
showMessage: true);
return baseModel;
}
}

@ -1,5 +1,6 @@
import 'package:akuCommunity/constants/api.dart'; import 'package:akuCommunity/constants/api.dart';
import 'package:akuCommunity/model/user/pick_building_model.dart'; import 'package:akuCommunity/model/user/pick_building_model.dart';
import 'package:akuCommunity/model/user/user_detail_model.dart';
import 'package:akuCommunity/model/user/user_info_model.dart'; import 'package:akuCommunity/model/user/user_info_model.dart';
import 'package:akuCommunity/provider/sign_up_provider.dart'; import 'package:akuCommunity/provider/sign_up_provider.dart';
import 'package:akuCommunity/provider/user_provider.dart'; import 'package:akuCommunity/provider/user_provider.dart';
@ -19,6 +20,7 @@ class SignFunc {
); );
return baseModel; return baseModel;
} }
static Future sendNewMessageCode(String newTel) async { static Future sendNewMessageCode(String newTel) async {
BaseModel baseModel = await NetUtil().post( BaseModel baseModel = await NetUtil().post(
API.login.sendNewMSCode, API.login.sendNewMSCode,
@ -27,6 +29,7 @@ class SignFunc {
); );
return baseModel; return baseModel;
} }
static Future<Response> login(String phone, String code) async { static Future<Response> login(String phone, String code) async {
Response response = await NetUtil().dio.post( Response response = await NetUtil().dio.post(
API.login.loginBySMS, API.login.loginBySMS,
@ -73,4 +76,11 @@ class SignFunc {
BaseModel baseModel = await NetUtil().get(API.user.userProfile); BaseModel baseModel = await NetUtil().get(API.user.userProfile);
return UserInfoModel.fromJson(baseModel.data); return UserInfoModel.fromJson(baseModel.data);
} }
static Future<UserDetailModel> getUserDetail() async {
BaseModel baseModel = await NetUtil().get(
API.user.userDetail,
);
return UserDetailModel.fromJson(baseModel.data);
}
} }

@ -1,4 +1,6 @@
import 'package:akuCommunity/pages/manager_func.dart';
import 'package:akuCommunity/pages/visitor_access_page/visitor_record_page.dart'; import 'package:akuCommunity/pages/visitor_access_page/visitor_record_page.dart';
import 'package:akuCommunity/provider/user_provider.dart';
import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
@ -7,6 +9,7 @@ import 'package:akuCommunity/base/assets_image.dart';
import 'package:flutter_icons/flutter_icons.dart'; import 'package:flutter_icons/flutter_icons.dart';
import 'package:akuCommunity/utils/headers.dart'; import 'package:akuCommunity/utils/headers.dart';
import 'package:akuCommunity/widget/common_input.dart'; import 'package:akuCommunity/widget/common_input.dart';
import 'package:provider/provider.dart';
import 'package:velocity_x/velocity_x.dart'; import 'package:velocity_x/velocity_x.dart';
class VisitorAccessPage extends StatefulWidget { class VisitorAccessPage extends StatefulWidget {
@ -19,12 +22,8 @@ class VisitorAccessPage extends StatefulWidget {
class _VisitorAccessPageState extends State<VisitorAccessPage> { class _VisitorAccessPageState extends State<VisitorAccessPage> {
TextEditingController _userName = new TextEditingController(); TextEditingController _userName = new TextEditingController();
TextEditingController _userCarNum = new TextEditingController(); TextEditingController _userCarNum = new TextEditingController();
String dateTime = '请选择到访时间'; DateTime dateTime;
List<Map<String, dynamic>> _sexList = [ int _selectSex;
{'sex': '先生', 'sexIcon': AntDesign.man, 'isCheck': true},
{'sex': '女士', 'sexIcon': AntDesign.woman, 'isCheck': false},
];
Widget _house() { Widget _house() {
return Container( return Container(
padding: EdgeInsets.only( padding: EdgeInsets.only(
@ -130,14 +129,16 @@ class _VisitorAccessPageState extends State<VisitorAccessPage> {
); );
} }
Widget _sexButton(String sex, IconData sexIcon, bool isCheck, int index) { Widget _sexButton(
String sex,
IconData sexIcon,
int value,
) {
return InkWell( return InkWell(
onTap: () { onTap: () {
_sexList.forEach((item) { setState(() {
item['isCheck'] = false; _selectSex = value;
}); });
_sexList[index]['isCheck'] = true;
setState(() {});
}, },
child: Container( child: Container(
height: 72.w, height: 72.w,
@ -149,7 +150,8 @@ class _VisitorAccessPageState extends State<VisitorAccessPage> {
color: Color(0xffffffff), color: Color(0xffffffff),
borderRadius: BorderRadius.all(Radius.circular(36)), borderRadius: BorderRadius.all(Radius.circular(36)),
border: Border.all( border: Border.all(
color: isCheck ? Color(0xffffc40c) : Color(0xff979797), color:
value == _selectSex ? Color(0xffffc40c) : Color(0xff979797),
width: 1)), width: 1)),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
@ -157,7 +159,8 @@ class _VisitorAccessPageState extends State<VisitorAccessPage> {
Icon( Icon(
sexIcon, sexIcon,
size: 32.sp, size: 32.sp,
color: isCheck ? Color(0xff333333) : Color(0xff979797), color:
value == _selectSex ? Color(0xff333333) : Color(0xff979797),
), ),
SizedBox(width: 9.w), SizedBox(width: 9.w),
Text( Text(
@ -165,7 +168,9 @@ class _VisitorAccessPageState extends State<VisitorAccessPage> {
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
fontSize: 30.sp, fontSize: 30.sp,
color: isCheck ? Color(0xff333333) : Color(0xff979797)), color: value == _selectSex
? Color(0xff333333)
: Color(0xff979797)),
), ),
], ],
), ),
@ -190,11 +195,9 @@ class _VisitorAccessPageState extends State<VisitorAccessPage> {
Container( Container(
child: Row( child: Row(
children: [ children: [
_sexButton(_sexList[0]['sex'], _sexList[0]['sexIcon'], _sexButton('先生', AntDesign.man, 1),
_sexList[0]['isCheck'], 0),
SizedBox(width: 80.w), SizedBox(width: 80.w),
_sexButton(_sexList[1]['sex'], _sexList[1]['sexIcon'], _sexButton('女士', AntDesign.woman, 2),
_sexList[1]['isCheck'], 1),
], ],
), ),
), ),
@ -214,7 +217,7 @@ class _VisitorAccessPageState extends State<VisitorAccessPage> {
print('change $date in time zone ' + print('change $date in time zone ' +
date.timeZoneOffset.inHours.toString()); date.timeZoneOffset.inHours.toString());
}, onConfirm: (date) { }, onConfirm: (date) {
dateTime = date.toString().substring(0, 11); dateTime = date;
setState(() {}); setState(() {});
}, currentTime: DateTime.now(), locale: LocaleType.zh); }, currentTime: DateTime.now(), locale: LocaleType.zh);
}, },
@ -236,7 +239,9 @@ class _VisitorAccessPageState extends State<VisitorAccessPage> {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text( Text(
'$dateTime', dateTime == null
? '请选择到访时间'
: '${dateTime.toString().substring(0, 11)}',
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
fontSize: 34.sp, fontSize: 34.sp,
@ -258,8 +263,16 @@ class _VisitorAccessPageState extends State<VisitorAccessPage> {
); );
} }
Widget _create() { Widget _create(
int id,
int type,
String tel,
) {
return InkWell( return InkWell(
onTap: () {
ManagerFunc.insertVisitorInfo(id, type, _userName.text, _selectSex, tel,
_userCarNum.text, dateTime);
},
child: Container( child: Container(
alignment: Alignment.center, alignment: Alignment.center,
height: 96.w, height: 96.w,
@ -296,6 +309,7 @@ class _VisitorAccessPageState extends State<VisitorAccessPage> {
} }
Widget build(BuildContext context) { Widget build(BuildContext context) {
UserProvider userProvider=Provider.of<UserProvider>(context);
return BeeScaffold( return BeeScaffold(
title: '访客通行', title: '访客通行',
actions: [ actions: [
@ -328,7 +342,11 @@ class _VisitorAccessPageState extends State<VisitorAccessPage> {
_input('是否驾车', '请输入,例如浙A88888(没有驾车可不填)', _userCarNum), _input('是否驾车', '请输入,例如浙A88888(没有驾车可不填)', _userCarNum),
_selectTime(), _selectTime(),
SizedBox(height: 64.w), SizedBox(height: 64.w),
_create(), _create(
userProvider.userDetailModel.id,
userProvider.userDetailModel.type,
userProvider.userDetailModel.tel
),
_tips(), _tips(),
], ],
), ),

@ -1,4 +1,5 @@
import 'package:akuCommunity/constants/api.dart'; import 'package:akuCommunity/constants/api.dart';
import 'package:akuCommunity/model/user/user_detail_model.dart';
import 'package:akuCommunity/model/user/user_info_model.dart'; import 'package:akuCommunity/model/user/user_info_model.dart';
import 'package:akuCommunity/pages/sign/sign_func.dart'; import 'package:akuCommunity/pages/sign/sign_func.dart';
import 'package:akuCommunity/utils/hive_store.dart'; import 'package:akuCommunity/utils/hive_store.dart';
@ -23,6 +24,7 @@ class UserProvider extends ChangeNotifier {
HiveStore.appBox.put('token', token); HiveStore.appBox.put('token', token);
HiveStore.appBox.put('login', true); HiveStore.appBox.put('login', true);
await updateProfile(); await updateProfile();
await updateUserDetail();
notifyListeners(); notifyListeners();
} }
@ -30,6 +32,7 @@ class UserProvider extends ChangeNotifier {
_isLogin = false; _isLogin = false;
_token = null; _token = null;
_userInfoModel = null; _userInfoModel = null;
_userDetailModel=null;
NetUtil().get(API.user.logout, showMessage: true); NetUtil().get(API.user.logout, showMessage: true);
NetUtil().dio.options.headers.remove('App-Admin-Token'); NetUtil().dio.options.headers.remove('App-Admin-Token');
HiveStore.appBox.delete('token'); HiveStore.appBox.delete('token');
@ -42,12 +45,19 @@ class UserProvider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
Future updateUserDetail()async{
_userDetailModel=await SignFunc.getUserDetail();
}
String _token; String _token;
String get token => _token ?? ''; String get token => _token ?? '';
UserInfoModel _userInfoModel; UserInfoModel _userInfoModel;
UserInfoModel get userInfoModel => _userInfoModel; UserInfoModel get userInfoModel => _userInfoModel;
UserDetailModel _userDetailModel;
UserDetailModel get userDetailModel => _userDetailModel;
/// ///
Future setSex(int sex) async { Future setSex(int sex) async {
BaseModel baseModel = await NetUtil().post( BaseModel baseModel = await NetUtil().post(

Loading…
Cancel
Save