zoomla
Version:
16年专业研发|中文alexa排名第一的CMS品牌-基于dotNET core、功能强大,集成站群、微信开发、小程序与ERP及OA办公系统,支持国际语言和多民族语言,世界五百强与大型门户专用高端网站内核CMS系统
45 lines • 1.45 kB
JavaScript
var Product = { apiUrl: "/API/Mod/shop_cart.ashx?action=", proid: 0,proModel:{}, $pronum: $("#Pronum") };
//将商品提交至购物车
Product.addToCart=function(){
var ref=this;
var pronum=ref.$pronum.val();
var url="/Cart/Cart?ID="+ref.proid+"&pronum="+pronum;
$.post(url,{},function(){
alert("加入购物车成功!");
})
}
Product.submitToCart = function () {
var ref = this;
var pronum = ref.$pronum.val();
var url = "/Cart/Cart?ID=" + ref.proid + "&pronum=" + pronum;
location = url;
}
Product.minus = function () {
var ref = this;
var pronum = ref.$pronum.val();
if (pronum && pronum > 1) { pronum--; }
else { pronum = 1; }
ref.$pronum.val(pronum);
}
Product.plus = function () {
var ref = this;
var pronum = ref.$pronum.val();
if (pronum && pronum > 0) { pronum++; }
else { pronum = 1; }
ref.$pronum.val(pronum);
}
Product.addFav = function () {
var ref=this;
var packet = { favurl: location.pathname, infoid: ref.proid, type: 2, title: $("title").text() };
$.post("/API/mod/collect.ashx?action=add", packet, function (data) {
var model = JSON.parse(data);
if (APIResult.isok(model)) {
alert("收藏成功!");
} else {
alert("收藏失败!原因:" + model.retmsg);
}
});
}
Product.init = function () {
console.log("Product inited");
}