Пример #1
0
        public HouseDetailPage2(HouseInfo2 house)
        {
            InitializeComponent();

            BindingContext = new HouseDetailViewModel2(house);
        }
Пример #2
0
        public AllHouseListViewModel2()
        {
            PageSize = "20";
            PageNum  = "1";

            DistrictList  = new[] { "全部区域", "青白江区", "郫都区", "金牛区", "成华区", "高新西区", "武侯区", "锦江区", "高新区", "天府新区", "温江区", "新都区", "青羊区", "双流区", "龙泉驿区" };
            RoomStyleList = new[] { "全部房型", "1房", "2房", "3房", "4房及以上" };
            SalePriceList = new[] { "全部价格", "0-30万", "30-50万", "50-100万", "100-150万", "150-200万", "200-300万", "300-500万", "500万以上" };
            SquareList    = new[] { "全部面积", "0-20平", "20-50平", "50-100平", "100-150平", "150-200平", "200-250平", "250-500平", "500-800平", "800平以上" };

            //UsageList = new List<string> { "全部用途", "住宅", "商住", "商铺", "网店", "写字楼", "厂房", "写厂", "铺厂", "仓库", "地皮", "车位", "其他" };
            //PanTypeList = new List<string> { "全部类型", "公盘", "私盘", "特盘", "封盘" };

            District  = DistrictList[0];
            RoomStyle = RoomStyleList[0];
            SalePrice = SalePriceList[0];
            Square    = SquareList[0];

            HouseItemList = new ObservableCollection <HouseInfo2>();

            SaleHousePara = new HousePara
            {
                DistrictName  = "区域",
                CountF        = "房型",
                Price         = "价格",
                Square        = "面积",
                PropertyUsage = "用途",
                EstateName    = "",
                BuildNo       = "",
                RoomNo        = "",
                PanType       = "有效",
                Floor         = "",
                MinPrice      = "",
                MaxPrice      = "",
                EmpID         = ""
            };

            SortCommand = new Command <string>((t) =>
            {
                /*
                 * switch (t)
                 * {
                 *  //分类
                 *  case "0":
                 *      {
                 *          string result = await Application.Current.MainPage.DisplayActionSheet("分类", "取消", null, SortTypeList);
                 *          SortType = result == null || result == "取消" ? SortType : result;
                 *
                 *          if (SortType == "出售")
                 *          {
                 *              if (saleHouseItemList.Count == 0)
                 *              {
                 *                  GetHouseList();
                 *              }
                 *              else
                 *              {
                 *                  HouseItemList.Clear();
                 *                  saleHouseItemList.ForEach(item => { HouseItemList.Add(item); });
                 *              }
                 *          }
                 *          else if (SortType == "出租")
                 *          {
                 *              if (rentHouseItemList.Count == 0)
                 *              {
                 *                  GetHouseList();
                 *              }
                 *              else
                 *              {
                 *                  HouseItemList.Clear();
                 *                  rentHouseItemList.ForEach(item => { HouseItemList.Add(item); });
                 *              }
                 *          }
                 *      }
                 *      break;
                 *
                 *  //区域
                 *  case "1":
                 *      {
                 *          string result = await Application.Current.MainPage.DisplayActionSheet("区域", "取消", null, DistrictList);
                 *          District = result == null || result == "取消" ? District : result;
                 *          SaleHousePara.DistrictName = District == "全部区域" ? "区域" : District.TrimEnd('区');
                 *          GetHouseList();
                 *      }
                 *      break;
                 *
                 *  //房型
                 *  case "2":
                 *      {
                 *          string result = await Application.Current.MainPage.DisplayActionSheet("区域", "取消", null, RoomStyleList);
                 *          RoomStyle = result == null || result == "取消" ? RoomStyle : result;
                 *          SaleHousePara.CountF = RoomStyle == "全部房型" ? "房型" : RoomStyle;
                 *          GetHouseList();
                 *      }
                 *      break;
                 *
                 *  //价格
                 *  case "3":
                 *      {
                 *          string result = await Application.Current.MainPage.DisplayActionSheet("价格", "取消", null, SalePriceList);
                 *          SalePrice = result == null || result == "取消" ? SalePrice : result;
                 *          SaleHousePara.Price = SalePrice == "全部价格" ? "价格" : SalePrice;
                 *          GetHouseList();
                 *      }
                 *      break;
                 *
                 *  //面积
                 *  case "4":
                 *      {
                 *          string result = await Application.Current.MainPage.DisplayActionSheet("面积", "取消", null, SquareList);
                 *          Square = result == null || result == "取消" ? Square : result;
                 *          SaleHousePara.Square = Square == "全部面积" ? "面积" : Square;
                 *          GetHouseList();
                 *      }
                 *      break;
                 *
                 *  default:
                 *      break;
                 * }
                 */
            }, (t) => { return(true); });

            SearchCommand = new Command(() =>
            {
                //GetHouseList();
            }, () => { return(true); });

            TappedCommand = new Command <long>((h) =>
            {
                HouseInfo2 temp = new HouseInfo2();
                foreach (var item in HouseItemList)
                {
                    if (item.proId == h)
                    {
                        temp = item;
                    }
                }

                HouseDetailPage2 houseDetailPage2 = new HouseDetailPage2(temp);
                Application.Current.MainPage.Navigation.PushAsync(houseDetailPage2);
            }, (h) => { return(true); });

            LoadMoreCommand = new Command(() =>
            {
                int page = int.Parse(PageNum) + 1;
                GetHouseList("chengdu", page.ToString(), PageSize);
            }, () => { return(true); });

            GetHouseList("chengdu", PageNum, PageSize);
        }
