protected override void OnNavigatedTo(NavigationEventArgs e) { HardwareButtons.BackPressed += HardwareButtons_BackPressed;//注册重写后退按钮事件 UmengSDK.UmengAnalytics.TrackPageStart("DetailDatePage"); //先显示传进来的数据 datelistNavigate = (DateList)e.Parameter; DetailNameTextBlock.Text = datelistNavigate.nickname; if (datelistNavigate.gender == "1") DetailGenderImage.Source = new BitmapImage(new Uri("ms-appx:///Assets/ic_man.png", UriKind.Absolute)); else if ((datelistNavigate.gender == "2")) DetailGenderImage.Source = new BitmapImage(new Uri("ms-appx:///Assets/ic_woman.png", UriKind.Absolute)); DetailSignatureTextBlock.Text = datelistNavigate.signature; DetailTitleTextBlock.Text = datelistNavigate.title; DetailPlaceTextBlock.Text = datelistNavigate.place; DetailTimeTextBlock.Text = datelistNavigate.date_time; DetailCostTextBlock.Text = datelistNavigate.cost_model; DetailHeadImage.ImageSource = new BitmapImage(new Uri(datelistNavigate.head, UriKind.Absolute)); if (e.NavigationMode == NavigationMode.Back) getDateInfo(2); else getDateInfo(1); }
/// <summary> /// 收藏的网络请求 /// </summary> private async void getMyCollect(int ch, int cc) { string collect = ""; DateListProgressStackPanel.Visibility = Visibility.Visible; if (cc == 1) { List<KeyValuePair<String, String>> paramList = new List<KeyValuePair<String, String>>(); paramList.Add(new KeyValuePair<string, string>("uid", appSetting.Values["uid"].ToString())); paramList.Add(new KeyValuePair<string, string>("token", appSetting.Values["token"].ToString())); if (ch == 1) collect = Utils.ConvertUnicodeStringToChinese(await NetWork.getHttpWebRequest("/person/collection", paramList)); else collect = Utils.ConvertUnicodeStringToChinese(await NetWork.getHttpWebRequest("/person/join", paramList)); App.CacheString3 = collect; } else collect = App.CacheString3; Debug.WriteLine("collect" + collect); try { if (collect != "") { JObject obj = JObject.Parse(collect); if (Int32.Parse(obj["status"].ToString()) == 200) { JArray dateListArray = Utils.ReadJso(collect); for (int i = 0; i < dateListArray.Count; i++) { JObject jobj = (JObject)dateListArray[i]; DateList d = new DateList(); d.Date_id = (Int32)jobj["date_id"]; d.Head = jobj["head"].ToString(); d.Nickname = jobj["nickname"].ToString(); if (jobj["gender"].ToString() == "1") d.Gender = "ms-appx:///Assets/ic_man.png"; else if ((jobj["gender"].ToString() == "2")) d.Gender = "ms-appx:///Assets/ic_woman.png"; d.Signature = jobj["signature"].ToString(); d.Title = jobj["title"].ToString(); d.Place = jobj["place"].ToString(); d.Date_time = Utils.GetTime(jobj["date_time"].ToString()).ToString(); d.Created_at = Utils.GetTime(jobj["created_at"].ToString()).ToString(); if (jobj["cost_model"].ToString() == "1") d.Cost_model = "AA"; else if ((jobj["cost_model"].ToString() == "2")) d.Cost_model = "你请客"; else if ((jobj["cost_model"].ToString() == "3")) d.Cost_model = "我买单"; else d.Cost_model = "AA"; mdatelist.Add(d); } dateListView.ItemsSource = mdatelist; DateListProgressStackPanel.Visibility = Visibility.Collapsed; DateListFailedStackPanel.Visibility = Visibility.Collapsed; } else { DateListProgressStackPanel.Visibility = Visibility.Collapsed; DateListFailedStackPanel.Visibility = Visibility.Visible; } } else { DateListProgressStackPanel.Visibility = Visibility.Collapsed; DateListFailedStackPanel.Visibility = Visibility.Visible; } } catch (Exception) { Debug.WriteLine("主页,列表网络异常"); DateListProgressStackPanel.Visibility = Visibility.Collapsed; DateListFailedStackPanel.Visibility = Visibility.Visible; } }
private void dateListView_ItemClick(object sender, ItemClickEventArgs e) { Debug.WriteLine("你点击了:" + ((DateList)e.ClickedItem).Title); DateList datelistNavigate = new DateList(((DateList)e.ClickedItem).Date_id, ((DateList)e.ClickedItem).Head, ((DateList)e.ClickedItem).Nickname, ((DateList)e.ClickedItem).Gender, ((DateList)e.ClickedItem).Signature, ((DateList)e.ClickedItem).Title, ((DateList)e.ClickedItem).Place, ((DateList)e.ClickedItem).Date_time, ((DateList)e.ClickedItem).Cost_model); Frame.Navigate(typeof(DetailDatePage), datelistNavigate); }
/// <summary> /// 获取约会列表 /// </summary> /// <param name="date_type"></param> /// <param name="page"></param> /// <param name="order"></param> private async void getDatelist(int date_type, int page = 1, int order = 0, bool isrefresh = true) { if (isrefresh) { mdatelist.Clear(); } List<KeyValuePair<String, String>> paramList = new List<KeyValuePair<String, String>>(); paramList.Add(new KeyValuePair<string, string>("uid", appSetting.Values["uid"].ToString())); paramList.Add(new KeyValuePair<string, string>("token", appSetting.Values["token"].ToString())); paramList.Add(new KeyValuePair<string, string>("date_type", date_type.ToString())); paramList.Add(new KeyValuePair<string, string>("page", page.ToString())); paramList.Add(new KeyValuePair<string, string>("order", order.ToString())); paramList.Add(new KeyValuePair<string, string>("size", size.ToString())); string datelist = Utils.ConvertUnicodeStringToChinese(await NetWork.getHttpWebRequest("/date/datelist", paramList)); Debug.WriteLine("datelist" + datelist); try { if (datelist != "") { JObject obj = JObject.Parse(datelist); if (Int32.Parse(obj["status"].ToString()) == 200) { JArray dateListArray = Utils.ReadJso(datelist); List<DateList> mdatelistuse = new List<DateList>(); mdatelist.Clear(); for (int i = 0; i < dateListArray.Count; i++) { JObject jobj = (JObject)dateListArray[i]; DateList d = new DateList(); d.Date_id = (Int32)jobj["date_id"]; d.Head = jobj["head"].ToString(); d.Nickname = jobj["nickname"].ToString(); if (jobj["gender"].ToString() == "1") d.Gender = "ms-appx:///Assets/ic_man.png"; else if ((jobj["gender"].ToString() == "2")) d.Gender = "ms-appx:///Assets/ic_woman.png"; d.Signature = jobj["signature"].ToString(); d.Title = jobj["title"].ToString(); d.Place = jobj["place"].ToString(); d.Date_time = Utils.GetTime(jobj["date_time"].ToString()).ToString(); d.Created_at = Utils.GetTime(jobj["created_at"].ToString()).ToString(); if (jobj["cost_model"].ToString() == "1") d.Cost_model = "AA"; else if ((jobj["cost_model"].ToString() == "2")) d.Cost_model = "你请客"; else if ((jobj["cost_model"].ToString() == "3")) d.Cost_model = "我买单"; else d.Cost_model = "AA"; d.Date_type = jobj["date_type"].ToString(); if (isrefresh) mdatelistuse.Add(d); else mdatelist.Add(d); } if (isrefresh) dateListView.ItemsSource = mdatelistuse; else { if (mdatelist.Count != 0) { ListView ll = new ListView(); ll.ItemTemplate = dateListView.ItemTemplate; ll.ItemsSource = mdatelist; ll.IsItemClickEnabled = true; ll.ItemClick += dateListView_ItemClick; ll.ContainerContentChanging += dateListView_ContainerContentChanging; dateStackPanel.Children.Remove(AddDateListProgressStackPanel); dateStackPanel.Children.Add(ll); } if (mdatelist.Count < size) { IsOver = true; AddDateListProgressProgressBar.Visibility = Visibility.Collapsed; AddDateListProgressTextBlock.Text = "到底喽~"; try { dateStackPanel.Children.Add(AddDateListProgressStackPanel); } catch (Exception) { } Debug.WriteLine("加载完了"); } } DateListProgressStackPanel.Visibility = Visibility.Collapsed; DateListFailedStackPanel.Visibility = Visibility.Collapsed; } else if (isrefresh) DateListFailedStackPanel.Visibility = Visibility.Visible; else { AddDateListProgressProgressBar.Visibility = Visibility.Collapsed; AddDateListProgressTextBlock.Text = "加载失败 T_T"; } } else if (isrefresh) DateListFailedStackPanel.Visibility = Visibility.Visible; else { AddDateListProgressProgressBar.Visibility = Visibility.Collapsed; AddDateListProgressTextBlock.Text = "加载失败 T_T"; } } catch (Exception) { Debug.WriteLine("主页,列表网络异常"); if (isrefresh) DateListFailedStackPanel.Visibility = Visibility.Visible; else { AddDateListProgressProgressBar.Visibility = Visibility.Collapsed; AddDateListProgressTextBlock.Text = "加载失败 T_T"; } } }
private void MyDatesList_ItemClick(object sender, ItemClickEventArgs e) { Debug.WriteLine("你点击了:" + ((MyDate)e.ClickedItem).Title); DateList datelistNavigate = new DateList(Int32.Parse(((MyDate)e.ClickedItem).Date_id), ((MyDate)e.ClickedItem).Head, ((MyDate)e.ClickedItem).Nickname, ((MyDate)e.ClickedItem).Gender, "加载中...", ((MyDate)e.ClickedItem).Title, ((MyDate)e.ClickedItem).Place, ((MyDate)e.ClickedItem).Date_time, ((MyDate)e.ClickedItem).Cost_model); App.gotoPage = "detail"; Frame.Navigate(typeof(DetailDatePage), datelistNavigate); }