if(typeof(loadingbar)=='undefined'){ var loadingbar=function(){ this.show=function(msg){ if(typeof(msg)=='undefined'){msg='loading...';} var $loadingbar=$('#loadingbar_______1'); if($loadingbar.length==0){ $(document.body).append(''); $loadingbar=$('#loadingbar_______1'); if($.browser.msie && $.browser.version=='6.0'){ $loadingbar.css({'position':'absolute'}); $(window).bind('scroll',setSize); } $(window).bind('resize',setSize); } setSize(); $loadingbar.html(msg).show(); } this.hide=function(){ $('#loadingbar_______1').hide(); } var setSize=function(){ setresize($('#loadingbar_______1'),200,50); } } } $.loadingbar=new loadingbar(); if(typeof(setresize)=='undefined'){ var setresize=function($obj,w,h){ var $window = $(window); var windowHeight = $window.height(); var left = ($window.width() - w) / 2; var top =(windowHeight - h) / 2 ; if($.browser.msie && $.browser.version=='6.0'){ top=top+parseInt($window.scrollTop(), 10); } if (top < 0) { top = 0; } setTimeout(function () { $obj.css({ left: left + 'px', top: top + 'px' }); }, 0); } } var corssajax=function(url,data,callback,timeoutcallback){ var timeout=true var corssajaxcallback='corssajaxcallback__'+new Date().getTime(); if(url.indexOf('jsoncallback=?')>-1){ url=url.replace('jsoncallback=?','jsoncallback='+corssajaxcallback); }else{ if(url.indexOf('?')>-1){ url+="&"; }else{ url+="?"; } url+="jsoncallback="+corssajaxcallback; } window[corssajaxcallback]=function(json){ if(timeout==true){ timeout=false; callback(json); timeout=true; } } var corssform=$('#corssform__'); if(corssform.length==0){ $(document.body).append(''); corssform=$('#corssform__'); } var html=''; html+='' for(var o in data){ html+=''; } corssform.html(html); corssform.submit(); if(timeoutcallback){ setTimeout(function(){ if(timeout){ timeoutcallback(); } },5000); } } var sellask = function (type,host,contacts) { /* 0-供应产品,1-供应服务*/ var sellaskhtml = ''; this.host=host||''; this.tjhost='http://tj.bmlink.com'; this.type=type||0; this.contacts=contacts;/*[{id,name,tel}]*/ this.anony=0; var $this = this; this.con = null; this.child = null; this.setType=function(type){ $this.type=type||0; } this.init = function () { $(document.body).append(''); $this.con = $('#sellaskdiv'); $(document.body).append(sellaskhtml); $this.child = $(document.body).find('#logonalready_sellask'); $this.child.css({ position: 'fixed', border: '1px solid #ccc', margin: '0px', 'z-index': 1001, width: '630px', height: '540px', 'background-color': '#fff','font-size':'12px' }); $this.child.find('textarea').css({'font-size':'12px','height':'100px','width':'450px','border':'1px solid #ccc','line-height':'18px','padding':'5px 0'}).val('规格:\r\n目标价:\r\n交货期:\r\n特殊要求:'); $this.child.find('.regline').css({'padding-bottom':'2px',color:'#333','display':'block','overflow':'hidden','width':'100%'}).find(':text').css({padding:'0'}); $this.child.find('.btn').css({padding:0,clear:'both',float:'right','margin-right':'20px'}); $this.child.find('.post_scoll').css({'height':'520px','width':'100%','overflow-x':'hidden','overflow-y':'auto','margin-top':'-1px','margin-bottom':'0'}); $this.child.find('.lef').css({'text-align':'right','width': '100px','float':'left','line-height':'28px','padding':'0 5px'}); $this.child.find('.mid').css({'display':'inline-block','float':'left','line-height':'28px','padding':'0 5px'}); $this.child.find(':text').css({border:'1px solid #ccc','color':'#666',width:'230px','padding':'3px 5px','line-height':'14px'}); $this.child.find('.submit').css({'padding-left':'115px','line-height':'32px'}); $this.child.find('.btnShiMing').css({'background':'url(https://meta.bmlink.com/2012/images/reglogin/bg_red.gif) repeat-x scroll 0 0 transparent','border':'1px solid #024ECA','color':'#fff','font-size':'14px','font-weight':'bold','height':'32px','margin-right':'10px','width':'160px'}); $this.child.find('a').css({color:'#095CB4','text-decoration':'none'}); $this.child.find('.red').css({'color':'#f00'}); $this.child.find('.title').css({'height':'29px','line-height':'29px','background':'url(https://meta.bmlink.com/2012/images/bg_title.gif) repeat-x scroll 0 0 transparent'}); $this.child.find('.title>strong').css({'float':'left','font-size':'14px','padding-left':'10px'}); $this.child.find('.title>div').css({'float':'right','margin-right':'10px'}); if($this.contacts){ var ContactAccountId=$this.child.find('#ContactAccountId'); if($this.contacts.length>0){ for (var i = 0; i < $this.contacts.length; i++) { var item=$this.contacts[i]; ContactAccountId.append(''); }; } else { ContactAccountId.after(' 还没填写联系信息?立即完善'); } } $(window).bind('resize',setSize); if($.browser.msie && $.browser.version=='6.0'){ $this.child.css({ position: 'absolute'}); //$this.child.find('.title').css({ 'margin-top':'-20px'}); $(window).bind('scroll',setSize); } $this.child.find('.close1').click(function(){ $this.close(); }); $this.child.find('.btnShiMing').click(function(){ var comp = $this.type; var cate = $this.child.find('.cateclass'); var title = $this.child.find('#titleid'); var unit = $this.child.find('.unitsclass'); var idsid= $this.child.find('#idsid'); var content=$this.child.find('textarea'); var ContactAccountId=$this.child.find('#ContactAccountId'); var data={ type:$this.type, ids:$.trim(idsid.val()), title:encodeURIComponent($.trim(title.val())), content:encodeURIComponent($.trim(content.val())), cateid:cate.val(), unit:unit.val(), count:$.trim($this.child.find('.countclass').val()), valid:$this.child.find('#ValidSetting').val(), account:ContactAccountId.val(), tel:encodeURIComponent(ContactAccountId.find('option:selected').attr('tel')), contact:encodeURIComponent(ContactAccountId.find('option:selected').attr('linkman')), isneedreply:$this.child.find('.isneedreply').attr('checked')==true?1:0, ispublic:$this.child.find('.ispublic').attr('checked')==true?1:0, province:$this.child.find('#provinceid').val(), city:$this.child.find('#cityid').val(), issendtoother:$this.child.find('.sendtoother').attr('checked')==true?1:0 } if(data.ids.length==0){ alert('参数错误');return; } if(decodeURIComponent(data.title)=='' || decodeURIComponent(data.title)=='采购'){ alert('请填写信息标题');title.focus();return; } if(decodeURIComponent(data.content)=='' || decodeURIComponent(data.content).replace('\r\n','').replace(/\s/ig,'')=='规格:目标价:交货期:特殊要求:'){ alert('请填写信息内容');content.focus(); return; } var reg=/^[1-9]\d*.\d*|0.\d*[1-9]\d*$/; var reg1=/^\d+$/; if(!reg.test(data.count) && !reg1.test(data.count)){ alert('请填写采购数量');$this.child.find('.countclass').focus();return; } if($this.anony==1){ data.contact=encodeURIComponent($.trim($this.child.find('#ContactAccountIdtxt').val())); data.tel=encodeURIComponent($.trim($this.child.find('#ContactAccountTeltxt').val())); data.ispublic=0; data.account=0; if(decodeURIComponent(data.contact).length==0){ alert('请填写联系人姓名');return; } if(decodeURIComponent(data.tel).length==0){ alert('请填写联系人电话');return; } } $.loadingbar.show(); corssajax($this.host+'/ashx/pub.ashx?method=savesellask',data,function(json){ $.loadingbar.hide(); if(json.error){ alert(json.msg); }else{ alert('发送成功'); $.ajax({ url:$this.tjhost+'/pub.ashx?method=addtradestat&jsoncallback=?', dataType:'jsonp', type:'GET', data:{ids:data.ids,t:$this.type==1?2:0,st:2}, success:function(){} }); $this.close(); } }); }); } function setSize(){ $this.resize(); } this.init(); this.resize = function () { var $window = $(window); var bodyHeight = $(document.body).outerHeight(true); var windowHeight = $window.height(); var height = bodyHeight > windowHeight ? bodyHeight : windowHeight; setresize($this.child,630,540); $this.con.css({ height: height + 'px' }); } this.show = function (anony,options) {//[{c:{id,name},s:{id,title},ct:[{id,name},{id,name},{id,name}],u:{id,name}},{c:{id,name},s:{id,title},ct:[{id,name},{id,name},{id,name}],u:{id,name}}] if (options == null || typeof (options) == 'undefined') { return; } $this.anony=anony; if(anony==1){ /*匿名*/ $('#divcontacttext2').show(); $('#divcontacttext1').show(); $('#divcontactselect').hide(); $this.child.find('.ispublic').parent().parent().parent().hide(); }else{ $('#divcontacttext2').hide(); $('#divcontacttext1').hide(); $('#divcontactselect').show(); $this.child.find('.ispublic').parent().parent().parent().show(); } $this.con.show(); $this.child.show(); $this.resize(); var comp = $this.child.find('#companynameid'); var cate = $this.child.find('.cateclass'); var title = $this.child.find('#titleid'); var unit = $this.child.find('.unitsclass'); var idsid= $this.child.find('#idsid'); $this.child.find('textarea').val('规格:\r\n目标价:\r\n交货期:\r\n特殊要求:'); comp.empty(); cate.empty(); title.empty(); unit.empty(); idsid.val(''); var ids=''; var catestringall=''; for (var i = 0; i < options.length; i++) { var item = options[i]; if (comp.find('span[v="' + item.c.id + '"]').length == 0) { comp.append('' + item.c.name + ''); } var cateid=";"; for (var j = 0; j < item.ct.length; j++) { var ct = item.ct[j]; cateid+=ct.id.toString()+','; }; if(catestringall.indexOf(';'+cateid+';')==-1) { catestringall+=cateid+';'; } if (unit.find('option[value="' + item.u.id + '"]').length == 0 && item.u.name.length>0) { unit.append(''); } ids+=item.s.id+'|'+item.c.id+',' }; $.get("http://member.bmlink.com/ashx/ajaxurl.ashx?method=getcateforask&catestringall="+catestringall+"&rand="+ new Date().getTime()+"&categoryType="+($this.type==0?1:2), function(result){ cate.append(result.result); },"jsonp"); idsid.val(ids); if (options.length > 1) { title.val('采购'); } else { title.val('采购' + options[0].s.title.replace('供应', '')); } loadArea1(); } var provinceid=$this.child.find('#provinceid'); var cityid=$this.child.find('#cityid'); provinceid.change(function(){ if(provinceid.val()>0) { loadArea2(provinceid.val()); } else { loadArea2(0); } }); function loadArea1() { provinceid.html(''); cityid.html(''); var json=findjson(0,0); $.each(json, function (i, area) { provinceid.append(''); }); } function loadArea2(parentid) { cityid.html(''); var json=findjson(parentid,1); $.each(json, function (i, area) { cityid.append(''); }); } function findjson(pid,index) { if(index==0) //1rank { var select=''; $.each(areastring, function (i, area) { select += '{"Id":'+area.Id+',"Name":"'+area.Name+'"},' ; }); return eval('['+RTrim(select)+']'); } else if(index==1) //2rank { var select=''; $.each(areastring, function (i, area) { if(pid==area.Id) {select=""; $.each(area.List, function (i2, area2) { select += '{"Id":'+area2.Id+',"Name":"'+area2.Name+'"},' ; });} }); return eval('['+RTrim(select)+']'); } } function RTrim(str) { var i; for(i=str.length-1;i>=0;i--) { if(str.charAt(i)!=','&&str.charAt(i)!=',')break; } str=str.substring(0,i+1); return str; } this.close=function(){ $(window).unbind('resize',$this.resize); $(window).unbind('scroll',$this.resize); $this.con.hide(); $this.child.hide(); } } $.sellask=new sellask(0,'https://member.bmlink.com',[]);