头像对接完成

hmxc
小赖 4 years ago
parent b4dbc40ab8
commit 2157c18058

@ -1,6 +1,15 @@
class API {
static const String host = 'http://192.168.2.201:8804/IntelligentCommunity';
///HOST
static const String host = 'http://192.168.2.201:8804';
///
static const String baseURL = '$host/IntelligentCommunity/app';
///
static String get resource => '$host/static';
static String image(String path) => '$resource$path';
static const int networkTimeOut = 10000;
static _Login login = _Login();
static _User user = _User();

@ -2,7 +2,7 @@ import 'package:common_utils/common_utils.dart';
class UserInfoModel {
int id;
List<String> imgUrls;
String imgUrl;
String name;
String nickName;
String tel;
@ -28,7 +28,7 @@ class UserInfoModel {
UserInfoModel(
{this.id,
this.imgUrls,
this.imgUrl,
this.name,
this.nickName,
this.tel,
@ -37,23 +37,12 @@ class UserInfoModel {
UserInfoModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
imgUrls = json['imgUrls'].cast<String>();
if (json['imgUrls'] != null)
imgUrl = (json['imgUrls'] as List).first['url'];
name = json['name'];
nickName = json['nickName'];
tel = json['tel'];
sex = json['sex'];
birthday = json['birthday'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['imgUrls'] = this.imgUrls;
data['name'] = this.name;
data['nickName'] = this.nickName;
data['tel'] = this.tel;
data['sex'] = this.sex;
data['birthday'] = this.birthday;
return data;
}
}

@ -1,4 +1,5 @@
import 'package:akuCommunity/const/resource.dart';
import 'package:akuCommunity/constants/api.dart';
import 'package:akuCommunity/pages/activities_page/activities_page.dart';
import 'package:akuCommunity/pages/address_page/address_page.dart';
import 'package:akuCommunity/pages/life_pay/life_pay_page.dart';
@ -118,14 +119,16 @@ class _PersonalIndexState extends State<PersonalIndex>
margin: EdgeInsets.only(left: 32.w),
child: Row(
children: [
Container(
Hero(
tag: 'AVATAR',
child: ClipOval(
child: CachedImageWrapper(
url:
'https://dss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1851283359,3457678391&fm=26&gp=0.jpg',
width: 106.w,
child: FadeInImage.assetNetwork(
//TODO PLACEHOLDER
placeholder: R.ASSETS_ICONS_PROPOSAL_PNG,
image: API
.image(userProvider.userInfoModel.imgUrl),
height: 106.w,
isSigned: userProvider.isSigned,
width: 106.w,
),
),
),

@ -1,6 +1,7 @@
import 'dart:io';
import 'package:akuCommunity/base/base_style.dart';
import 'package:akuCommunity/const/resource.dart';
import 'package:akuCommunity/constants/api.dart';
import 'package:akuCommunity/pages/personal/change_nick_name_page.dart';
import 'package:akuCommunity/pages/personal/update_tel_page.dart';
@ -105,7 +106,21 @@ class _UserProfilePageState extends State<UserProfilePage> {
title: '个人资料',
body: ListView(
children: [
_buildTile('头像', CircleAvatar(), onPressed: _pickAvatar),
_buildTile(
'头像',
Hero(
tag: 'AVATAR',
child: ClipOval(
child: FadeInImage.assetNetwork(
placeholder: R.ASSETS_ICONS_PROPOSAL_PNG,
image: API.image(userProvider.userInfoModel.imgUrl),
height: 56.w,
width: 56.w,
),
),
),
onPressed: _pickAvatar,
),
_buildTile(
'姓名',
userProvider.userInfoModel.name.text.make(),

@ -82,6 +82,7 @@ class SignFunc {
BaseModel baseModel = await NetUtil().get(
API.user.userDetail,
);
if (baseModel.data == null) return null;
return UserDetailModel.fromJson(baseModel.data);
}
}

@ -125,8 +125,7 @@ class UserProvider extends ChangeNotifier {
showMessage: true,
);
if (model.status) {
_userInfoModel.imgUrls = [path];
notifyListeners();
await updateProfile();
}
}
}

@ -30,7 +30,7 @@ class NetUtil {
errorMethodCount: 4,
));
BaseOptions options = BaseOptions(
baseUrl: '${API.host}/app',
baseUrl: API.baseURL,
connectTimeout: API.networkTimeOut,
receiveTimeout: API.networkTimeOut,
sendTimeout: API.networkTimeOut,
@ -172,8 +172,8 @@ class NetUtil {
_parseRequestError(BaseModel model, {bool showMessage = false}) {
final userProvider = Provider.of<UserProvider>(Get.context, listen: false);
if (!model.status && model.message == '登录失效,请登录') {
Get.offAll(SignInPage());
userProvider.logout();
Get.offAll(SignInPage());
}
if (!model.status || showMessage) {
BotToast.showText(text: model.message);

Loading…
Cancel
Save