/// <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; } }
private async void InitCollectionPage() { try { if (!Tools.IsNetConnective()) { CrossToastPopUp.Current.ShowToastError("无网络连接,请检查网络。", ToastLength.Short); return; } string content = await RestSharpService.GetCollection(); BaseResponse baseResponse = JsonConvert.DeserializeObject <BaseResponse>(content); if (baseResponse.Flag == "fail") { CrossToastPopUp.Current.ShowToastError(baseResponse.Msg, ToastLength.Short); return; } 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); } HouseItemList = new ObservableCollection <HouseItemInfo>(list); } catch (Exception) { throw; } }