var frontproducts = { openwindow : function(url, target, name) { var windowname = ""; if (name) { windowname = name; } if (target) { if (target == '_blank') { window .open( url, windowname, "toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes, location=yes, status=yes"); } else if (target == '_self') { document.location.href = url; } else { document.location.href = url; } } else { document.location.href = url; } }, /* * 购买按钮 参数1:商品id 参数2:购买url,未经过标签转义的 参数3:商品url,经过标签转义的 参数4:弹出与否标示 */ buy : function(pid, buyhref, producthref, targetopen) { // 判读是否有规格或用户输入项,如果有直接进入商品详细信息,否则直接购买 2010-5-12 var ynbuy = frontproducts.directbuy(pid); if (ynbuy) { frontorders_showminicart01.addproduct("&productid=" + pid + "&action_page=" + buyhref, targetopen); } else { if (targetopen == '_blank') { window .open( producthref, "", "toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes, location=yes, status=yes"); } else if (targetopen == '_self') { document.location.href = producthref; } else { document.location.href = producthref; } } }, backorder : function(pid, buyhref, producthref, targetopen) { // 判读是否有规格,如果有直接进入商品详细信息,否则直接缺货登记 var ynbuy = frontproducts.directbackorder(pid); if (ynbuy) { if (targetopen == '_blank') { window .open( buyhref, "", "toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes, location=yes, status=yes"); } else { document.location.href = buyhref; } } else { if (targetopen == '_blank') { window .open( producthref, "", "toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes, location=yes, status=yes"); } else if (targetopen == '_self') { document.location.href = producthref; } else { document.location.href = producthref; } } }, /* 创建动层窗口 */ createmodaldialog : function(name, width, height, title) { var divwidth = "auto"; var divheight = "auto"; if (width) { divwidth = width; } if (height) { divheight = height; } jquery("body") .append( "
"); jquery("#" + name).dialog( { autoopen : false, bgiframe : false, closeonescape : false, resizable : false, modal : true, width : divwidth, height : divheight }); }, /* 打开浮动层窗口 */ openmodaldialog : function(name, url, width, height) { jquery("#" + name + " iframe").attr("src", url); if (width) { jquery("#" + name).dialog('option', 'width', width); // jquery("#" + name + " iframe").attr("width",jquery("#" + // name).innerwidth() + "px"); } else { } if (height) { jquery("#" + name).dialog('option', 'height', height); // jquery("#" + name + " iframe").attr("height",jquery("#" + // name).innerheight() + "px"); } else { } jquery("#" + name).dialog("open"); }, /* 关闭浮动层窗口 */ closemodaldialog : function(name) { jquery("#" + name).dialog("close"); }, createmodaldiv : function(name, width, height) { jquery("body").append( "
"); jquery("#" + name).dialog( { autoopen : false, bgiframe : false, closeonescape : false, resizable : false, modal : true, width : 'auto', height : 'auto' }); if (width) { jquery("#" + name).dialog('option', 'width', width); } if (height) { jquery("#" + name).dialog('option', 'height', height); } }, /* 打开浮动层窗口 */ openmodaldiv : function(name, content, width, height) { jquery("#" + name).html(content); if (width) { jquery("#" + name).dialog('option', 'width', width); } if (height) { jquery("#" + name).dialog('option', 'height', height); } jquery("#" + name).dialog("open"); }, /* 关闭浮动层窗口 */ closemodaldiv : function(name) { jquery("#" + name).dialog("close"); }, // 异步请求获得商品库存,商品id 参数1 getstock : function(prodcutid) { var stock = "0"; jquery.ajax( { type : "post", url : "/frontproducts.do?method=getstock", data : { "productid" : prodcutid }, datatype : "json", cache : false, async : false, success : function(jsondata, textstatus) { if (typeof (jsondata.stock) != "undefined") { stock = jsondata.stock; } } }); return stock; }, // 异步请求判断商品是否可以直接购买,商品id 参数1 directbuy : function(prodcutid) { var ynbuy = false; jquery.ajax( { type : "post", url : "/frontproductsasyn.do?method=directbuy", data : { "productid" : prodcutid }, datatype : "json", cache : false, async : false, success : function(data, textstatus) { if (data.directbuy) { ynbuy = data.directbuy; } } }); return ynbuy; }, directbackorder : function(prodcutid) { var ynbuy = false; jquery.ajax( { type : "post", url : "/frontproductsasyn.do?method=directbuy&disabledorder=true", data : { "productid" : prodcutid }, datatype : "json", cache : false, async : false, success : function(data, textstatus) { if (data.directbuy) { ynbuy = data.directbuy; } } }); return ynbuy; }, getmemberlevelid : function() { var cookiestring = document.cookie; var starindex = cookiestring.indexof('c_memberinfo='); if (starindex == -1) { return ""; } var endindex = cookiestring.indexof(';', starindex); if (endindex == -1) { endindex = cookiestring.length; } starindex = 'c_memberinfo'.length + 1 + starindex; var cookiecontent = unescape(cookiestring.substring(starindex, endindex)); return cookiecontent; }, /* 创建等待中浮动层窗口 */ createwaitingdialog : function(width, height) { if (jquery("#dialog-waiting").length == 0) { jquery("body") .append( "
"); jquery("#dialog-waiting").dialog( { autoopen : false, bgiframe : false, closeonescape : false, resizable : true, modal : true, width : 'auto', height : 'auto' }); if (width) { jquery("#dialog-waiting").dialog('option', 'width', width); } if (height) { jquery("#dialog-waiting").dialog('option', 'height', height); } jquery("#dialog-waiting").prev("div.ui-dialog-titlebar").hide(); } }, /* 打开等待中浮动层窗口 */ openwaitingdialog : function(width, height) { if (width) { jquery("#dialog-waiting").dialog('option', 'width', width); } if (height) { jquery("#dialog-waiting").dialog('option', 'height', height); } jquery("#dialog-waiting").dialog("open"); }, /* 关闭等待中浮动层窗口 */ closewaitingdialog : function() { jquery("#dialog-waiting").dialog("close"); }, /* html分页 */ showhtml:function(compid,csshtml,idhtml){ jquery("#"+compid+" ."+csshtml).hide(); jquery("#"+compid+" #"+idhtml).show(); } }