Example #1
0
        public string RendHtml()
        {
            IList <BannerInfo> banners = VShopHelper.GetAllBanners(ClientType.PC, supplierId);
            StringBuilder      str     = new StringBuilder();

            if (banners != null && banners.Count > 0)
            {
                foreach (BannerInfo b in banners)
                {
                    var url = b.Url.ToString().Length > 0 ? b.Url : "javascript:void(0);";
                    str.AppendFormat("<li><a href='{0}' style='background:url({1})  no-repeat center top;'></a></li>", url, b.ImageUrl);
                }
            }
            return(str.ToString());
        }
Example #2
0
        private ListResult <BannerListItem> GetBanner(int siteId)
        {
            ListResult <BannerListItem> data = null;

            if (base.IsUseCache)
            {
                data = MemoryCacher.GetValue("SITE-BANNER") as ListResult <BannerListItem>;

                if (data != null)
                {
                    return(data);
                }
            }

            IList <BannerInfo>    allBanners = VShopHelper.GetAllBanners(ClientType.App);
            List <BannerListItem> items      = new List <BannerListItem>();

            if (allBanners != null)
            {
                BannerListItem item = null;
                allBanners = allBanners.Where(m => m.LocationType != LocationType.Register).ToList();
                foreach (var current in allBanners)
                {
                    item = new BannerListItem();

                    item.Id              = current.BannerId;
                    item.Title           = current.ShortDesc;
                    item.ImageUrl        = Util.AppendImageHost(current.ImageUrl);
                    item.BannerType      = (int)current.LocationType;
                    item.Values          = current.Url;
                    item.DisplaySequence = current.DisplaySequence;

                    items.Add(item);
                }
            }

            data = new ListResult <BannerListItem>();
            data.TotalNumOfRecords = items.Count;
            data.Results           = items;

            if (base.IsUseCache)
            {
                MemoryCacher.Add("SITE-BANNER", data, DateTimeOffset.UtcNow.AddMinutes(SITE_CACHE_KEEP_TIME));
            }

            return(data);
        }
Example #3
0
        /// <summary>
        /// 获取轮播图
        /// </summary>
        /// <param name="context"></param>
        public void GetBanner(System.Web.HttpContext context)
        {
            StringBuilder stringBuilder = new StringBuilder();

            context.Response.ContentType = "application/json";
            int supplierId;

            if (int.TryParse(context.Request["supplierId"], out supplierId))
            {
                IList <BannerInfo> info = VShopHelper.GetAllBanners(ClientType.PC, supplierId);

                if (info == null)
                {
                    stringBuilder.Append("{");
                    stringBuilder.Append("\"Success\":0");
                    stringBuilder.Append("}");
                    this.message = stringBuilder.ToString();
                    return;
                }

                else
                {
                    stringBuilder.Append("{");
                    stringBuilder.Append("\"Success\":1");
                    stringBuilder.Append(",");


                    stringBuilder.Append("\"Banners\":");
                    string strBanners = Newtonsoft.Json.JsonConvert.SerializeObject(info);
                    stringBuilder.Append(strBanners);
                    stringBuilder.Append("}");
                    this.message = stringBuilder.ToString();
                    return;
                }
            }

            else
            {
                stringBuilder.Append("{");
                stringBuilder.Append("\"Success\":0");
                stringBuilder.Append("}");
                this.message = stringBuilder.ToString();
                return;
            }
        }
Example #4
0
        public IHttpActionResult GetRegisterBanner(int siteId, string accessToken, int channel, int platform, string ver)
        {
            // 保存访问信息
            base.SaveVisitInfo(siteId, "", channel, platform, ver);

            // 验证令牌
            string appId            = "";
            int    accessTookenCode = VerifyAccessToken(accessToken, out appId);

            if (accessTookenCode > 0)
            {
                return(base.JsonFaultResult(new CommonException(accessTookenCode).GetMessage(), "Site.AppBanner"));
            }
            ListResult <BannerListItem> data       = null;
            IList <BannerInfo>          allBanners = VShopHelper.GetAllBanners(ClientType.App);
            BannerInfo            registerBanner   = allBanners.Where(m => m.LocationType == LocationType.Register).FirstOrDefault();
            List <BannerListItem> items            = new List <BannerListItem>();

            if (registerBanner != null)
            {
                BannerListItem item = new BannerListItem();

                item.Id              = registerBanner.BannerId;
                item.Title           = registerBanner.ShortDesc;
                item.ImageUrl        = Util.AppendImageHost(registerBanner.ImageUrl);
                item.BannerType      = (int)registerBanner.LocationType;
                item.Values          = registerBanner.Url;
                item.DisplaySequence = registerBanner.DisplaySequence;

                items.Add(item);
            }

            data = new ListResult <BannerListItem>();
            data.TotalNumOfRecords = items.Count;
            data.Results           = items;

            return(base.JsonActionResult(new StandardResult <ListResult <BannerListItem> >()
            {
                code = 0,
                msg = "",
                data = data
            }));
        }
