Пример #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 BrandIndex(string brand, string city, string area, string word, int page = 1)
        {
            page = page <= 0 ? 1 : page;
            ViewBag.PageIndex  = page;
            ViewBag.PageSize   = 10;
            ViewData["brand"]  = brand;
            ViewData["city"]   = city;
            ViewData["area"]   = area;
            ViewData["word"]   = word;
            ViewBag.BrandModel = BrandList.List.FirstOrDefault(x => x.Py == brand);
            ViewBag.BrandName  = ViewBag.BrandModel?.Name ?? string.Empty;
            var request = new StoreSearchRequest
            {
                Area      = area,
                Brand     = brand,
                City      = city,
                PageSize  = ViewBag.PageSize,
                PageIndex = ViewBag.PageIndex,
                SearchKey = word
            };

            ViewBag.AreaList = HotCityList.List;
            var list = new List <StoreSearchModel>();
            var data = StoresAccess.GetStoreList(request);

            ViewBag.Total = data?.Count ?? 0;
            if (data != null && data.Any())
            {
                data = data.Skip((request.PageIndex - 1) * request.PageSize).Take(request.PageSize).ToList();
                list = StoresAccess.ConvertList(data);
            }
            ViewBag.List = list;
            return(View());
        }
Пример #3
0
        public ActionResult Index()
        {
            var mvcName = typeof(Controller).Assembly.GetName();
            var isMono  = Type.GetType("Mono.Runtime") != null;

            ViewData["Version"] = mvcName.Version.Major + "." + mvcName.Version.Minor;
            ViewData["Runtime"] = isMono ? "Mono" : ".NET";
            var ipCity = IPHelper.GetIPCitys()?.ToLower();

            if (string.IsNullOrEmpty(ipCity) || ipCity == "未知" || ipCity == "内网ip")
            {
                ipCity = "苏州";
            }
            var request = new StoreSearchRequest
            {
                City     = ipCity,
                PageSize = 4,
            };
            var list = new List <StoreSearchModel>();
            var data = StoresAccess.GetStoreList(request);

            if (data != null && data.Any())
            {
                data = data.Take(request.PageSize).ToList();
                list = StoresAccess.ConvertList(data);
            }
            ViewBag.List     = list;
            ViewBag.AreaList = HotCityList.List;
            return(View());
        }
Пример #4
0
        /// <summary>
        /// 列表页
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public JsonResult GetStoreList(StoreSearchRequest request)
        {
            var list = new List <StoreSearchModel>();
            var data = StoresAccess.GetStoreList(request);

            if (data != null && data.Any())
            {
                data = data.Take(request.PageSize).ToList();
                list = StoresAccess.ConvertList(data);
            }
            return(Json(list, JsonRequestBehavior.AllowGet));
        }
Пример #5
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());
        }
Пример #6
0
        /// <summary>
        /// 获取店铺详情页面
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Detail(int id)
        {
            var model = StoresAccess.GetStoresDetail(id);

            ViewBag.store      = model;
            ViewBag.BrandModel = BrandList.GetModel(model.brand);
            ViewBag.brand      = ViewBag.BrandModel.Py;
            var request = new StoreSearchRequest
            {
                City     = model.city,
                Brand    = ViewBag.BrandModel.Py,
                PageSize = 4,
            };
            var list = new List <StoreSearchModel>();
            var data = StoresAccess.GetStoreList(request);

            if (data != null && data.Any())
            {
                data = data.Where(x => x.Id != id).Take(request.PageSize).ToList();
                list = StoresAccess.ConvertList(data);
            }
            ViewBag.List = list;
            return(View());
        }