async void Load() { string uri = Config.apiCommentUserGet + Config.UserPhone; string response = await HttpGet.HttpGets(uri); if (response != null) { try { JsonArray jsonList = JsonArray.Parse(response); foreach (var item in jsonList) { JsonObject user = item.GetObject(); UserModel userModel = new UserModel(); userModel.uid = user.GetNamedString("user_phone"); userModel.name = user.GetNamedString("user_name"); userModel.image = user.GetNamedString("user_image"); userModel.day = user.GetNamedString("post_id"); //文章ID UserList.Add(userModel); } } catch (Exception ex) { HelpMethods.Msg(ex.Message.ToString()); } } }
//取消关注 private async void care_Click(object sender, RoutedEventArgs e) { Button btn = sender as Button; FollowerModel follower = btn.DataContext as FollowerModel; string uri = Config.apiUserUnFollow + Config.UserPhone + "/" + follower.cphone; string response = await HttpGet.HttpGets(uri); }
async void Find() { string uri = Config.apiUserFind + Word; string response = await HttpGet.HttpGets(uri); if (response != null) { try { JsonArray jsonList = JsonArray.Parse(response); foreach (var item in jsonList) { JsonObject user = item.GetObject(); UserModel userModel = new UserModel(); userModel.uid = user.GetNamedString("phone"); userModel.name = user.GetNamedString("name"); userModel.image = Config.apiFile + user.GetNamedString("image"); userModel.dream = user.GetNamedString("dream"); UserList.Add(userModel); } } catch (Exception ex) { HelpMethods.Msg(ex.Message.ToString()); } } }
async void Load(string id) { string uri = Config.apiUserFollowers + id; string response = await HttpGet.HttpGets(uri); try { DataContractJsonSerializer ds = new DataContractJsonSerializer(typeof(List <FollowerModel>)); MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(response)); List <FollowerModel> list = ds.ReadObject(ms) as List <FollowerModel>; List = list; } catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); } }
async void LoadComment(string id) { string response = await HttpGet.HttpGets(Config.apiCommentGet + id); if (response != null) { try { DataContractJsonSerializer ds = new DataContractJsonSerializer(typeof(ObservableCollection <CommentModel>)); MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(response)); commentsList = ds.ReadObject(ms) as ObservableCollection <CommentModel>; } catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); } } this.listview.ItemsSource = commentsList; }
async void LoadPost(string id) { string response = await HttpGet.HttpGets(Config.apiDreamingOne + id); if (response != null) { try { DataContractJsonSerializer ds = new DataContractJsonSerializer(typeof(DreamingModel)); MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(response)); dreaming = ds.ReadObject(ms) as DreamingModel; postGrid.DataContext = dreaming; } catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); } } }
async void UserInit() { if (Config.IsNetWork) { string uri = Config.apiUserInfo + Config.UserPhone; string response = await HttpGet.HttpGets(uri); if (response != null) { try { JsonObject user = JsonObject.Parse(response); UserName = user.GetNamedString("name"); UserImage = Config.apiFile + user.GetNamedString("image"); UserDream = user.GetNamedString("dream"); UserCare = (int)user.GetNamedNumber("follow_count"); UserFollow = (int)user.GetNamedNumber("fans_count"); UserPost = (int)user.GetNamedNumber("post_count"); Config.UserTag = user.GetNamedString("tag"); Config.UserImage = Config.apiFile + user.GetNamedString("image"); Config.UserName = UserName; Config.UserDream = UserDream; Config.UserCare = UserCare; Config.UserFollow = UserFollow; Config.UserPost = UserPost; } catch (Exception ex) { HelpMethods.Msg(ex.Message.ToString()); } } } else { UserName = Config.UserName; UserImage = Config.UserLocalImage; UserDream = Config.UserDream; UserCare = Config.UserCare; UserFollow = Config.UserFollow; UserPost = Config.UserPost; } }
public async void Load(string id) { string uri = Config.apiUserInfo + id; string response = await HttpGet.HttpGets(uri); try { JsonObject user = JsonObject.Parse(response); userId = user.GetNamedString("phone"); UserImage = Config.apiFile + user.GetNamedString("image"); UserName = user.GetNamedString("name"); UserDay = user.GetNamedString("date"); UserDream = user.GetNamedString("dream"); User = new UserModel { uid = userId, name = UserName, image = UserImage, dream = UserDream, day = UserDay }; } catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); } string dreamingUri = Config.apiDreamingUserId + id; string dreamingResponse = await HttpGet.HttpGets(dreamingUri); try { DataContractJsonSerializer ds = new DataContractJsonSerializer(typeof(List <DreamingModel>)); MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(dreamingResponse)); List <DreamingModel> dreaming = ds.ReadObject(ms) as List <DreamingModel>; DreamingList = dreaming; } catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); } }