/// <summary> /// 获取在商品吧详细页的用户浏览历史 /// </summary> /// <returns></returns> public static string GetProductDetailBrowserHistoryProductsHTML() { string productDetailBroswerHistoryHTML = String.Empty; string cookie = CookieUtil.GetDESEncryptedCookieValue(CookieUtil.Cookie_BrowseHistory); ArrayList al = CustomerBrowserHistoryProductService.GetBrowseHistoryList(cookie); if (al != null) { StringBuilder strb = new StringBuilder("<ul class='group'>"); string liHTML = @"<li><a class='photo' href='{0}'> <img alt='{1}' src='{2}' width='60' height='60'></a> <div> <a class='name' title='{3}' href='{4}'>{5}</a> <span class='adText'>{6}</span> </div> <p class='price'> <b>¥{7}</b><span>¥{8}</span></p> </li>"; var products = al.ToArray().Take(4); foreach (CustomerBrowserHistoryProduct product in products) { string thumbImg = YoeJoyConfig.ImgVirtualPathBase + product.SmallImg; string deeplink = YoeJoyConfig.SiteBaseURL + "Pages/Product.aspx?c1=" + product.C1SysNo + "&c2=" + product.C2SysNo + "&c3=" + product.C3SysNo + "&pid=" + product.ProductSysNo; strb.Append(String.Format(liHTML, deeplink, product.ProductBriefName, thumbImg, product.ProductBriefName, deeplink, product.ProductBriefName, product.PromotionWord, product.CurrentPrice, product.StandardPrice)); } strb.Append("</ul>"); productDetailBroswerHistoryHTML = strb.ToString(); } return(productDetailBroswerHistoryHTML); }
public Hashtable GetCartHash() { //get cart string; //build cart hash; //增加期望订购数量,ProductSysNo1,Quantity1,ExpectQty1;ProductSysNo2,Quantity2,ExpectQty2 Hashtable ht = new Hashtable(5); string cartCookieValue = CookieUtil.GetDESEncryptedCookieValue("cart"); if (cartCookieValue == null) { return(ht); } string[] cartItems = cartCookieValue.Split(';'); try { for (int i = 0; i < cartItems.Length; i++) { string cartItem = cartItems[i]; string[] cartValues = cartItem.Split(','); CartInfo oCart = new CartInfo(); oCart.ProductSysNo = Convert.ToInt32(cartValues[0]); oCart.Quantity = Convert.ToInt32(cartValues[1]); if (cartValues.Length > 2) { oCart.ExpectQty = Convert.ToInt32(cartValues[2]); } else { oCart.ExpectQty = Convert.ToInt32(cartValues[1]); } if (oCart.Quantity > 99) { oCart.Quantity = 99; } ht.Add(oCart.ProductSysNo, oCart); } } catch {} return(ht); }
/// <summary> /// 设置用户的浏览记录 /// </summary> /// <param name="productSysNo"></param> public static void SetCustomerBrowserHistory(int productSysNo) { // 如果product已经存在于cookie中,就不用更新了 // 更新Cookie // 更新Session string cookie = CookieUtil.GetDESEncryptedCookieValue(CookieUtil.Cookie_BrowseHistory); string newCookie = productSysNo.ToString(); if (cookie != null) { string[] productArray = cookie.Split(','); int index = 0; // 新的字符串的个数 for (int i = 0; i < productArray.Length; i++) { if (productArray[i] != productSysNo.ToString()) { newCookie += ","; try { Convert.ToInt32(productArray[i]); } catch { //出错重置为当前product newCookie = productSysNo.ToString(); break; } newCookie += productArray[i]; index++; } if (index == 9) { break; } } } CookieUtil.SetDESEncryptedCookie(CookieUtil.Cookie_BrowseHistory, newCookie, DateTime.MaxValue); }
/// <summary> /// 获得用户的所有浏览商品记录 /// </summary> /// <returns></returns> public static string GetCustomerBrowserHistoryProductsAllHTML() { string productDetailBroswerHistoryHTML = String.Empty; string cookie = CookieUtil.GetDESEncryptedCookieValue(CookieUtil.Cookie_BrowseHistory); ArrayList al = CustomerBrowserHistoryProductService.GetBrowseHistoryList(cookie); if (al != null) { StringBuilder strb = new StringBuilder(); string liHTML = @"<tr> <td> <span>2012-09-09 21:30</span> </td> <td> <a href='{0}'> <img src='{1}'></a> <em><b>{2}</b><br> <span>攸怡价:<strong>¥{3}</strong> 市场价:<i>¥{4}</i> </span></em> </td> <td style='text-align: left;'> <a href='#'> <img src='../static/images/history.jpg'></a><br> <a href='#'> <img src='../static/images/adda.jpg'></a><br> <a href='#'>清除浏览历史</a> </td> </tr>"; var products = al.ToArray(); foreach (CustomerBrowserHistoryProduct product in products) { string thumbImg = YoeJoyConfig.ImgVirtualPathBase + product.LargeImg; string deeplink = YoeJoyConfig.SiteBaseURL + "Pages/Product.aspx?c1=" + product.C1SysNo + "&c2=" + product.C2SysNo + "&c3=" + product.C3SysNo + "&pid=" + product.ProductSysNo; strb.Append(String.Format(liHTML, deeplink, thumbImg, product.ProductBriefName, product.CurrentPrice, product.StandardPrice)); } productDetailBroswerHistoryHTML = strb.ToString(); } return(productDetailBroswerHistoryHTML); }