///?userCode=xxx&avatarUrl=xxx&nickName=xxx
Future<String> _formatUrl(String oldUrl) async {
if (oldUrl != null && oldUrl.isNotEmpty == true) {
String _userCode;
String _avatarUrl;
String _nickName;
UserInfoModel _user = await UserManager.getUserInfo();
if (_user != null) {
_userCode = _user?.resultData?.organization?.organizationId?.toString();
_nickName = _user?.resultData?.organization?.organizationName;
String _userHead = _user?.resultData?.user?.portraitUrl ?? "";
if (_userHead.contains('https://wx.qlogo.cn/')) {
_avatarUrl = _userHead;
} else {
_avatarUrl = ImgSize.getImgUrlBySize(_userHead);
}
String _suffix;
if (oldUrl.contains("?")) {
_suffix =
'&userCode=$_userCode&avatarUrl=$_avatarUrl&nickName=${Uri.encodeComponent(_nickName)}';
} else {
_suffix =
'?userCode=$_userCode&avatarUrl=$_avatarUrl&nickName=${Uri.encodeComponent(_nickName)}';
}
return '$oldUrl$_suffix';
} else {
return oldUrl;
}
} else {
return oldUrl;
}
}
中文需要用Uri.encodeComponent转码