///
//删除元素
function remove(obj) {
// $("#" + obj).parent().css("position", "");
$("#" + obj).remove();
window.location.reload();
}
//添加进购物车
function cartadd(obj, type, producttype, product_id, product_quantityinput, product_number, product_price) {
$("#cart_info").remove();
var product_quantity = product_quantityinput.val();
if (product_id == "" || product_quantity == "") {
return false;
}
if (parseint(product_quantity) > parseint(product_number)) {
$.post("/member/ajax/languagehandler.ashx", { action: "loadlanguage", langus: "购买商品失败;商品添加到购物车失败;购买数量不能大于库存哦", cache: math.random() }, function (langu) {
var hinthtml = '
'
+ '
'
+ '
';
if (type == 1)
hinthtml += langu.购买商品失败 + '!';
else
hinthtml += langu.商品添加到购物车失败 + '!';
hinthtml += '
' + langu.购买数量不能大于库存哦 + '!
'
+ '
'
+ '
';
$(obj).after(hinthtml); //添加节点
//$("#cart_info").parent().css("position", "relative");
}, "json");
return false;
}
$.ajax({
type: "post",
url: "/ajax/shoppingcarthandler.ashx",
data: { action: "cart_product_add", product_id: product_id, product_quantity: product_quantity, producttype: producttype, type: type, product_price: product_price, cache: math.random() },
datatype: "json",
beforesend: function (xmlhttprequest) {
//发送前动作
},
success: function (data, textstatus) {
if (data.msg == 1) {
if (type == 1) {
location.href = "/member/buynow.aspx";
} else {
var hinthtml = ''
+ '
'
+ '
'
+ '
' + data.msgtitle + '
'
+ '
' + data.msgbox + '
'
+ '
'
+ '
'
+ '
';
$(obj).after(hinthtml); //添加节点
//$("#cart_info").parent().css("position", "relative");
$(".login-cart em").html(data.count); //给头部购物车数量赋值
}
}
else if (data.msg == 2) {
loadlogin(product_id, product_quantity, producttype);
}
else {
var hinthtml = ''
+ '
'
+ '
';
if (type == 1)
hinthtml += data.msgtitle1 + '!';
else
hinthtml += data.msgtitle2 + '!';
hinthtml += '
' + data.msgbox + '
'
+ '
'
+ '
';
$(obj).after(hinthtml); //添加节点
//$("#cart_info").parent().css("position", "relative");
}
}
});
return false;
}
//删除购物车商品
function deletecart(obj, product_id, cartitemselector) {
if (product_id == "") {
return false;
}
$.ajax({
url: "/ajax/shoppingcarthandler.ashx",
data: { action: "cart_product_delete", product_id: product_id, cache: math.random() },
datatype: "json",
type: "post",
beforesend: function (xmlhttprequest) {
//发送前动作
},
success: function (data) {
if (data.msg == 1) {
var $cartitem = $(obj).parents(cartitemselector + ":first");
if (product_id == "0") {
$cartitem.replacewith(data.cartmsg);
}
else {
if ($cartitem.siblings(cartitemselector).length > 0) {
$cartitem.remove();
} else {
$(".cartitemplace").remove();
$(".cartitemempty").show();
$("#j_header-cart .header-carthd a em").html(0);
}
}
} else {
alert(data.msgbox);
}
}
});
return false;
}
function loadlogin(product_id, product_quantity, producttype) {
$.post("/member/ajax/languagehandler.ashx", {
action: "loadlanguage",
langus: "用户登录;用户名;密码toeasydialog;验证码;登录2;注册;忘记密码;看不清换一张;请输入用户名密码和验证码;请输入用户名和密码;请输入用户名和验证码;请输入密码和验证码;请输入用户名;请输入密码;请输入验证码"
, cache: math.random()
}, function (langu) {
var strhtml = '';
strhtml += '
';
strhtml += '
' + langu.用户登录 + '
';
strhtml += '
';
strhtml += '
';
strhtml += '
';
strhtml += '
' + langu.验证码 + ':';
strhtml += '
';
strhtml += '
';
strhtml += '
';
strhtml += '
';
strhtml += '
';
strhtml += '
';
strhtml += '
';
$("#easydialoginfo").remove();
$("body").append(strhtml);
// ie6模拟fixed
var isie = ! -[1, ], isie6 = isie && /msie 6/.test(navigator.useragent.tolowercase()); // 判断ie6
if (isie6) {
document.body.style.height = '100%';
document.getelementbyid("overlay").style.position = 'absolute';
document.getelementbyid("overlay").style.setexpression('top', 'fuckie6=document.documentelement.scrolltop+"px"');
document.getelementbyid("easydialogbox").style.setexpression('top', 'fuckie6=document.documentelement.scrolltop+document.documentelement.clientheight/2-100+"px"');
} else {
document.getelementbyid("easydialogbox").style.position = 'fixed';
document.getelementbyid("easydialogbox").style.top = '40%';
}
$(".dia-yzmpic").html($('').click(function () {
$(this).attr("src", '/ajax/validatecode.ashx?r=' + math.random());
}));
$(".dia-gbyzm").html($('' + langu.看不清换一张 + '').click(function () {
$(".dia-yzmpic img").attr("src", '/ajax/validatecode.ashx?r=' + math.random());
})).removeclass("dia-gbyzm");
$("#subinfo").html($('').attr("type", "submit").attr("value", langu.登录2).addclass("dia-loginbtn").click(function () {
var username = $("#txtusername").val();
var pwd = $("#txtpwd").val();
var code = $("#txtcode").val();
if ($.trim(username) == "" && $.trim(pwd) == "" && $.trim(code) == "") {
$("#errormsg").addclass("ct-diaerrortip").html(langu.请输入用户名密码和验证码);
$("#txtusername").addclass("loginerror");
$("#txtpwd").addclass("loginerror");
$("#txtcode").addclass("loginerror");
return false;
}
if ($.trim(username) == "" && $.trim(pwd) == "") {
$("#errormsg").addclass("ct-diaerrortip").html(langu.请输入用户名和密码);
$("#txtusername").addclass("loginerror");
$("#txtpwd").addclass("loginerror");
return false;
}
if ($.trim(username) == "" && $.trim(code) == "") {
$("#errormsg").addclass("ct-diaerrortip").html(langu.请输入用户名和验证码);
$("#txtusername").addclass("loginerror");
$("#txtcode").addclass("loginerror");
return false;
}
if ($.trim(pwd) == "" && $.trim(code) == "") {
$("#errormsg").addclass("ct-diaerrortip").html(langu.请输入密码和验证码);
$("#txtpwd").addclass("loginerror");
$("#txtcode").addclass("loginerror");
return false;
}
if ($.trim(username) == "") {
$("#errormsg").addclass("ct-diaerrortip").html(langu.请输入用户名);
$("#txtusername").addclass("loginerror");
return false;
}
if ($.trim(pwd) == "") {
$("#errormsg").addclass("ct-diaerrortip").html(langu.请输入密码);
$("#txtpwd").addclass("loginerror");
return false;
}
if ($.trim(code) == "") {
$("#errormsg").addclass("ct-diaerrortip").html(langu.请输入验证码);
$("#txtcode").addclass("loginerror");
return false;
}
$.post("/member/ajax/loginhandler.ashx", {
action: "loadlogin", username: username, pwd: pwd, code: code,
product_id: product_id, product_quantity: product_quantity, producttype: producttype, cache: math.random()
}, function (rs) {
if (rs.success)
location.href = "/member/buynow.aspx";
else
$("#errormsg").addclass("ct-diaerrortip").html(rs.message);
}, "json");
}));
$("#overlay").show();
$("#easydialogbox").show();
}, "json");
}
var replaceclass = function (input) {
$(input).removeclass("loginerror");
$(input).removeclass("login-form-error");
};
function addenquiry(productid) {
loadtableinfo(productid);
}
function loadtableinfo(productid) {
$.post("/member/ajax/languagehandler.ashx", { action: "loadlanguage", langus: "真实姓名;公司名称;联系手机;联系邮箱;期望价格;了解内容;询价提交", cache: math.random() }, function (langu) {
var strhtml = '';
$("#easydialoginfo").remove();
$("body").append(strhtml);
// ie6模拟fixed
var isie = ! -[1, ], isie6 = isie && /msie 6/.test(navigator.useragent.tolowercase()); // 判断ie6
if (isie6) {
document.body.style.height = '100%';
document.getelementbyid("overlay").style.position = 'absolute';
document.getelementbyid("overlay").style.setexpression('top', 'fuckie6=document.documentelement.scrolltop+"px"');
document.getelementbyid("easydialogbox").style.setexpression('top', 'fuckie6=document.documentelement.scrolltop+document.documentelement.clientheight/2-100+"px"');
} else {
document.getelementbyid("easydialogbox").style.position = 'fixed';
document.getelementbyid("easydialogbox").style.top = '30%';
}
$("#overlay").show();
$("#easydialogbox").show();
$("#subinfo").html($('').attr("type", "submit").attr("value", langu.询价提交).addclass("zdyform-subtn").click(function () {
var username = document.getelementbyid("txtusername");
var companyname = document.getelementbyid("txtcompanyname");
var phone = document.getelementbyid("txtphone");
var email = document.getelementbyid("txtemail");
var expectedprice = document.getelementbyid("txtexpectedprice");
var qq = $("#txtqq").val();
var contents = document.getelementbyid("txtcontent");
if (!checkenquiry(username, "姓名不能为空哦!") || !checkenquiry(companyname, "公司名称不能为空哦!")
|| !checkenquiry(phone, "联系手机不能为空哦!") || !checkenquiry(email, "联系邮箱不能为空哦!")
|| !checkenquiry(expectedprice, "期望价格不能为空哦!") || !checkenquiry(contents, "了解内容不能为空哦!"))
return false;
// if (!/^[\u4e00-\u9fa5]{2,6}(?:·[\u4e00-\u9fa5]{2,6})*$/.test(username.value)) {
// $("#txtusername").addclass("loginerror");
// //alert("您输入的姓名不正确,请重新输入");
// $("#txtusername").focus();
// return false;
// }
// if (!/^[\u4e00-\u9fa5]{5,50}(?:·[\u4e00-\u9fa5]{5,50})*$/.test(companyname.value)) {
// $("#txtcompanyname").addclass("loginerror");
// // alert("您输入的公司名称不正确,请重新输入");
// $("#txtcompanyname").focus();
// return false;
// }
if (!/^(13|15|18|14)[0-9]{9}$/.test(phone.value)) {
$("#txtphone").addclass("loginerror");
//artbox.alert("您输入的联系手机不正确,请重新输入");
$("#txtphone").focus();
return false;
}
if (!/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00a0-\ud7ff\uf900-\ufdcf\ufdf0-\uffef])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00a0-\ud7ff\uf900-\ufdcf\ufdf0-\uffef])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00a0-\ud7ff\uf900-\ufdcf\ufdf0-\uffef])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00a0-\ud7ff\uf900-\ufdcf\ufdf0-\uffef]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00a0-\ud7ff\uf900-\ufdcf\ufdf0-\uffef])|(([a-z]|\d|[\u00a0-\ud7ff\uf900-\ufdcf\ufdf0-\uffef])([a-z]|\d|-|\.|_|~|[\u00a0-\ud7ff\uf900-\ufdcf\ufdf0-\uffef])*([a-z]|\d|[\u00a0-\ud7ff\uf900-\ufdcf\ufdf0-\uffef])))\.)+(([a-z]|[\u00a0-\ud7ff\uf900-\ufdcf\ufdf0-\uffef])|(([a-z]|[\u00a0-\ud7ff\uf900-\ufdcf\ufdf0-\uffef])([a-z]|\d|-|\.|_|~|[\u00a0-\ud7ff\uf900-\ufdcf\ufdf0-\uffef])*([a-z]|[\u00a0-\ud7ff\uf900-\ufdcf\ufdf0-\uffef])))$/i.test(email.value)) {
$("#txtemail").addclass("loginerror");
//alert("您输入的联系邮箱不正确,请重新输入");
$("#txtemail").focus();
return false;
}
$.post("/member/ajax/enquiryhandler.ashx", {
action: "addenquiry", productid: productid, username: username.value, companyname: companyname.value
, phone: phone.value, email: email.value, expectedprice: expectedprice.value, qq: qq, contents: contents.value, cache: math.random()
}, function (data) {
if (data.success)
$("#easydialoginfo").remove();
else
alert(data.message);
}, "json");
}));
}, "json");
}
// 表单验证
var checkenquiry = function (input, msg) {
if (input.value == '' || input.value == 0) {
input.classname = "loginerror " + input.classname;
//alert(msg);
input.focus();
return false;
} else {
return true;
};
};
//不让输入除数字以外字符(第一个字符不能为0) invobj 控件id
function updateinventory(invobj) {
var inventory = invobj.value;
if ((/(^0+)|[^\d]/g).test(inventory)) {
inventory = inventory.replace(/(^0+)|[^\d]/g, "");
invobj.value = inventory;
}
}
//价格区间不让输入除数字以外字符
function validatenumpricerw(rangepriceid) {
var priceobj = document.getelementbyid(rangepriceid);
var pvalue = priceobj.value;
if ((/[^0-9\.]*/g).test(pvalue)) {
pvalue = pvalue.replace(/[^0-9\.]*/g, "");
priceobj.value = pvalue;
}
var fpvalue = number(pvalue);
if (isnan(fpvalue)) {
priceobj.value = "";
return;
}
if (fpvalue == 0) {
if (pvalue.length > 1 && !(/\./.test(pvalue))) {
priceobj.value = "0";
}
return;
}
if (/\./.test(pvalue)) {
var integer = pvalue.split(".")[0];
var decimal = pvalue.split(".")[1];
pvalue = number(integer) + "." + decimal;
} else {
pvalue = number(pvalue);
}
priceobj.value = pvalue;
}