Пример #1
0
        protected override void AttachChildControls()
        {
            int.TryParse(this.Page.Request.QueryString["categoryId"], out this.categoryId);
            this.keyWord = this.Page.Request.QueryString["keyWord"];
            //this.rptProducts = (VshopTemplatedRepeater)this.FindControl("rptProducts");
            this.rptCategories = (VshopTemplatedRepeater)this.FindControl("rptCategories");
            this.litCategoryId = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("litCategoryId");
            this.litCategoryId.SetWhenIsNotNull(this.categoryId.ToString());


            MemberInfo currentMember = MemberProcessor.GetCurrentMember();

            if (currentMember == null)
            {
                this.Page.Response.Redirect("UserLogin.aspx");
            }
            HttpCookie cookie         = HttpContext.Current.Request.Cookies["Vshop-ReferralId"];
            int        ReferralUserId = 0;

            if ((cookie != null) && !string.IsNullOrEmpty(cookie.Value))
            {
                ReferralUserId = Convert.ToInt32(cookie.Value);
            }

            Hidistro.Core.HiCache.Remove("DataCache-CategoriesRange");//清除分类缓存
            //获取手机端所有商品的分类
            DataTable dt = CategoryBrowser.GetCategoriesByRange(2);

            this.rptCategories.DataSource = dt;
            this.rptCategories.DataBind();
        }
Пример #2
0
        /// <summary>
        /// 根据分类id获取商品信息
        /// </summary>
        /// <param name="context"></param>
        private void getProductsAsyc(System.Web.HttpContext context)
        {
            context.Response.ContentType = "application/json";
            int currentCategoryId = -1;
            IList <ProductInfo> dtMobileProducts = new List <ProductInfo>();

            try
            {
                int categoryId = Convert.ToInt32(context.Request["CategoryId"]);


                Hidistro.Core.HiCache.Remove("DataCache-CategoriesRange");//清除分类缓存
                //获取手机端所有商品的分类
                DataTable dtMobileCagegories = CategoryBrowser.GetCategoriesByRange(2);
                if (categoryId == 0)
                {
                    if (dtMobileCagegories.Rows.Count > 0)
                    {
                        //获取手机端商品的第一个分类id
                        int FirstCategoryID = Convert.ToInt32(dtMobileCagegories.Rows[0]["categoryId"]);
                        dtMobileProducts  = ProductBrowser.GetProductList(FirstCategoryID);
                        currentCategoryId = FirstCategoryID;
                    }
                }
                else
                {
                    dtMobileProducts  = ProductBrowser.GetProductList(categoryId);
                    currentCategoryId = categoryId;
                }
                CategoryInfo currentCategory = CatalogHelper.GetCategory(currentCategoryId);
                string       backHtml        = "";
                backHtml += string.Format("<div role='categoryProducts' CategoryId='{0}'>", currentCategoryId);
                foreach (ProductInfo info in dtMobileProducts)
                {
                    backHtml += string.Format("<div class='goods' role='productItem'  ProductId='{0}' ProductName='{1}' BuyPrice='{2}' SkuCounts='{3}' Quantity='{4}' Stock='{5}' SkuId='{6}'>", info.ProductId, info.ProductName, info.DefaultSku.SalePrice, info.Skus.Count, 0, info.Stock, info.SkuId);
                    backHtml += " <div id='slides'><div class='swiper-container productImg'><div class='swiper-wrapper'>";
                    //循环增加商品轮播图
                    string       locationUrl = "javascript:;";
                    SlideImage[] imageArray  = new SlideImage[] { new SlideImage(info.ImageUrl1, locationUrl), new SlideImage(info.ImageUrl2, locationUrl), new SlideImage(info.ImageUrl3, locationUrl), new SlideImage(info.ImageUrl4, locationUrl), new SlideImage(info.ImageUrl5, locationUrl) };
                    foreach (SlideImage image in imageArray)
                    {
                        if (!string.IsNullOrWhiteSpace(image.ImageUrl))
                        {
                            backHtml += "<div class='swiper-slide'><img src='" + image.ImageUrl + "' /></div>";
                        }
                    }
                    backHtml += "</div></div></div><div class='info'>";
                    backHtml += "<span class='title'>" + info.ProductName + "</span>";
                    backHtml += "<p class='price'>¥" + info.DefaultSku.SalePrice.ToString("F2") + "<i class='fa fa-plus-circle'></i></p>";
                    backHtml += "</div></div>";
                }
                backHtml += "</div>";
                //<li id='product_<%# Eval('ProductId') %>' ProductId='<%#Eval('ProductId') %>' ProductName='<%# Eval('ProductName') %>' BuyPrice='<%# Eval('SalePrice') %>' SkuCounts='<%# Eval('skuCounts') %>' Quantity='<%# Eval('Quantity') %>' Stock='<%# Eval('stock') %>' SkuId='<%# Eval('SkuId') %>'>
                //<div id='slides'><div class='swiper-container productImg'><div class='swiper-wrapper'>
                //            <hi:vshoptemplatedrepeater id='rptProductImages' templatefile='/Tags/skin-Common_QuickOrderSlide.ascx' runat='server' />
                //        </div></div></div>
                //<div class='info'>
                //    <span class='title'><%# Eval('ProductName') %></span>
                //    <p class='price'>¥<%# Eval('SalePrice','{0:F0}') %><i class='fa fa-plus-circle'></i></p>
                //</div></li>

                //System.Threading.Thread.Sleep(3000);
                context.Response.Write("{\"success\":true,\"backHtml\":\"" + backHtml + "\",\"categoryBannerImgUrl\":\"" + currentCategory.MetaKeywords + "\"}");
            }
            catch (Exception ex)
            {
                context.Response.Write("{\"success\":true,\"errMsg\":\"" + ex.Message + "\"}");
            }
            finally
            {
                dtMobileProducts = null;
            }
        }
