对接修改头像接口

hmxc
小赖 4 years ago
parent 19c10cce68
commit 80e1b40418

@ -14,6 +14,7 @@ class API {
static _Auth auth = _Auth(); static _Auth auth = _Auth();
static _User user = _User(); static _User user = _User();
static _Manage manage = _Manage(); static _Manage manage = _Manage();
static _Upload upload = _Upload();
} }
class _Auth { class _Auth {
@ -42,6 +43,8 @@ class _User {
/// ///
String get updateTel => '/user/personalData/updateTel'; String get updateTel => '/user/personalData/updateTel';
///
String get updateAvatar => '/user/personalData/updateHeadPortrait';
} }
class _Manage { class _Manage {
@ -93,3 +96,8 @@ class _Manage {
/// ///
String get goodsOutNotRelease => '/user/articleOut/noRelease'; String get goodsOutNotRelease => '/user/articleOut/noRelease';
} }
class _Upload {
///
String get avatar => '/user/upload/butlerAppHeadSculpture';
}

@ -2,6 +2,8 @@
import 'dart:io'; import 'dart:io';
// Flutter imports: // Flutter imports:
import 'package:aku_community_manager/utils/network/base_file_model.dart';
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
// Project imports: // Project imports:
@ -87,16 +89,30 @@ class UserProvider extends ChangeNotifier {
_isSigned = true; _isSigned = true;
notifyListeners(); notifyListeners();
} }
/// ///
setNickName(String name) { setNickName(String name) {
_infoModel.nickName = name; _infoModel.nickName = name;
notifyListeners(); notifyListeners();
} }
setAvatar(File file) { ///
_userInfoModel.avatar = file; setAvatar(File file) async {
Function cancel = BotToast.showLoading();
BaseFileModel fileModel = await NetUtil().upload(API.upload.avatar, file);
if (fileModel.status == true) {
await NetUtil().post(
API.user.updateAvatar,
params: {
'fileUrls': [fileModel.url],
},
showMessage: true,
);
await updateProfile();
cancel();
notifyListeners(); notifyListeners();
} }
}
/// ///
setTel(String tel) { setTel(String tel) {

@ -1,4 +1,6 @@
// Flutter imports: // Flutter imports:
import 'dart:io';
import 'package:aku_community_manager/tools/aku_divider.dart'; import 'package:aku_community_manager/tools/aku_divider.dart';
import 'package:aku_community_manager/ui/settings/nick_name_change_page.dart'; import 'package:aku_community_manager/ui/settings/nick_name_change_page.dart';
import 'package:aku_community_manager/ui/settings/tel_change_page.dart'; import 'package:aku_community_manager/ui/settings/tel_change_page.dart';
@ -35,10 +37,9 @@ class _UserInfoPageState extends State<UserInfoPage> {
padding: EdgeInsets.symmetric(vertical: 24.w), padding: EdgeInsets.symmetric(vertical: 24.w),
children: [ children: [
AkuTile( AkuTile(
onTap: () { onTap: () async {
akuPickImage().then((file) { File file = await akuPickImage();
if (file != null) userProvider.setAvatar(file); if (file != null) await userProvider.setAvatar(file);
});
}, },
title: Text('头像'), title: Text('头像'),
height: 168.w, height: 168.w,
@ -55,9 +56,7 @@ class _UserInfoPageState extends State<UserInfoPage> {
AkuTile( AkuTile(
onTap: () async { onTap: () async {
await TelChangePage().to(); await TelChangePage().to();
setState(() { setState(() {});
});
}, },
title: Text('手机'), title: Text('手机'),
suffix: Text(TextUtil.hideNumber(userProvider.profileModel.tel)), suffix: Text(TextUtil.hideNumber(userProvider.profileModel.tel)),

Loading…
Cancel
Save