任意模块开启订单功能之后,都可以使用购物车功能// 购物车
var is_cart = true;
function dr_cart() {
if (!is_cart) {
alert('刷新后再试');
return;
}
var cart = "{dr_url('order/cart/add', array('mid'=>APP_DIR, 'cid'=>$id))}&num=购买数量";
is_cart = false;
$.ajax({type: "GET", url: cart, dataType:"jsonp",
success: function (data) {
if (data.status) {
var html = "
art.dialog({
id: 'cart',
lock: true,
opacity: 0.1,
content: html,
ok: function () {
location.href="{dr_url('order/cart/index')}";
is_cart = true;
return false;
},
okVal: '去结算',
cancelVal: '继续购物',
cancel: function () {
is_cart = true;
return true;
}
});
} else {
dr_tips(data.code);
is_cart = true;
}
}
});
}
以上的js代码,用于将指定数量的商品加入到购物车中,通过下面的调用加入购物车
购物中商品数量
$.get("/index.php?s=order&c=cart&m=nums", function(data){
alert('商品数:'+data.code);
}, 'jsonp');
文档最后更新时间:2017-05-08 13:16:27