
本文实例讲述了jquery.cookie实现的客户端购物车操作。分享给大家供大家参考,具体如下:
//购物车
var Cart = function () {
this.Count = 0;
this.Total = 0;
this.Items = new Array();
};
//购物车集合对象
var CartItem = function () {
this.Id = 0;
this.Name = “”;
this.Count = 0;
this.Price = 0;
};
//购物车操作
var CartHelper = function () {
this.cookieName = “yxhCart”;
this.Clear = function () {
var cart = new Cart();
this.Save(cart);
return cart;
};
//向购物车添加
this.Add = function (id, name, count, price) {
var cart = this.Read();
var index = this.Find(id);
//如果ID已存在,覆盖数量
if (index
© 版权声明
文章版权归作者所有,未经允许请勿转载。
相关文章
暂无评论...