Пример #3
0
        public int managerId;          //当前pc端点餐管理员id

        protected override void AttachChildControls()
        {
            if (!Hidistro.ControlPanel.Config.CustomConfigHelper.Instance.AnonymousOrder)
            {
                GotoResourceNotFound("pc点餐功能暂未开启!");
            }
            if (!string.IsNullOrEmpty(this.Page.Request.QueryString["Id"]))
            {
                System.Web.HttpCookie cookie = new System.Web.HttpCookie("Vshop-Manager")
                {
                    Value   = this.Page.Request.QueryString["Id"].ToString(),
                    Expires = System.DateTime.Now.AddDays(1.0)
                };
                System.Web.HttpContext.Current.Response.Cookies.Add(cookie);
            }


            int.TryParse(this.Page.Request.QueryString["categoryId"], out this.categoryId);
            this.keyWord                 = this.Page.Request.QueryString["keyWord"];
            this.imgUrl                  = (HiImage)this.FindControl("imgUrl");
            this.litContent              = (Literal)this.FindControl("litContent");
            this.rptProducts             = (VshopTemplatedRepeater)this.FindControl("rptProducts");
            this.rptCategories           = (VshopTemplatedRepeater)this.FindControl("rptCategories");
            this.litCategoryId           = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("litCategoryId");
            this.txtTotal                = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("txtTotal");
            this.defaultShippingtype     = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("defaultShippingtype");
            this.txtStoreId              = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("txtStoreId");
            this.txtThirdWayDiscountInfo = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("txtThirdWayDiscountInfo");
            this.litBuyToGive            = (Literal)this.FindControl("litBuyToGive");
            this.litHalf                 = (Literal)this.FindControl("litHalf");//第二杯半价
            this.litOrderList            = (Literal)this.FindControl("litOrderList");
            this.litCategoryId.SetWhenIsNotNull(this.categoryId.ToString());
            this.Page.Session["stylestatus"] = "4";
            this.litStoreName = (Literal)this.FindControl("litStoreName");

            //获取所有活动列表
            //this.dtpromotion = ProductBrowser.GetAllFull();
            SiteSettings masterSettings = SettingsManager.GetMasterSettings(false);

            this.txtThirdWayDiscountInfo.Value = masterSettings.thirdWayDiscountInfo;

            //获取当前点餐门店信息
            ManagerInfo currentManager = ManagerHelper.GetCurrentManager();

            storeId               = currentManager.ClientUserId;
            litStoreName.Text     = ManagerHelper.GetStoreName(storeId);
            this.txtStoreId.Value = this.storeId.ToString();

            switch (Hidistro.Core.SettingsManager.GetMasterSettings(true).VTheme.ToLower())
            {
            case "common":
            case "hotel":
                //this.rptProducts.ItemDataBound += new RepeaterItemEventHandler(this.rptProducts_ItemDataBound);

                DataTable dtProducts = new DataTable();                               //商品dt
                DataTable dt         = CategoryBrowser.GetCategoriesByRange(rangeId); //CategoryBrowser.GetCategoriesRange(ProductInfo.ProductRanage.All);
                int       total      = 0;
                int       num;
                int       num2;
                if (!int.TryParse(this.Page.Request.QueryString["page"], out num))
                {
                    num = 1;
                }
                if (!int.TryParse(this.Page.Request.QueryString["size"], out num2))
                {
                    num2 = 16;
                }
                if (categoryId == 0)
                {
                    if (dt.Rows.Count > 0)
                    {
                        //获取第一个分类id
                        int FirstCategoryID = Convert.ToInt32(dt.Rows[0]["categoryId"]);
                        this.litCategoryId.SetWhenIsNotNull(FirstCategoryID.ToString());
                        //匿名点餐情况下,商品为总店的所有商品,用户则是匿名用户(无需登录)

                        dtProducts = ProductBrowser.GetProducts(MemberProcessor.GetAnonymousMember(this.Page.Request.QueryString["type"].ToString()), null, 0, FirstCategoryID, this.keyWord, num, num2, out total, "ShowSaleCounts", "desc", "", rangeId, storeId);
                    }
                }
                else
                {
                    dtProducts = ProductBrowser.GetProducts(MemberProcessor.GetAnonymousMember(this.Page.Request.QueryString["type"].ToString()), null, 0, categoryId, this.keyWord, num, num2, out total, "ShowSaleCounts", "desc", "", rangeId, storeId);
                }
                //绑定购物车的信息
                this.cart = ShoppingCartProcessor.GetShoppingCartAviti(Globals.GetCurrentManagerUserId());

                //根据商品id判断是否包含其余规格,如果有,则新增一个字段存入规格号
                dtProducts.Columns.Add("skuCounts");
                foreach (DataRow row in dtProducts.Rows)
                {
                    DataTable skus = ProductBrowser.GetSkus(Convert.ToInt32(row["ProductId"]));
                    row["skuCounts"] = skus.Rows.Count;
                }

                this.rptProducts.DataSource = dtProducts;
                this.rptProducts.DataBind();

                if (!dt.Columns.Contains("PType"))
                {
                    dt.Columns.Add("PType", typeof(string));
                }
                foreach (DataRow dr in dt.Rows)
                {
                    dr["PType"] = this.Page.Request.QueryString["type"];
                }
                this.rptCategories.DataSource = dt;
                this.rptCategories.DataBind();



                if (cart != null)
                {
                    this.litOrderList.Text = "";
                    //根据购物车的信息绑定左侧点单列表的信息
                    foreach (ShoppingCartInfo cartInfo in cart)
                    {
                        foreach (ShoppingCartItemInfo info in cartInfo.LineItems)
                        {
                            this.litOrderList.Text += string.Format(@"<li><span>{4}</span><div class='guige'><d type='skuName'>{8}</d><b style='display:none'>{3}</b>{7}</div>
                                                <span>
                                                    <a id='spSub_{0}' class='shopcart-minus'>-</a>
                                                    <input type='tel' id='buyNum_{0}' class='form-control' value='{2}' disabled='disabled' />
                                                    <input type='hidden' id='skuid_{1}' value='{1}'/>
                                                    <a id='spAdd_{0}' class='shopcart-add'>+</a>
                                                    <input type='hidden' id='giveNum' value='{5}'/>
                                                    <input type='hidden' id='halfNum' value='{6}'/>
                                                </span></li>
                                                ", info.ProductId, info.SkuId, info.Quantity, info.AdjustedPrice.ToString("F2"), info.Name, info.GiveQuantity, info.HalfPriceQuantity, info.GiveQuantity <= 0 ? (info.HalfPriceQuantity <= 0 ? "" : "(半价" + info.HalfPriceQuantity + ")") : "(送" + info.GiveQuantity + ")", skuContentFormat(info.SkuContent));
                        }
                    }
                }
                this.txtTotal.SetWhenIsNotNull(total.ToString());
                break;

            default:
                this.rptCategories.ItemDataBound += new RepeaterItemEventHandler(this.rptCategories_ItemDataBound);
                if (this.Page.Request.QueryString["TypeId"] != null)
                {
                    this.rptCategories.DataSource = CategoryBrowser.GetCategoriesByPruductType(100, Convert.ToInt32(this.Page.Request.QueryString["TypeId"]));
                    this.rptCategories.DataBind();
                }
                else
                {
                    IList <CategoryInfo> maxSubCategories = CategoryBrowser.GetMaxSubCategoriesRange(this.categoryId, 0x3e8, DistributorsBrower.GetCurrStoreProductRange());
                    this.rptCategories.DataSource = maxSubCategories;
                    this.rptCategories.DataBind();
                }

                PageTitle.AddSiteNameTitle("电脑点餐");
                break;
            }

            if (masterSettings.BuyOrGive)
            {
                this.litBuyToGive.Text = "<a id=\"btnGiveBuy\" class=\"account-all\" onclick=\"BuyGive()\">买一送一</a>";
            }
            if (masterSettings.BuyOrHalf)
            {
                this.litHalf.Text = "<a id=\"btnHalf\" class=\"account-all\" onclick=\"BuyHalf()\">第二杯半价</a>";
            }

            IList <ShippingModeInfo> shippingmodesList = SalesHelper.GetShippingModes();

            this.defaultShippingtype.Value = shippingmodesList[0].ModeId.ToString();
        }
Пример #4
0
        public int rangeId = 1;//范围id 1:pc端,0:微信端,


        protected override void AttachChildControls()
        {
            int.TryParse(this.Page.Request.QueryString["categoryId"], out this.categoryId);
            this.keyWord            = this.Page.Request.QueryString["keyWord"];
            this.imglogo            = (HiImage)this.FindControl("imglogo");
            this.litTitle           = (Literal)this.FindControl("litTitle");
            this.litDes             = (Literal)this.FindControl("litDes");
            this.litMemberGradeInfo = (Literal)this.FindControl("litMemberGradeInfo");
            this.imgUrl             = (HiImage)this.FindControl("imgUrl");
            this.litContent         = (Literal)this.FindControl("litContent");
            this.rptProducts        = (VshopTemplatedRepeater)this.FindControl("rptProducts");
            this.rptCategories      = (VshopTemplatedRepeater)this.FindControl("rptCategories");
            this.litCategoryId      = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("litCategoryId");
            this.litCategoryId.SetWhenIsNotNull(this.categoryId.ToString());
            this.Page.Session["stylestatus"] = "4";

            this.storeId = !string.IsNullOrEmpty(this.Page.Request.QueryString["storeid"]) ? int.Parse(this.Page.Request.QueryString["storeid"]) : 0;

            MemberInfo currentMember = MemberProcessor.GetCurrentMember();

            if (currentMember == null)
            {
                this.Page.Response.Redirect("UserLogin.aspx");
            }
            HttpCookie cookie         = HttpContext.Current.Request.Cookies["Vshop-ReferralId"];
            int        ReferralUserId = 0;

            if ((cookie != null) && !string.IsNullOrEmpty(cookie.Value))
            {
                ReferralUserId = Convert.ToInt32(cookie.Value);
            }

            Hidistro.Entities.Members.DistributorsInfo userIdDistributors = DistributorsBrower.GetUserIdDistributors(ReferralUserId);
            Hidistro.Core.Entities.SiteSettings        masterSettings     = Hidistro.Core.SettingsManager.GetMasterSettings(false);
            //店铺logo
            if (userIdDistributors != null && !string.IsNullOrEmpty(userIdDistributors.Logo))
            {
                this.imglogo.ImageUrl = userIdDistributors.Logo;
            }
            else
            {
                if (!string.IsNullOrEmpty(masterSettings.DistributorLogoPic))
                {
                    this.imglogo.ImageUrl = masterSettings.DistributorLogoPic.Split(new char[] { '|' })[0];
                }
            }
            //店铺名和店铺描述
            if (ReferralUserId == 0)//如果没有上级店铺
            {
                this.litTitle.Text = masterSettings.SiteName;
                this.litDes.Text   = masterSettings.ShopIntroduction;
            }
            else
            {
                this.litTitle.Text = userIdDistributors.StoreName;
                this.litDes.Text   = userIdDistributors.StoreDescription;
            }

            //会员等级优惠信息
            if (this.litMemberGradeInfo != null)
            {
                MemberGradeInfo gradeInfo = MemberHelper.GetMemberGrade(currentMember.GradeId);//会员等级信息
                string          gradeName = gradeInfo.Name;
                string          currentMemberGradeName = (currentMember == null) ? "" :
                                                         string.Format("<span style='font-size:12px; background:#F90; color:#FFF; border-radius:3px; padding:3px 5px; margin-right:5px;'>{0}</span>"
                                                                       , gradeName);
                if (gradeInfo.Discount < 100)
                {
                    litMemberGradeInfo.Text = string.Format("{0}以下商品已获得{1}%折扣!", currentMemberGradeName, 100 - gradeInfo.Discount);
                }
                else
                {
                    litMemberGradeInfo.Text = string.Format("{0}以下商品均无打折", currentMemberGradeName, 100 - gradeInfo.Discount);;
                }
            }
            switch (Hidistro.Core.SettingsManager.GetMasterSettings(true).VTheme.ToLower())
            {
            case "common":
            case "hotel":
                Hidistro.Core.HiCache.Remove("DataCache-CategoriesRange");    //清除分类缓存
                //获取手机端所有商品的分类
                DataTable dt = CategoryBrowser.GetCategoriesByRange(rangeId); //CategoryBrowser.GetCategoriesRange(ProductInfo.ProductRanage.NormalSelect);

                int       total = 0;
                DataTable dt2   = new DataTable();
                if (categoryId == 0)
                {
                    if (dt.Rows.Count > 0)
                    {
                        //获取手机端商品的第一个分类id
                        int FirstCategoryID = Convert.ToInt32(dt.Rows[0]["categoryId"]);
                        this.litCategoryId.SetWhenIsNotNull(FirstCategoryID.ToString());

                        dt2 = ProductBrowser.GetProducts(MemberProcessor.GetCurrentMember(), null, 0, FirstCategoryID, this.keyWord, 1, 20, out total, "ShowSaleCounts", "desc", "", rangeId, storeId);
                    }
                }
                else
                {
                    dt2 = ProductBrowser.GetProducts(MemberProcessor.GetCurrentMember(), null, 0, categoryId, this.keyWord, 1, 20, out total, "ShowSaleCounts", "desc", "", rangeId, storeId);
                }
                //根据商品id判断是否包含其余规格,如果有,则新增一个字段存入规格号
                dt2.Columns.Add("skuCounts");
                dt2.Columns.Add("Quantity");
                List <Hidistro.Entities.Sales.ShoppingCartInfo> cart = ShoppingCartProcessor.GetShoppingCartList();   //获取购物车信息
                foreach (DataRow row in dt2.Rows)
                {
                    DataTable skus = ProductBrowser.GetSkus(Convert.ToInt32(row["ProductId"]));
                    row["skuCounts"] = skus.Rows.Count;
                    row["Quantity"]  = 0;
                    //根据商品id获取购物车中已存在的数量,防止页面刷新后选中的数量遗失
                    foreach (Hidistro.Entities.Sales.ShoppingCartInfo info in cart)
                    {
                        foreach (Hidistro.Entities.Sales.ShoppingCartItemInfo itemInfo in info.LineItems)
                        {
                            if (Convert.ToInt32(row["ProductId"]) == itemInfo.ProductId)
                            {
                                row["Quantity"] = itemInfo.Quantity;
                            }
                        }
                    }
                }
                this.rptCategories.DataSource = dt;
                this.rptCategories.DataBind();

                this.rptProducts.DataSource = dt2;
                this.rptProducts.DataBind();
                break;

            default:
                this.rptCategories.ItemDataBound += new RepeaterItemEventHandler(this.rptCategories_ItemDataBound);
                if (this.Page.Request.QueryString["TypeId"] != null)
                {
                    this.rptCategories.DataSource = CategoryBrowser.GetCategoriesByPruductType(100, Convert.ToInt32(this.Page.Request.QueryString["TypeId"]));
                    this.rptCategories.DataBind();
                }
                else
                {
                    IList <CategoryInfo> maxSubCategories = CategoryBrowser.GetMaxSubCategoriesRange(this.categoryId, 0x3e8, DistributorsBrower.GetCurrStoreProductRange());
                    this.rptCategories.DataSource = maxSubCategories;
                    this.rptCategories.DataBind();
                }
                PageTitle.AddSiteNameTitle("移动点餐");
                break;
            }
        }