Ejemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     Response.Clear();
     try
     {
         string key = Request.QueryString["key"];
         Response.StatusCode = 200;
         string typeID = BLL_GoodsType.QueryTypeID(3, key).ElementAt(0).TypeID;
         var    list   = BLL_Goods.QueryGoods(typeID);
         Random rd     = new Random();
         for (int i = 0; i < 3; i++)
         {
             int pos = rd.Next(0, list.Count());
             Response.Write("<img class=\"sup_img J_sup_img\" src=\"" + list.ElementAt(pos).ImageName + "\">");
         }
     }
     catch (Exception ex)
     {
         Response.StatusCode = 500;
         Response.Write(ex.Message);
     }
     finally
     {
         Response.End();
     }
 }
Ejemplo n.º 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     Response.Clear();
     try
     {
         string key       = Request.QueryString["key"];      // 关键词
         string typeLevel = Request.QueryString["level"];    // 类别等级
         string typeID    = Request.QueryString["type"];     // 类别
         string typeName  = Request.QueryString["typeName"]; // 类别名称
         Response.StatusCode = 200;
         typeName            = HttpUtility.UrlEncode(typeName);
         typeName            = HttpUtility.UrlDecode(typeName, System.Text.Encoding.GetEncoding("utf-8"));
         if ((typeID == null || typeID == "") && (typeName != null && typeName != ""))
         {
             typeID = BLL_GoodsType.QueryTypeID(3, typeName).ElementAt(0).TypeID;
         }
         List <Entitys.Goods> list = null;
         if (typeID != null && typeID != "")
         {
             list = BLL_Goods.QueryGoods(typeID);                                 /// !商品量大不能直接获取所有商品,需要先生成随机数,再query取商品!
         }
         else
         {
             list = BLL_Goods.QueryGoodsKeyList(key, false, 0, 0);
         }
         Random rd = new Random();
         for (int i = 0; i < 7; i++)
         {
             int pos = rd.Next(0, list.Count() - 1);
             Response.Write("<li>");
             Response.Write("<div class=\"p-img\">");
             Response.Write("<a target=\"_blank\" href=\"#\">");
             Response.Write("<img width=\"160\" height=\"160\" src=\"" + list.ElementAt(pos).ImageName + "\" class=\"err-product\">");
             Response.Write("</a>");
             Response.Write("</div>");
             Response.Write("<div class=\"p-price\">");
             Response.Write("<strong class=\"J_11243404989\" data-adv=\"1\"><em>¥</em><i>" + list.ElementAt(pos).UnitPrice + "</i></strong>");
             Response.Write("</div>");
             Response.Write("<div class=\"p-name\">");
             Response.Write("<a target=\"_blank\" href=\"#\">");
             Response.Write("<em>" + (key != null && key != ""? (list.ElementAt(pos).Name.Replace(key, "<font class=\"skcolor_ljg\">" + key + "</font>")) : (list.ElementAt(pos).Name)) + "</em>");
             Response.Write("</a>");
             Response.Write("</div>");
             Response.Write("<div class=\"p-comm\" style=\"padding: 8px 10px 0\">已有<span style=\"color: #005aa0\">?</span>人评价</div>");
             Response.Write("</li>");
         }
     }
     catch (Exception ex)
     {
         Response.StatusCode = 500;
         Response.Write(ex.Message);
     }
     finally
     {
         Response.End();
     }
 }
