Ejemplo n.º 1
0
        /// <summary>
        /// 获取首页相关内容信息
        /// </summary>
        /// <returns></returns>
        public async Task <HomeContentRD> GetHomeContent()
        {
            string url = "/goods/home";

            HomeContentRD homeContentRD = await RestSharpHelper <HomeContentRD> .GetAsync(url);

            return(homeContentRD);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取首页相关内容信息
        /// </summary>
        /// <returns></returns>
        public async Task <HomeContentRD> GetHomeContent()
        {
            string url = rootUrl3 + "/goods/home";

            string responseBody = await GetStringDataAsync(url);

            HomeContentRD homeContentRD = JsonConvert.DeserializeObject <HomeContentRD>(responseBody);

            return(homeContentRD);
        }
Ejemplo n.º 3
0
        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;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 获取首页相关内容信息
        /// </summary>
        /// <returns></returns>
        public static async Task <HomeContentRD> GetHomeContent()
        {
            try
            {
                string url = "/goods/home";

                HomeContentRD homeContentRD = await RestSharpHelper <HomeContentRD> .GetAsync(url);

                //HomeContentRD homeContentRD = RestSharpHelper<HomeContentRD>.Get(url);
                return(homeContentRD);
            }
            catch (ApplicationException ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 5
0
        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;
            }
        }