예제 #1
0
        private HtmlInputHidden specialHideShow;     //特殊客户屏蔽展示功能

        protected override void AttachChildControls()
        {
            this.rptCartProducts                = (VshopTemplatedRepeater)this.FindControl("rptCartProducts");
            this.rptCartGifts                   = (VshopTemplatedRepeater)this.FindControl("rptCartGifts"); //礼品列表
            this.gifts                          = (HtmlControl)this.FindControl("gifts");                   //礼物板块
            this.products                       = (HtmlControl)this.FindControl("products");                //商品板块
            this.litTotalPoint                  = (Literal)this.FindControl("litTotalPoint");               //总积分
            this.litPointLeft                   = (Literal)this.FindControl("litPointLeft");                //剩余积分
            this.litTotalPoint.Text             = "0";
            this.rptCartProducts.ItemDataBound += new RepeaterItemEventHandler(this.rptCartProducts_ItemDataBound);
            this.rptCartGifts.ItemDataBound    += new RepeaterItemEventHandler(this.rptCartGifts_ItemDataBound);
            this.litTotal                       = (Literal)this.FindControl("litTotal");
            this.littext                        = (Literal)this.FindControl("littext");
            this.litStoreMoney                  = (Literal)this.FindControl("litStoreMoney");
            this.litExemption                   = (Literal)this.FindControl("litExemption");
            this.litcount                       = (Literal)this.FindControl("litcount");
            this.divShowTotal                   = (HtmlGenericControl)this.FindControl("divShowTotal");
            this.aLink                          = (HtmlAnchor)this.FindControl("aLink");
            this.specialHideShow                = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("specialHideShow");
            this.Page.Session["stylestatus"]    = "0";
            this.litExemption.Text              = "0.00";
            //this.cart = ShoppingCartProcessor.GetShoppingCartAviti();
            this.cart = ShoppingCartProcessor.GetShoppingCartList();//获取购物车信息
            int num = 0;

            //购物车数据源
            if (this.cart != null)
            {
                this.rptCartProducts.DataSource = this.cart;
                this.rptCartProducts.DataBind();
                for (int i = 0; i < this.cart.Count; i++)
                {
                    num += this.cart[i].GetQuantity();
                }
            }
            else
            {
                if (products != null)
                {
                    products.Visible = false;
                }
            }
            //绑定礼品数据
            if (cart != null && cart.Count > 0)
            {
                this.rptCartGifts.DataSource = cart;
                this.rptCartGifts.DataBind();
                for (int i = 0; i < this.cart.Count; i++)
                {
                    num += this.cart[i].GetGiftQuantity();
                }
            }
            else
            {
                if (gifts != null)
                {
                    gifts.Visible = false;
                }
            }
            this.litcount.Text = num.ToString();
            //传递爽爽挝啡的特殊名到前端,前端用jquery进行相应的功能隐藏
            if (Hidistro.ControlPanel.Config.CustomConfigHelper.Instance.AutoShipping)
            {
                specialHideShow.Value = "sswk";//爽爽挝啡
            }

            this.litTotal.Text = "¥" + "0.00";
            if (MemberProcessor.GetCurrentMember() != null)
            {
                //显示剩余积分
                this.litPointLeft.Text = MemberProcessor.GetCurrentMember().Points.ToString();
                decimal num3 = 0M;
                if (this.cart != null)
                {
                    foreach (ShoppingCartInfo info in this.cart)
                    {
                        num3 += info.GetAmount();
                    }
                }
                PageTitle.AddSiteNameTitle("购物车");
                DataTable allFull = ProductBrowser.GetAllFull(0);
                if (allFull.Rows.Count > 0)
                {
                    #region 获取相关活动
                    decimal num4 = 0M;
                    decimal num5 = 0M;
                    string  str  = "";
                    string  str2 = "";
                    string  str3 = "";
                    for (int j = 0; j < allFull.Rows.Count; j++)
                    {
                        if (num3 >= decimal.Parse(allFull.Rows[allFull.Rows.Count - 1]["MeetMoney"].ToString()))
                        {
                            str  = allFull.Rows[allFull.Rows.Count - 1]["ActivitiesName"].ToString();
                            num5 = decimal.Parse(allFull.Rows[allFull.Rows.Count - 1]["MeetMoney"].ToString());
                            num4 = decimal.Parse(allFull.Rows[allFull.Rows.Count - 1]["ReductionMoney"].ToString());
                            str3 = allFull.Rows[allFull.Rows.Count - 1]["ActivitiesType"].ToString();
                            str2 = allFull.Rows[allFull.Rows.Count - 1]["ActivitiesId"].ToString();
                            break;
                        }
                        if (num3 <= decimal.Parse(allFull.Rows[0]["MeetMoney"].ToString()))
                        {
                            str  = allFull.Rows[0]["ActivitiesName"].ToString();
                            num5 = decimal.Parse(allFull.Rows[0]["MeetMoney"].ToString());
                            num4 = decimal.Parse(allFull.Rows[0]["ReductionMoney"].ToString());
                            str3 = allFull.Rows[0]["ActivitiesType"].ToString();
                            str2 = allFull.Rows[0]["ActivitiesId"].ToString();
                            break;
                        }
                        if (num3 >= decimal.Parse(allFull.Rows[j]["MeetMoney"].ToString()))
                        {
                            str  = allFull.Rows[j]["ActivitiesName"].ToString();
                            num5 = decimal.Parse(allFull.Rows[j]["MeetMoney"].ToString());
                            num4 = decimal.Parse(allFull.Rows[j]["ReductionMoney"].ToString());
                            str3 = allFull.Rows[j]["ActivitiesType"].ToString();
                            str2 = allFull.Rows[j]["ActivitiesId"].ToString();
                        }
                    }
                    this.littext.Text = "";
                    if (num3 >= num5)
                    {
                        string text = this.littext.Text;
                        this.littext.Text       = text + "<div id=\"cartProducts\" class=\"well shopcart\"><div class=\"price-sale\"><span class=\"title\">促销活动:</span><span class=\"purchase\"><a href=\"/Vshop/ActivityDetail.aspx?ActivitiesId=" + str2 + "&CategoryId=" + str3 + "\">" + str + "</a></span><span>已满" + num5.ToString("0") + "已减" + num4.ToString("0") + "</span></div></div>";
                        this.ReductionMoneyALL += num4;
                    }
                    else
                    {
                        string str5 = this.littext.Text;
                        this.littext.Text = str5 + "<div id=\"cartProducts\" class=\"well shopcart\"><div class=\"price-sale\"><span class=\"title\">促销活动:</span><span class=\"purchase\"><a href=\"/Vshop/ActivityDetail.aspx?ActivitiesId=" + str2 + "&CategoryId=" + str3 + "\">" + str + "</a></span><span>满" + num5.ToString("0") + "减" + num4.ToString("0") + "</span></div></div>";
                    }
                    this.litExemption.Text = this.ReductionMoneyALL.ToString("0.00");
                    if (num3 == 0M)
                    {
                        this.littext.Text = "";
                    }
                    #endregion
                }
                this.litStoreMoney.Text = "¥" + num3.ToString("0.00");
                this.litTotal.Text      = "¥" + ((num3 - this.ReductionMoneyALL)).ToString("0.00");
                //如果有gift,则需要提示需要支付的积分总额
                if (cart.Count > 0)
                {
                    this.litTotalPoint.Text = getTotalPoints().ToString() == "0" ? "0" : getTotalPoints().ToString();
                }

                //隐藏
                if (getTotalPoints() == 0)
                {
                    gifts.Visible = false;
                }
            }
        }
예제 #2
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;
            }
        }