public ActionResult Header()
        {
            ViewBag.Now = DateTime.Now;
            bool isLogin = CurrentUser != null;
            var  model   = new ProductPartialHeaderModel();

            model.PlatformCustomerServices = CustomerServiceApplication.GetPlatformCustomerService(true, false);
            model.isLogin = isLogin ? "true" : "false";
            //用户积分
            model.MemberIntegral = isLogin ? _iMemberIntegralService.GetMemberIntegral(CurrentUser.Id).AvailableIntegrals : 0;

            //关注诊疗项目
            //var concern = isLogin ? _iProductService.GetUserAllConcern(CurrentUser.Id) : new List<FavoriteInfo>();
            //model.Concern = concern.Take(10).ToList();

            List <IBaseCoupon> baseCoupons = new List <IBaseCoupon>();
            //优惠卷
            var coupons = isLogin ? _iCouponService.GetAllUserCoupon(CurrentUser.Id).ToList() : new List <UserCouponInfo>();

            coupons = coupons == null ? new List <UserCouponInfo>() : coupons;
            baseCoupons.AddRange(coupons);

            //红包
            var shopBonus = isLogin ? _iShopBonusService.GetCanUseDetailByUserId(CurrentUser.Id) : new List <ShopBonusReceiveInfo>();

            shopBonus = shopBonus == null ? new List <ShopBonusReceiveInfo>() : shopBonus;
            baseCoupons.AddRange(shopBonus);
            model.BaseCoupon = baseCoupons;

            //广告
            var imageAds = _iSlideAdsService.GetImageAds(0).Where(p => p.TypeId == Himall.CommonModel.ImageAdsType.HeadRightAds).ToList();

            if (imageAds.Count > 0)
            {
                ViewBag.HeadAds = imageAds;
            }
            else
            {
                ViewBag.HeadAds = _iSlideAdsService.GetImageAds(0).Take(1).ToList();
            }
            //浏览的诊疗项目
            //var browsingPro = isLogin ? BrowseHistrory.GetBrowsingProducts(10, CurrentUser == null ? 0 : CurrentUser.Id) : new List<ProductBrowsedHistoryModel>();
            //model.BrowsingProducts = browsingPro;

            InitHeaderData();

            return(PartialView("~/Areas/Web/Views/Shared/Header.cshtml", model));
        }
        // GET: SellerAdmin/PageSettings
        public ActionResult Management()
        {
            var images = _iSlideAdsService.GetImageAds(CurrentSellerManager.ShopId).OrderBy(item => item.Id);

            ViewBag.Logo         = _iShopService.GetShop(CurrentSellerManager.ShopId).Logo;
            ViewBag.Logo         = ViewBag.Logo == null ? "" : ViewBag.Logo;
            ViewBag.TransverseAD = images.FirstOrDefault(p => p.IsTransverseAD);
            return(View(images.Where(p => !p.IsTransverseAD)));
        }
예제 #3
0
        public JsonResult GetSlideImage()
        {
            var slideAds   = _iSlideAdsService.GetImageAds(CurrentSellerManager.ShopId);
            var slideModel = slideAds.ToArray().Select(item => new
            {
                id    = item.Id,
                image = item.ImageUrl,
                url   = item.Url
            });

            return(Json(new { rows = slideModel, total = 100 }, JsonRequestBehavior.AllowGet));
        }
예제 #4
0
        // GET: SellerAdmin/PageSettings
        public ActionResult Management()
        {
            var images = _iSlideAdsService.GetImageAds(CurrentSellerManager.ShopId).OrderBy(item => item.Id);
            var shop   = _iShopService.GetShop(CurrentSellerManager.ShopId);

            ViewBag.Logo             = shop.Logo;
            ViewBag.Logo             = ViewBag.Logo == null ? "" : ViewBag.Logo;
            ViewBag.TransverseAD     = images.FirstOrDefault(p => p.IsTransverseAD);
            ViewBag.SlidAds          = SlideApplication.GetSlidAds(CurrentSellerManager.ShopId, Entities.SlideAdInfo.SlideAdType.ShopHome);
            ViewBag.IsOpenTopImageAd = shop.IsOpenTopImageAd;
            return(View(images.Where(p => !p.IsTransverseAD)));
        }
