protected void Page_Load(object sender, EventArgs e) { //CookieHelper.Set("user_carts", "[{\"BookId\":\"4995\",\"Count\":\"1\"},{\"BookId\":\"4996\",\"Count\":\"2\"}]", DateTime.Now.AddDays(10)); if (CurrentUser == null) { Login(Request.Url.ToString()); } var item = Request["item"]; if (CurrentUser != null) { if (!string.IsNullOrEmpty(item)) { // 添加购物车 AddCart(item.ToInt32()); } // 代码执行顺序 CartList = InfoBLL.QueryList(-1, -1, new { userId = CurrentUser.userId }, "cartId", true); } else { // 离线购物车 } }
protected void Page_Load(object sender, EventArgs e) { if (CurrentUser == null) { Login(); } from = Request["from"]; if (string.IsNullOrEmpty(from)) { //Response.Write(from); NotFound(); } address = addressBLL.QueryList(-1, -1, new { userId = CurrentUser.userId }, "isDefault", true); users = usersBLL.QuerySingle(CurrentUser.userId); if (!Request.IsPostBack()) { //购物车提交 if (CurrentUser != null) { Id = Convert.ToInt32(CurrentUser.userId); } CartList = InfoBLL.QueryList(1, 20, new { userId = Id }, "cartId", false); if (CartList == null) { NotFound(); } foreach (var item in CartList) { total += item.productPrice * item.productCount; count += item.productCount; } } else { //详细页提交 productId = Request["id"].ToInt32(); Amount = Request["amount"].ToInt32(); products = productsBLL.QuerySingle(productId); if (products == null) { NotFound(); } total = products.productPrice * Amount; count = Amount; } }