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

修改头像

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