예제 #5
0
        // GET: Admin/PageSettings
        public ActionResult Index()
        {
            var settings = _iSiteSettingService.GetSiteSettings();

            ViewBag.Logo        = settings.Logo;
            ViewBag.Keyword     = settings.Keyword;
            ViewBag.Hotkeywords = settings.Hotkeywords;

            var imageAds = _iSlideAdsService.GetImageAds(0).ToList();

            ViewBag.ImageAdsTop            = imageAds.Where(p => p.TypeId == Himall.CommonModel.ImageAdsType.BannerAds).ToList();
            ViewBag.HeadAds                = imageAds.Where(p => p.TypeId == Himall.CommonModel.ImageAdsType.HeadRightAds).ToList();
            ViewBag.CenterAds              = imageAds.Where(p => p.TypeId == Himall.CommonModel.ImageAdsType.Customize).ToList();
            ViewBag.ShopAds                = imageAds.Where(p => p.TypeId == Himall.CommonModel.ImageAdsType.BrandsAds).ToList();
            ViewBag.BottomPic              = CurrentSiteSetting.PCBottomPic;
            ViewBag.AdvertisementUrl       = CurrentSiteSetting.AdvertisementUrl;
            ViewBag.AdvertisementImagePath = CurrentSiteSetting.AdvertisementImagePath;
            ViewBag.AdvertisementState     = CurrentSiteSetting.AdvertisementState;

            var imageAdsz = imageAds.Where(p => p.TypeId == Himall.CommonModel.ImageAdsType.Single).ToArray();

            return(View(imageAdsz));
        }
예제 #6
0
        // GET: Admin/APPShop
        //APP首页配置共用于安卓和IOS,这里的平台类型写的为IOS,安卓调用首页接口数据时平台类型也选IOS
        public ActionResult HomePageSetting()
        {
            var homeTopicInfos = _iMobileHomeTopicService.GetMobileHomeTopicInfos(PlatformType.IOS).ToArray();

            //专题
            ViewBag.imageAds = _iSlideAdsService.GetImageAds(0).Where(p => p.TypeId == Himall.CommonModel.ImageAdsType.APPSpecial).ToList();
            //门店授权
            ViewBag.IsOpenStore = SiteSettingApplication.GetSiteSettings() != null && SiteSettingApplication.GetSiteSettings().IsOpenStore;

            var models = homeTopicInfos.Select(item =>
            {
                return(new TopicModel()
                {
                    FrontCoverImage = item.Himall_Topics.frontCoverImage,
                    Id = item.Id,
                    Name = item.Himall_Topics.Name,
                    Tags = item.Himall_Topics.Tags,
                    Sequence = item.Sequence
                });
            });

            return(View(models));
        }
