Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        private async void GetHouseList(string cityPinYin, string pageNum, string pageSize)
        {
            try
            {
                IsLoading = true;
                if (!Tools.IsNetConnective())
                {
                    CrossToastPopUp.Current.ShowToastError("无网络连接,请检查网络。", ToastLength.Short);
                    return;
                }

                //SaleHousePara.SearchContent = SearchContent;
                //HouseRD houseRD = await RestSharpService.GetHouseAsync(SaleHousePara, SortType);
                string content = await RestSharpService.GetHouseAsync(cityPinYin, pageNum, pageSize);

                if (string.IsNullOrWhiteSpace(content))
                {
                    CrossToastPopUp.Current.ShowToastError("服务器错误", ToastLength.Short);
                    return;
                }

                JObject jObject = JObject.Parse(content);

                if (jObject["code"].ToString() == "200")
                {
                    PageNum   = jObject["data"]["pageNum"].ToString();
                    PageSize  = jObject["data"]["pageSize"].ToString();
                    TotalPage = jObject["data"]["totalPage"].ToString();
                    Total     = jObject["data"]["total"].ToString();

                    IsEnable = !(PageNum == TotalPage);

                    List <HouseInfo2> houseInfoList = JsonConvert.DeserializeObject <List <HouseInfo2> >(jObject["data"]["list"].ToString());

                    foreach (var h in houseInfoList)
                    {
                        HouseItemList.Add(h);
                    }
                }
                IsLoading = false;
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #2
0
        /// <summary>
        /// 获取房源列表
        /// </summary>
        private async void GetHouseList()
        {
            try
            {
                if (!Tools.IsNetConnective())
                {
                    CrossToastPopUp.Current.ShowToastError("无网络连接,请检查网络。", ToastLength.Short);
                    return;
                }

                SaleHousePara.SearchContent = SearchContent;
                string content = await RestSharpService.GetHouseAsync(SaleHousePara, "出售");

                if (string.IsNullOrWhiteSpace(content))
                {
                    CrossToastPopUp.Current.ShowToastError("服务器错误", ToastLength.Short);
                    return;
                }

                BaseResponse baseResponse = JsonConvert.DeserializeObject <BaseResponse>(content);

                if (baseResponse.Flag == "success")
                {
                    List <HouseInfo> houseList = JsonConvert.DeserializeObject <List <HouseInfo> >(baseResponse.Result.ToString());

                    List <HouseItemInfo> list = new List <HouseItemInfo>();
                    foreach (var h in houseList)
                    {
                        HouseItemInfo houseItemInfo = new HouseItemInfo
                        {
                            //houseItemInfo.HouseTitle = h.Title == "" ? h.DistrictName + " " + h.AreaName + " " + h.EstateName : h.Title;
                            HouseTitle = h.DistrictName + " " + h.AreaName + " " + h.EstateName,
                            RoomStyle  = ((h.CountF.Length == 0 || h.CountF == " ") ? "-" : h.CountF) + "室"
                                         + ((h.CountT.Length == 0 || h.CountT == " ") ? "-" : h.CountT) + "厅"
                                         + ((h.CountW.Length == 0 || h.CountW == " ") ? "-" : h.CountW) + "卫",
                            Square      = (h.Square.Length > 5 ? h.Square.Substring(0, 5) : h.Square) + "㎡",
                            EstateName  = h.EstateName,
                            Price       = h.Price.Substring(0, h.Price.Length - 2) + "万元",
                            SinglePrice = h.Trade == "出售" ? h.RentPrice.Substring(0, h.RentPrice.Length - 2) + "元/平" : "",
                            PhotoUrl    = (h.PhotoUrl == "" ? "NullPic.jpg" : h.PhotoUrl),
                            PropertyID  = h.PropertyID
                        };

                        switch (h.Privy)
                        {
                        case "0": houseItemInfo.PanType = "公盘"; break;

                        case "1": houseItemInfo.PanType = "私盘"; break;

                        case "2": houseItemInfo.PanType = "特盘"; break;

                        default: houseItemInfo.PanType = "封盘"; break;
                        }

                        houseItemInfo.PropertyDecoration = h.PropertyDecoration;
                        houseItemInfo.PropertyLook       = h.PropertyLook;

                        list.Add(houseItemInfo);
                    }

                    saleHouseList.Clear();
                    saleHouseItemList.Clear();
                    HouseItemList.Clear();

                    saleHouseList.AddRange(houseList);
                    saleHouseItemList.AddRange(list);
                    saleHouseItemList.ForEach(item => { HouseItemList.Add(item); });

                    CrossToastPopUp.Current.ShowToastSuccess(baseResponse.Msg, ToastLength.Short);
                }
                else
                {
                    CrossToastPopUp.Current.ShowToastWarning(baseResponse.Msg, ToastLength.Short);
                    return;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }