@@ -710,7 +710,7 @@ | |||||
"languageVersion": "2.1" | "languageVersion": "2.1" | ||||
} | } | ||||
], | ], | ||||
"generated": "2020-09-16T07:59:23.044545Z", | |||||
"generated": "2020-09-17T03:20:15.312540Z", | |||||
"generator": "pub", | "generator": "pub", | ||||
"generatorVersion": "2.7.2" | "generatorVersion": "2.7.2" | ||||
} | } |
@@ -1,4 +1,5 @@ | |||||
import 'dart:async'; | import 'dart:async'; | ||||
import 'dart:convert' as convert; | |||||
import 'dart:io'; | import 'dart:io'; | ||||
import 'package:fluttertoast/fluttertoast.dart'; | import 'package:fluttertoast/fluttertoast.dart'; | ||||
@@ -37,12 +38,17 @@ class MineDetailBloc extends BlocBase { | |||||
} | } | ||||
/* 更新用户信息 | /* 更新用户信息 | ||||
avatar 头像url | |||||
nickname 昵称 | nickname 昵称 | ||||
gender 性别(1女2男3未知) | gender 性别(1女2男3未知) | ||||
birthday 生日(时间戳) | birthday 生日(时间戳) | ||||
* */ | * */ | ||||
void updateUser({String nickname, String gender, String birthday}) { | |||||
void updateUser( | |||||
{String avatar, String nickname, String gender, String birthday}) { | |||||
Map<String, dynamic> params = Map(); | Map<String, dynamic> params = Map(); | ||||
if (avatar != null && avatar != '') { | |||||
params['avatar'] = avatar; | |||||
} | |||||
if (nickname != null && nickname != '') { | if (nickname != null && nickname != '') { | ||||
params['nickname'] = nickname; | params['nickname'] = nickname; | ||||
} | } | ||||
@@ -70,14 +76,35 @@ class MineDetailBloc extends BlocBase { | |||||
params['dir'] = 'avatar'; | params['dir'] = 'avatar'; | ||||
params['file_size'] = originBytes.length; | params['file_size'] = originBytes.length; | ||||
params['file_name'] = basename(file.path); | params['file_name'] = basename(file.path); | ||||
NetUtil.request('/api/v1/file/upload', | |||||
NetUtil.request('/api/v1/img/upload', | |||||
method: NetMethod.PUT, | method: NetMethod.PUT, | ||||
params: params, | params: params, | ||||
onCache: (data) {}, onSuccess: (data) { | |||||
onCache: (data) {}, onSuccess: (data) async { | |||||
String method = data['method']; | String method = data['method']; | ||||
String host = data['host']; | String host = data['host']; | ||||
String key = data['key']; | String key = data['key']; | ||||
String token = data['token']; | String token = data['token']; | ||||
var result = await NetUtil.uploadFile(host, file, | |||||
params: { | |||||
'key': key, | |||||
'token': token, | |||||
}, | |||||
method: method); | |||||
print(result.toString()); | |||||
Map<String, dynamic> json = convert.jsonDecode(result.toString()); | |||||
String filename = json['fname'] ?? ''; | |||||
print(filename); | |||||
String imageUrl = | |||||
'${_user.fileBucketUrl.toString()}${filename.toString()}'; | |||||
if (_user.format != null && _user.format != '') { | |||||
imageUrl += _user.format; | |||||
imageUrl += '/${DateTime.now().millisecondsSinceEpoch.toString()}'; | |||||
} else { | |||||
imageUrl += '?${DateTime.now().millisecondsSinceEpoch.toString()}'; | |||||
} | |||||
updateUser(avatar: imageUrl); | |||||
}); | }); | ||||
} | } | ||||
} | } |
@@ -19,12 +19,20 @@ class MineDetailModel extends Object { | |||||
@JsonKey(name: 'register_time') | @JsonKey(name: 'register_time') | ||||
String registerTime; | String registerTime; | ||||
@JsonKey(name: 'file_bucket_url') | |||||
String fileBucketUrl; | |||||
@JsonKey(name: 'file_format') | |||||
String format; | |||||
MineDetailModel( | MineDetailModel( | ||||
this.avatar, | this.avatar, | ||||
this.nickname, | this.nickname, | ||||
this.gender, | this.gender, | ||||
this.birthday, | this.birthday, | ||||
this.registerTime, | this.registerTime, | ||||
this.fileBucketUrl, | |||||
this.format, | |||||
); | ); | ||||
factory MineDetailModel.fromJson(Map<String, dynamic> srcJson) => | factory MineDetailModel.fromJson(Map<String, dynamic> srcJson) => | ||||
@@ -13,6 +13,8 @@ MineDetailModel _$MineDetailModelFromJson(Map<String, dynamic> json) { | |||||
json['gender'] as String, | json['gender'] as String, | ||||
json['birthday'] as String, | json['birthday'] as String, | ||||
json['register_time'] as String, | json['register_time'] as String, | ||||
json['file_bucket_url'] as String, | |||||
json['file_format'] as String, | |||||
); | ); | ||||
} | } | ||||
@@ -23,4 +25,6 @@ Map<String, dynamic> _$MineDetailModelToJson(MineDetailModel instance) => | |||||
'gender': instance.gender, | 'gender': instance.gender, | ||||
'birthday': instance.birthday, | 'birthday': instance.birthday, | ||||
'register_time': instance.registerTime, | 'register_time': instance.registerTime, | ||||
'file_bucket_url': instance.fileBucketUrl, | |||||
'file_format': instance.format, | |||||
}; | }; |
@@ -52,9 +52,15 @@ class _MineHeaderContainerState extends State<MineHeaderContainer> { | |||||
left: 20, top: 20, bottom: 20, right: 12), | left: 20, top: 20, bottom: 20, right: 12), | ||||
width: 56, | width: 56, | ||||
height: 56, | height: 56, | ||||
child: CachedNetworkImage( | |||||
imageUrl: profile.avatar, | |||||
fit: BoxFit.cover, | |||||
decoration: BoxDecoration( | |||||
color: Color(0xfff3f3f3), | |||||
borderRadius: BorderRadius.circular(28)), | |||||
child: ClipRRect( | |||||
borderRadius: BorderRadius.circular(28), | |||||
child: CachedNetworkImage( | |||||
imageUrl: profile.avatar, | |||||
fit: BoxFit.cover, | |||||
), | |||||
), | ), | ||||
), | ), | ||||
onTap: () { | onTap: () { | ||||