예제 #7
0
        public ActionResult Home(string id)
        {
            long     shopId  = 0;
            ShopInfo shopObj = null;

            //shopId 不是数字
            if (!long.TryParse(id, out shopId))
            {
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
                //404 页面
            }

            //店铺Id不存在
            shopObj = _iShopService.GetShop(shopId);
            if (null == shopObj)
            {
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
                //404 页面
            }

            #region 初始化Model

            ShopHomeModel model = new ShopHomeModel
            {
                HotAttentionProducts = new List <HotProductInfo>(),
                HotSaleProducts      = new List <HotProductInfo>(),
                Floors       = new List <ShopHomeFloor>(),
                Navignations = new List <BannerInfo>(),
                Shop         = new ShopInfoModel(),
                ShopCategory = new List <CategoryJsonModel>(),
                Slides       = new List <SlideAdInfo>(),
                Logo         = ""
            };


            #endregion

            #region 店铺信息

            var mark = ShopServiceMark.GetShopComprehensiveMark(shopObj.Id);
            model.Shop.Name              = shopObj.ShopName;
            model.Shop.CompanyName       = shopObj.CompanyName;
            model.Shop.Id                = shopObj.Id;
            model.Shop.PackMark          = mark.PackMark;
            model.Shop.ServiceMark       = mark.ServiceMark;
            model.Shop.ComprehensiveMark = mark.ComprehensiveMark;
            model.Shop.Phone             = shopObj.CompanyPhone;
            model.Shop.Address           = _iRegionService.GetFullName(shopObj.CompanyRegionId);
            model.Logo = shopObj.Logo;

            #endregion

            if (shopObj.IsSelf)
            {
                model.Shop.PackMark          = 5;
                model.Shop.ServiceMark       = 5;
                model.Shop.ComprehensiveMark = 5;
            }



            #region 导航和3个推荐商品

            //导航
            model.Navignations = _iNavigationService.GetSellerNavigations(shopObj.Id).ToList();

            //banner和3个推荐商品
            var list = _iSlideAdsService.GetImageAds(shopObj.Id).OrderBy(item => item.Id).ToList();
            model.ImageAds     = list.Where(p => !p.IsTransverseAD).ToList();
            model.TransverseAD = list.FirstOrDefault(p => p.IsTransverseAD);
            model.Slides       = _iSlideAdsService.GetSlidAds(shopObj.Id, SlideAdInfo.SlideAdType.ShopHome).ToList();

            #endregion

            #region 店铺分类

            var categories = _iShopCategoryService.GetShopCategory(shopObj.Id).ToList();
            foreach (var main in categories.Where(s => s.ParentCategoryId == 0))
            {
                var topC = new CategoryJsonModel()
                {
                    Name        = main.Name,
                    Id          = main.Id.ToString(),
                    SubCategory = new List <SecondLevelCategory>()
                };
                foreach (var secondItem in categories.Where(s => s.ParentCategoryId == main.Id))
                {
                    var secondC = new SecondLevelCategory()
                    {
                        Name = secondItem.Name,
                        Id   = secondItem.Id.ToString(),
                    };

                    topC.SubCategory.Add(secondC);
                }
                model.ShopCategory.Add(topC);
            }

            #endregion

            #region 楼层信息

            var shopHomeModules = _iShopHomeModuleService.GetAllShopHomeModuleInfos(shopObj.Id).Where(a => a.IsEnable).ToArray().OrderBy(p => p.DisplaySequence);
            foreach (var item in shopHomeModules)
            {
                List <ShopHomeFloorProduct> products = new List <ShopHomeFloorProduct>();
                foreach (var p in item.ShopHomeModuleProductInfo.Where(d => d.ProductInfo.AuditStatus == ProductInfo.ProductAuditStatus.Audited && d.ProductInfo.SaleStatus == ProductInfo.ProductSaleStatus.OnSale).ToList().OrderBy(p => p.DisplaySequence))
                {
                    products.Add(new ShopHomeFloorProduct
                    {
                        Id        = p.ProductId,
                        Name      = p.ProductInfo.ProductName,
                        Pic       = p.ProductInfo.ImagePath,
                        Price     = p.ProductInfo.MinSalePrice.ToString("f2"),
                        SaleCount = (int)_iProductService.GetProductVistInfo(p.ProductInfo.Id).SaleCounts
                    });
                }

                List <ShopHomeFloorTopImg> topimgs = new List <ShopHomeFloorTopImg>();
                foreach (var i in item.Himall_ShopHomeModulesTopImg.ToList().OrderBy(p => p.DisplaySequence))
                {
                    topimgs.Add(new ShopHomeFloorTopImg
                    {
                        Url     = i.Url,
                        ImgPath = i.ImgPath
                    });
                }
                ShopHomeFloor floor = new ShopHomeFloor
                {
                    FloorName = item.Name,
                    FloorUrl  = item.Url,
                    Products  = products,
                    TopImgs   = topimgs
                };

                model.Floors.Add(floor);
            }
            #endregion

            #region 热门销售

            var sale = _iProductService.GetHotSaleProduct(shopObj.Id, 5);
            if (sale != null)
            {
                foreach (var item in sale.ToArray())
                {
                    model.HotSaleProducts.Add(new HotProductInfo
                    {
                        ImgPath   = item.ImagePath,
                        Name      = item.ProductName,
                        Price     = item.MinSalePrice,
                        Id        = item.Id,
                        SaleCount = (int)item.SaleCounts
                    });
                }
            }

            #endregion

            #region 热门关注

            var hot = _iProductService.GetHotConcernedProduct(shopObj.Id, 5);
            if (hot != null)
            {
                foreach (var item in hot.ToList())
                {
                    model.HotAttentionProducts.Add(new HotProductInfo
                    {
                        ImgPath   = item.ImagePath,
                        Name      = item.ProductName,
                        Price     = item.MinSalePrice,
                        Id        = item.Id,
                        SaleCount = (int)item.ConcernedCount
                    });
                }
            }
            #endregion

            #region 累加浏览次数

            _iShopService.LogShopVisti(shopObj.Id);

            #endregion

            #region 微店二维码
            var    vshop    = _iVShopService.GetVShopByShopId(shopObj.Id);
            string vshopUrl = "";
            if (vshop != null)
            {
                vshopUrl = "http://" + HttpContext.Request.Url.Host + "/m-" + PlatformType.WeiXin.ToString() + "/vshop/detail/" + vshop.Id;
                CreateQR(model, vshop.Logo, vshopUrl);
            }
            else
            {
                vshopUrl = "http://" + HttpContext.Request.Url.Host + "/m-" + PlatformType.WeiXin.ToString();
                CreateQR(model, string.Empty, vshopUrl);
            }
            #endregion

            #region 店铺页脚
            model.Footer = _iShopHomeModuleService.GetFooter(shopObj.Id);
            #endregion

            ViewBag.IsExpired = _iShopService.IsExpiredShop(shopId);
            ViewBag.IsFreeze  = _iShopService.IsFreezeShop(shopId);

            //补充当前店铺红包功能
            ViewBag.isShopPage     = true;
            ViewBag.CurShopId      = shopId;
            TempData["isShopPage"] = true;
            TempData["CurShopId"]  = shopId;
            //统计店铺访问人数
            StatisticApplication.StatisticShopVisitUserCount(shopId);
            return(View(model));
        }
