private async void LoadUser() { try { pr_Load.Visibility = Visibility.Visible; loading = true; string uri = ""; if (pageNum == 1) { ls_items.Items.Clear(); } uri = string.Format("https://picaapi.picacomic.com/comics?page={1}&ca={0}", name, pageNum); string results = await WebClientClass.GetResults(new Uri(uri)); ComicsModel lists = JsonConvert.DeserializeObject <ComicsModel>(results); if (lists.code == 200) { if (lists.data.comics.docs.Count != 0) { lists.data.comics.docs.ForEach(x => ls_items.Items.Add(x)); pageNum++; } else { messShow.Show("沒有更多了", 2000); } } else { messShow.Show(lists.message, 2000); } } catch (Exception ex) { if (ex.HResult == -2147012867) { messShow.Show("檢查你的網絡連接!", 3000); } else { messShow.Show("讀取信息失敗了,挂個VPN試試?", 3000); } } finally { pr_Load.Visibility = Visibility.Collapsed; loading = false; } }
private async void LoadData() { try { pr_Load.Visibility = Visibility.Visible; loading = true; string uri = ""; if (pageNum == 1) { ls_items.Items.Clear(); } switch (name) { case "隨機本子": uri = "https://picaapi.picacomic.com/comics/random?page=" + pageNum; break; case "最近更新": //https://picaapi.picacomic.com/comics?page=1&s=ua uri = "https://picaapi.picacomic.com/comics?page=" + pageNum + "&s=ua"; break; default: uri = string.Format("https://picaapi.picacomic.com/comics?page={1}&c={0}&s=ua", Uri.EscapeDataString(name), pageNum); break; } string results = await WebClientClass.GetResults(new Uri(uri)); ComicsModel lists = JsonConvert.DeserializeObject <ComicsModel>(results); if (lists.code == 200) { if (lists.data.comics.docs.Count != 0) { lists.data.comics.docs.ForEach(x => ls_items.Items.Add(x)); pageNum++; } else { messShow.Show("沒有更多了", 2000); } } else { messShow.Show(lists.message, 2000); } } catch (Exception ex) { if (ex.HResult == -2147012867) { messShow.Show("檢查你的網絡連接!", 3000); } else { messShow.Show("讀取信息失敗了,挂個VPN試試?", 3000); } } finally { pr_Load.Visibility = Visibility.Collapsed; loading = false; } }