/// <summary> /// 显示本地用户详情 /// </summary> /// <param name="userId">UserId</param> private void ShowLocalUserDetial(string userId) { var tmpFri = new DataOfFriends() { toUserId = userId }.GetByUserId(); if (tmpFri != null) { Friend = tmpFri.ToDataOfUserDetial(); Friend.sex = -1; //好友列表中无性别 Friend.birthday = 0; //无生日数据 RemarkName = Friend.remarkName; } var dclient = APIHelper.GetUserDetialAsync(userId);//详情 //LogHelper.log.Info("用户详情GetUserDetial" + userId); dclient.UploadDataCompleted += (s, res) => { if (res.Error == null) { var user = JsonConvert.DeserializeObject <JsonuserDetial>(Encoding.UTF8.GetString(res.Result)); var tmpfriend = user.data.ConvertToDataFriend(); if (tmpfriend != null) { int status = Friend.status; //暂时保存好友关系 Friend = user.data; //显示数据 Friend.status = status; //重新赋值正确好友关系 if (!string.IsNullOrWhiteSpace(user.data._remarkName)) { RemarkName = user.data._remarkName; } else { RemarkName = Friend.friends.remarkName; } var resfriend = new DataOfFriends(); resfriend = user.data.ToDataOfFriend(); //resfriend.status = 2;//设置为朋友 resfriend.AutoInsert(); if (Friend.remarkName != user.data.remarkName) { //刷新 Messenger.Default.Send(new MessageListItem { Jid = user.data.userId, ShowTitle = user.data._remarkName, Avator = Applicate.LocalConfigData.GetDisplayAvatorPath(user.data.userId) }, MainViewNotifactions.UpdateAccountName); } } } else { Snackbar.Enqueue(res.Error.Message); } }; }
/// <summary> /// 显示陌生人详情 /// </summary> /// <param name="userId">UserId</param> private void ShowStrangerDetial(string userId) { var dclient = APIHelper.GetUserDetialAsync(userId);//详情 LogHelper.log.Info("陌生用户GetUserDetial" + userId); dclient.UploadDataCompleted += (s, res) => { var user = JsonConvert.DeserializeObject <JsonuserDetial>(Encoding.UTF8.GetString(res.Result)); var tmpFri = user.data.ConvertToDataFriend(); if (tmpFri != null) { Friend = user.data; var downloads = new List <DownLoadFile>(); downloads.Add(new DownLoadFile() { Jid = userId, Token = userId, Name = user.data.nickname, Type = DownLoadFileType.Image, LocalUrl = Applicate.LocalConfigData.GetDownloadAvatorPath(userId), ShouldDeleteWhileFileExists = true }); //下载头像 HttpDownloader.Download(downloads, (file) => { switch (file.State) { case DownloadState.Successed: App.Current.Dispatcher.Invoke(() => { Friend.userId = file.Jid; }); break; case DownloadState.Error: break; default: break; } }); if (!string.IsNullOrWhiteSpace(user.data._remarkName)) { RemarkName = user.data._remarkName; } else { RemarkName = Friend.remarkName; } var stranger = new DataOfFriends(); stranger = user.data.ToDataOfFriend(); stranger.status = 0; stranger.AutoInsert(); } }; }