private string CreateProductHtml(JToken data, List <long> idArray)
        {
            string           layout = data["content"]["layout"].ToString();//1:小图,2:大图,3:一大两小,4:列表,5:小图有标题
            var              name   = "~/Views/Shared/GoodGroup" + layout + ".cshtml";
            ProductAjaxModel model  = new ProductAjaxModel()
            {
                list = new List <ProductContent>()
            };

            model.showIco   = bool.Parse(data["content"]["showIco"].ToString());
            model.showPrice = bool.Parse(data["content"]["showPrice"].ToString());
            model.showName  = data["content"]["showName"].ToString() == "1";
            var prod = _iProductService.GetProductByIds(idArray);

            foreach (var id in idArray)
            {
                var pro = prod.FirstOrDefault(d => d.Id == id);
                if (pro != null)
                {
                    model.list.Add(
                        new ProductContent
                    {
                        product_id     = pro.Id,
                        link           = "/m-wap/Product/Detail/" + pro.Id.ToString(),
                        price          = pro.MinSalePrice.ToString("f2"),
                        original_price = pro.MarketPrice.ToString("f2"),
                        pic            = pro.ImagePath + "/1_350.png",
                        title          = pro.ProductName,
                        is_limitbuy    = _iProductService.IsLimitBuy(pro.Id),
                        SaleCounts     = pro.SaleCounts
                    });
                }
            }
            return(this.ControllerContext.RenderViewToString(name, model));
        }
        public ActionResult Hi_Ajax_GetGoodsList(int status = 2, string title = "", int p = 1)
        {
            int pageNo             = p;
            ProductAjaxModel model = new ProductAjaxModel()
            {
                list = new List <ProductContent>()
            };

            InitialProductModel(model, status, title, pageNo);
            return(Json(model, JsonRequestBehavior.AllowGet));
        }
        private void InitialProductModel(ProductAjaxModel model, int status, string name, int pageNo)
        {
            var productList = _iProductService.GetProducts(new IServices.QueryModel.ProductQuery
            {
                AuditStatus = new ProductInfo.ProductAuditStatus[] { (ProductInfo.ProductAuditStatus)status },
                KeyWords    = name,
                PageNo      = pageNo,
                PageSize    = 10,
                Sort        = "Id",
                IsAsc       = true
            });
            int pageCount = TemplatePageHelper.GetPageCount(productList.Total, 10);

            if (productList != null)
            {
                model.status = 1;
                model.page   = TemplatePageHelper.GetPageHtml(pageCount, pageNo);
                InitialProductContentModel(productList.Models, model);
            }
        }
 private void InitialProductContentModel(IQueryable <ProductInfo> productList, ProductAjaxModel model)
 {
     foreach (var product in productList)
     {
         model.list.Add(new ProductContent
         {
             create_time    = "",
             item_id        = product.Id,
             link           = "/m-wap/Product/Detail/" + product.Id.ToString(),
             pic            = product.GetImage(ImageSize.Size_350),
             title          = product.ProductName,
             price          = product.MinSalePrice.ToString("F2"),
             original_price = product.MarketPrice.ToString("F2"),
             is_compress    = "0"
         });
     }
 }
 private void InitialSmallProgProductContentModel(IQueryable <ProductInfo> productList, ProductAjaxModel model)
 {
     foreach (var product in productList)
     {
         model.list.Add(new ProductContent
         {
             create_time    = "",
             item_id        = product.Id,
             link           = "../productdetail/productdetail?id=" + product.Id.ToString(),
             pic            = Himall.Core.HimallIO.GetRomoteProductSizeImage(product.ImagePath, 1, (int)ImageSize.Size_350),
             title          = product.ProductName,
             price          = product.MinSalePrice.ToString("F2"),
             original_price = product.MarketPrice.ToString("F2"),
             is_compress    = "0"
         });
     }
 }
Пример #6
0
        // GET: Admin/TemplateVisualizationProcess
        public ActionResult GoodsListAction()
        {
            var    data = this.ControllerContext.RouteData.Values;
            var    layout = data["Layout"];
            string ids = "";
            bool   showIco = false, showPrice = false, showName = false;
            bool   showWarp = true;
            string warpId   = "";

            if (layout != null)
            {
                ids       = data["IDs"].ToString();
                showIco   = bool.Parse(data["ShowIco"].ToString());
                showPrice = bool.Parse(data["showPrice"].ToString());
                showName  = data["showName"].ToString() == "1";
                warpId    = data["ID"].ToString();
                showWarp  = true;
            }
            else
            {
                layout    = Request["Layout"];
                ids       = Request["IDs"];
                showIco   = bool.Parse(Request["ShowIco"]);
                showPrice = bool.Parse(Request["showPrice"]);
                showName  = Request["showName"] == "1";
                if (!string.IsNullOrWhiteSpace(Request["showWarp"]))
                {
                    showWarp = bool.Parse(Request["showWarp"]);
                }
            }
            var name = "~/Views/Shared/GoodGroup" + layout + ".cshtml";
            ProductAjaxModel model = new ProductAjaxModel()
            {
                list = new List <ProductContent>()
            };

            model.showIco   = showIco;
            model.showPrice = showPrice;
            model.showName  = showName;
            model.showWarp  = showWarp;
            model.warpId    = warpId;
            var         productSaleCountOnOff = SiteSettingApplication.SiteSettings.ProductSaleCountOnOff == 1;
            List <long> idArray = new List <long>();

            idArray = ids.Split(',').Where(d => !string.IsNullOrWhiteSpace(d)).Select(d => long.Parse(d)).ToList();
            if (idArray != null && idArray.Count > 0)
            {
                var products = ProductManagerApplication.GetProductByIds(idArray);
                model.list = new List <ProductContent>();
                var     selfshop = _iShopService.GetSelfShop();
                decimal discount = 1m;
                if (CurrentUser != null)
                {
                    discount = CurrentUser.MemberDiscount;
                }
                foreach (var id in idArray)
                {
                    Entities.ProductInfo d = products.FirstOrDefault(p => p.Id == id);
                    if (null == d)
                    {
                        continue;
                    }
                    decimal minprice = d.MinSalePrice;
                    if (selfshop != null && d.ShopId == selfshop.Id)
                    {
                        minprice = d.MinSalePrice * discount;
                    }
                    var _tmp = new ProductContent
                    {
                        product_id            = d.Id,
                        link                  = "/m-wap/Product/Detail/" + d.Id.ToString(),
                        price                 = minprice.ToString("f2"),
                        original_price        = d.MarketPrice.ToString("f2"),
                        pic                   = Core.HimallIO.GetProductSizeImage(d.RelativePath, 1, (int)ImageSize.Size_350),
                        title                 = d.ProductName,
                        is_limitbuy           = _iProductService.IsLimitBuy(d.Id),
                        SaleCounts            = d.SaleCounts + (int)d.VirtualSaleCounts,
                        ProductSaleCountOnOff = productSaleCountOnOff,
                        productType           = d.ProductType
                    };
                    model.list.Add(_tmp);
                }
            }
            return(PartialView(name, model));
        }