Ejemplo n.º 3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     Response.Clear();
     try
     {
         var    cate_first = BLL_GoodsType.QueryAllTypes(1);
         string text       = "";
         for (int i = 0; i < cate_first.Count; i++)
         {
             text += "<div class=\"cate_part clearfix\" id=\"cate_item" + (i + 1).ToString() + "\" data-id=\"" + (char)((int)'a' + i) + "\" data-inlazuqueue=\"true\" style=\"display: none;padding-top: 10px;\">\n";
             var cate_pop = BLL_GoodsType.QueryTypesChild(1, cate_first.ElementAt(i).TypeID);
             text += "<div class=\"cate_part_col1\">\n<div class=\"cate_detail\">\n";
             for (int j = 0; j < cate_pop.Count; j++)
             {
                 text += "<dl class=\"cate_detail_item cate_detail_item1\">\n";
                 text += "<dt class=\"cate_detail_tit\">\n";
                 text += "<a href=\"/search.aspx?level=2&type=" + cate_pop.ElementAt(j).TypeID + "\" class=\"cate_detail_tit_lk\" target=\"_blank\">\n";
                 text += cate_pop.ElementAt(j).TypeName + "\n";
                 text += "<i class=\"iconfont cate_detail_titi_arror\"></i>\n</a>\n</dt>\n";
                 var cate_third = BLL_GoodsType.QueryTypesChild(2, cate_pop.ElementAt(j).TypeID);
                 text += "<dd class=\"cate_detail_con\">\n";
                 for (int k = 0; k < cate_third.Count; k++)
                 {
                     text += "<a href=\"/search.aspx?type=" + cate_third.ElementAt(k).TypeID + "\" class=\"cate_detail_con_lk\" target=\"_blank\">" + cate_third.ElementAt(k).TypeName + "</a>\n";
                 }
                 text += "</dd>\n</dl>\n";
             }
             text += "</div>\n</div>\n</div>\n";
         }
         Response.StatusCode = 200;
         Response.Write(text);
     }
     catch (Exception ex)
     {
         Response.StatusCode = 500;
         Response.Write(ex.Message);
     }
     finally
     {
         Response.End();
     }
 }
Ejemplo n.º 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (Session["name"] != null)
         {
             ttbar_login_server.Text        = "欢迎,<a style='color:red;'>" + Session["name"].ToString() + "</a>";
             server_user_hi.InnerHtml       = "Hi," + Session["name"];
             server_user_loginreg.InnerHtml = "<a class=\"user_info_level0\" href=\"//vip.jd.com\" target=\"_blank\"><i class=\"user_info_lvico\"></i>注册会员</a><a class=\"user_info_logout\" href=\"/logout.aspx\">退出</a>";
         }
         var    cate_first = BLL_GoodsType.QueryAllTypes(1);
         string text       = "";
         for (int i = 0; i < cate_first.Count; i++)
         {
             text += "<li class=\"cate_menu_item\" data-index=\"" + (i + 1).ToString() + "\"><a target=\"_blank\" class=\"cate_menu_lk\" href=\"#\">" + cate_first.ElementAt(i).TypeName + "</a></li>\n";
         }
         server_cate.Text = text;
     }
     catch (Exception ex)
     {
         server_cate.Text = ex.Message;
     }
 }
Ejemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["name"] != null)
            {
                ttbar_login_server.Text = "欢迎,<a style='color:red;'>" + Session["name"].ToString() + "</a>";
            }

            string key = Request.QueryString["key"];                                                 // 关键词
            string typeLevel = Request.QueryString["level"];                                         // 类别等级
            string typeID = Request.QueryString["type"];                                             // 类别
            string typeName = Request.QueryString["typeName"];                                       // 类别名称
            string price_u = Request.QueryString["priceu"], price_t = Request.QueryString["pricet"]; // 价格区间
            string page = Request.QueryString["page"];                                               // 页数

            if (IsNullorEmpty(key) && IsNullorEmpty(typeID) && IsNullorEmpty(typeName) && IsNullorEmpty(typeName))
            {
                J_searchWrap.InnerHtml = "<div class=\"notice-search\"><div class=\"ns-wrap clearfix info\"><span class=\"ns-icon\"></span><div class=\"ns-content\"><span>抱歉,没有找到与“<em></em>”相关的商品</span></div></div></div>";
                return;
            }

            try
            {
                if (key != null && key != "")
                {
                    server_qbjg.Text = key;
                }
                else if (typeID != null && typeID != "")
                {
                    server_qbjg.Text = BLL_GoodsType.QueryTypeName(3, typeID).TypeName;
                }
                else if (typeName != null && typeName != "")
                {
                    server_qbjg.Text = typeName;
                }
                int pos = 0;
                if (page != null && page != "")
                {
                    int _page = Convert.ToInt32(page);
                    pos = (_page - 1) * 20;
                }
                else
                {
                    page = "1";
                }
                bool   _f_type = true;
                string _type   = "";
                if (typeID != null && typeID != "")
                {
                    _type = typeID;
                }
                else if (typeName != null && typeName != "")
                {
                    _type = BLL_GoodsType.QueryTypeID(3, typeName).ElementAt(0).TypeID;
                }
                else
                {
                    _f_type = false;
                }
                int _f_price = 0;
                if (price_u != null && price_u != "")
                {
                    _f_price++;
                }
                if (price_t != null && price_t != "")
                {
                    _f_price += 2;
                }
                var list  = BLL_Goods.QueryGoodsKeyList(key, true, pos, 20, _f_type, _type, _f_price, Convert.ToInt32(price_u), Convert.ToInt32(price_t));
                int count = BLL_Goods.QueryGoodsKeyCount(key, _f_type, _type, _f_price, Convert.ToInt32(price_u), Convert.ToInt32(price_t));
                server_count.Text = count.ToString();
                server_page.Text  = "<b>" + page + "</b><em>/</em><i>" + (count % 20 == 0 ? count / 20 : (count / 20 + 1)).ToString() + "</i>";

                string text = "";
                foreach (var item in list)
                {
                    text += "<li class=\"gl-item\">";
                    text += "<div class=\"gl-i-wrap\">";
                    text += "<div class=\"p-img\">";
                    text += "<a target=\"_blank\" title=\"" + item.Name + "\" href=\"/detail.aspx?id=" + item.Id + "\" onclick=\"javascript:;\">";
                    text += "<img width=\"220\" height=\"220\" class=\"err-product\" data-img=\"1\" src=\"" + item.ImageName + "\" />";
                    text += "</a>";
                    text += "</div>";
                    text += "<div class=\"p-price\">";
                    text += "<strong class=\"J_2457023\" data-price=\"" + item.UnitPrice + "\"><em>¥</em><i>" + item.UnitPrice + "</i></strong>";
                    text += "</div>";
                    text += "<div class=\"p-name p-name-type-2\">";
                    text += "<a target=\"_blank\" title=\"" + item.Name + "\" href=\"/detail.aspx?id=\"" + item.Id + "onclick=\"searchlog(1,2457023,1,1,'','flagsClk=1614811784')\">";
                    text += "<em>" + (key != null && key != ""?item.Name.Replace(key, "<font class=\"skcolor_ljg\">" + key + "</font>"):item.Name) + "<font class=\"skcolor_ljg\" /></em>";
                    text += "<i class=\"promo-words\" id=\"J_AD_2457023\"></i>";
                    text += "</a>";
                    text += "</div>";
                    text += "<div class=\"p-shop\" data-selfware=\"1\" data-score=\"5\" data-reputation=\"96\" data-shopid=\"1000001772\"><a title=\"" + item.Desctipt + "\">" + item.Desctipt + "</a></div>";
                    text += "<div class=\"p-operate\">";
                    text += "<a class=\"p-o-btn contrast J_contrast\" data-sku=\"" + item.Id + "\" href=\"javascript:;\" onclick=\"javascript:;\"><i></i>对比</a>";
                    text += "<a class=\"p-o-btn focus J_focus\" data-sku=\"" + item.Id + "\" href=\"javascript:;\" onclick=\"javascript:;\"><i></i>关注</a>";
                    text += "<a class=\"p-o-btn addcart\" data-stock=\"" + item.Id + "\" data-stock-val=\"1\" data-disable-notice=\"0\" data-presale=\"0\" href=\"#\" data-limit=\"0\"><i></i>加入购物车</a>";
                    text += "</div>";
                    text += "</div>";
                    text += "</li>";
                }
                server_goods.Text = text;
            }
            catch (Exception ex)
            {
                server_goods.Text = "ERROR" + ex.Message;
            }
        }
Ejemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["name"] != null)
            {
                ttbar_login_server.Text = "欢迎,<a style='color:red;'>" + Session["name"].ToString() + "</a>";
            }
            try
            {
                string id = Request.QueryString["id"];
                if (id == null || id == "")
                {
                    Response.Redirect("/index.aspx");
                    return;
                }
                var good        = BLL_Goods.QueryGood(id);
                var type        = BLL_GoodsType.QueryTypeName(3, good.TypeID);
                var type_second = BLL_GoodsType.QueryTypeName(2, type.ParentTypeID);
                var type_top    = BLL_GoodsType.QueryTypeName(1, type_second.ParentTypeID);
                cate_first.InnerHtml  = "<a href='/search.aspx?type=" + type_top.TypeID + "'>" + type_top.TypeName + "</a>";
                cate_second.InnerHtml = "<a href='/search.aspx?type=" + type_second.TypeID + "'>" + type_second.TypeName + "</a>";
                cate_third.InnerHtml  = "<a href='/search.aspx?type=" + type.TypeID + "'>" + type.TypeName + "</a>";
                cate_ellipsis.Attributes.Add("title", good.Name);
                cate_ellipsis.InnerHtml = good.Name;
                server_follow.Attributes.Add("data-id", good.Id);
                server_sku_name.InnerText = good.Name;
                server_price.InnerText    = Math.Round(good.UnitPrice, 2).ToString();
                InitCartUrl.Attributes.Add("sku-id", good.Id);

                // 从京东获取展示图片、详细信息
                var res   = GetHttpWebRequest("http://search.jd.com/Search?keyword=" + good.Name + "&enc=utf-8");
                var regex = new Regex("<a target=\\\"_blank\\\" title=\\\"[^\"]*\\\" href=\\\"[/.\\w\\d]*\\\" onclick=\\\"searchlog[^\\\"]*\\\">");
                var match = regex.Match(res);
                res   = match.Value;
                regex = new Regex("href=\\\"[/.\\w\\d]*\\\"");
                match = regex.Match(res);
                res   = match.Value;
                regex = new Regex("\".*\"");
                match = regex.Match(res);
                res   = match.Value.Replace("\"", "");
                var rreess = res;
                regex = new Regex("/\\d*\\.");
                match = regex.Match(res);
                res   = match.Value.Substring(1, match.Value.Length - 2);
                res   = GetHttpWebRequest("https://cd.jd.com/description/channel?enc=utf-8&skuId=" + res + "&mainSkuId=" + res);
                glofot.Attributes.Add("style", "display:none;");
                glofot.InnerText = res.Replace("data-lazyload", "src");
                //return;
                res   = GetHttpWebRequest("http:" + rreess);
                regex = new Regex("<img alt='[^']*' src='[^']*' data-url='[^']*' data-img='[^']*' width='\\d*' height='\\d*'>");
                var matches = regex.Matches(res);
                spec_img.Attributes.Add("src", Regex.Match(matches[0].ToString().Replace("/n5/", "/n1/"), "src='[^']*'").Value.Replace("src='", "").Replace("'", "").Replace("s54x54", "s450x450")); spec_img.Attributes.Add("alt", good.Name);
                foreach (var item in matches)
                {
                    server_img_lh.InnerHtml += "<li>" + item.ToString() + "</li>\n";
                }
            }
            catch
            {
                Response.Write("<script>alert('从京东获取数据失败,图片和详细商品描述将不可用。');</script>");
            }
        }