Example #5
0
 private void BindData()
 {
     this.grdBanner.DataSource = VShopHelper.GetAllBanners();
     this.grdBanner.DataBind();
 }
Example #6
0
 private void GetDefaultData(System.Web.HttpContext context)
 {
     System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
     stringBuilder.Append("{\"result\":{\"advs\":[");
     System.Collections.Generic.IList <BannerInfo> allBanners = VShopHelper.GetAllBanners(ClientType.App);
     if (allBanners != null && allBanners.Count > 0)
     {
         allBanners = allBanners.Where(m => m.LocationType != LocationType.Register).ToList();
         if (allBanners != null && allBanners.Count > 0)
         {
             foreach (BannerInfo current in allBanners)
             {
                 stringBuilder.Append("{");
                 stringBuilder.AppendFormat("\"pic\":\"{0}\",", Globals.FullPath(current.ImageUrl));
                 stringBuilder.AppendFormat("\"description\":\"{0}\",", current.ShortDesc);
                 if (!string.IsNullOrEmpty(current.LoctionUrl))
                 {
                     stringBuilder.AppendFormat("\"url\":\"{0}\"", current.LoctionUrl);
                 }
                 else
                 {
                     stringBuilder.AppendFormat("\"url\":\"{0}\"", "javascript:;");
                 }
                 stringBuilder.Append("},");
             }
         }
         stringBuilder.Remove(stringBuilder.Length - 1, 1);
     }
     stringBuilder.Append("],");
     stringBuilder.Append("\"navigates\":[");
     System.Collections.Generic.IList <NavigateInfo> allNavigate = VShopHelper.GetAllNavigate(ClientType.App);
     if (allNavigate != null && allNavigate.Count > 0)
     {
         foreach (NavigateInfo current2 in allNavigate)
         {
             stringBuilder.Append("{");
             stringBuilder.AppendFormat("\"pic\":\"{0}\",", Globals.FullPath(current2.ImageUrl));
             stringBuilder.AppendFormat("\"description\":\"{0}\",", current2.ShortDesc);
             if (!string.IsNullOrEmpty(current2.LoctionUrl))
             {
                 stringBuilder.AppendFormat("\"url\":\"{0}\"", current2.LoctionUrl);
             }
             else
             {
                 stringBuilder.AppendFormat("\"url\":\"{0}\"", "javascript:;");
             }
             stringBuilder.Append("},");
         }
         stringBuilder.Remove(stringBuilder.Length - 1, 1);
     }
     stringBuilder.Append("],");
     stringBuilder.Append("\"topics\":[");
     System.Data.DataTable homeTopics = VShopHelper.GetHomeTopics(ClientType.App);
     if (homeTopics != null && homeTopics.Rows.Count > 0)
     {
         foreach (System.Data.DataRow dataRow in homeTopics.Rows)
         {
             stringBuilder.Append("{");
             stringBuilder.AppendFormat("\"tid\":{0},", dataRow["TopicId"]);
             stringBuilder.AppendFormat("\"title\":\"{0}\",", dataRow["title"]);
             stringBuilder.AppendFormat("\"pic\":\"{0}\",", Globals.FullPath((string)dataRow["IconUrl"]));
             stringBuilder.AppendFormat("\"url\":\"{0}\"", Globals.FullPath(string.Format("/AppShop/Topics.aspx?TopicId={0}", dataRow["TopicId"])));
             stringBuilder.Append("},");
         }
         stringBuilder.Remove(stringBuilder.Length - 1, 1);
     }
     stringBuilder.Append("],");
     stringBuilder.Append("\"tagProducts\":[");
     System.Data.DataTable homeProducts = VShopHelper.GetHomeProducts(ClientType.App);
     if (homeProducts != null && homeProducts.Rows.Count > 0)
     {
         foreach (System.Data.DataRow dataRow2 in homeProducts.Rows)
         {
             stringBuilder.Append("{");
             stringBuilder.AppendFormat("\"pid\":{0},", dataRow2["ProductId"]);
             stringBuilder.AppendFormat("\"name\":\"{0}\",", dataRow2["ProductName"].ToString().Replace("\\", "").Replace("\\", ""));
             stringBuilder.AppendFormat("\"pic\":\"{0}\",", (dataRow2["ThumbnailUrl180"] != System.DBNull.Value) ? Globals.FullPath((string)dataRow2["ThumbnailUrl180"]) : Globals.FullPath(this.siteSettings.DefaultProductThumbnail5));
             stringBuilder.AppendFormat("\"price\":\"{0}\",", ((decimal)dataRow2["SalePrice"]).ToString("F2"));
             stringBuilder.AppendFormat("\"saleCounts\":\"{0}\",", ((int)dataRow2["ShowSaleCounts"]).ToString());
             stringBuilder.AppendFormat("\"url\":\"{0}\"", Globals.FullPath(string.Format("/AppShop/ProductDetails.aspx?productId={0}", dataRow2["ProductId"])));
             stringBuilder.Append("},");
         }
         stringBuilder.Remove(stringBuilder.Length - 1, 1);
     }
     stringBuilder.Append("]}}");
     context.Response.Write(stringBuilder.ToString());
 }
 private void BindData()
 {
     this.grdBanner.DataSource = VShopHelper.GetAllBanners(ClientType.App, supplierId);
     this.grdBanner.DataBind();
 }