예제 #8
0
        // GET: Web/Shop
        // [OutputCache(VaryByParam = "id", Duration = ConstValues.PAGE_CACHE_DURATION)]
        public ActionResult Home(string id)
        {
            long shopId = 0;

            Entities.ShopInfo shopObj = null;

            //shopId 不是数字
            if (!long.TryParse(id, out shopId))
            {
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
                //404 页面
            }

            //店铺Id不存在
            shopObj = _iShopService.GetShop(shopId);
            if (null == shopObj)
            {
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
                //404 页面
            }

            #region 初始化Model

            ShopHomeModel model = new ShopHomeModel
            {
                HotAttentionProducts = new List <HotProductInfo>(),
                HotSaleProducts      = new List <HotProductInfo>(),
                Floors       = new List <ShopHomeFloor>(),
                Navignations = new List <Entities.BannerInfo>(),
                Shop         = new ShopInfoModel(),
                ShopCategory = new List <CategoryJsonModel>(),
                Slides       = new List <Entities.SlideAdInfo>(),
                Logo         = ""
            };


            #endregion

            #region 店铺信息

            var mark = ShopServiceMark.GetShopComprehensiveMark(shopObj.Id);
            model.Shop.Name              = shopObj.ShopName;
            model.Shop.CompanyName       = shopObj.CompanyName;
            model.Shop.Id                = shopObj.Id;
            model.Shop.PackMark          = mark.PackMark;
            model.Shop.ServiceMark       = mark.ServiceMark;
            model.Shop.ComprehensiveMark = mark.ComprehensiveMark;
            model.Shop.Phone             = shopObj.CompanyPhone;
            model.Shop.Address           = _iRegionService.GetFullName(shopObj.CompanyRegionId);
            model.Logo = shopObj.Logo;

            #endregion

            if (shopObj.IsSelf)
            {
                model.Shop.PackMark          = 5;
                model.Shop.ServiceMark       = 5;
                model.Shop.ComprehensiveMark = 5;
            }



            #region 导航和3个推荐商品

            //导航
            model.Navignations = _iNavigationService.GetSellerNavigations(shopObj.Id).ToList();

            //banner和3个推荐商品
            var list = _iSlideAdsService.GetImageAds(shopObj.Id).OrderBy(item => item.Id).ToList();
            model.ImageAds     = list.Where(p => !p.IsTransverseAD).ToList();
            model.TransverseAD = list.FirstOrDefault(p => p.IsTransverseAD);
            model.Slides       = _iSlideAdsService.GetSlidAds(shopObj.Id, Entities.SlideAdInfo.SlideAdType.ShopHome).ToList();

            #endregion

            #region 店铺分类

            var categories = _iShopCategoryService.GetShopCategory(shopObj.Id).Where(a => a.IsShow).ToList();//这里不好写到底层去,有些地方产品设计上不需要过滤
            foreach (var main in categories.Where(s => s.ParentCategoryId == 0))
            {
                var topC = new CategoryJsonModel()
                {
                    Name        = main.Name,
                    Id          = main.Id.ToString(),
                    SubCategory = new List <SecondLevelCategory>()
                };
                foreach (var secondItem in categories.Where(s => s.ParentCategoryId == main.Id))
                {
                    var secondC = new SecondLevelCategory()
                    {
                        Name = secondItem.Name,
                        Id   = secondItem.Id.ToString(),
                    };

                    topC.SubCategory.Add(secondC);
                }
                model.ShopCategory.Add(topC);
            }

            #endregion

            #region 楼层信息
            bool isSaleCountOnOff     = SiteSettingApplication.SiteSettings.ProductSaleCountOnOff == 1;
            var  shopHomeModules      = _iShopHomeModuleService.GetAllShopHomeModuleInfos(shopObj.Id).Where(a => a.IsEnable).OrderBy(p => p.DisplaySequence);
            ShopHomeFloorProduct info = null;
            var modules        = shopHomeModules.Select(p => p.Id).ToList();
            var imgs           = _iShopHomeModuleService.GetImages(modules);
            var moduleProducts = _iShopHomeModuleService.GetProducts(modules);
            var onSaleProducts = ProductManagerApplication.GetOnSaleProducts(moduleProducts.Select(p => p.ProductId).ToList());

            foreach (var item in shopHomeModules)
            {
                List <ShopHomeFloorProduct> products = new List <ShopHomeFloorProduct>();
                var moduleProduct = moduleProducts.Where(p => p.HomeModuleId == item.Id);
                foreach (var p in moduleProduct.OrderBy(p => p.DisplaySequence))
                {
                    var product = onSaleProducts.FirstOrDefault(x => x.Id == p.ProductId);
                    if (product == null)
                    {
                        continue;
                    }
                    info = new ShopHomeFloorProduct
                    {
                        Id    = product.Id,
                        Name  = product.ProductName,
                        Pic   = product.ImagePath,
                        Price = product.MinSalePrice.ToString("f2"),
                        //TODO:FG 循环查询销量 待优化
                        SaleCount = (int)_iProductService.GetProductVistInfo(product.Id).SaleCounts
                    };

                    if (isSaleCountOnOff)
                    {
                        info.SaleCount = info.SaleCount + (int)product.VirtualSaleCounts;
                    }
                    products.Add(info);
                }
                var topimgs = imgs
                              .Where(p => p.HomeModuleId == item.Id)
                              .OrderBy(p => p.DisplaySequence)
                              .Select(i => new ShopHomeFloorTopImg
                {
                    Url     = i.Url,
                    ImgPath = i.ImgPath
                }).ToList();

                model.Floors.Add(new ShopHomeFloor
                {
                    FloorName = item.Name,
                    FloorUrl  = item.Url,
                    Products  = products,
                    TopImgs   = topimgs
                });
            }
            #endregion

            #region 热门销售
            //热门销售不受平台销量开关影响
            var sale = _iProductService.GetHotSaleProduct(shopObj.Id, 5);
            if (sale != null)
            {
                HotProductInfo hotInfo = null;
                foreach (var item in sale.ToArray())
                {
                    hotInfo = new HotProductInfo
                    {
                        ImgPath   = item.ImagePath,
                        Name      = item.ProductName,
                        Price     = item.MinSalePrice,
                        Id        = item.Id,
                        SaleCount = (int)item.SaleCounts
                    };
                    hotInfo.SaleCount = hotInfo.SaleCount + Mall.Core.Helper.TypeHelper.ObjectToInt(item.VirtualSaleCounts);
                    model.HotSaleProducts.Add(hotInfo);
                }
            }

            #endregion

            #region 热门关注

            var hot = _iProductService.GetHotConcernedProduct(shopObj.Id, 5);
            if (hot != null)
            {
                HotProductInfo hot_Info = null;
                foreach (var item in hot.ToList())
                {
                    hot_Info = new HotProductInfo
                    {
                        ImgPath   = item.ImagePath,
                        Name      = item.ProductName,
                        Price     = item.MinSalePrice,
                        Id        = item.Id,
                        SaleCount = (int)item.ConcernedCount
                    };
                    model.HotAttentionProducts.Add(hot_Info);
                }
            }
            #endregion


            #region 微店二维码
            var    vshop    = _iVShopService.GetVShopByShopId(shopObj.Id);
            string vshopUrl = "";
            if (vshop != null)
            {
                vshopUrl = CurrentUrlHelper.CurrentUrlNoPort() + "/m-" + PlatformType.WeiXin.ToString() + "/vshop/detail/" + vshop.Id;
                CreateQR(model, vshop.StrLogo, vshopUrl);
            }
            else
            {
                vshopUrl = CurrentUrlHelper.CurrentUrlNoPort() + "/m-" + PlatformType.WeiXin.ToString();
                CreateQR(model, string.Empty, vshopUrl);
            }
            #endregion

            #region 店铺页脚
            model.Footer = _iShopHomeModuleService.GetFooter(shopObj.Id);
            #endregion

            ViewBag.IsExpired = _iShopService.IsExpiredShop(shopId);
            ViewBag.IsFreeze  = _iShopService.IsFreezeShop(shopId);

            //补充当前店铺红包功能
            ViewBag.isShopPage     = true;
            ViewBag.CurShopId      = shopId;
            TempData["isShopPage"] = true;
            TempData["CurShopId"]  = shopId;
            //统计店铺访问人数
            StatisticApplication.StatisticShopVisitUserCount(shopId);
            ViewBag.Keyword          = string.IsNullOrWhiteSpace(SiteSettings.SearchKeyword) ? SiteSettings.Keyword : SiteSettings.SearchKeyword;
            ViewBag.Keywords         = SiteSettings.HotKeyWords;
            ViewBag.IsOpenTopImageAd = shopObj.IsOpenTopImageAd;
            return(View(model));
        }
