提交 f5087672 authored 作者: yueweilu's avatar yueweilu

修改头像

上级 01eb5429
...@@ -145,21 +145,22 @@ abstract class CommonAPI { ...@@ -145,21 +145,22 @@ abstract class CommonAPI {
'is_select':love 'is_select':love
}, },
); );
if (result.data is Map && result.data['is_success'] == 1){ if (result.data is! Map && result.data['is_success'] == 1){
return true; return true;
} }
return false; return false;
} }
/// 10、上传文件 /// 10、上传文件
static Future upload({ static Future <String> upload({
required String path required String path
}) async { }) async {
final result = await HttpService.to.upload( final result = await HttpService.to.upload(
'/v1/members/Information/uploadFile', '/v1/members/Information/uploadFile',
path: path path: path
); );
print(result.data); if (result.data is! Map) return '';
return result.data['filesUrl'];
} }
} }
\ No newline at end of file
part of user_info; part of user_info;
class UserInfoController extends GetxController { class UserInfoController extends GetxController {
final UserInfoModel userInfo;
UserInfoController(this.userInfo);
/// 上传头像 /// 上传头像
void upload({ void upload({
required String path required String path
}) async { }) async {
var result = await CommonAPI.upload(path:path); String result = await CommonAPI.upload(path:path);
print(result); _changeInfo(result);
update();
} }
/// 修改用用户信息 /// 修改用用户信息
void _changeInfo(String img) async {
final result = await MineAPI.changeInfo(headImg: img);
if(result){
Toast.show('修改成功');
userInfo.headImg = img;
update();
}
}
} }
\ No newline at end of file
...@@ -15,7 +15,7 @@ class _UserInfoPageState extends State<UserInfoPage> { ...@@ -15,7 +15,7 @@ class _UserInfoPageState extends State<UserInfoPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return GetBuilder<UserInfoController>( return GetBuilder<UserInfoController>(
init: UserInfoController(), init: UserInfoController(widget.userInfo),
builder: (controller) =>Scaffold( builder: (controller) =>Scaffold(
appBar: AppBar( appBar: AppBar(
title: const Text('个人信息'), title: const Text('个人信息'),
...@@ -70,7 +70,7 @@ class _UserInfoPageState extends State<UserInfoPage> { ...@@ -70,7 +70,7 @@ class _UserInfoPageState extends State<UserInfoPage> {
shape: BoxShape.circle, shape: BoxShape.circle,
color: Colors.cyan, color: Colors.cyan,
), ),
child: CustomImage.network(url: widget.userInfo.headImg??''), child: CustomImage.network(url: controller.userInfo.headImg??'',radius: 16.5,),
), ),
Gaps.hGaps10, Gaps.hGaps10,
SizedBox( SizedBox(
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论