对接修改性别和生日接口

hmxc
小赖 4 years ago
parent fd0a549296
commit f556fedd73

Binary file not shown.

@ -1,8 +1,8 @@
/// Generate by [resource_generator](https://github.com/CaiJingLong/flutter_resource_generator) library. /// Generate by [resource_generator](https://github.com/CaiJingLong/flutter_resource_generator) library.
/// PLEASE DO NOT EDIT MANUALLY. /// PLEASE DO NOT EDIT MANUALLY.
class R { class R {
/// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/agreement.pdf) /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/.DS_Store)
static const String ASSETS_AGREEMENT_PDF = 'assets/agreement.pdf'; static const String ASSETS__DS_STORE = 'assets/.DS_Store';
/// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/example/QR_code.png) /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/example/QR_code.png)
static const String ASSETS_EXAMPLE_QR_CODE_PNG = 'assets/example/QR_code.png'; static const String ASSETS_EXAMPLE_QR_CODE_PNG = 'assets/example/QR_code.png';

@ -26,4 +26,10 @@ class _Login {
class _User { class _User {
/// ///
String get userProfile => '/user/personalData/findPersonalData'; String get userProfile => '/user/personalData/findPersonalData';
///
String get setSex => '/user/personalData/updateSex';
///
String get setBirthday => '/user/personalData/updateBirthday';
} }

@ -53,10 +53,7 @@ class _MyAppState extends State<MyApp> {
child: GetMaterialApp( child: GetMaterialApp(
title: '智慧社区', title: '智慧社区',
debugShowCheckedModeBanner: false, debugShowCheckedModeBanner: false,
theme: ThemeData( theme: ThemeData(primarySwatch: Colors.yellow),
primarySwatch: Colors.yellow,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: SplashPage(), home: SplashPage(),
// //
localizationsDelegates: [ localizationsDelegates: [

@ -1,12 +1,31 @@
import 'package:common_utils/common_utils.dart';
class UserInfoModel { class UserInfoModel {
int id; int id;
List<String> imgUrls; List<String> imgUrls;
String name; String name;
String nickName; String nickName;
String tel; String tel;
/// 1. 2.
int sex; int sex;
String birthday; String birthday;
String get sexValue {
if (sex == null) return '未设置';
if (sex == 1) return '';
if (sex == 2) return '';
return '未设置';
}
DateTime get birthdayDate => DateUtil.getDateTime(birthday);
String get birthdayValue {
if (TextUtil.isEmpty(birthday))
return '未设置';
else
return DateUtil.formatDate(birthdayDate, format: 'yyyy-MM-dd');
}
UserInfoModel( UserInfoModel(
{this.id, {this.id,
this.imgUrls, this.imgUrls,

@ -5,6 +5,7 @@ import 'package:akuCommunity/pages/life_pay/life_pay_page.dart';
import 'package:akuCommunity/pages/mine_car_page/mine_car_page.dart'; import 'package:akuCommunity/pages/mine_car_page/mine_car_page.dart';
import 'package:akuCommunity/pages/mine_house_page/mine_house_page.dart'; import 'package:akuCommunity/pages/mine_house_page/mine_house_page.dart';
import 'package:akuCommunity/pages/personal/order_page.dart'; import 'package:akuCommunity/pages/personal/order_page.dart';
import 'package:akuCommunity/pages/personal/user_profile_page.dart';
import 'package:akuCommunity/pages/setting_page/settings_page.dart'; import 'package:akuCommunity/pages/setting_page/settings_page.dart';
import 'package:akuCommunity/pages/sign/sign_in_page.dart'; import 'package:akuCommunity/pages/sign/sign_in_page.dart';
import 'package:akuCommunity/pages/things_page/fixed_submit_page.dart'; import 'package:akuCommunity/pages/things_page/fixed_submit_page.dart';
@ -131,7 +132,10 @@ class _PersonalIndexState extends State<PersonalIndex>
), ),
InkWell( InkWell(
onTap: () { onTap: () {
if (!userProvider.isLogin) SignInPage().to(); if (!userProvider.isLogin)
SignInPage().to();
else
UserProfilePage().to();
}, },
child: Container( child: Container(
margin: EdgeInsets.only(left: 16.w), margin: EdgeInsets.only(left: 16.w),

@ -0,0 +1,176 @@
import 'package:akuCommunity/base/base_style.dart';
import 'package:akuCommunity/provider/user_provider.dart';
import 'package:akuCommunity/widget/bee_scaffold.dart';
import 'package:akuCommunity/utils/headers.dart';
import 'package:common_utils/common_utils.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:provider/provider.dart';
import 'package:velocity_x/velocity_x.dart';
class UserProfilePage extends StatefulWidget {
UserProfilePage({Key key}) : super(key: key);
@override
_UserProfilePageState createState() => _UserProfilePageState();
}
class _UserProfilePageState extends State<UserProfilePage> {
int _sex = 1;
DateTime _birthday = DateTime.now();
Widget _buildTile(String title, Widget suffix, {VoidCallback onPressed}) {
return MaterialButton(
color: Colors.white,
elevation: 0,
onPressed: onPressed,
height: 96.w,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
child: DefaultTextStyle(
style: TextStyle(
fontSize: 34.sp,
color: ktextPrimary,
),
child: Row(
children: [
32.wb,
title.text.make(),
Spacer(),
suffix ?? SizedBox(),
24.wb,
Icon(
CupertinoIcons.chevron_forward,
color: Color(0xFFDCDCDC),
size: 32.w,
),
16.wb,
],
),
),
);
}
@override
Widget build(BuildContext context) {
final userProvider = Provider.of<UserProvider>(context);
return BeeScaffold(
title: '个人资料',
body: ListView(
children: [
_buildTile(
'头像',
CircleAvatar(),
onPressed: () {},
),
_buildTile(
'姓名',
userProvider.userInfoModel.name.text.make(),
onPressed: () {},
),
_buildTile(
'昵称',
userProvider.userInfoModel.nickName.text.make(),
onPressed: () {},
),
_buildTile(
'手机号',
TextUtil.hideNumber(userProvider.userInfoModel.tel).text.make(),
onPressed: () {},
),
_buildTile(
'性别',
userProvider.userInfoModel.sexValue.text.make(),
onPressed: () {
showCupertinoDialog(
context: context,
builder: (context) {
return CupertinoAlertDialog(
title: '请选择'.text.isIntrinsic.make(),
content: SizedBox(
child: CupertinoPicker(
itemExtent: 50,
onSelectedItemChanged: (index) {
_sex = index + 1;
},
children: [
''.text.isIntrinsic.make().centered(),
''.text.isIntrinsic.make().centered(),
],
useMagnifier: true,
),
height: 300.w,
),
actions: [
CupertinoDialogAction(
child: '取消'.text.isIntrinsic.make(),
onPressed: Get.back,
),
CupertinoDialogAction(
child: '确定'.text.isIntrinsic.make(),
onPressed: () {
userProvider.setSex(_sex);
Get.back();
},
),
],
);
},
);
},
),
_buildTile(
'出生日期',
userProvider.userInfoModel.birthdayValue.text.make(),
onPressed: () {
Get.dialog(
CupertinoAlertDialog(
title: '请选择'.text.isIntrinsic.make(),
content: SizedBox(
height: 340.w,
child: CupertinoTheme(
data: CupertinoThemeData(
textTheme: CupertinoTextThemeData(
dateTimePickerTextStyle: TextStyle(
fontSize: 30.sp,
color: Colors.black87,
),
),
),
child: CupertinoDatePicker(
maximumYear: DateTime.now().year,
minimumYear: 1900,
mode: CupertinoDatePickerMode.date,
onDateTimeChanged: (date) {
_birthday = date;
},
),
),
),
actions: [
CupertinoDialogAction(
child: '取消'.text.isIntrinsic.make(),
onPressed: Get.back,
),
CupertinoDialogAction(
child: '确定'.text.isIntrinsic.make(),
onPressed: () {
userProvider.setBirthday(_birthday);
Get.back();
},
),
],
),
);
},
),
].sepWidget(
separate: Divider(
indent: 104.w,
height: 1.w,
thickness: 1.w,
color: Color(0xFFEEEEEE),
)),
),
);
}
}

@ -28,7 +28,7 @@ class _AccountManagerPageState extends State<AccountManagerPage> {
return CupertinoActionSheet( return CupertinoActionSheet(
message: Text('注销当前账号'), message: Text('注销当前账号'),
actions: [ actions: [
CupertinoButton( CupertinoDialogAction(
child: Text( child: Text(
'确定', '确定',
style: TextStyle( style: TextStyle(
@ -40,11 +40,9 @@ class _AccountManagerPageState extends State<AccountManagerPage> {
}, },
), ),
], ],
cancelButton: CupertinoButton( cancelButton: CupertinoDialogAction(
child: Text('取消'), child: Text('取消'),
onPressed: () { onPressed: Get.back,
Get.back();
},
), ),
); );
}, },

@ -70,7 +70,7 @@ class _SettingsPageState extends State<SettingsPage> {
return CupertinoActionSheet( return CupertinoActionSheet(
message: Text('退出当前账号'), message: Text('退出当前账号'),
actions: [ actions: [
CupertinoButton( CupertinoDialogAction(
child: Text( child: Text(
'确定', '确定',
style: TextStyle( style: TextStyle(
@ -83,7 +83,7 @@ class _SettingsPageState extends State<SettingsPage> {
}, },
), ),
], ],
cancelButton: CupertinoButton( cancelButton: CupertinoDialogAction(
child: Text('取消'), child: Text('取消'),
onPressed: () { onPressed: () {
Get.back(); Get.back();

@ -264,9 +264,7 @@ class _SignInPageState extends State<SignInPage> {
children: [ children: [
FlatButton( FlatButton(
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
onPressed: () { onPressed: AgreementPage().to,
ARoute.push(context, AgreementPage());
},
child: Text( child: Text(
'《小蜜蜂用户协议》', '《小蜜蜂用户协议》',
style: TextStyle( style: TextStyle(
@ -276,9 +274,7 @@ class _SignInPageState extends State<SignInPage> {
SizedBox(width: 15.w), SizedBox(width: 15.w),
FlatButton( FlatButton(
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
onPressed: () { onPressed: PrivacyPage().to,
ARoute.push(context, PrivacyPage());
},
child: Text( child: Text(
'《小蜜蜂隐私政策》', '《小蜜蜂隐私政策》',
style: TextStyle( style: TextStyle(

@ -1,7 +1,10 @@
import 'package:akuCommunity/constants/api.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';
import 'package:akuCommunity/utils/network/base_model.dart';
import 'package:akuCommunity/utils/network/net_util.dart'; import 'package:akuCommunity/utils/network/net_util.dart';
import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class UserProvider extends ChangeNotifier { class UserProvider extends ChangeNotifier {
@ -42,4 +45,28 @@ class UserProvider extends ChangeNotifier {
UserInfoModel _userInfoModel; UserInfoModel _userInfoModel;
UserInfoModel get userInfoModel => _userInfoModel; UserInfoModel get userInfoModel => _userInfoModel;
Future setSex(int sex) async {
BaseModel baseModel = await NetUtil().post(
API.user.setSex,
params: {'sex': sex},
showMessage: true,
);
if (baseModel.status) {
_userInfoModel.sex = sex;
notifyListeners();
}
}
Future setBirthday(DateTime date) async {
BaseModel baseModel = await NetUtil().post(
API.user.setBirthday,
params: {'birthday': date.toIso8601String()},
showMessage: true,
);
if (baseModel.status) {
_userInfoModel.birthday = date.toIso8601String();
notifyListeners();
}
}
} }

Loading…
Cancel
Save