예제 #9
0
 public static IEnumerable <ImageAdInfo> GetImageAds(long shopId, Mall.CommonModel.ImageAdsType?ImageAdsType = Mall.CommonModel.ImageAdsType.Initial)
 {
     return(_iSlideAdsService.GetImageAds(shopId, ImageAdsType));
 }
예제 #10
0
        /// <summary>
        /// 页面缓存时间
        /// </summary>


        // GET: Web/ProductPartial
        //[OutputCache(Duration = ConstValues.PAGE_CACHE_DURATION)]
        public ActionResult Header()
        {
            ViewBag.Now = DateTime.Now;
            bool isLogin = CurrentUser != null;
            var  model   = new ProductPartialHeaderModel();

            model.PlatformCustomerServices = CustomerServiceApplication.GetPlatformCustomerService(true, false);
            model.isLogin = isLogin ? "true" : "false";
            //用户积分
            model.MemberIntegral = isLogin ? MemberIntegralApplication.GetAvailableIntegral(CurrentUser.Id) : 0;

            //关注商品
            var user        = CurrentUser?.Id ?? 0;
            var baseCoupons = new List <DisplayCoupon>();
            //优惠卷
            var usercoupons = _iCouponService.GetAllUserCoupon(user);//优惠卷
            var coupons     = CouponApplication.GetCouponInfo(usercoupons.Select(p => p.CouponId));
            var shops       = ShopApplication.GetShops(coupons.Select(p => p.ShopId));
            var shopBonus   = ShopBonusApplication.GetShopBounsByUser(user);//红包

            baseCoupons.AddRange(usercoupons.Select(item =>
            {
                var coupon = coupons.FirstOrDefault(p => p.Id == item.CouponId);
                var shop   = shops.FirstOrDefault(p => p.Id == coupon.ShopId);
                return(new DisplayCoupon
                {
                    Type = CommonModel.CouponType.Coupon,
                    Limit = coupon.OrderAmount,
                    Price = item.Price,
                    ShopId = shop.Id,
                    ShopName = shop.ShopName,
                    EndTime = coupon.EndTime,
                });
            }));

            baseCoupons.AddRange(shopBonus.Select(p => new DisplayCoupon
            {
                Type     = CommonModel.CouponType.ShopBonus,
                EndTime  = p.Bonus.DateEnd,
                Limit    = p.Bonus.UsrStatePrice,
                Price    = p.Receive.Price,
                ShopId   = p.Shop.Id,
                ShopName = p.Shop.ShopName,
                UseState = p.Bonus.UseState
            }));
            model.BaseCoupon = baseCoupons;
            //广告
            var imageAds = _iSlideAdsService.GetImageAds(0).Where(p => p.TypeId == Himall.CommonModel.ImageAdsType.HeadRightAds).ToList();

            if (imageAds.Count > 0)
            {
                ViewBag.HeadAds = imageAds;
            }
            else
            {
                ViewBag.HeadAds = _iSlideAdsService.GetImageAds(0).Take(1).ToList();
            }
            //浏览的商品
            //var browsingPro = isLogin ? BrowseHistrory.GetBrowsingProducts(10, CurrentUser == null ? 0 : CurrentUser.Id) : new List<ProductBrowsedHistoryModel>();
            //model.BrowsingProducts = browsingPro;

            InitHeaderData();

            string html = System.IO.File.ReadAllText(this.Server.MapPath(_templateHeadHtmlFileFullName));//读取模板头部html静态文件内容

            ViewBag.Html = html;
            return(PartialView("~/Areas/Web/Views/Shared/Header.cshtml", model));
        }