Example #8
0
        //private VshopTemplatedRepeater rptCategories;


        protected override void AttachChildControls()
        {
            //this.rptCategories = (VshopTemplatedRepeater)this.FindControl("rptCategories");
            this.img            = (HtmlImage)this.FindControl("imgDefaultBg");
            this.pager          = (Pager)this.FindControl("pager");
            this.litdescription = (Literal)this.FindControl("litdescription");
            this.imgback        = (HiImage)this.FindControl("imgback");
            this.imglogo        = (HiImage)this.FindControl("imglogo");
            this.iconsRepeater  = (VshopTemplatedRepeater)this.FindControl("iconsRepeater");
            this.grdBanner      = (VshopTemplatedRepeater)this.FindControl("grdBanner");
            //this.litReferralId = (Literal) this.FindControl("litReferralId");
            this.litSaleService = (Literal)this.FindControl("litSaleService");

            this.logoLinkStart = (Literal)this.FindControl("logoLinkStart");
            this.logoLinkEnd   = (Literal)this.FindControl("logoLinkEnd");

            AppConfigModel model = AppConfigHelper.GetAppConfig();


            this.Page.Session["stylestatus"] = "3";
            SiteSettings masterSettings = SettingsManager.GetMasterSettings(false);

            PageTitle.AddSiteNameTitle();
            if (base.referralId <= 0)
            {
                HttpCookie cookie = HttpContext.Current.Request.Cookies["Vshop-ReferralId"];
                if (!((cookie == null) || string.IsNullOrEmpty(cookie.Value)))
                {
                    base.referralId = int.Parse(cookie.Value);
                }
            }

            //this.litReferralId.Text = base.referralId.ToString();

            DistributorsInfo userIdDistributors = new DistributorsInfo();

            userIdDistributors = DistributorsBrower.GetUserIdDistributors(base.referralId);

            if (this.img != null)
            {
                this.img.Src = new VTemplateHelper().GetDefaultBg();
            }

            MemberInfo member = MemberProcessor.GetMember(base.referralId);

            if (member != null)
            {
                this.litSaleService.Text = member.CellPhone;
            }

            //读取图标配置
            this.iconsRepeater.DataSource = VShopHelper.GetAllNavigate();
            this.iconsRepeater.DataBind();

            //幻灯片
            this.grdBanner.DataSource = VShopHelper.GetAllBanners();
            this.grdBanner.DataBind();


            //IList<CategoryInfo> maxSubCategories = CategoryBrowser.GetMaxMainCategories(100);
            //this.rptCategories.DataSource = maxSubCategories;
            //this.rptCategories.DataBind();
        }