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 userDetail => '/user/personalData/getUserDetail';
///
String get setSex => '/user/personalData/updateSex';
@ -57,4 +60,6 @@ class _Manager {
///
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/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/provider/sign_up_provider.dart';
import 'package:akuCommunity/provider/user_provider.dart';
@ -19,14 +20,16 @@ class SignFunc {
);
return baseModel;
}
static Future sendNewMessageCode(String newTel) async{
BaseModel baseModel =await NetUtil().post(
static Future sendNewMessageCode(String newTel) async {
BaseModel baseModel = await NetUtil().post(
API.login.sendNewMSCode,
params: {'newTel':newTel},
params: {'newTel': newTel},
showMessage: true,
);
return baseModel;
}
static Future<Response> login(String phone, String code) async {
Response response = await NetUtil().dio.post(
API.login.loginBySMS,
@ -73,4 +76,11 @@ class SignFunc {
BaseModel baseModel = await NetUtil().get(API.user.userProfile);
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/provider/user_provider.dart';
import 'package:akuCommunity/widget/bee_scaffold.dart';
import 'package:flutter/material.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:akuCommunity/utils/headers.dart';
import 'package:akuCommunity/widget/common_input.dart';
import 'package:provider/provider.dart';
import 'package:velocity_x/velocity_x.dart';
class VisitorAccessPage extends StatefulWidget {
@ -19,12 +22,8 @@ class VisitorAccessPage extends StatefulWidget {
class _VisitorAccessPageState extends State<VisitorAccessPage> {
TextEditingController _userName = new TextEditingController();
TextEditingController _userCarNum = new TextEditingController();
String dateTime = '请选择到访时间';
List<Map<String, dynamic>> _sexList = [
{'sex': '先生', 'sexIcon': AntDesign.man, 'isCheck': true},
{'sex': '女士', 'sexIcon': AntDesign.woman, 'isCheck': false},
];
DateTime dateTime;
int _selectSex;
Widget _house() {
return Container(
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(
onTap: () {
_sexList.forEach((item) {
item['isCheck'] = false;
setState(() {
_selectSex = value;
});
_sexList[index]['isCheck'] = true;
setState(() {});
},
child: Container(
height: 72.w,
@ -149,7 +150,8 @@ class _VisitorAccessPageState extends State<VisitorAccessPage> {
color: Color(0xffffffff),
borderRadius: BorderRadius.all(Radius.circular(36)),
border: Border.all(
color: isCheck ? Color(0xffffc40c) : Color(0xff979797),
color:
value == _selectSex ? Color(0xffffc40c) : Color(0xff979797),
width: 1)),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
@ -157,7 +159,8 @@ class _VisitorAccessPageState extends State<VisitorAccessPage> {
Icon(
sexIcon,
size: 32.sp,
color: isCheck ? Color(0xff333333) : Color(0xff979797),
color:
value == _selectSex ? Color(0xff333333) : Color(0xff979797),
),
SizedBox(width: 9.w),
Text(
@ -165,7 +168,9 @@ class _VisitorAccessPageState extends State<VisitorAccessPage> {
style: TextStyle(
fontWeight: FontWeight.w600,
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(
child: Row(
children: [
_sexButton(_sexList[0]['sex'], _sexList[0]['sexIcon'],
_sexList[0]['isCheck'], 0),
_sexButton('先生', AntDesign.man, 1),
SizedBox(width: 80.w),
_sexButton(_sexList[1]['sex'], _sexList[1]['sexIcon'],
_sexList[1]['isCheck'], 1),
_sexButton('女士', AntDesign.woman, 2),
],
),
),
@ -214,7 +217,7 @@ class _VisitorAccessPageState extends State<VisitorAccessPage> {
print('change $date in time zone ' +
date.timeZoneOffset.inHours.toString());
}, onConfirm: (date) {
dateTime = date.toString().substring(0, 11);
dateTime = date;
setState(() {});
}, currentTime: DateTime.now(), locale: LocaleType.zh);
},
@ -236,7 +239,9 @@ class _VisitorAccessPageState extends State<VisitorAccessPage> {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'$dateTime',
dateTime == null
? '请选择到访时间'
: '${dateTime.toString().substring(0, 11)}',
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 34.sp,
@ -258,8 +263,16 @@ class _VisitorAccessPageState extends State<VisitorAccessPage> {
);
}
Widget _create() {
Widget _create(
int id,
int type,
String tel,
) {
return InkWell(
onTap: () {
ManagerFunc.insertVisitorInfo(id, type, _userName.text, _selectSex, tel,
_userCarNum.text, dateTime);
},
child: Container(
alignment: Alignment.center,
height: 96.w,
@ -296,6 +309,7 @@ class _VisitorAccessPageState extends State<VisitorAccessPage> {
}
Widget build(BuildContext context) {
UserProvider userProvider=Provider.of<UserProvider>(context);
return BeeScaffold(
title: '访客通行',
actions: [
@ -328,7 +342,11 @@ class _VisitorAccessPageState extends State<VisitorAccessPage> {
_input('是否驾车', '请输入,例如浙A88888(没有驾车可不填)', _userCarNum),
_selectTime(),
SizedBox(height: 64.w),
_create(),
_create(
userProvider.userDetailModel.id,
userProvider.userDetailModel.type,
userProvider.userDetailModel.tel
),
_tips(),
],
),

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

Loading…
Cancel
Save