对接修改性别和生日接口

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.
/// PLEASE DO NOT EDIT MANUALLY.
class R {
/// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/agreement.pdf)
static const String ASSETS_AGREEMENT_PDF = 'assets/agreement.pdf';
/// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/.DS_Store)
static const String ASSETS__DS_STORE = 'assets/.DS_Store';
/// ![preview](file:///Users/akufe/Documents/akuCommunity/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 {
///
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(
title: '智慧社区',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.yellow,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
theme: ThemeData(primarySwatch: Colors.yellow),
home: SplashPage(),
//
localizationsDelegates: [

@ -1,12 +1,31 @@
import 'package:common_utils/common_utils.dart';
class UserInfoModel {
int id;
List<String> imgUrls;
String name;
String nickName;
String tel;
/// 1. 2.
int sex;
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(
{this.id,
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_house_page/mine_house_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/sign/sign_in_page.dart';
import 'package:akuCommunity/pages/things_page/fixed_submit_page.dart';
@ -131,7 +132,10 @@ class _PersonalIndexState extends State<PersonalIndex>
),
InkWell(
onTap: () {
if (!userProvider.isLogin) SignInPage().to();
if (!userProvider.isLogin)
SignInPage().to();
else
UserProfilePage().to();
},
child: Container(
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(
message: Text('注销当前账号'),
actions: [
CupertinoButton(
CupertinoDialogAction(
child: Text(
'确定',
style: TextStyle(
@ -40,11 +40,9 @@ class _AccountManagerPageState extends State<AccountManagerPage> {
},
),
],
cancelButton: CupertinoButton(
cancelButton: CupertinoDialogAction(
child: Text('取消'),
onPressed: () {
Get.back();
},
onPressed: Get.back,
),
);
},

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

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

@ -1,7 +1,10 @@
import 'package:akuCommunity/constants/api.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';
import 'package:akuCommunity/utils/network/base_model.dart';
import 'package:akuCommunity/utils/network/net_util.dart';
import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart';
class UserProvider extends ChangeNotifier {
@ -42,4 +45,28 @@ class UserProvider extends ChangeNotifier {
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