Пример #1
0
        /// <summary>
        /// 搜索
        /// </summary>
        /// <param name="brand"></param>
        /// <param name="word"></param>
        /// <returns></returns>
        public RedirectResult Search(int brand, string word)
        {
            var areaModel = StoresAccess.GetAreaFilter(word);
            var brandList = new List <string> {
                "apple", "huawei", "xiaomi", "oppo", "vivo"
            };
            var brandName = StoresAccess.GetBrandString(brand);
            var isBrand   = brandList.IndexOf(brandName) >= 0;
            var url       = isBrand ? $"{brandName}/" : "list/";

            if (areaModel != null && areaModel.AreaType > 0)
            {//带区域的
                if (areaModel.AreaType == 1)
                {
                    url += $"{areaModel.CityName}/";
                }
                else
                {
                    url += $"{areaModel.CityName}/{areaModel.AreaName}/";
                }
            }
            else
            {
                url += $"?word={word}";
            }

            return(Redirect(url));
        }
Пример #2
0
        public ActionResult CityIndex(string city, string area)
        {
            var areaModel = new AreaFilteMobdel();

            if (!string.IsNullOrEmpty(area))
            {
                areaModel = StoresAccess.GetAreaFilter(area);
            }
            else if (!string.IsNullOrEmpty(city))
            {
                areaModel = StoresAccess.GetAreaFilter(city);
            }
            if (areaModel == null || areaModel.AreaType == 0)
            {
                return(Redirect("/"));
            }
            ViewBag.CityName = areaModel?.CityName ?? string.Empty;
            ViewBag.CityPy   = areaModel?.CityNamePy ?? string.Empty;
            ViewBag.AreaPy   = areaModel?.AreaNamePy ?? string.Empty;
            ViewBag.AreaName = areaModel?.AreaName ?? string.Empty;
            ViewBag.AreaList = HotCityList.List;
            var request = new StoreSearchRequest
            {
                Area = area,
                City = city,
            };
            var cityList = new List <CityBrandModel>();
            var data     = StoresAccess.GetStoreList(request);

            if (data != null && data.Count > 0)
            {
                BrandList.List.ForEach(x =>
                {
                    var bData = data.Where(d => d.brand == x.Id).OrderBy(d => d.sortby).ToList();
                    if (bData != null && bData.Count > 0)
                    {
                        var cityModel = new CityBrandModel
                        {
                            Brand     = x.Id,
                            BrandName = x.Name,
                            List      = new List <StoreSearchModel>()
                        };
                        bData = bData.Take(4).ToList();
                        cityModel.List.AddRange(StoresAccess.ConvertList(bData));
                        cityList.Add(cityModel);
                    }
                });
            }
            ViewBag.CityList = cityList;
            return(View());
        }