Пример #3
0
        public HouseDetailViewModel2(HouseInfo2 houseInfo)
        {
            House = houseInfo;
            //HouseTitle = house.DistrictName + " " + house.AreaName + " " + house.EstateName;
            //House.PhotoUrl = string.IsNullOrWhiteSpace(House.proCoverUrl) ? "NullPic.jpg" : House.PhotoUrl;
            //Visible = House.EmpID == GlobalVariables.LoggedUser.EmpID;

            //CheckCollected();

            GetPhotos();

            GetComments();

            ShareCommand = new Command(() =>
            {
                var page = new ShareView(House.proId.ToString());
                PopupNavigation.Instance.PushAsync(page);
            }, () => { return(true); });

            CallCommand = new Command(async() =>
            {
                string action = await Application.Current.MainPage.DisplayActionSheet("联系发布人" + House.proEmployee1Phone, "取消", null, "打电话", "发短信");
                if (action == "打电话")
                {
                    try
                    {
                        if (!string.IsNullOrWhiteSpace(House.proEmployee1Phone))
                        {
                            PhoneDialer.Open(House.proEmployee1Phone);
                        }
                        else
                        {
                            CrossToastPopUp.Current.ShowToastError("电话号码为空", ToastLength.Long);
                        }
                    }
                    catch (FeatureNotSupportedException)
                    {
                        // Phone Dialer is not supported on this device.
                        CrossToastPopUp.Current.ShowToastError("该设备不支持拨号", ToastLength.Long);
                    }
                    catch (Exception)
                    {
                        // Other error has occurred.
                    }
                }
                else if (action == "发短信")
                {
                    try
                    {
                        if (!string.IsNullOrWhiteSpace(House.proEmployee1Phone))
                        {
                            string result = await Application.Current.MainPage.DisplayPromptAsync("短信", "请输入短消息", "发送", "取消", "短消息(140个字以内)", 140, null);

                            if (result == null)
                            {
                                CrossToastPopUp.Current.ShowToastWarning("已取消", ToastLength.Long);
                            }
                            else if (result == "")
                            {
                                CrossToastPopUp.Current.ShowToastWarning("请输入短消息(140字以内)", ToastLength.Long);
                            }
                            else
                            {
                                var message = new SmsMessage()
                                {
                                    Body       = result,
                                    Recipients = new List <string>()
                                    {
                                        House.proEmployee1Phone
                                    }
                                };
                                await Sms.ComposeAsync(message);
                            }
                        }
                        else
                        {
                            CrossToastPopUp.Current.ShowToastError("电话号码为空", ToastLength.Long);
                        }
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }
            }, () => { return(true); });

            CollectCommand = new Command(() =>
            {
                //CollectOrCancel();
            }, () => { return(true); });

            CarouselTappedCommand = new Command <string>((p) =>
            {
                var page = new PhotoView(p);
                PopupNavigation.Instance.PushAsync(page);
            }, (p) => { return(true); });
        }