var productdetail = { initpage:function(){ productdetail.initdata(); productdetail.initstyle(); productdetail.initbtn(); }, initbtn:function(){ $('#bargainpopup, #bargainpopup2').click(function() { productdetail.showbargainpopup($("#productid").val(), $("#productname").val()); }); $('.pay[dataid]').click(function() { var _this = $(this); productdetail.showbargainpopup(_this.attr("dataid"), _this.attr("dataname")); }); }, initstyle:function(logindatelist){ productdetail.productscrollimg(); }, initdata : function(messagecount) { }, showbargainpopup : function(productid, productname) { $.msgbox.window({ html : '
' +'
' +'

请供应商联系我

' +'' +'
' +'
' +'
' +'
' +'联系人*' +'' +'' +'' +'
' +'
' +'联系电话*' +'' +'' +'' +'
' +'
' +' ' +'' +'
' +'
' +'' +'
' +'
' +'
' +'
' +'', width : 600 }); }, //验证消息提示 verificationmessage : function($obj){ $obj.find('input').focus(function(){ $(this).nextall('.message').css('display','inline-block').prev('.validform_checktip').hide(); }).blur(function(){ $(this).nextall('.message').hide().prev('.validform_checktip').css('display','inline-block'); }).keyup(function(){ $(this).nextall('.message').hide(); }); }, msgpricev:function(productid, productname){ var $dfrom=$('#msgpopform'); $dfrom.find('.msgclose').click(function(){ $.msgbox.close(); }); productdetail.verificationmessage($dfrom); var form=$dfrom.validform({ tiptype:3, showallerror:true, btnsubmit:"#submitbutton", beforesubmit:function(curform){ productdetail.leavemessage(productid, productname); return false; } }); //验证规则 form.addrule([ { ele:"#contactname", datatype:/^[\u4e00-\u9fa5\uf900-\ufa2d]{2,6}$/, nullmsg:"请输入您的中文姓名!", errormsg:"请正确输入您的中文姓名!" }, { ele:"#contacttel", datatype:/^\d{1,4}(-)?\d{4,8}(-)?\d{3,7}$/+" | m", nullmsg:"请输入联系方式", errormsg:"请正确输入联系方式" } ]); }, productscrollimg:function(){ var scrollparam={ pre:$('#pre'), next:$('#next'), scrollobj:$('#scrollimg'), index : 1, setimg : function(img) { scrollparam.scrollobj.find('li').parent().find("img").css('border-color', '#dddddd'); img.css('border-color', '#ef3a07'); scrollparam.index = img.attr("alt"); var bigimg=img.attr('bigsrc'); $('#bigimg').attr('src',bigimg); } }; scrollparam.scrollobj.find('img').click(function(){ scrollparam.setimg($(this)); }); scrollparam.next.click(function(){ scrollparam.index++; if (scrollparam.index <= 4) { var img = scrollparam.scrollobj.find('img[alt="'+scrollparam.index+'"]'); scrollparam.setimg(img); } else { scrollparam.index = 4; } }); scrollparam.pre.click(function(){ scrollparam.index--; if (scrollparam.index >= 1) { var img = scrollparam.scrollobj.find('img[alt="'+scrollparam.index+'"]'); scrollparam.setimg(img); } else { scrollparam.index = 1; } }); scrollparam.scrollobj.find('li :first img').click(); }, //留言 leavemessage : function(productid, productname) { $.ajax({ type: "post", url: "/d17/product/leavemessage.json", datatype: "json", data : { "companyid" : $("#companyid").val(), "phone" : $("#contacttel").val(), "productname" : productname, "truename" : $("#contactname").val(), "productid" : productid }, success: function(data){ alert("询价成功"); $.msgbox.close(); } }); } };