shoppingCart.js

ylbtech-JavaScript-util: shoppingCart.js

 购物车脚本

1.A,JS-效果图返回顶部
 
1.B,JS-Source Code(源代码)返回顶部
1.B.1,m.yintai
/*
*/
function Product() {
    var itemcode; //商品编码
    var count; //数量
    var type; //类型
    var paramid; //参数
}
/*
添加商品
*/
function addShoppingCartProduct(itemCode, count, type, paramid) {
    if (itemCode == "" || itemCode == null) {
        alert("商品编号不能为空!");
        return false;
    }
    var productList = getShoppingCartProductList();
    var found = false;
    var i = 0;
    while (i < productList.length) {
        var productInfo = productList[i];
        if (productInfo.itemcode == itemCode) {
            productInfo.count = productInfo.count + count;
            productInfo.type = type;
            productInfo.paramid = paramid;
            found = true;
            break;
        }
        i++;
    }
    if (!found) {
        product = new Object();
        product.itemcode = itemCode;
        product.count = count;
        product.type = type;
        product.paramid = paramid;
        productList.push(product);
    }
    localStorage.shoppingCartProductList = JSON.stringify(productList);
    return true;
}
/*
取得商品
*/
function getShoppingCartProduct(itemCode) {
    var productList = getShoppingCartProductList();
    var i = 0;
    while (i < productList.length) {
        var productInfo = productList[i];
        if (productInfo.itemcode == itemCode) {
            return productInfo;
        }
        i++;
    }
    return null;
}
/*
取得商品列表
*/
function getShoppingCartProductList() {
    if (localStorage.shoppingCartProductList == undefined || localStorage.shoppingCartProductList == "undefined" || localStorage.shoppingCartProductList == "") {
        var newProductList = new Array();
        localStorage.shoppingCartProductList = JSON.stringify(newProductList);
    }
    var productList = JSON.parse(localStorage.shoppingCartProductList);
    return productList;
}
/*
清空购物车
*/
function clearShoppingCart() {
    var productList = new Array();
    localStorage.shoppingCartProductList = JSON.stringify(productList);
}
/*
删除商品
*/
function removeShoppingCartProduct(itemCode) {
    var productList = getShoppingCartProductList();
    var i = 0;
    while (i < productList.length) {
        var productInfo = productList[i];
        if (productInfo.itemcode == itemCode) {
            productList.splice(i, 1);
            break;
        }
        i++;
    }
    localStorage.shoppingCartProductList = JSON.stringify(productList);
}
/*
修改商品数量
*/
function updateShoppingCartProduct(itemCode, count) {
    var productList = getShoppingCartProductList();
    var i = 0;
    while (i < productList.length) {
        var productInfo = productList[i];
        if (productInfo.itemcode == itemCode) {
            productInfo.count = count;
            break;
        }
        i++;
    }
    localStorage.shoppingCartProductList = JSON.stringify(productList);
}
View Code

1.B.2,

1.C,JS-Relevent References(相关引用)返回顶部

 

warn作者:ylbtech
出处:http://ylbtech.cnblogs.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
网上购物系统是一套基于Web的适用于企业或个人网上开店的首选软件。产品凭借功能强大、性能稳定、页面美观等 特点深受用户喜爱。经过一年的创新开发和实践,产品已相当成熟和稳健,网趣网上购物系统集合目前网络所有购物 系统精华于一体,拥有多项国内领先的功能优势,并以不断追求和创新的步伐为用户更广泛的服务。 1、支持商品增加、修改功能,特别方便!<br>  2、支持4种在线支付:快钱、云网、支付宝、财付通接口。<br>  3、商品数据可直接导入Excel 电子表格!<br>  4、删除商品的同时,可以自动删除商品图片,大大节约空间!<br>   5、支持商品分类设置,分类划分更明细:大类->商品<br>  6、多元化展示,支持商品尺码、商品颜色的选择,适合各行业。<br>  7、诸多智能开关选项,全后台操作,前台支持订单查询功能!<br>  8、新增商品上、下架管理。<br>  9、具有强大的商品关键词、站点关键词设置功能,SEO优化一步到位。<br>  10、强大的权限分类管理功能,可设置不同管理级别的管理员进行网站管理<br>  11、商品大图支持缩放功能,具有强大的站点 访问统计功能。<br>  12、强大的商城报价中心功能,可以快速浏览商品价格。<br>  23、支持管理员登陆日志 ,可以对非法登陆的信息一一记录。<br> 13、支持商品订单后期支付,下完订单无立即支付也可进行再次付款。<br>  14、支持商品订单发货单号功能,支持商品缺货管理功能。<br>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值