头像对接完成

hmxc
小赖 4 years ago
parent b4dbc40ab8
commit 2157c18058

@ -1,6 +1,15 @@
class API { 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 get resource => '$host/static';
static String image(String path) => '$resource$path';
static const int networkTimeOut = 10000; static const int networkTimeOut = 10000;
static _Login login = _Login(); static _Login login = _Login();
static _User user = _User(); static _User user = _User();

@ -2,7 +2,7 @@ import 'package:common_utils/common_utils.dart';
class UserInfoModel { class UserInfoModel {
int id; int id;
List<String> imgUrls; String imgUrl;
String name; String name;
String nickName; String nickName;
String tel; String tel;
@ -28,7 +28,7 @@ class UserInfoModel {
UserInfoModel( UserInfoModel(
{this.id, {this.id,
this.imgUrls, this.imgUrl,
this.name, this.name,
this.nickName, this.nickName,
this.tel, this.tel,
@ -37,23 +37,12 @@ class UserInfoModel {
UserInfoModel.fromJson(Map<String, dynamic> json) { UserInfoModel.fromJson(Map<String, dynamic> json) {
id = json['id']; id = json['id'];
imgUrls = json['imgUrls'].cast<String>(); if (json['imgUrls'] != null)
imgUrl = (json['imgUrls'] as List).first['url'];
name = json['name']; name = json['name'];
nickName = json['nickName']; nickName = json['nickName'];
tel = json['tel']; tel = json['tel'];
sex = json['sex']; sex = json['sex'];
birthday = json['birthday']; 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/const/resource.dart';
import 'package:akuCommunity/constants/api.dart';
import 'package:akuCommunity/pages/activities_page/activities_page.dart'; import 'package:akuCommunity/pages/activities_page/activities_page.dart';
import 'package:akuCommunity/pages/address_page/address_page.dart'; import 'package:akuCommunity/pages/address_page/address_page.dart';
import 'package:akuCommunity/pages/life_pay/life_pay_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), margin: EdgeInsets.only(left: 32.w),
child: Row( child: Row(
children: [ children: [
Container( Hero(
tag: 'AVATAR',
child: ClipOval( child: ClipOval(
child: CachedImageWrapper( child: FadeInImage.assetNetwork(
url: //TODO PLACEHOLDER
'https://dss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1851283359,3457678391&fm=26&gp=0.jpg', placeholder: R.ASSETS_ICONS_PROPOSAL_PNG,
width: 106.w, image: API
.image(userProvider.userInfoModel.imgUrl),
height: 106.w, height: 106.w,
isSigned: userProvider.isSigned, width: 106.w,
), ),
), ),
), ),

@ -1,6 +1,7 @@
import 'dart:io'; import 'dart:io';
import 'package:akuCommunity/base/base_style.dart'; import 'package:akuCommunity/base/base_style.dart';
import 'package:akuCommunity/const/resource.dart';
import 'package:akuCommunity/constants/api.dart'; import 'package:akuCommunity/constants/api.dart';
import 'package:akuCommunity/pages/personal/change_nick_name_page.dart'; import 'package:akuCommunity/pages/personal/change_nick_name_page.dart';
import 'package:akuCommunity/pages/personal/update_tel_page.dart'; import 'package:akuCommunity/pages/personal/update_tel_page.dart';
@ -105,7 +106,21 @@ class _UserProfilePageState extends State<UserProfilePage> {
title: '个人资料', title: '个人资料',
body: ListView( body: ListView(
children: [ 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( _buildTile(
'姓名', '姓名',
userProvider.userInfoModel.name.text.make(), userProvider.userInfoModel.name.text.make(),

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

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

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

Loading…
Cancel
Save