对接修改头像接口

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

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

@ -2,6 +2,8 @@
import 'dart:io';
// 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';
// Project imports:
@ -87,20 +89,34 @@ class UserProvider extends ChangeNotifier {
_isSigned = true;
notifyListeners();
}
///
///
setNickName(String name) {
_infoModel.nickName = name;
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();
}
}
///
setTel(String tel){
_profileModel.tel=tel;
setTel(String tel) {
_profileModel.tel = tel;
notifyListeners();
}
}

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

Loading…
Cancel
Save