diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 15d28a25..19aa5b88 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -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'; } diff --git a/lib/model/user/user_detail_model.dart b/lib/model/user/user_detail_model.dart new file mode 100644 index 00000000..f21048c2 --- /dev/null +++ b/lib/model/user/user_detail_model.dart @@ -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 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 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(); + } + + Map toJson() { + final Map data = new Map(); + 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; + } +} diff --git a/lib/pages/manager_func.dart b/lib/pages/manager_func.dart new file mode 100644 index 00000000..05103079 --- /dev/null +++ b/lib/pages/manager_func.dart @@ -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; + } +} diff --git a/lib/pages/sign/sign_func.dart b/lib/pages/sign/sign_func.dart index 68e173e1..6755fbba 100644 --- a/lib/pages/sign/sign_func.dart +++ b/lib/pages/sign/sign_func.dart @@ -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 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 getUserDetail() async { + BaseModel baseModel = await NetUtil().get( + API.user.userDetail, + ); + return UserDetailModel.fromJson(baseModel.data); + } } diff --git a/lib/pages/visitor_access_page/visitor_access_page.dart b/lib/pages/visitor_access_page/visitor_access_page.dart index fc81d5ba..b353c252 100644 --- a/lib/pages/visitor_access_page/visitor_access_page.dart +++ b/lib/pages/visitor_access_page/visitor_access_page.dart @@ -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 { TextEditingController _userName = new TextEditingController(); TextEditingController _userCarNum = new TextEditingController(); - String dateTime = '请选择到访时间'; - List> _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 { ); } - 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 { 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 { 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 { 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 { 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 { 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 { 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 { ); } - 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 { } Widget build(BuildContext context) { + UserProvider userProvider=Provider.of(context); return BeeScaffold( title: '访客通行', actions: [ @@ -328,7 +342,11 @@ class _VisitorAccessPageState extends State { _input('是否驾车', '请输入,例如浙A88888(没有驾车可不填)', _userCarNum), _selectTime(), SizedBox(height: 64.w), - _create(), + _create( + userProvider.userDetailModel.id, + userProvider.userDetailModel.type, + userProvider.userDetailModel.tel + ), _tips(), ], ), diff --git a/lib/provider/user_provider.dart b/lib/provider/user_provider.dart index 315724be..541e849c 100644 --- a/lib/provider/user_provider.dart +++ b/lib/provider/user_provider.dart @@ -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(