/******************************************************************************
* filename: common.js
* ajax modul scripting
* (c) masterli(masterlijf#hotmail.com),oran day(likecode#qq.com)
* (c) nsw(http://www.nsw88.com)
*******************************************************************************/
/********************
* 初始化头部信息,如购物车产品总数,登录状态等
* 回应 : xml对象
********************/
var flag=false;
function drawimage(imgd,wcc,hcc,showcc){
var image=new image();
image.src=imgd.src;
if(image.width>0 && image.height>0){
flag=true;
if(image.width/image.height>= wcc/hcc){
if(image.width>wcc){
imgd.width=wcc;
imgd.height=(image.height*wcc)/image.width;
}else{
imgd.width=image.width;
imgd.height=image.height;
}
// imgd.alt=image.width+"x"+image.height;
if(showcc==1)
{
if(hcc>imgd.height&&wcc>imgd.width)
{
imgd.style.padding=(hcc-imgd.height)/2+"px 0 0 "+(wcc-image.width)/2+"px";
}
else if(hcc>imgd.height)
{
imgd.style.padding=(hcc-imgd.height)/2+"px 0 0 0";
}
else if(wcc>imgd.width)
{
imgd.style.padding="0 0 0 "+(wcc-imgd.width)/2+"px";
}
}
// imgd.style.padding-top=(185-image.height)/2+"px";
}
else{
if(image.height>hcc){
imgd.height=hcc;
imgd.width=(image.width*hcc)/image.height;
}else{
imgd.width=image.width;
imgd.height=image.height;
}
//imgd.alt=image.width+"x"+image.height;
if(showcc==1)
{
if(hcc>imgd.height&&wcc>imgd.width)
{
imgd.style.padding=(hcc-imgd.height)/2+"px 0 0 "+(wcc-imgd.width)/2+"px";
}
else if(hcc>imgd.height)
{
imgd.style.padding=(hcc-imgd.height)/2+"px 0 0 0";
}
else if(wcc>imgd.width)
{
imgd.style.padding="0 0 0 "+(wcc-imgd.width)/2+"px";
}
}
}
}
}
function initcommonheader() {
$.get("/ajax.ashx?action=initcommonheader&t=" + math.random(), function(rsp) {
// $j("headercartcount").html(gav(rsp, "prod_count"));
var im = gav(rsp, "showim");
showim(im);
var username = gav(rsp, "username");
if (username.length > 0) {
$j("commonheaderguest").hide();
$j("commonheaderusername").html(username);
$j("commonheaderuser").fadein(80);
}
});
}
//是否显示在线客服
function showim(res) {
if ($("#bodd").html() != "") {
if (res == "true") {
$("#bodd").show();
$("#kefubtn").hide();
$("#divoranim").show();
}
else {
$("#bodd").hide();
$("#kefubtn").show();
$("#divoranim").hide();
}
}
}
//初始化头部热门关键词
function initcommonheaderkeywords(_s) {
if (_s == "") _s = "6";
$.post("/ajax.ashx?action=initcommonheaderkeywords&t=" + math.random(), {
s: _s
}, function (msg) {
$j("commonheaderkeywords").html(msg);
});
}
/********************
* 添加产品到购物车
* src : 触发事件的源对象
* _pid : 产品id
* qutielmid : 数量(重载:number购买数量、string数量的文本框元素id)
* atts : 附加属性
* reloadcartpage : (可选)是否询问重新刷新购物车首页
* redirecturl : (可选)当产品添加成功后,跳转到的页面(优先权高)
* 回应 : xml对象
********************/
function addtocart(src, _pid, qutielmid, _atts,_pidlist, reloadcartpage, redirecturl) {
showproc(src);
if (reloadcartpage == null) {
reloadcartpage = false;
}
_atts = $j(_atts).html();
_pidlist = $j(_pidlist).val();
var _quti;
if (qutielmid == null) {
_quti = 1;
} else if (typeof (qutielmid) == "number") {
_quti = qutielmid;
} else {
_quti = $tv(qutielmid);
}
if (_atts == null) {
_atts = "";
}
if (_pidlist==null)
{
_pidlist = "";
}
$.post("/ajax.ashx?action=addtocart&t=" + math.random(), {
pid: _pid,
quti: _quti,
atts: _atts,
pidlist: _pidlist
}, function(msg) {
var smsg = gav(msg, "msg");
var scount = gav(msg, "count");
var sta = gav(msg, "state");
if (redirecturl != null) {
location.href = redirecturl;
return;
}
if (sta != "1") {
$a(smsg);
showproc(src, false);
return;
}
$confirm(smsg, { title: "去结算", todo: "/paycenter/cart.aspx" }, { title: "再选购", todo: function() {
hideconfirm();
}
});
$j("headercartcount").html(scount);
if (reloadcartpage && (gav(msg, "state") == 1) && confirm("添加到购物车成功,是否马上刷新页面购物车页面?\r\n\r\n是 - 刷新本页面查看最新结果\r\n否 - 保留当前页面状态")) {
location.href = "cart.aspx?t=" + math.random();
return;
}
showproc(src, false);
});
}
/********************
* 清空购物车
* src : 触发事件的源对象
* 回应 : string
* 1 - 成功
* 0 - 失败
********************/
function emptycart(src) {
showbgproc();
$.get("/ajax.ashx?action=emptycart&t=" + math.random(), function(msg) {
if (msg == "1") {
$a("清空购物车成功,单击确认返回产品中心。", 1, false, null, "消息", function() {
location.href = "/product";
});
} else {
$a("清空购物车失败,请稍候重试。");
}
showbgproc(false);
});
}
/********************
* 清空购物车
* src : 触发事件的源对象
* _pid : 产品id
* 回应 : xml
********************/
function changequantity(src, _pid,_attrs) {
var newval = $(src).parent().find("input").attr("value");
if (!/^\d+$/.test(newval)) {
$a("数量必须是一个整数。");
return;
}
if (parseint(newval) == 0) {
$a("数量必须大于0,若要删商品,请点操作中的‘删除’。");
return;
}
showbgproc();
$.post("/ajax.ashx?action=addtocart&t=" + math.random(), {
pid: _pid,
quti: newval,
atts: _attrs
}, function(msg) {
if (gav(msg, "state") == "1") {
if (confirm("数量修改成功,是否马上刷新页面查看购物车结果?\n\n是 - 刷新页面查看结果\n否 - 保留当前页面状态")) {
location.href = "cart.aspx?t=" + math.random();
} else {
showbgproc(false);
$(src).hide();
}
} else {
$a(msg);
showbgproc(false);
}
});
}
function delcartproduct(src, _pid, _atts) {
showbgproc();
var _quti = 0;
$.post("/ajax.ashx?action=addtocart&t=" + math.random(), {
pid: _pid,
atts: _atts
}, function(msg) {
if (gav(msg, "state") == "1") {
if (confirm("商品已删除,是否马上刷新页面查看结果?\n\n\r\n是 - 刷新页面查看结果\n否 - 保留当前页面状态")) {
location.href = "cart.aspx?t=" + math.random();
}
} else {
$a(gav(msg, "msg"));
}
showbgproc(false);
});
}
/********************
* 清空购物车
* src : 触发事件的源对象
* _pid : 产品id
* 回应 : xml
********************/
function changequantity(src, _pid) {
var newval = $(src).parent().find("input").attr("value");
if (!/^\d+$/.test(newval)) {
$a("数量必须是一个整数。");
return;
}
if (parseint(newval) == 0) {
$a("数量必须大于0,若要删商品,请点操作中的‘删除’。");
return;
}
showbgproc();
$.post("/ajax.ashx?action=addtocart&t=" + math.random(), {
pid: _pid,
quti: newval
}, function(msg) {
if (gav(msg, "state") == "1") {
if (confirm("数量修改成功,是否马上刷新页面查看购物车结果?\n\n是 - 刷新页面查看结果\n否 - 保留当前页面状态")) {
location.href = "cart.aspx?t=" + math.random();
} else {
showbgproc(false);
$(src).hide();
}
} else {
$a(msg);
showbgproc(false);
}
});
}
function delcartproduct(src, _pid, _atts) {
showbgproc();
var _quti = 0;
$.post("/ajax.ashx?action=addtocart&t=" + math.random(), {
pid: _pid,
atts: _atts
}, function(msg) {
if (gav(msg, "state") == "1") {
if (confirm("商品已删除,是否马上刷新页面查看结果?\n\n\r\n是 - 刷新页面查看结果\n否 - 保留当前页面状态")) {
location.href = "cart.aspx?t=" + math.random();
}
} else {
$a(gav(msg, "msg"));
}
showbgproc(false);
});
}
function cancelorder(src, _orderno) {
showbgproc();
$.post("/ajax.ashx?action=cancelorder&t=" + math.random(), {
no: _orderno
}, function(msg) {
if (gav(msg, "state") == "1") {
$(src).parent().parent().parent().find("td[name=orderstate]").html("已取消");
$(src).hide();
} else {
$a("
无浏览历史
");
$j("divhistorycntr").html("
无浏览历史");
});
}
function subscription(src, elmid) {
if (elmid == null) {
elmid = "txtsubscriptionemail";
}
var _email = $.trim($j(elmid).val());
var ptn = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
if (_email.length == 0) {
$a("e-mail 不可为空");
$j(elmid).focus();
return false;
}
if (!ptn.test(_email)) {
$a("e-mail 格式错误。");
$j(elmid).focus();
return false;
}
showproc(src);
$.post("/ajax.ashx?action=subscription&t=" + math.random(), {
email: _email
}, function(msg) {
var sta = gav(msg, "state");
var smsg = gav(msg, "msg");
if (sta == "1") {
$a(smsg, 1);
} else {
$a(smsg);
}
showproc(src, false);
});
}
function userfeedback(src) {
var _title = $tv("txtfdtitle");
var _shortdesc = $tv("txtfdshortdesc");
if (_title.length == 0 || _shortdesc.length == 0) {
$a("内容或标题不可为空。");
return false;
}
showbgproc(true, "正在提交...");
$.post("/ajax.ashx?action=userfeedback&t=" + math.random(), {
title: _title,
shortdesc: _shortdesc
}, function(msg) {
var sta = gav(msg, "state");
var smsg = gav(msg, "msg");
if (sta == "1") {
showmsgpage("
您的意见提交成功,感谢您的意见,有您的支持,我们会做得更好。", 1, "/user/faq.aspx", "意见/反馈", "/user/faq.aspx");
return;
} else if (smsg.length > 0) {
$a(smsg);
} else {
$a(msg);
}
showbgproc(false);
});
}
function checkauthority(_authids, _title) {
$.post("/ajax.ashx?action=checkauthority&t=" + math.random(), {
authids: _authids
}, function(msg) {
if (msg == "1") {
$j("div___________perm").hide();
document.oncontextmenu = function() { return true; };
document.onselectstart = function() { return true; };
} else {
showmsgpage("您不具有查看 " + _title + " 的权限。");
return;
}
});
}
function changefavcolumn(src, itemtabid) {
var _ids = getcheckedval(itemtabid);
if (_ids.length == 0) {
$a("无选中项。");
return;
}
showproc(src);
$.post("/ajax.ashx?action=changefavcolumn&t=" + math.random(), {
ids: _ids,
targetid: src.value
}, function(msg) {
var sta = gav(msg, "state");
var smsg = gav(msg, "msg");
if (sta == "1") {
location.reload();
} else {
//alert(smsg);
}
});
showproc(src, false);
}
function getrecommentproductbyhistory(_oid) {
$.post("/ajax.ashx?action=getrecommentproductbyhistory&t=" + math.random(), {
oid: _oid
}, function(msg) {
var jo = $j("divhistoryrecommentcntr");
if (msg.length == 0) {
jo.remove();
} else {
jo.html(msg);
}
});
}
function getrecommentprojectbyhistory(_oid) {
$.post("/ajax.ashx?action=getrecommentprojectbyhistory&t=" + math.random(), {
oid: _oid
}, function(msg) {
var jo = $j("divhistoryrecommentcntr");
if (msg.length == 0) {
jo.remove();
} else {
jo.html(msg);
}
});
}
function getrelevantsales(_oid) {
$.post("/ajax.ashx?action=getrelevantsales&t=" + math.random(), {
oid: _oid
}, function(msg) {
var jo = $j("divrelevantsalescntr");
if (msg.length == 0) {
jo.remove();
} else {
jo.html(msg);
}
});
}
function getrelevantviewed(_oid) {
$.post("/ajax.ashx?action=getrelevantviewed&t=" + math.random(), {
oid: _oid
}, function(msg) {
var jo = $j("divrelevantviewedcntr");
if (msg.length == 0) {
jo.remove();
} else {
jo.html(msg);
}
});
}
//浏览服务的历史记录
function getrelevantviewedproject(_oid) {
$.post("/ajax.ashx?action=getrelevantviewedproject&t=" + math.random(), {
oid: _oid
}, function(msg) {
var jo = $j("divrelevantviewedcntr");
if (msg.length == 0) {
jo.remove();
} else {
jo.html(msg);
}
});
}
//浏览下载的历史记录
function getrelevantvieweddownload(_oid) {
$.post("/ajax.ashx?action=getrelevantvieweddownload&t=" + math.random(), {
oid: _oid
}, function(msg) {
var jo = $j("divrelevantviewedcntr");
if (msg.length == 0) {
jo.remove();
} else {
jo.html(msg);
}
});
}
function delinitationlog(src, itemtabid) {
var _ids = getcheckedval(itemtabid);
if (_ids.length == 0) {
$a("无选中项。");
return;
}
showbgproc();
$.post("/ajax.ashx?action=delinitationlog&t=" + math.random(), {
ids: _ids
}, function(msg) {
if (gav(msg, "state") == "1") {
var chks = $j(itemtabid).find("input[name=item]:checked");
chks.each(function(i) {
$(this).parent().parent().remove();
});
} else {
$a(gav(msg, "msg"));
}
showbgproc(false);
});
}
function sendinvitation(src) {
var jsrc = $j(src);
var semail = $j("txtemail").val();
if (semail == null || semail.length == 0) {
$a("电子邮箱地址不可为空。");
return;
}
if (!ptn_email.test(semail)) {
$a("电子邮箱地址格式不正确。");
return;
}
showproc(src);
$.post("/ajax.ashx?action=sendinvitation&t=" + math.random(), {
_email: semail
}, function(msg) {
var sta = gav(msg, "state");
var smsg = gav(msg, "msg");
if (sta == "1") {
showmsgpage(smsg, 1, "/user/inviteuserlist.aspx", "邀请函列表", "/user/inviteuserlist.aspx");
} else {
$a(smsg);
showproc(src, false);
}
});
}
//填充报告分类
function fillreportcategories() {
$.get("/ajax.ashx?action=getreportcategories&t=" + math.random(), function(msg) {
var arrcat = msg.split("$$");
var sopthtml = "
";
for (var i = 0; i < arrcat.length; ++i) {
sopthtml += "
";
}
$j("rpt_tdcats").html("
");
});
}
//填充留言分类
function fillleavewordcategories() {
$.get("/ajax.ashx?action=getleavewordcategories&t=" + math.random(), function(msg) {
var arrcat = msg.split("$$");
var sopthtml = "
";
for (var i = 0; i < arrcat.length; ++i) {
sopthtml += "
";
}
$j("leaveword_tdcats").html("
");
});
}
//发送留言
function sendleaveword(src) {
var scat = $j("leaveword_cats").val();
var stitle = $v("leaveword_txttitle");
var stel = $v("leaveword_txttel");
var smobile = $v("leaveword_txtmobile");
var scontact = $v("leaveword_txtcontact");
var semail = $v("leaveword_txtemail");
var sshortdesc = $v("leaveword_txtshortdesc");
var err = "";
if (stitle == "") {
err += "
标题不可为空";
}
if (scontact == "") {
err += "
联系人不可为空";
}
if (semail == "") {
err += "
电子邮箱地址不可为空";
}
else if (!ptn_email.test(semail)) {
err += "
电子邮箱地址格式错误";
}
if (scat == "") {
err += "
留言类型必选";
}
if (err.length > 0) {
$a(err);
return;
}
showproc(src);
$.post("/ajax.ashx?action=sendleaveword&t=" + math.random(), {
title: stitle,
cat: scat,
contact: scontact,
email: semail,
shortdesc: sshortdesc,
tel: stel,
mobile: smobile
}, function(msg) {
var sta = gav(msg, "state");
var smsg = gav(msg, "msg");
if (sta == "1") {
$a(smsg, 1);
} else {
$a(smsg);
}
showproc(src, false);
});
}
//发送报告
function sendreprots(src) {
var scat = $j("rpt_cats").val();
var stitle = document.title;
var surl = document.url;
var scontact = $v("rpt_txtcontact");
var semail = $v("rpt_txtemail");
var sshortdesc = $v("rpt_txtshortdesc");
if (scat.length == 0) {
$a("请选择报告分类。");
return;
}
showproc(src);
$.post("/ajax.ashx?action=sendreports&t=" + math.random(), {
title: stitle,
url: surl,
cat: scat,
contact: scontact,
email: semail,
shortdesc: sshortdesc
}, function(msg) {
var sta = gav(msg, "state");
var smsg = gav(msg, "msg");
if (sta == "1") {
$a(smsg, 1);
} else {
$a(smsg);
}
showproc(src, false);
});
}
//提交直接付款
function directpay(src) {
var spayer = $v("dir_pay_txtpayer");
var semail = $v("dir_pay_txtemail");
var stel = $v("dir_pay_txttel");
var smobile = $v("dir_pay_txtmobile");
var ssalesman = $v("dir_pay_txtsalesmanname");
var smoney = $v("dir_pay_txtmoney");
var suse = $v("dir_pay_txtuse");
var spayment = $v("dir_pay_ddlpayment");
var err = "";
if (spayer.length == 0) {
err += "
付款人不可为空。"
}
if (semail == "") {
err += "
电子邮箱地址不可为空";
}
else if (!ptn_email.test(semail)) {
err += "
电子邮箱地址格式错误";
}
if (smoney.length == 0) {
err += "
付款金额不可为空。";
}
else if (!ptn_float.test(smoney)) {
err += "
付款金额必须为数字,如89.00。";
}
if (suse.length == 0) {
err += "
款项用途不可为空。";
}
if (spayment.length == 0) {
err += "
请选择付款方式。";
}
if (err.length > 0) {
$a(err);
return;
}
showproc(src);
$.post("/ajax.ashx?action=directpay&t=" + math.random(), {
payer: spayer,
email: semail,
tel: stel,
mobile: smobile,
salesman: ssalesman,
_money: smoney,
_use: suse,
payment: spayment
}, function(msg) {
var sta = gav(msg, "state");
var smsg = gav(msg, "msg");
if (sta == "1") {
location.href = "/paycenter/paydirectconfirm.aspx";
return;
} else {
$a(smsg);
}
showproc(src, false);
});
}
function submitorder(src, _oid) {
showproc(src);
var _contact = $j("txtcontact").val();
var _compname = $j("txtcompname").val();
var _tel = $j("txttel").val();
var _mobile = $j("txtmobile").val();
var _email = $j("txtemail").val();
var _addr = $j("txtaddr").val();
var _content = $j("txtcontent").val();
var errormsg = "";
if (_contact.length == 0) {
errormsg += "
联系人不可为空
";
}
if (_mobile.length == 0) {
errormsg += "
手机不可为空
";
}
var ptns = /^\d{11,13}$/;
if (_mobile.length > 0 && !ptns.test(_mobile)) {
errormsg += "
手机格式错误
";
}
var ptn = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
if (_email.length > 0 && !ptn.test(_email)) {
errormsg += "
e-mail格式错误
";
}
if (_content.length == 0) {
errormsg += "
采购意向描述不可为空
";
}
if (errormsg.length > 0) {
$a(errormsg);
showproc(src, false);
return;
}
$.post("/ajax.ashx?action=submitorder&t=" + math.random(), {
oid: _oid,
contact: _contact,
compname: _compname,
tel: _tel,
mobile: _mobile,
email: _email,
addr: _addr,
content: _content
}, function(msg) {
var sta = gav(msg, "state");
var smsg = gav(msg, "msg");
if (sta == "1") {
$a(smsg, 1);
emptytext('tbform1');
} else {
$a(msg);
emptytext('tbform1');
}
});
showproc(src, false);
}
/********************************************* 代理加盟:start *********************************/
function getagenthelpstatic(_oid) {
$.post("/ajax.ashx?action=agenthelpsatisfaction&t=" + math.random(), {
oid: _oid
}, function(msg) {
var arri = [parseint(gav(msg, "1")), parseint(gav(msg, "2")), parseint(gav(msg, "3"))];
var total = arri[0] + arri[1] + arri[2];
if (total == 0) {
total = 1;
}
var maxheight = 100;
for (var i = 0; i < arri.length; ++i) {
var percent = (arri[i] / total).tofixed(2);
var h = maxheight * percent;
if (h == 0) {
h = 1;
}
var shtml = "
"
+ (percent * 100).tofixed(2) + "%
";
$j("cntrstatic_" + i).html(shtml);
}
});
}
function submitagenthelpuse(src, _oid) {
showproc(src);
var _notice = $("input[name=use]:checked").val();
$.post("/ajax.ashx?action=agenthelpuseful&t=" + math.random(), {
oid: _oid,
notion: _notice
}, function(msg) {
if (gav(msg, "state") == "0") {
$a(gav(msg, "msg"));
} else {
$a(gav(msg, "msg"), 1);
getagenthelpstatic(_oid);
}
showproc(src, false);
});
}
/********************************************* 代理加盟:end *********************************/
/*显示产品的简介(一排四个的显示模式)*/
function showproductinfo(src, _oid, _index) {
var time1 = null;
var time2 = null;
var id = null;
var time = null;
//鼠标移到图片上的事件
$(src).hover(function() { time1 = new date(); showtime(); }, function() { window.clearinterval(id); });
//js定时器
function showtime() {
id = window.setinterval(function() {
time2 = new date();
time = time2 - time1;
//时间差,停留200毫秒时触发ajax请求
if (time > 400) {
if ($(src).parent().parent().next().attr("class") == "mesbook4" || $(src).parent().parent().next().attr("class") == "mesbook40") {
if ($(src).parent().parent().next().is(":visible")) {
return;
}
else {
$(src).parent().parent().next().show();
}
}
else {
$.post("/ajax.ashx?action=showproductinfo&t=" + math.random(), {
oid: _oid,
index: _index
}, function(msg) {
if ($(src).parent().parent().next().attr("class") == "mesbook4" || $(src).parent().parent().next().attr("class") == "mesbook40") {
return;
}
else {
$(src).parent().parent().after(msg);
return;
}
});
}
}
}, 450);
}
}
/*显示产品的简介(竖排显示模式)*/
function showproductinfos(src, _oid) {
var time1 = null;
var time2 = null;
var id = null;
var time = null;
//鼠标移到图片上的事件
$(src).hover(function() { time1 = new date(); showtime(); }, function() { window.clearinterval(id); });
//js定时器
function showtime() {
id = window.setinterval(function() {
time2 = new date();
time = time2 - time1;
//时间差,停留200毫秒时触发ajax请求
if (time > 400) {
if ($(src).parent().parent().next().attr("class") == "mesbook44") {
if ($(src).parent().parent().next().is(":visible")) {
return;
}
else {
$(src).parent().parent().next().show();
}
}
else {
$.post("/ajax.ashx?action=showproductinfos&t=" + math.random(), {
oid: _oid
}, function(msg) {
if ($(src).parent().parent().next().attr("class") == "mesbook44") {
return;
}
else {
$(src).parent().parent().after(msg);
return;
}
});
}
}
}, 450);
}
}
//隐藏产品预览的层
function hideproductinfo(src) {
if ($(src).parent().parent().next().attr("class") == "mesbook4" || $(src).parent().parent().next().attr("class") == "mesbook40" || $(src).parent().parent().next().attr("class") == "mesbook44") {
// $(src).parent().parent().next().hide();
$(src).parent().parent().next().mouseover(function() {
$(src).parent().parent().next().show();
return;
});
$(src).parent().parent().next().mouseout(function() {
$(src).parent().parent().next().hide();
return;
});
$(src).parent().parent().next().hide();
}
}
//显示购买小tips
function showproducttips(oid) {
var jlayer = $j("div_nsw_tips");
if (jlayer.length == 0) {
var shtml = "
";
$(document.body).append(shtml);
}
setcm("div_nsw_tips");
showfullbg("div_nsw_tips_bg");
relocation("div_nsw_tips");
}
//购买产品小tips
function submitproducttips(_oid, _email, _content, _rdotips) {
var _oid = $j("txthide").val();
var _email = $j("txtemail").val();
var _content = $j("txtcontent").val();
var _state = $("input[name=rdotips]:checked").val();
if (_content.length > 500) {
$a('简述太长,不能超过500个字节,请填写简短描述');
}
var ptn = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
if (_email.length == 0) {
$a('e-mail 不可为空');
return false;
}
if (!ptn.test(_email)) {
$a('e-mail 格式错误');
return false;
}
$.post("/ajax.ashx?action=postproducttips&t=" + math.random(), {
oid: _oid,
email: _email,
content: _content,
state: _state
}, function(msg) {
if (gav(msg, "state") == "1") {
$a(gav(msg, "msg"),1);
} else {
$a(gav(msg, "msg"));
}
});
$j("div_nsw_tips").hide();
hidefullbg('div_nsw_tips_bg');
}
//产品预览(愿望夹)
function showmywish(_oid) {
var jlayer = $j("div_nsw_wishs");
if (jlayer.length == 0) {
var shtml = "
";
$(document.body).append(shtml);
}
$.post("/ajax.ashx?action=showmywish&t=" + math.random(), {
oid: _oid
}, function(msg) {
$j("div_nsw_wishs").html(msg);
});
setcm("div_nsw_wishs");
showfullbg("div_nsw_wishs_bg");
relocation("div_nsw_wishs");
}
//保存数据到愿望夹
function submitproductwishs(_oid, _attr, _num) {
var _oid = $j("txthide").val();
var _attr = $j("txtattr").html();
var _num = $j("txtnum").val();
$.post("/ajax.ashx?action=postproductwishs&t=" + math.random(), {
oid: _oid,
attr: _attr,
num: _num
}, function(msg) {
if (gav(msg, "state") == "1") {
$a(gav(msg, "msg"), 1);
} else {
$a(gav(msg, "msg"));
}
});
$j("div_nsw_wishs").hide();
hidefullbg('div_nsw_wishs_bg');
}
/*加盟商在线下单*/
function sendgetproductsnotify(src) {
var _productcolumn = $j("ddlproductscolumns").val();
var _searchtext = $j("txtsearch").val();
if (_searchtext == "关键词") { _searchtext = ""; }
//showproc(src);
$.post("/ajax.ashx?action=sendgetproductsbycolumn&t=" + math.random(), {
columnid: _productcolumn,
searchtext: _searchtext
}, function(msg) {
//创建下拉表单
initdropdownlist(document.getelementbyid("packageselectlist"), "请选择关联资讯", "0", msg);
});
}
//设置产品数据源
function initdropdownlist(sel, defaulttext, defaultvalue, arry) {
//1\清除所有的数据源
var len = sel.options.length;
for (i = 0; i < len; i++) {
sel.remove(0);
}
//2\设置一个默认值
//sel.add(new option(defaulttext, defaultvalue));
//3\制作数据源,键值对中间用$$分开,||作为键值对之间的分割符
var ary = arry.split("||");
len = ary.length;
if (len) {
for (i = 0; i < len-1; i++) {
text_value = ary[i].split("$$");
text = text_value[1];
value = text_value[0];
sel.add(new option(text, value));
}
}
}
/**定单提交
********************/
function userorder(src) {
var s_name = $tv("txtname");
var s_title = $tv("txttitle");
var s_email = $tv("txtemail");
var s_tel = $tv("txttel");
var s_content = $tv("txtcontent");
var s_address = $tv("txtaddress");
var s_enddate = $tv("txtenddate");
var s_idlist = $("#packagepicklist").val();
//alert(s_idlist);
if (s_title == "") {
$a("定单名称不能为空", "txttitle");
return;
}
if (s_name == "") {
$a("下单人姓名不能为空", "txtname");
return;
}
if (s_tel == "") {
$a("联系电话不能为空", "txttel");
return;
}
if (s_address == "") {
$a("联系地址不能为空", "txtaddress");
return;
}
if (s_enddate == "") {
$a("到货时间不能为空", "txtenddate");
return;
}
if (s_content == "" || s_content.length > 1000) {
$a("详细描述不能为空或者大于1000字", "txtcontent");
return;
}
else {
var _email = $.trim($(src).attr("value"));
var ptn = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
if (!ptn.test(s_email)) {
$a("e-mail错误");
return false;
}
}
$.post("/ajax.ashx?action=agentorder&t=" + math.random(), {
s_name: s_name,
s_title: s_title,
s_email: s_email,
s_tel: s_tel,
s_content: s_content,
s_address: s_address,
s_enddate: s_enddate,
s_idlist: s_idlist
}, function(msg) {
var sta = gav(msg, "state");
var smsg = gav(msg, "msg");
if (sta == "1") {
showmsgpage("
定单提交成功,我们会尽快与您联系,谢谢!", 1, "/user/userorder.aspx", "在线定单", "/user/userorder.aspx");
return;
} else if (smsg.length > 0) {
$a(smsg);
} else {
$a(msg);
}
});
}
/*招商加盟:删除定单end*/
function delagentorder(src, itemtabid) {
var _ids = getcheckedval(itemtabid);
if (_ids.length == 0) {
$a("无选中项。");
return;
}
showbgproc();
$.post("/ajax.ashx?action=delagentorder&t=" + math.random(), {
ids: _ids
}, function(msg) {
if (gav(msg, "state") == "1") {
var chks = $j(itemtabid).find("input[name=item]:checked");
chks.each(function(i) {
$(this).parent().parent().remove();
});
$a(gav(msg, "msg"),1);
} else {
$a(gav(msg, "msg"));
}
showbgproc(false);
});
}
//填加友情连接
function addapply(src) {
var s_type = document.getelementbyid("txttype").selectedindex;
var s_url = $tv("txturl");
var s_name = $tv("txtname");
var s_photopath = $tv("txtphotopath");
var s_content = $tv("txtmsg");
var s_username = $tv("txtusername");
var s_phone = $tv("txttel");
var s_email = $tv("txtemail");
var s_qq = $tv("txtqq");
if (s_url == "" || s_url == "http://") {
$a("请输入网址!", "txturl");
return;
}
if (s_name == "") {
$a("请输入网站名称!", "txtname");
return;
}
if (s_content.length > 400) {
$a("网站简况不能大于400字!", "txtusername");
return;
}
$.post("/ajax.ashx?action=apply&t=" + math.random(), {
type: s_type,
url: s_url,
name: s_name,
photopath: s_photopath,
content: s_content,
username: s_username,
phone: s_phone,
email: s_email,
qq: s_qq
},
function(msg) {
if (gav(msg, "state") == "1") {
$a(gav(msg, "msg"));
emptytext('tbform');
}
else {
$a(gav(msg, "msg"));
}
;
});
}
//产品的对比车
function addcompare(src) {
var _flag = false;
if(src.checked)
{
_flag = true;
$(src).next().next().next().show();
}
else
{
_flag = false;
$(src).next().next().next().hide();
}
var _ids = $(src).val();
$.post("/ajax.ashx?action=addcompare&t=" + math.random(), {
ids: _ids,
flag: _flag
}, function(msg) {
if (gav(msg, "state") == "1") {
var newcookie = gav(msg, "newcookie");
var arr = new array();
arr = newcookie.split(',');
if (arr.length > 0) {
for (var i = 0; i < arr.length; i++) {
if (i == arr.length-1)
{
$(".pro_main").find("input[id=" + arr[i] + "]").show();
}
else
{
$(".pro_main").find("input[id=" + arr[i] + "]").hide();
}
}
}
}
});
}
//产品对比车,移除该产品
function delonecompare(src) {
var _ids = $(src).attr("id");
$.post("/ajax.ashx?action=delonecompare&t=" + math.random(), {
ids: _ids
}, function(msg) {
if (gav(msg, "state") == "1") {
window.location = "/product/compare.aspx";
}
else {
showmsgpage("
产品对比车中不存在对比的产品记录,请选择需要对比的产品", 0, "/", "首页", "/");
}
});
}
//产品对比车,移除该产品
function delallcompare() {
$.post("/ajax.ashx?action=delallcompare&t=" + math.random(), {
}, function(msg) {
showmsgpage("
产品对比车中所有产品已移除,您可以继续挑选产品进行比较", 1, "/", "首页", "/");
});
}
//添加下载日志
function adddownload(oid,url)
{
//提交数据到数据库记录那个用户下载了什么资料
$.post("/ajax.ashx?action=adddownload&t=" + math.random(), {
oid: oid
}, function(msg) {
if (gav(msg, "state") == "1") {
window.location = url;
}
else {
$a(gav(msg, "msg"));
}
});
}
function showproduct(id, sid) {
$.post("/ajax.ashx?action=showproductinfor&t=" + math.random(), {
id: id,
sid: sid
}, function (msg) {
var smsg = gav(msg, "msg");
var sta = gav(msg, "state");
if (sta == 1) {
$j("csscontent").html(smsg);
}
});
}