예제 #11
0
        public ActionResult Index()
        {
            if (!IsInstalled())
            {
                return(RedirectToAction("Agreement", "Installer"));
            }
            var ser_user = _iMemberService;

            #region 初始化首页数据
            var homePageModel = new HomePageModel();

            if (CurrentSiteSetting.AdvertisementState)
            {
                homePageModel.AdvertisementUrl       = CurrentSiteSetting.AdvertisementUrl;
                homePageModel.AdvertisementImagePath = CurrentSiteSetting.AdvertisementImagePath;
            }

            //获取信任登录插件需要在首页head中填充的验证内容
            ViewBag.OAuthValidateContents = GetOAuthValidateContents();
            homePageModel.SiteName        = CurrentSiteSetting.SiteName;
            homePageModel.Title           = string.IsNullOrWhiteSpace(CurrentSiteSetting.Site_SEOTitle) ? "商城首页" : CurrentSiteSetting.Site_SEOTitle;
            var view = ViewEngines.Engines.FindView(ControllerContext, "Index", null);
            List <HomeFloorModel> floorModels = new List <HomeFloorModel>();
            homePageModel.handImage = _iSlideAdsService.GetHandSlidAds().ToList();
            var silder = _iSlideAdsService.GetSlidAds(0, SlideAdInfo.SlideAdType.PlatformHome).ToList();
            homePageModel.slideImage = silder;
            var imageAds = _iSlideAdsService.GetImageAds(0).ToList();
            //人气单品
            homePageModel.imageAds = imageAds.Where(p => p.TypeId == Himall.CommonModel.ImageAdsType.Single).ToList();
            //banner右侧广告
            homePageModel.imageAdsTop = imageAds.Where(p => p.TypeId == Himall.CommonModel.ImageAdsType.BannerAds).ToList();

            homePageModel.CenterAds = imageAds.Where(p => p.TypeId == Himall.CommonModel.ImageAdsType.Customize).ToList();
            homePageModel.ShopAds   = imageAds.Where(p => p.TypeId == Himall.CommonModel.ImageAdsType.BrandsAds).ToList();

            if (homePageModel.imageAds.Count == 0)
            {
                homePageModel.imageAds = imageAds.Take(8).ToList();
            }
            if (homePageModel.imageAdsTop.Count == 0)
            {
                homePageModel.imageAdsTop = imageAds.Take(2).ToList();
            }
            if (homePageModel.CenterAds.Count == 0)
            {
                homePageModel.CenterAds = imageAds.Take(3).ToList();
            }
            if (homePageModel.ShopAds.Count == 0)
            {
                homePageModel.ShopAds = imageAds.Take(2).ToList();
            }

            /*没地方用,先去掉
             * var articleService = ServiceHelper.Create<IArticleService>();
             * ViewBag.ArticleTabs = new List<IQueryable<ArticleInfo>>()
             * {   articleService.GetTopNArticle<ArticleInfo>(8, 4),
             *      articleService.GetTopNArticle<ArticleInfo>(8, 5),
             *      articleService.GetTopNArticle<ArticleInfo>(8, 6),
             *      articleService.GetTopNArticle<ArticleInfo>(8, 7)
             * };
             */

            //楼层数据
            var floors = _iFloorService.GetHomeFloors().ToList();
            foreach (var f in floors)
            {
                var model          = new HomeFloorModel();
                var texts          = f.FloorTopicInfo.Where(a => a.TopicType == Position.Top).ToList();
                var products       = f.FloorTopicInfo.Where(a => a.TopicType != Position.Top).ToList();
                var productModules = f.FloorProductInfo.ToList();
                var brands         = f.FloorBrandInfo.Take(10).ToList();
                model.Name           = f.FloorName;
                model.SubName        = f.SubName;
                model.StyleLevel     = f.StyleLevel;
                model.DefaultTabName = f.DefaultTabName;

                //文本设置
                foreach (var s in texts)
                {
                    model.TextLinks.Add(new HomeFloorModel.WebFloorTextLink()
                    {
                        Id   = s.Id,
                        Name = s.TopicName,
                        Url  = s.Url
                    });
                }

                //广告设置
                foreach (var s in products)
                {
                    model.Products.Add(new HomeFloorModel.WebFloorProductLinks
                    {
                        Id       = s.Id,
                        ImageUrl = s.TopicImage,
                        Url      = s.Url,
                        Type     = s.TopicType
                    });
                }

                //推荐品牌
                foreach (var s in brands)
                {
                    model.Brands.Add(new WebFloorBrand
                    {
                        Id   = s.BrandInfo.Id,
                        Img  = s.BrandInfo.Logo,
                        Url  = "",
                        Name = s.BrandInfo.Name
                    });
                }

                //推荐商品
                foreach (var s in productModules)
                {
                    model.ProductModules.Add(new HomeFloorModel.ProductModule
                    {
                        Id          = s.Id,
                        ProductId   = s.ProductId,
                        MarketPrice = s.ProductInfo.MarketPrice,
                        price       = s.ProductInfo.MinSalePrice,
                        productImg  = Himall.Core.HimallIO.GetProductSizeImage(s.ProductInfo.ImagePath, 1, (int)ImageSize.Size_350),
                        productName = s.ProductInfo.ProductName,
                        Tab         = s.Tab
                    });
                }

                if (model.StyleLevel == 1 || model.StyleLevel == 4 || model.StyleLevel == 5 || model.StyleLevel == 6 || model.StyleLevel == 7)
                {
                    model.Tabs = f.Himall_FloorTabls.OrderBy(p => p.Id).Select(p => new Himall.Web.Areas.Web.Models.HomeFloorModel.Tab()
                    {
                        Name   = p.Name,
                        Detail = p.Himall_FloorTablDetails.ToList()
                                 .Where(d => d.Himall_Products.AuditStatus == ProductInfo.ProductAuditStatus.Audited &&
                                        d.Himall_Products.SaleStatus == ProductInfo.ProductSaleStatus.OnSale)
                                 .Select(d => new Himall.Web.Areas.Web.Models.HomeFloorModel.ProductDetail()
                        {
                            ProductId = d.Himall_Products.Id,
                            ImagePath = Himall.Core.HimallIO.GetProductSizeImage(d.Himall_Products.ImagePath, 1, (int)ImageSize.Size_350),
                            Price     = d.Himall_Products.MinSalePrice,
                            Name      = d.Himall_Products.ProductName
                        }).ToList()
                    }).ToList();

                    model.Scrolls = model.Products.Where(p => p.Type == Position.ScrollOne || p.Type == Position.ScrollTwo ||
                                                         p.Type == Position.ScrollThree || p.Type == Position.ScrollFour).ToList();

                    model.RightTops = model.Products.Where(p => p.Type == Position.ROne || p.Type == Position.RTwo ||
                                                           p.Type == Position.RThree || p.Type == Position.RFour).ToList();

                    model.RightBottons = model.Products.Where(p => p.Type == Position.RFive || p.Type == Position.RSix ||
                                                              p.Type == Position.RSeven || p.Type == Position.REight).ToList();
                }
                floorModels.Add(model);
            }
            homePageModel.floorModels = floorModels;

            //全部品牌
            HomeBrands homeBrands = new HomeBrands();
            var        listBrands = Application.BrandApplication.GetBrands(null);
            foreach (var item in listBrands)
            {
                homeBrands.listBrands.Add(new WebFloorBrand
                {
                    Id   = item.Id,
                    Img  = item.Logo,
                    Url  = "",
                    Name = item.Name
                });
            }
            homePageModel.brands = homeBrands;

            //限时购
            var setting = _iSiteSettingService.GetSiteSettings();
            if (setting.Limittime)
            {
                homePageModel.FlashSaleModel = _iLimitTimeBuyService.GetRecentFlashSale();
            }
            else
            {
                homePageModel.FlashSaleModel = new List <FlashSaleModel>();
            }

            return(View(homePageModel));

            #endregion
        }