/// <summary> /// 初始化 /// </summary> private async void InitCategories() { try { if (!Tools.IsNetConnective()) { CrossToastPopUp.Current.ShowToastError("无网络连接,请检查网络。", ToastLength.Long); return; } RestSharpService _restSharpService = new RestSharpService(); CategoryRD categoryRD = await _restSharpService.GetCategories(); categoryViewModel.categoryList = categoryRD.result; foreach (var item in categoryViewModel.categoryList) { if (item.isParent) { categoryViewModel.ParentCategoryList.Add(item); } } ParentStack.Children[0].Behaviors[0].SetValue(RadioBehavior.IsCheckedProperty, true); categoryViewModel.GetSubCategories(categoryViewModel.ParentCategoryList[0].id); } catch (Exception) { throw; } }
/// <summary> /// 初始化 /// </summary> private async void InitCategories() { try { if (!Tools.IsNetConnective()) { CrossToastPopUp.Current.ShowToastError("无网络连接,请检查网络。", ToastLength.Long); return; } //RestSharpService _restSharpService = new RestSharpService(); CategoryRD categoryRD = await RestSharpService.GetCategories(); List <Category> categoryList = categoryRD.result; foreach (var item in categoryList) { if (!item.isParent) { SubCategoryList.Add(item); } } } catch (Exception) { throw; } }
/// <summary> /// 获取分类列表 /// </summary> /// <returns></returns> public async Task <CategoryRD> GetCategories() { string url = "/goods/SearchAllItemCat"; CategoryRD categoryRD = await RestSharpHelper <CategoryRD> .GetAsync(url); return(categoryRD); }
/// <summary> /// 获取分类列表 /// </summary> /// <returns></returns> public async Task <CategoryRD> GetCategories() { string url = rootUrl3 + "/goods/SearchAllItemCat"; string responseBody = await GetStringDataAsync(url); CategoryRD categoryRD = JsonConvert.DeserializeObject <CategoryRD>(responseBody); return(categoryRD); }
private async void InitHomePage() { try { if (!Tools.IsNetConnective()) { CrossToastPopUp.Current.ShowToastError("无网络连接,请检查网络。", ToastLength.Long); return; } RestSharpService _restSharpService = new RestSharpService(); HomeContentRD homeContentRD = await _restSharpService.GetHomeContent(); CategoryRD categoryRD = await _restSharpService.GetCategories(); //CarouselList = homeContentRD.result[0].panelContents.ToList<HomePanelContent>(); HotProductList = homeContentRD.result[1].panelContents.ToList <HomePanelContent>(); //OfficialChoiceList = homeContentRD.result[2].panelContents.ToList<HomePanelContent>(); //GoodBrandList = homeContentRD.result[3].panelContents.ToList<HomePanelContent>(); //BrandChoiceList = homeContentRD.result[4].panelContents.ToList<HomePanelContent>(); CarouselList = new List <HomePanelContent> { new HomePanelContent { picUrl = "sanye.png", fullUrl = "http://www.sanecn.com/" }, new HomePanelContent { picUrl = "bianselong.jpg", fullUrl = "http://www.cdbsljs.com/" }, new HomePanelContent { picUrl = "jiabei.jpg", fullUrl = "http://www.cdbsljs.com/" } }; List <Category> temp = new List <Category>(); foreach (var item in categoryRD.result) { if (!item.isParent) { temp.Add(item); } } CatList = temp.GetRange(0, 10); } catch (Exception) { throw; } }
/// <summary> /// 获取分类列表 /// </summary> /// <returns></returns> public static async Task <CategoryRD> GetCategories() { try { string url = "/goods/SearchAllItemCat"; CategoryRD categoryRD = await RestSharpHelper <CategoryRD> .GetAsync(url); return(categoryRD); } catch (ApplicationException ex) { throw ex; } }
/// <summary> /// 初始化 /// </summary> private async void InitCategories() { try { if (!Tools.IsNetConnective()) { CrossToastPopUp.Current.ShowToastError("无网络连接,请检查网络。", ToastLength.Long); return; } RestSharpService _restSharpService = new RestSharpService(); CategoryRD categoryRD = await _restSharpService.GetCategories(); categoryList = categoryRD.result; foreach (var item in categoryList) { if (item.isParent) { ParentCategoryList.Add(item); } } //ParentStack.Children[0].Behaviors[0].SetValue(RadioBehavior.IsCheckedProperty, true); //GetSubCategories(0); //Application.Current.MainPage.FindByName<StackLayout>("ParentStack").Children[0].Behaviors[0].SetValue(RadioBehavior.IsCheckedProperty, true); //GetSubCategories(ParentCategoryList[0].id); //ParentCategoryList[0].Checked = true; //GetSubCategories(ParentCategoryList[0].id); } catch (Exception) { throw; } }
private async void InitHomePage() { try { if (!Tools.IsNetConnective()) { CrossToastPopUp.Current.ShowToastError("无网络连接,请检查网络。", ToastLength.Long); return; } string result1 = await RestSharpHelper <string> .GetAsyncWithoutDeserialization("/goods/home"); if (!string.IsNullOrWhiteSpace(result1)) { HomeContentRD homeContentRD = JsonConvert.DeserializeObject <HomeContentRD>(result1); HotProductList = homeContentRD.result[1].panelContents.ToList(); await LocalDatabaseHelper <HomePanelContent> .InsertByList(HotProductList); } else { HotProductList = await LocalDatabaseHelper <HomePanelContent> .GetAllItems(); } string result2 = await RestSharpHelper <string> .GetAsyncWithoutDeserialization("/goods/SearchAllItemCat"); if (!string.IsNullOrWhiteSpace(result2)) { CategoryRD categoryRD = JsonConvert.DeserializeObject <CategoryRD>(result2); List <Category> temp = new List <Category>(); foreach (var item in categoryRD.result) { if (!item.isParent) { temp.Add(item); } } await LocalDatabaseHelper <Category> .InsertByList(categoryRD.result); CatList = temp.GetRange(0, 10); } else { List <Category> temp = new List <Category>(); List <Category> localCategoryList = await LocalDatabaseHelper <Category> .GetAllItems(); foreach (var item in localCategoryList) { if (!item.isParent) { temp.Add(item); } } CatList = temp.GetRange(0, 10); } //RestSharpService _restSharpService = new RestSharpService(); //HomeContentRD homeContentRD = await RestSharpService.GetHomeContent(); //CategoryRD categoryRD = await RestSharpService.GetCategories(); //CarouselList = homeContentRD.result[0].panelContents.ToList<HomePanelContent>(); //HotProductList = homeContentRD.result[1].panelContents.ToList<HomePanelContent>(); //OfficialChoiceList = homeContentRD.result[2].panelContents.ToList<HomePanelContent>(); //GoodBrandList = homeContentRD.result[3].panelContents.ToList<HomePanelContent>(); //BrandChoiceList = homeContentRD.result[4].panelContents.ToList<HomePanelContent>(); CarouselList = new List <HomePanelContent> { new HomePanelContent { picUrl = "sanye.png", fullUrl = "http://www.sanecn.com/" }, new HomePanelContent { picUrl = "bianselong.jpg", fullUrl = "http://www.cdbsljs.com/" }, new HomePanelContent { picUrl = "jiabei.jpg", fullUrl = "http://www.cdbsljs.com/" } }; //List<Category> temp = new List<Category>(); //foreach (var item in categoryRD.result) //{ // if (!item.isParent) // { // temp.Add(item); // } //} //CatList = temp.GetRange(0, 10); } catch (Exception) { throw; } }