enterprise.js 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635
  1. var c_hfl=[["全部","0"],["农、林、牧、渔业","A"],["采矿业","B"],["制造业","C"],["住宿和餐饮业","H"],["信息传输、软件和信息技术服务业","I"],["金融业","J"],["房地产业","K"],["租赁和商务服务业","L"],["科学研究和技术服务业","M"],["水利、环境和公共设施管理业","N"],["居民服务、修理和其他服务业","O"],["教育","P"],["卫生和社会工作","Q"],["文化、体育和娱乐业","R"],["公共管理、社会保障和社会组织","S"],["电力、热力、燃气及水生产和供应业","D"],["建筑业","E"],["批发和零售业","F"],["交通运输、仓储和邮政业","G"]]
  2. var c_zb=[["全部","0"],["10W以下","0-10"],["10w-100w","10-100"],["100w-1000w","100-1000"],["1000万-1亿","1000-10000"],["1亿以上","10000"]]
  3. var c_qfl=[["全部","0"],["股份有限公司分公司(上市、外商投资企业投资)","2211"],["普通合伙企业","4531"],["农民专业合作经济组织","9100"],["个体工商户","9600"],["有限责任公司(自然人投资或控股)","1130"]]
  4. var template = "<tr><td><div class='contentbg borderB' ><div><a target='_blank' href='/enterprise/${_id}.html'>${EntName}</a>${s_action}</div>"+
  5. "<div><small>注册号:${RegNo}</small><small>${label}:${LeRep}</small><small>登记机关:${RegOrgName}</small><small>成立日期:${EstDate}</small></div>"+
  6. "${s_servicenames}</div></td></tr>";
  7. var citySim=[{k:11,n:"北京市"},{k:12,n:"天津市"},{k:13,n:"河北省"},{k:14,n:"山西省"},{k:15,n:"内蒙古"},{k:21,n:"辽宁省"},{k:22,n:"吉林省"},{k:23,n:"黑龙江省"},{k:31,n:"上海市"},{k:32,n:"江苏省"},{k:33,n:"浙江省"},{k:34,n:"安徽省"},{k:35,n:"福建省"},{k:36,n:"江西省"},{k:37,n:"山东省"},{k:41,n:"河南省"},{k:42,n:"湖北省"},{k:43,n:"湖南省"},{k:44,n:"广东省"},{k:45,n:"广西"},{k:46,n:"海南省"},{k:50,n:"重庆市"},{k:51,n:"四川省"},{k:52,n:"贵州省"},{k:53,n:"云南省"},{k:54,n:"西藏"},{k:61,n:"陕西省"},{k:62,n:"甘肃省"},{k:63,n:"青海省"},{k:64,n:"宁夏"},{k:65,n:"新疆"},{k:71,n:"台湾省"},{k:81,n:"香港"},{k:82,n:"澳门"}];
  8. //点击关闭微信版企明星
  9. function colseWeixin(){document.getElementById('weixintu').style.visibility = 'hidden';}
  10. $(function(){
  11. //点击回车执行搜索
  12. $(document).keydown(function(event){
  13. if(event.keyCode == 13){
  14. $("#c_words").click()
  15. }
  16. });
  17. });
  18. function getCityN(code){
  19. if(code){
  20. var n=code.substring(0,2)
  21. for(var i=0;i<citySim.length;i++){
  22. if (citySim[i].k==n) {
  23. return citySim[i].n;
  24. }
  25. }
  26. }
  27. return "";
  28. }
  29. function reloadData(obj,name){
  30. name=name||obj.attr("name")
  31. var val=(obj.attr("value")||obj.val());
  32. if (val==0) val=""
  33. if(name=="city"&&!val){
  34. var pids=obj.attr("id")
  35. if(pids=="c_area"){
  36. var v=obj.prev("select").val()
  37. if(!v){
  38. v=obj.prev("select").prev("select").val()
  39. }
  40. if(v){
  41. val=v
  42. }
  43. }else if(pids=="c_city"){
  44. var v=obj.prev("select").val()
  45. if(v){
  46. val=v
  47. }
  48. }
  49. }
  50. //调整value 值
  51. if(val==10){
  52. val = "10-100"
  53. }else if(val ==100){
  54. val = "100-1000"
  55. }else if(val ==1000){
  56. val = "1000-10000"
  57. }
  58. //搜索表单提交
  59. $("#searchForm input[name="+name+"]").val(val);
  60. document.forms['searchForm'].submit();
  61. }
  62. function setLocation(entsel,serviceloc){
  63. //所在地处理
  64. var le = entsel.length
  65. var sel1 = "";
  66. var sel2 = "";
  67. var sel3 = "";
  68. if (le == 2) {
  69. sel1 = entsel.substring(0,2);
  70. sel2 = 0;
  71. sel3 = 0;
  72. }else if (le == 4){
  73. sel1 = entsel.substring(0,2);
  74. sel2 = entsel.substring(0,4);
  75. sel3 = 0;
  76. }else{
  77. sel1 = entsel.substring(0,2);
  78. sel2 = entsel.substring(0,4);
  79. sel3 = entsel.substring(0,6);
  80. }
  81. $.cxSelect.setVal(sel1,sel2,sel3);
  82. $("#city_china select").each(function(){
  83. if($(this).find("option:selected").index() > 0){
  84. $(this).addClass("sel-checked");
  85. }
  86. });
  87. if(serviceloc){
  88. //添加编辑服务中的省
  89. $("#servicecity_china .province option").each(function(){
  90. if(sel1 == $(this).val()){
  91. $(this).attr("selected","selected");
  92. }
  93. });
  94. //添加编辑服务中的市
  95. $("#servicecity_china .city option").each(function(){
  96. if(sel2 == $(this).val()){
  97. $(this).attr("selected","selected");
  98. }
  99. });
  100. //添加编辑服务中的县
  101. $("#servicecity_china .area option").each(function(){
  102. if(sel3 == $(this).val()){
  103. $(this).attr("selected","selected");
  104. }
  105. });
  106. }
  107. }
  108. cityMouse="";
  109. $(function(){
  110. ////推荐企业
  111. loadImg(1);
  112. //行业类别 注册资本 加载
  113. makeFl();
  114. //所在地信息加载
  115. if($chiancity){
  116. $('#city_china').cxSelect({
  117. selects: ['province', 'city', 'area'],
  118. required:0,
  119. somep:true,
  120. someps:[41,45]
  121. });
  122. setLocation(entsel)
  123. }
  124. //处理点击重新加载
  125. $("div[id^=c_] li,li[id^=c_],input[id^=c_]").click(function(){
  126. if(this.id=="c_words"){
  127. reloadData($("#header-searchInputs"))
  128. }else{
  129. reloadData($(this))
  130. }
  131. })
  132. $("select[id^=c_]").click(function(){
  133. cityMouse=this.id
  134. }).change(function(){
  135. if(this.id==cityMouse){
  136. reloadData($(this),"city")
  137. }
  138. })
  139. //处理选择样式
  140. $("div[id^=c_] li").click(function(){
  141. $("li",$(this).closest("div")).removeClass("text-primary");
  142. //$(this).addClass("text-primary");
  143. })
  144. //搜索关键字
  145. var words=""
  146. if(btempwords){
  147. words=btempwords
  148. $("#header-searchInput").val(words);
  149. }
  150. })
  151. function makeFl(){
  152. //行业类别
  153. $(["c_hfl"]).each(function(i,ad){
  154. var str="<ul>";
  155. var tmp=eval(ad)
  156. for(var i=0;i<tmp.length;i++){
  157. var val = chf1;
  158. if (val !=""){
  159. if (val == tmp[i][1]){
  160. str+="<li name='"+ad+"' value='"+tmp[i][1]+"' class='entlist-allclaify'>"+tmp[i][0]+"</li>"
  161. var j ="J"
  162. if (val > j || val == "D" || val == "E" || val == "F" || val == "G" ){
  163. $("#c_hfl").next().find("small").text("收起<")
  164. $("#c_hfl").removeClass("less")
  165. }
  166. }else{
  167. str+="<li name='"+ad+"' value='"+tmp[i][1]+"'>"+tmp[i][0]+"</li>"
  168. }
  169. }else{
  170. str+="<li name='"+ad+"' value='"+tmp[i][1]+"' "+(i==0?"class='entlist-allclaify'":"")+">"+tmp[i][0]+"</li>"
  171. }
  172. }
  173. str+="</ul>"
  174. $("#"+ad).html(str)
  175. })
  176. //注册资本
  177. $(["c_zb"]).each(function(i,ad){
  178. var str="<ul>";
  179. var tmp=eval(ad)
  180. for(var i=0;i<tmp.length;i++){
  181. var val = czb;
  182. var livtemp= tmp[i][1]+"";
  183. if (val !=""){
  184. if (val == tmp[i][1]){
  185. str+="<li name='"+ad+"' value='"+livtemp+"' class='entlist-allclaify'>"+tmp[i][0]+"</li>"
  186. }else{
  187. str+="<li name='"+ad+"' value='"+livtemp+"'>"+tmp[i][0]+"</li>"
  188. }
  189. }else{
  190. str+="<li name='"+ad+"' value='"+livtemp+"' "+(i==0?"class='entlist-allclaify'":"")+">"+tmp[i][0]+"</li>"
  191. }
  192. }
  193. str+="</ul>"
  194. $("#"+ad).html(str)
  195. })
  196. }
  197. function less(obj){
  198. pred=$(obj).prev()
  199. var text=$(obj).text()
  200. if(text=="更多"){
  201. $(obj).text("收起")
  202. pred.removeClass("less")
  203. }else{
  204. $(obj).text("更多")
  205. pred.addClass("less")
  206. }
  207. }
  208. //推荐企业
  209. function loadImg(n){
  210. var str=""
  211. for(var i=0;i<n;i++){
  212. str+="<img src='/images/right_ad.png'>"
  213. }
  214. $("#tjqy").html(str)
  215. }
  216. //当前位置
  217. function currPos(){
  218. return [["企业社区","/search/enterprise/ent.html"]]
  219. }
  220. function GetDiffName(i) {
  221. ret=["法定代表人"]
  222. //ret=["法定代表人","住所","成立日期"]
  223. switch (i) {
  224. case "9600":
  225. {
  226. ret[0] = "经营者"
  227. //ret[1] = "经营场所"
  228. //ret[2] = "注册日期"
  229. break;
  230. }
  231. case "4500":
  232. case "6800":
  233. case "6810":
  234. case "6820":
  235. case "7100":
  236. case "7110":
  237. case "7120":
  238. case "7130":
  239. case "7190":
  240. case "9200":
  241. case "6840":
  242. case "2100":
  243. case "2110":
  244. case "2120":
  245. case "2121":
  246. case "2122":
  247. case "2123":
  248. case "2130":
  249. case "2140":
  250. case "2150":
  251. case "2151":
  252. case "2152":
  253. case "2190":
  254. case "2200":
  255. case "2210":
  256. case "2211":
  257. case "2212":
  258. case "2213":
  259. case "2219":
  260. case "2220":
  261. case "2221":
  262. case "2222":
  263. case "2223":
  264. case "2229":
  265. case "4000":
  266. case "4300":
  267. case "4310":
  268. case "4320":
  269. case "4330":
  270. case "4340":
  271. case "4550":
  272. case "4551":
  273. case "4552":
  274. case "4553":
  275. case "4560":
  276. case "5800":
  277. case "5810":
  278. case "5820":{
  279. ret[0] = "负责人"
  280. //ret[1] = "营业场所"
  281. //ret[2] = "成立日期"
  282. break;
  283. }
  284. }
  285. return ret
  286. }
  287. /////////////////////企业名片详细信息页js代码///////////////////////
  288. //判断是否为企业名片列表页
  289. if(!$listent){
  290. $(function(){
  291. //联系地址
  292. if($chiancity){
  293. setcxSelect();
  294. var pt=province?($("#provincesel option[value="+province+"]").text()+" "):"";
  295. var ct=city?($("#citysel option[value="+city+"]").text()+" "):"";
  296. var at=area?($("#areasel option[value="+area+"]").text()+" "):"";
  297. //设置地图上显示的位置
  298. $("#location").attr("value",as1);
  299. $("#cityname").attr("value",pt.trim()+ct.trim()+at.trim());
  300. //获取地图的经纬度
  301. doOptions();
  302. $("#city_china").text(pt+ct+at+as1);
  303. }else{
  304. setcxSelect();
  305. }
  306. //公式信息是否显示
  307. if(!$gs){
  308. $("#ags").parent().hide();
  309. $("#gs").hide();
  310. }
  311. //关系网的设置
  312. if($relationlen>0&&typeof($("#gx").css("width")) != "undefined"){
  313. var zoomlevel=1;
  314. var w = parseInt($("#gx").css("width").replace("px","")) - 10;
  315. $("#infovis").css("width",w+"px");
  316. var h = $("#infovis").height();
  317. $(".controlls").css({left:$("#infovis").offset().left+w-$(".controlls").width()-10});
  318. //查找逻辑
  319. var index=-1;
  320. var reg = new RegExp(/(有限公司|有限责任公司|股份有限公司|总公司|分公司|公司|事务所|合伙企业)$|\(.*\)|\(.*\)/g);
  321. var provinces = [];
  322. $.ajax({
  323. url: "/js/provinceData.min.json",
  324. dataType: "json",
  325. cache: true,
  326. async: false,
  327. success: function(json){
  328. provinces = json;
  329. }
  330. });
  331. var filterEntName = function(text){
  332. this.allProvinces = "河南省、青海省、山西省、黑龙江省、安徽省、广西壮族自治区、西藏自治区";
  333. this.commonReplace = function(t){
  334. if(t.length > 1 && text.startWith(t)){
  335. var textCopy = text.replace(new RegExp("^"+t),"");
  336. if(textCopy.length > 2){
  337. text = textCopy;
  338. }
  339. return true;
  340. }
  341. return false;
  342. };
  343. this.replaceStart = function(t,f){
  344. var flag = false;
  345. var minus = null;
  346. if(this.commonReplace(t)){//替换省、市、县、区
  347. return true;
  348. }
  349. if(f){//不替换
  350. flag = false;
  351. }else if(t.endWith("维吾尔自治区")){
  352. flag = true;
  353. minus = 6;
  354. }else if(t.endWith("回族自治区") || t.endWith("壮族自治区") || t.endWith("特别行政区")){
  355. flag = true;
  356. minus = 5;
  357. }else if(t.endWith("自治州") || t.endWith("自治县") || t.endWith("自治区")){
  358. flag = true;
  359. minus = 3;
  360. }else if(t.endWith("地区")){
  361. flag = true;
  362. minus = 2;
  363. }else if(t.endWith("省") || t.endWith("市") || t.endWith("区")){
  364. flag = true;
  365. minus = 1;
  366. }
  367. if(flag){
  368. return this.commonReplace(t.substring(0,t.length-minus));
  369. }
  370. return false;
  371. };
  372. this.replaceCity = function(citys){
  373. if(citys){
  374. for(var c in citys){//市
  375. var c_name = citys[c].n;
  376. if(this.replaceStart(c_name)){
  377. this.replaceAreas(citys[c].s);
  378. return true;
  379. }else if(this.replaceAreas(citys[c].s)){
  380. return true;
  381. }
  382. }
  383. }
  384. };
  385. this.replaceAreas = function(areas){
  386. if(areas){
  387. for(var a in areas){//县、区
  388. var a_name = areas[a].n;
  389. if(this.replaceStart(a_name,true)){
  390. return true;
  391. }
  392. }
  393. }
  394. };
  395. for(var p in provinces){//省
  396. var p_name = provinces[p].n;
  397. if(this.allProvinces.indexOf(p_name) == -1){
  398. continue;
  399. }
  400. if(this.replaceStart(p_name)){
  401. this.replaceCity(provinces[p].s);
  402. break;
  403. }else if(this.replaceCity(provinces[p].s)){
  404. break;
  405. }
  406. }
  407. return text;
  408. }
  409. for(var i=0;i<data.nodes.length;i++){
  410. var nodeObj = data.nodes[i];
  411. nodeObj.text = $.trim(nodeObj.text);
  412. nodeObj.shortText = nodeObj.text;
  413. if(nodeObj.type == "e" || nodeObj.type == "ce"){
  414. var text = nodeObj.shortText;
  415. if(text.length > 2){//先替换结尾
  416. text = text.replace(reg,"");
  417. }
  418. if(text.length > 2){//再替换开头
  419. text = filterEntName(text);
  420. }
  421. if(text.length > 2){//小于两个字符不生效
  422. nodeObj.shortText = text;
  423. }
  424. if(nodeObj.name==regno){//先找本企业位置
  425. index=i;
  426. nodeObj["regcap"] = (typeof(d1) == "undefined")?0:d1;
  427. nodeObj["legcerno"] = legcerno;
  428. }
  429. }
  430. }
  431. /*********************************连线处理***********************************/
  432. var minLink=-1,maxLink=-1;
  433. for(var i=0;i<data.links.length;i++){
  434. var linkObj = data.links[i];
  435. if(linkObj.target==index && data.nodes[linkObj.source].name==legcerno){
  436. //data.nodes[linkObj.source].type="cp";
  437. linkObj.type = "cp"
  438. linkObj.isLegal = 1;
  439. }
  440. //
  441. data.nodes[linkObj.target]["istarget"] = 1;
  442. if(data.nodes[linkObj.source].name == data.nodes[linkObj.target].invlegcerno || data.nodes[linkObj.source].name == data.nodes[linkObj.target].legcerno){
  443. linkObj.isLegal = 1;
  444. }
  445. if(typeof(linkObj.invacconam) == "undefined"){
  446. continue;
  447. }
  448. var invacconam = new Number(linkObj.invacconam);
  449. if(minLink == -1 && maxLink == -1){
  450. minLink = invacconam;
  451. maxLink = invacconam;
  452. }else if(invacconam > maxLink){
  453. maxLink = invacconam;
  454. }else if(invacconam < minLink){
  455. minLink = invacconam;
  456. }
  457. }
  458. var getLineSectionArray = function(){
  459. var countSection = 6;
  460. var section = (maxLink - minLink) / countSection;
  461. var sectionArr = [];
  462. for(var i=2;i<=countSection;i++){
  463. var minVal = minLink;
  464. if(sectionArr.length > 0){
  465. minVal = sectionArr[sectionArr.length - 1].maxVal;
  466. }
  467. var maxVal = minLink+section*i;
  468. if(i == countSection){
  469. maxVal += section;
  470. }
  471. var sectionObj = {linkVal:i,minVal:minVal,maxVal:maxVal};
  472. sectionArr.push(sectionObj);
  473. }
  474. return sectionArr;
  475. }
  476. /////////////
  477. var linkSectionArray = getLineSectionArray();
  478. for(var i=0;i<data.links.length;i++){
  479. var linksObj = data.links[i];
  480. linksObj["linkVal"] = 2;
  481. if(typeof(linkObj.invacconam) == "undefined"){
  482. continue;
  483. }
  484. var invacconam = new Number(linksObj.invacconam);
  485. for(var s in linkSectionArray){
  486. var sectionObj = linkSectionArray[s];
  487. if(invacconam >= sectionObj.minVal && invacconam < sectionObj.maxVal){
  488. linksObj["linkVal"] = sectionObj.linkVal;
  489. continue;
  490. }
  491. }
  492. }
  493. /*********************************节点处理***********************************/
  494. var minNode=-1,maxNode=-1;
  495. for(var i=0;i<data.nodes.length;i++){
  496. var nodeObj = data.nodes[i];
  497. if(nodeObj.type == "e" || nodeObj.type == "ce"){
  498. var regcap = 0;
  499. if(nodeObj.istarget == 1){
  500. regcap = new Number(nodeObj.regcap);
  501. }else{
  502. regcap = new Number(nodeObj.invregcap);
  503. }
  504. if(minNode == -1 && maxNode == -1){
  505. minNode = regcap;
  506. maxNode = regcap;
  507. }else if(regcap > maxNode){
  508. maxNode = regcap;
  509. }else if(regcap < minNode){
  510. minNode = regcap;
  511. }
  512. }
  513. }
  514. var getNodeSectionArray = function(){
  515. var countSection = 7;
  516. var section = (maxNode - minNode) / countSection;
  517. var sectionArr = [];
  518. for(var i=1;i<=countSection;i++){
  519. var minVal = minNode;
  520. if(sectionArr.length > 0){
  521. minVal = sectionArr[sectionArr.length - 1].maxVal;
  522. }
  523. var maxVal = minNode+section*i;
  524. if(i == countSection){
  525. maxVal += section;
  526. }
  527. var sectionObj = {nodeVal:6+i,minVal:minVal,maxVal:maxVal};
  528. sectionArr.push(sectionObj);
  529. }
  530. return sectionArr;
  531. }
  532. var nodeSectionArray = getNodeSectionArray();
  533. for(var i=0;i<data.nodes.length;i++){
  534. var nodeObj = data.nodes[i];
  535. nodeObj["nodeVal"] = 7;
  536. if(nodeObj.type == "e" || nodeObj.type == "ce"){
  537. var invacconam = new Number(nodeObj.invacconam);
  538. var regcap = new Number(nodeObj.regcap);
  539. for(var s in nodeSectionArray){
  540. var sectionObj = nodeSectionArray[s];
  541. if(regcap >= sectionObj.minVal && regcap < sectionObj.maxVal){
  542. nodeObj["nodeVal"] = sectionObj.nodeVal;
  543. continue;
  544. }
  545. }
  546. }
  547. }
  548. //屏蔽鼠标右点击事件
  549. document.getElementById("infovis").oncontextmenu=function(){return false;};
  550. $("#op_fullscreen").attr("title","进入全屏视图"+((!!window.ActiveXObject || "ActiveXObject" in window)?"":" (F11)"));
  551. //处理全屏
  552. function launchFullScreen(element) {
  553. if (element.requestFullscreen) {
  554. element.requestFullscreen();
  555. } else if (element.msRequestFullscreen) {
  556. element.msRequestFullscreen();
  557. } else if (element.mozRequestFullScreen) {
  558. element.mozRequestFullScreen();
  559. } else if (element.webkitRequestFullscreen) {
  560. element.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
  561. }
  562. }
  563. function cancelFullScreen() {
  564. $("#op_fullscreen").attr("title","进入全屏视图"+((!!window.ActiveXObject || "ActiveXObject" in window)?"":" (F11)"));
  565. //force.linkDistance(120).charge(-200).size([w,h]).resume();
  566. $("#infovis").css({width:w,height:h});
  567. svg.attr("width",w).attr("height",h);
  568. $(".controlls").css({left:$("#infovis").offset().left+w-$(".controlls").width()-10});
  569. if(document.exitFullscreen) {
  570. document.exitFullscreen();
  571. } else if (document.msExitFullscreen) {
  572. document.msExitFullscreen();
  573. } else if (document.mozCancelFullScreen) {
  574. document.mozCancelFullScreen();
  575. } else if (document.webkitExitFullscreen) {
  576. document.webkitExitFullscreen();
  577. }
  578. }
  579. $(document).on('webkitfullscreenchange mozfullscreenchange msfullscreenchange fullscreenchange', function(){
  580. if (!document.fullscreenElement && // alternative standard method
  581. !document.mozFullScreenElement &&
  582. !document.webkitFullscreenElement &&
  583. !document.msFullscreenElement ) {
  584. //退出
  585. cancelFullScreen();
  586. }});
  587. var infovisdiv = document.getElementById("infovis");
  588. document.onkeydown=function(event){
  589. var e = event || window.event || arguments.callee.caller.arguments[0];
  590. if(e && e.keyCode==122){
  591. event.preventDefault?event.preventDefault():window.event.returnValue = false;
  592. if(!!window.ActiveXObject || "ActiveXObject" in window){//ie下F11不能用,屏蔽掉
  593. if($(".exit").length == 0){
  594. return;
  595. }
  596. }
  597. initFullScreen();
  598. }else if(e && e.keyCode==27){
  599. event.preventDefault?event.preventDefault():window.event.returnValue = false;
  600. cancelFullScreen();
  601. }
  602. };
  603. $("#op_fullscreen").bind("click",initFullScreen);
  604. function initFullScreen(){
  605. var fullscreenElement =
  606. document.fullscreenElement ||
  607. document.mozFullScreenElement ||
  608. document.webkitFullscreenElement ||
  609. document.msFullscreenElement;
  610. $(".ico_fullscreen").toggleClass("exit");
  611. if(!fullscreenElement || fullscreenElement==null){
  612. redrawflag = true;
  613. $("#op_fullscreen").attr("title","退出全屏视图 (F11)");
  614. launchFullScreen(infovisdiv);
  615. var timeout = 100;
  616. if(!!window.ActiveXObject || "ActiveXObject" in window){
  617. timeout = 400;
  618. }
  619. setTimeout(function(){
  620. //重绘
  621. var w=document.body.clientWidth;
  622. var h=document.body.clientHeight;
  623. $("#infovis").css({width:w,height:h});
  624. d3.select("svg").attr("width", w).attr("height", h);
  625. $(".controlls").css({left:w-$(".controlls").width() - 10});
  626. //force.linkDistance(h).charge(-700).size([w,h]).resume();
  627. },timeout);
  628. }else{
  629. cancelFullScreen();
  630. }
  631. }
  632. //计算点之间的距离
  633. var chargeArray = [[0,10],[10,20],[20,30],[30,40],[40,50],[50,60],[60,70],[70,80],[80,90],[90,100],[100,110]];
  634. var chargeVal = -1600;
  635. var nodeCount = data.nodes.length;
  636. for(var i in chargeArray){
  637. if(nodeCount >= chargeArray[i][0] && nodeCount < chargeArray[i][1]){
  638. chargeVal += i*100;
  639. break;
  640. }else if(i == chargeArray.length){
  641. chargeVal += i*100;
  642. }
  643. }
  644. var force = d3.layout.force()
  645. .nodes(data.nodes)
  646. .links(data.links)
  647. .size([w, h])
  648. .linkDistance(function(p){
  649. return Math.floor(Math.random()*60)+90;
  650. })
  651. .chargeDistance(600)
  652. .charge(chargeVal)
  653. .linkStrength(1)
  654. .on("tick", tick);
  655. var dragstatus = false,
  656. mouseoverstatus = false;
  657. var drag = force.drag()
  658. .on("dragstart",function(d,i){
  659. d.fixed = true; //拖拽开始后设定被拖拽对象为固定
  660. d3.event.sourceEvent.stopPropagation(); // Prevent panning
  661. })
  662. .on("drag",function(d,i){
  663. dragstatus = true;
  664. mouseoverstatus = true;
  665. })
  666. .on("dragend",function(d,i){
  667. mouseoverstatus = false;
  668. setTimeout(function(){
  669. dragstatus = false;
  670. },500)
  671. });
  672. //处理缩放
  673. var zoom = d3.behavior.zoom().scaleExtent([0.4, 10]).on("zoom", zoomed);
  674. function zoomed() {
  675. svg.attr("transform",
  676. "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
  677. }
  678. var svg = d3.select("#infovis").append("svg:svg")
  679. .attr("width", w)
  680. .attr("height", h)
  681. .call(zoom)
  682. .append("g");
  683. var lines = svg.append("svg:g")
  684. .selectAll("path")
  685. .data(force.links())
  686. .enter().append("path")
  687. .style("fill", function(p){
  688. return (p.type=="cp" || p.isLegal)?"#5cb85c":"#b5b5b5";
  689. })
  690. .style("stroke", function(p){
  691. return (p.type=="cp" || p.isLegal)?"#5cb85c":"#b5b5b5";
  692. })
  693. .attr("stroke-width",function (e,i){
  694. return e.linkVal;
  695. });
  696. lines.each(function (d,i){
  697. var invacconam = new Number(d.invacconam);
  698. if(invacconam > 0){
  699. var lenInvacconam = (invacconam + "").length;
  700. if(lenInvacconam > 4 && (invacconam + "").indexOf(".") > -1 && (lenInvacconam - (invacconam + "").indexOf(".")) > 4){
  701. invacconam = invacconam.toFixed(4)
  702. }
  703. d3.select(this).append("title").text("投资金额:"+invacconam+"万元");
  704. }
  705. });
  706. var nodes = svg.append("svg:g")
  707. .selectAll(".node")
  708. .data(force.nodes())
  709. .enter()
  710. .append("g")
  711. .call(force.drag)
  712. .attr('class', 'node')
  713. .on('mouseover', function(d) {
  714. highlightObject(this,true);
  715. })
  716. .on('mouseout', function(d) {
  717. highlightObject(this,false);
  718. })
  719. .on("mousedown",function (e,i){
  720. d3.event.preventDefault();
  721. removeNode(this);
  722. });
  723. nodes.append("rect")
  724. .attr("rx", 5)
  725. .attr("ry", 5)
  726. .attr('height', 20)
  727. .attr("fill", function(p){
  728. return p.type=="p"?"#7e388e":p.type=="ce"?"#da4e2b":"#0b93d1";
  729. })
  730. .attr("stroke", function(p){
  731. return p.type=="p"?"#7e388e":p.type=="ce"?"#da4e2b":"#0b93d1";
  732. })
  733. .style("opacity","0.7");
  734. nodes.each(function (d,i){
  735. if(d.type == "ce" || d.type == "e"){
  736. var title = "";
  737. if(d.text != d.shortText){
  738. title = d.text;
  739. }
  740. var regcap = 0;
  741. if(d.istarget == 1){
  742. regcap = new Number(d.regcap);
  743. }else{
  744. regcap = new Number(d.invregcap);
  745. }
  746. if(regcap > 0){
  747. var lenRegcap = (regcap + "").length;
  748. if(lenRegcap > 4 && (regcap + "").indexOf(".") > -1 && (lenRegcap - (regcap + "").indexOf(".")) > 4){
  749. regcap = regcap.toFixed(4)
  750. }
  751. if(title != ""){
  752. title += "\n";
  753. }
  754. title += "注册资本:"+regcap+"万元";
  755. }
  756. if(title != ""){
  757. d3.select(this).append("title").text(title);
  758. }
  759. }
  760. });
  761. nodes.append('text')
  762. .text(function(d){
  763. return d.shortText;
  764. })
  765. .style("cursor",function (d,i){
  766. if(d.type == "e"){
  767. return "pointer";
  768. }else{
  769. return "auto";
  770. }
  771. })
  772. .on("click",function (d,i){
  773. if(!dragstatus && d.type == "e"){
  774. window.open("/enterpriseInfoByRegNO/"+d.name+".html");
  775. }
  776. });
  777. setTimeout(function() {
  778. nodes.each(function(d) {
  779. var node = d3.select(this),
  780. text = node.selectAll('text'),
  781. bounds = {},
  782. first = true;
  783. text.each(function() {
  784. var box = this.getBBox();
  785. if (first || box.x < bounds.x1) {
  786. bounds.x1 = box.x;
  787. }
  788. if (first || box.y < bounds.y1) {
  789. bounds.y1 = box.y;
  790. }
  791. if (first || box.x + box.width > bounds.x2) {
  792. bounds.x2 = box.x + box.width;
  793. }
  794. if (first || box.y + box.height > bounds.y2) {
  795. bounds.y2 = box.y + box.height;
  796. }
  797. first = false;
  798. }).attr('text-anchor', 'middle');
  799. var padding = {"left":3,"right":3,"top":2,"bottom":2},
  800. margin = {"left":3,"right":3,"top":2,"bottom":2},
  801. oldWidth = bounds.x2 - bounds.x1;
  802. bounds.x1 -= oldWidth / 2;
  803. bounds.x2 -= oldWidth / 2;
  804. bounds.x1 -= padding.left;
  805. bounds.y1 -= padding.top;
  806. bounds.x2 += padding.left + padding.right;
  807. bounds.y2 += padding.top + padding.bottom;
  808. var width = bounds.x2 - bounds.x1;
  809. var height = bounds.y2 - bounds.y1;
  810. node.select('rect')
  811. .attr('x', bounds.x1)
  812. .attr('y', bounds.y1)
  813. //.attr('height', height)
  814. .attr('width', width);
  815. d.edge = {
  816. left : new geo.LineSegment(bounds.x1, bounds.y1, bounds.x1, bounds.y2),
  817. right : new geo.LineSegment(bounds.x2, bounds.y1, bounds.x2, bounds.y2),
  818. top : new geo.LineSegment(bounds.x1, bounds.y1, bounds.x2, bounds.y1),
  819. bottom : new geo.LineSegment(bounds.x1, bounds.y2, bounds.x2, bounds.y2)
  820. };
  821. });
  822. force.start();
  823. });
  824. function highlightObject(obj,flag){
  825. if(mouseoverstatus){
  826. return;
  827. }
  828. if(!flag){
  829. d3.selectAll(".node").each(function (){
  830. d3.select(this).style("opacity","1");
  831. });
  832. d3.selectAll("path").each(function (){
  833. d3.select(this).style("opacity","1");
  834. });
  835. return;
  836. }
  837. var name = obj.__data__.name;
  838. d3.selectAll(".node").each(function (){
  839. if(name != this.__data__.name){
  840. d3.select(this).style("opacity","0.2");
  841. }
  842. });
  843. d3.selectAll("path").each(function (){
  844. var targetName = this.__data__.target.name;
  845. var sourceName = this.__data__.source.name;
  846. if(name != targetName && name != sourceName){
  847. d3.select(this).style("opacity","0.2");
  848. }else{
  849. d3.selectAll(".node").each(function (){
  850. if(targetName == this.__data__.name || sourceName == this.__data__.name){
  851. d3.select(this).style("opacity","1");
  852. }
  853. });
  854. }
  855. });
  856. }
  857. function removeNode(obj){
  858. if(d3.event.which != 3){
  859. return;
  860. }
  861. highlightObject(obj,false);
  862. d3.select(obj).remove();
  863. var name = obj.__data__.name;
  864. var removeAloneNode = function(removeNodeName){
  865. var isRemoveAloneNode = true;
  866. d3.selectAll("path").each(function (i){
  867. if(removeNodeName == this.__data__.source.name || removeNodeName == this.__data__.target.name){
  868. isRemoveAloneNode = false;
  869. return true;
  870. }
  871. });
  872. if(isRemoveAloneNode){
  873. d3.selectAll("rect").each(function (){
  874. if(this.__data__.name == removeNodeName){
  875. d3.select(this).remove();
  876. return true;
  877. }
  878. });
  879. d3.selectAll("text").each(function (){
  880. if(this.__data__.name == removeNodeName){
  881. d3.select(this).remove();
  882. return true;
  883. }
  884. });
  885. }
  886. }
  887. d3.selectAll("path").each(function (){
  888. if(name == this.__data__.target.name){
  889. var fromNodeName = this.__data__.source.name;
  890. d3.select(this).remove();
  891. removeAloneNode(fromNodeName);
  892. }else if(name == this.__data__.source.name){
  893. var toNodeName = this.__data__.target.name;
  894. d3.select(this).remove();
  895. removeAloneNode(toNodeName);
  896. }
  897. });
  898. d3.selectAll("rect").each(function (){
  899. if(name == this.__data__.name){
  900. d3.select(this).remove();
  901. }
  902. });
  903. d3.selectAll("text").each(function (){
  904. if(name == this.__data__.name){
  905. d3.select(this).remove();
  906. }
  907. });
  908. }
  909. var diagonal = d3.svg.diagonal()
  910. .projection(function(d) { return [d.y, d.x]; });
  911. //关系网
  912. function tick(e) {
  913. lines.attr("d", function(d) {
  914. var sy = d.source.y,
  915. x = d.target.x,
  916. y = d.target.y;
  917. if(sy > y){
  918. sy -= 12;
  919. }else{
  920. sy += 5;
  921. }
  922. var line = new geo.LineSegment(d.source.x, sy, x, y);
  923. for (var e in d.target.edge) {
  924. var ix = line.intersect(d.target.edge[e].offset(x, y));
  925. if (ix.in1 && ix.in2) {
  926. x = ix.x;
  927. y = ix.y;
  928. break;
  929. }
  930. }
  931. var dx = x - d.source.x,
  932. dy = y - sy,
  933. dr = Math.sqrt(dx * dx + dy * dy),
  934. theta = Math.atan2(dy, dx) + Math.PI / 7.85,
  935. d90 = Math.PI / 2,
  936. dtxs = x - Math.cos(theta),
  937. dtys = y - Math.sin(theta);
  938. return "M" + d.source.x + "," + sy + "A" + dr + "," + dr + " 0 0 1," + x + "," + y + "A" + dr + "," + dr + " 0 0 0," + d.source.x + "," + sy + "M" + dtxs + "," + dtys + "l" + (3.5 * Math.cos(d90 - theta) - 10 * Math.cos(theta)) + "," + (-3.5 * Math.sin(d90 - theta) - 10 * Math.sin(theta)) + "L" + (dtxs - 3.5 * Math.cos(d90 - theta) - 10 * Math.cos(theta)) + "," + (dtys + 3.5 * Math.sin(d90 - theta) - 10 * Math.sin(theta)) + "z";
  939. });
  940. nodes.attr("transform", function(d) {
  941. return "translate(" + d.x + "," + d.y + ")scale(" + zoomlevel+ ")";
  942. });
  943. }
  944. /////////////重绘画布///////////////////
  945. var redrawflag=false;
  946. //重绘
  947. function redraw(){
  948. var w = parseInt($("#gx").css("width").replace("px","")) - 10;
  949. var h = parseInt($("#gx").css("height").replace("px",""))-10;
  950. d3.select("svg").attr("width", w).attr("height", h);
  951. force.size([w,h]).resume();
  952. $("#infovis").css({width:w,height:h});
  953. //
  954. redrawflag=false;
  955. }
  956. $(window).resize(function(){
  957. if(!redrawflag){
  958. //1秒后重绘
  959. redrawflag=true;
  960. setTimeout(redraw,1000);
  961. }
  962. firstresize=false;
  963. });
  964. ///////////////////////关系网实例////////////////////////////
  965. var htmls="<div style='position:absolute;' class='legend'>";
  966. htmls= htmls+ "<div class='legend-text-bg' style='margin-top: 10px;'><img src='/images/qfw_gxmain.png' style='width:10px;height:10px;margin:10px;' /><div style='background-color: #da4e2b;margin-top: 2px;'>&nbsp;</div><span style='margin-left: 10px;'>本企业</span></div>";
  967. htmls= htmls+ "<div class='legend-text-bg' style='margin-top: 10px;'><img src='/images/qfw_gxmain2.png' style='width:9px;height:9px;margin:10px;' /><div style='background-color: #0b93d1;margin-top: 2px;'>&nbsp;</div><span style='margin-left: 5px;'>其他企业</span></div>";
  968. htmls= htmls+ "<div class='legend-text-bg' style='margin-top: 10px;'><img src='/images/qfw_gxmain1.png' style='width:8px;height:8px;margin:10px;' /><div style='background-color: #7e388e;'>&nbsp;</div><span style='margin-left: 18px;'>个人</span></div>";
  969. htmls= htmls+ "<div style='margin:0px 7px;'><span style='font-size: 20px;font-weight: bold;color: #b5b5b5;'>→</span><span style=''>投资关系(股东→企业)</span></div>";
  970. htmls= htmls+ "<div style='margin:0px 7px;'><span style='font-size: 20px;font-weight: bold;color: #5cb85c;'>→</span><span style=''>法定代表人</span></div>";
  971. htmls= htmls+ "<div style='margin:10px 7px;' class='hidden-sm hidden-xs'><span class='text-muted'>提示:点击鼠标右键可以删除不想看的节点。</span></div>";
  972. htmls= htmls+"</div>"
  973. $("#gxw_bs").html(htmls);
  974. }else{
  975. //当关系网不存在的时候设置隐藏
  976. $("#agx").parent().hide();
  977. $("#gx").hide();
  978. }
  979. //微官网
  980. $(".wgw").click(function(){
  981. window.location.href="/ent/wsite/preview/"+id;
  982. })
  983. });
  984. }
  985. //设置级联位置信息
  986. function setcxSelect(){
  987. $('#city_china').cxSelect({
  988. selects: ['province', 'city', 'area'],
  989. required:0
  990. });
  991. $.cxSelect.setVal(province,city,area);
  992. }
  993. //咨询客服
  994. function openChat() {
  995. try {
  996. var url = "/chat/client/"+id;
  997. window.open(url, "TopChat", "toolbar=0,scrollbars=0,location=0,menubar=0,resizable=1,width=920,height=620");
  998. } catch (e) {
  999. }
  1000. }
  1001. //加载服务与服务列表展示
  1002. if(!$listent){
  1003. var perPage=5,currentPage=1
  1004. //解析服务列表
  1005. $(function(){
  1006. //加载服务列表
  1007. initServiceList();
  1008. });
  1009. //点击服务标题展示服务信息
  1010. function clickservicename(id,isshow){
  1011. if($("#"+id).length>0){
  1012. if(isshow.indexOf("3")>-1){
  1013. window.location.href="/market/detail/"+id+".html"
  1014. }else{
  1015. window.location.href="/market/showservice/"+id+".html"
  1016. }
  1017. }else{
  1018. window.location.href="/market/showservice/"+id+".html"
  1019. }
  1020. }
  1021. function initServiceList(){
  1022. $("#service_list").datatable({
  1023. perPage: perPage
  1024. ,showPagination:false
  1025. ,checkbox:""
  1026. ,checkboxHeader:false
  1027. ,showHeader:false
  1028. ,idField:"_id"
  1029. ,classname:"table-hover"
  1030. ,url: '/searchEntSer/' + $entid
  1031. ,rowCallback: analyList,
  1032. ajaxSuccess:function(res,o){
  1033. console.log(res);
  1034. if(!res || res === undefined || !res.data || res.data.length == 0) {
  1035. o.continueBody=false;
  1036. $("#loadMore").hide();
  1037. }
  1038. //判断加载更多是否显示
  1039. if(res.totalRows>5){
  1040. $("#loadMore").show();
  1041. }else{
  1042. $("#loadMore").hide();
  1043. }
  1044. }
  1045. });
  1046. }
  1047. /*//编辑企业名片事件
  1048. function btnSaveForm(){
  1049. //联系人
  1050. if($("#s_persion").val().length==0){
  1051. alert("请输入正确的联系人");
  1052. return;
  1053. }
  1054. if($("#s_persion").val().length>30){
  1055. alert("输入的联系人必须小于30个字");
  1056. return;
  1057. }
  1058. //联系电话
  1059. var tel = $("#Tel").val();
  1060. var telReg = !!tel.match(/^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/);
  1061. if(telReg == false){
  1062. alert("请输入正确的手机号");
  1063. return;
  1064. }
  1065. if($("#s_enturl").val().length>0&& $("#s_enturl").val().indexOf(".")==-1){
  1066. alert("请输入正确的企业网站域名");
  1067. return;
  1068. }
  1069. if($("#s_weixin").val().length>0&&$("#s_weixin").val().length>20 ){
  1070. alert("请输入正确的微信号");
  1071. return;
  1072. }
  1073. if($("#s_address").val().length>0&&$("#s_address").val().length>50 ){
  1074. alert("联系地址详细信息不能超过50个字");
  1075. return;
  1076. }
  1077. //序列化表格内容为字符串
  1078. var param = $("#entform").serialize();
  1079. $.ajax({
  1080. type:'post',
  1081. url:'/member/yellowpage/dosave/enterprise',
  1082. data:param,
  1083. cache:false,
  1084. dataType:'json',
  1085. success:function(data){
  1086. alert(data.info);
  1087. window.location.href="/member/yellowpage/show/enterprise/"+ $entid;
  1088. }
  1089. });
  1090. }
  1091. */
  1092. function analyList(rowHtml, rowData) {
  1093. var t="";
  1094. if(rowData.i_status==1){
  1095. t=template_content.replace("<a class='text-primary' id='${_id}' value='${_id}' data-id='${s_isEdit}' onclick='removeservice(this)'>下架</a>","");
  1096. }else{
  1097. t=template_content.replace("已下架","");
  1098. }
  1099. return t.replace(/\$\{(.*?)\}/g,
  1100. function(a, b, c) {
  1101. var res = rowData[b]||"";
  1102. //去掉后台服务列表中的图片
  1103. var data = res.replace(/<img.*>.*<\/img>/ig,""); //过滤如<img></img>形式的图片元素
  1104. res = data.replace(/<img.*\/>/ig, ""); //过滤如<img />形式的元素
  1105. if (!res&&b=="s_images"){
  1106. res="/images/services/default.png"
  1107. }else{
  1108. res = res.replace(/\n/g,"");
  1109. }
  1110. return res;
  1111. });
  1112. }
  1113. //加载更多
  1114. function loadMore(){
  1115. $.post('/searchEntSer/'+$entid ,{currentPage:currentPage+1,perPage:perPage},function(data){
  1116. if(data){
  1117. var res=data["data"]
  1118. if(!res || res === undefined || res.length == 0) {
  1119. $("#loadMore").hide();
  1120. return;
  1121. }else if(data.totalRows<=(perPage*data.currentPage)){
  1122. $("#loadMore").hide();
  1123. }else{
  1124. $("#loadMore").show();
  1125. }
  1126. currentPage=data["currentPage"];
  1127. var str="";
  1128. for(var i=0;i<res.length;i++){
  1129. var temp=res[i];
  1130. str+=analyList("",temp)
  1131. }
  1132. $("#service_list table tbody").append(str);
  1133. }
  1134. })
  1135. }
  1136. //上传二维码图片
  1137. function uploadBarCode(){
  1138. $("#upload").trigger("click");
  1139. }
  1140. //显示二维码图片
  1141. function viewBarCode(bcpath){
  1142. if(bcpath){
  1143. $('#myModal').modal({
  1144. keyboard: true
  1145. })
  1146. $("#viewImgs").html("<img style='width:300px;height:300px;' src='"+bcpath+"'/>")
  1147. }
  1148. }
  1149. //图片上传
  1150. function makeUpload(obj){
  1151. var option={
  1152. btnname:"图片上传",//按钮名
  1153. btnClass:"btn btn-primary tpsc_btnsize",
  1154. btnCss:{"width":"80px","height":"26px;"},
  1155. name:"upload",
  1156. action:"/filemanage/upload?resize=250",
  1157. afterUpload:function(data){ //此处可以重写,上传后的处理
  1158. $("#mblocation .pic").css('display','block');
  1159. $("#mblocation .pic li").remove();
  1160. $("<li class='imgLi' style='background-color:#eee;width:200px;text-align: center; height:200px;border:1px dashed #000;'><img src='"+data.url+"' style='width:176px; height:176px;margin:0px 5px;'><div id=tips style='text-align:center;width:196px;position: absolute;cursor: pointer; border:1px solid #ddd;background-color:#808080;padding:8px;color:#fff;font-size:20px;'>图片上传</div></li>").appendTo("#mblocation ul.pic");
  1161. var urls=$("#mblocation input.imgs").val();
  1162. urls=urls||""
  1163. //urls +=data.url+",";
  1164. urls= data.url;
  1165. limouseover();
  1166. $("#mblocation input.imgs").attr("value",urls);
  1167. $("#mblocation img.imgs").attr("src",urls);
  1168. if($("#mblocation ul.pic li img").size()>=1){
  1169. $("#upload").attr("disabled",false)
  1170. }
  1171. }
  1172. };
  1173. obj.upload(option);
  1174. }
  1175. /*
  1176. //添加服务
  1177. function btnAddServices(obj){
  1178. //判断信息是否为空
  1179. var v1=$("#mblocation input[name=servicename]").val();
  1180. var v_price=$("#mblocation input[name=s_price]").val();
  1181. var isselectprice=$("#s_pricemy").is(':checked');
  1182. var v2=editor.html();
  1183. //手机号
  1184. var phone = $("#mblocation input[name=s_phone]").val();
  1185. if(!v1){
  1186. alert("请填写产品服务名称")
  1187. return;
  1188. }
  1189. if(v_price.length>12){
  1190. alert("请填写小于12位的价格")
  1191. return;
  1192. }
  1193. var telReg = !!phone.match(/^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/);
  1194. if(telReg == false){
  1195. alert("请输入正确的手机号");
  1196. return;
  1197. }
  1198. $.post('/member/yellowpage/add/service/addservice?_new='+new Date().getTime(),$("#mblocation form").serialize(),function(data){
  1199. if(data.status=="y"){
  1200. alert(data.info);
  1201. cancelService();
  1202. }else{
  1203. alert("保存服务信息失败");
  1204. }
  1205. },'json');
  1206. initServiceList()
  1207. }
  1208. */
  1209. //删除服务
  1210. function delservice(obj){
  1211. console.log($(obj).attr("data-id"));
  1212. if($(obj).attr("data-id")==0){
  1213. alert("不能删除,请查看是否还有用户没评论或有预约未处理")
  1214. return false
  1215. }
  1216. var id = $(obj).attr("value");
  1217. var r = confirm("确定删除此服务吗?");
  1218. if(r==true){
  1219. $.ajax({
  1220. type:'post',
  1221. url:'/member/service/delservice',
  1222. data:{"id":id},
  1223. cache:true,
  1224. dataType:'json',
  1225. success:function(data){
  1226. alert(data.msg)
  1227. $("#service_list table tbody").html("");
  1228. currentPage=0;
  1229. loadMore();
  1230. }
  1231. });
  1232. }
  1233. }
  1234. //下架服务
  1235. function removeservice(obj){
  1236. if($(obj).attr("data-id")==0){
  1237. alert("不能下架,请查看是否还有用户没评论或有预约未处理")
  1238. return false
  1239. }
  1240. var id = $(obj).attr("value");
  1241. var r = confirm("确定下架此服务吗?");
  1242. if(r==true){
  1243. $.ajax({
  1244. type:'post',
  1245. url:'/member/service/removeservice',
  1246. data:{"id":id},
  1247. cache:true,
  1248. dataType:'json',
  1249. success:function(data){
  1250. alert(data.msg)
  1251. $("#service_list table tbody").html("");
  1252. currentPage=0;
  1253. loadMore();
  1254. }
  1255. });
  1256. }
  1257. }
  1258. //清除服务弹出窗口的表单信息
  1259. function formclane(){
  1260. //移除表单信息
  1261. $("#mblocation .sn").val("");
  1262. $("#mblocation .firstservicetype option").each(function(){
  1263. if("00" == $(this).val()){
  1264. $(this).attr("selected","selected");
  1265. }
  1266. });
  1267. //加载二级栏目下的内容
  1268. $("#mblocation .secondservicetype option").each(function(){
  1269. if("11" == $(this).val()){
  1270. $(this).attr("selected","selected");
  1271. }
  1272. });
  1273. $("#mblocation .price").val("");
  1274. $("#mblocation .phone").val("");
  1275. $("#mblocation .sd").val("");
  1276. $("#mblocation .pic li").parent().css('display','none');
  1277. $("#mblocation [name='isshow']:first").removeAttr("checked");
  1278. $("#mblocation .isshow_checked ").removeAttr("checked");
  1279. $("#mblocation [name='isshow']:last").removeAttr("checked");
  1280. }
  1281. //在列表中点击添加服务按钮事件
  1282. function addService(){
  1283. window.location.href="/member/yellowpage/show/showService/" + id;
  1284. }
  1285. //取消添加服务按钮事件
  1286. function cancelService(){
  1287. var entid = $("#entid").val();
  1288. window.location.href="/member/yellowpage/show/enterprise/" + entid;
  1289. }
  1290. //价格检测
  1291. function checkprice(obj){
  1292. var obj = $(obj).val();
  1293. if (obj.trim().length>0){
  1294. $("#s_pricemy").attr("disabled",true);
  1295. }else if (obj.trim().length==0){
  1296. $("#s_pricemy").attr("disabled",false);
  1297. }
  1298. }
  1299. //清除加载的图片
  1300. function cleanpicImg(tname){
  1301. $("#mblocation .pic li").remove();
  1302. $("#imgmessage").css("display","block")
  1303. //var srcimg="/images/services/qfw_" + tname +".png";
  1304. var srcimg="/images/services/default.png";
  1305. $("<li class='imgLi' style='background-color:#eee;width:200px;text-align: center; height:200px;border:1px dashed #000;'><img src='"+srcimg+"' style='width:176px; height:176px;margin:0px 5px;'><div id=tips style='text-align:center;width:196px;position: absolute;cursor: pointer; border:1px solid #ddd;background-color:#808080;padding:8px;color:#fff;font-size:20px;'>图片上传</div></li>").appendTo("#mblocation ul.pic");
  1306. $("#mblocation input.imgs").attr("value",srcimg);
  1307. limouseover();
  1308. }
  1309. //鼠标放到li上悬浮时间
  1310. function limouseover(){
  1311. // var lis=document.getElementsByTagName("li");
  1312. var lis=$("#mblocation ul li");
  1313. lis.each(function(index,element){
  1314. tips.style.left=this.offsetLeft+2+"px";
  1315. tips.style.top=this.offsetTop+this.offsetHeight-45+"px";
  1316. //tips.style.top = 948+"px";
  1317. $(this).click(function(){
  1318. $("#upload").trigger("click");
  1319. });
  1320. });
  1321. }
  1322. $(function(){
  1323. //图片上传
  1324. makeUpload($("#mblocation .mupload"));
  1325. //面议复选框点击事件
  1326. $("#s_pricemy").click(function(){
  1327. //是否选种面议
  1328. var isselect=$("#s_pricemy").is(':checked');
  1329. if(isselect){
  1330. $("#s_price").attr("readonly","readonly");
  1331. $("#s_price").attr("disabled",true);
  1332. $("#s_price").attr("value","");
  1333. }else{
  1334. $("#s_price").removeAttr("readonly");
  1335. $("#s_price").attr("disabled",false);
  1336. }
  1337. });
  1338. //一级栏目内容修改
  1339. $("#firstservicetype").change(function(){
  1340. var tname = $(this).val();
  1341. cleanpicImg(tname);
  1342. });
  1343. $("#mblocation .sid").val(serviceid);
  1344. $("#mblocation .sentid").val(serentinfoid);
  1345. if(dphone.length==0){
  1346. dphone= phone;
  1347. }
  1348. $("#mblocation .phone").val(dphone);
  1349. if(serviceid){
  1350. $('#servicecity_china').cxSelect({
  1351. selects: ['province', 'city', 'area'],
  1352. required:0
  1353. });
  1354. setLocation(entsel,1);
  1355. //产品服务类型
  1356. $("#mblocation .firstservicetype option").each(function(){
  1357. if(firstsertype == $(this).val()){
  1358. $(this).attr("selected","selected");
  1359. cleanpicImg(firstsertype);
  1360. }
  1361. });
  1362. //加载二级栏目下的内容
  1363. initSecondServiceType(firstsertype);
  1364. //设置选择二级栏目的内容
  1365. $("#mblocation .secondservicetype option").each(function(){
  1366. if(secondsertype == $(this).val()){
  1367. $(this).attr("selected","selected");
  1368. }
  1369. });
  1370. //面议复选框
  1371. if(serpricemy==1){
  1372. $("#s_pricemy").prop("checked",true);
  1373. $("#s_price").attr("readonly","readonly");
  1374. $("#s_price").attr("disabled",true);
  1375. $("#s_price").attr("value","");
  1376. }else{
  1377. $("#s_pricemy").attr("disabled",true);
  1378. }
  1379. //给kindereditor赋值
  1380. editor.html(introduction);
  1381. $("#mblocation .introduction").val(introduction);
  1382. if(images){
  1383. $("#mblocation .pic").css('display','block');
  1384. var imgurls = images.split(",");
  1385. var in1=0;
  1386. $("#mblocation .pic li").remove();
  1387. for(var i=0;i<imgurls.length;i++){
  1388. if(imgurls[i]){
  1389. in1++;
  1390. $("<li class='imgLi' style='background-color:#eee;width:200px;text-align: center; height:200px;border:1px dashed #000;'><img src='"+imgurls[i]+"' style='width:176px; height:176px;margin:0px 5px;'><div id=tips style='text-align:center;width:196px;position:absolute;cursor: pointer;border:1px solid #ddd;background-color:#808080;padding:8px;color:#fff;font-size:20px;'>图片上传</div></li>").appendTo("#mblocation ul.pic");
  1391. }
  1392. }
  1393. if(in1>=5){
  1394. $("#mblocation .mupload").closest(".row").hide()
  1395. }
  1396. }else{
  1397. //$("#mblocation .pic").css('display','none');
  1398. }
  1399. $("#mblocation .imgs").val(images);
  1400. //显示位置设置
  1401. if(strisshow!= undefined){
  1402. $("#isshow_checked1").prop("checked",(strisshow.indexOf("1")>-1));
  1403. $("#mblocation .isshow_checked ").prop("checked",(strisshow.indexOf("2")>-1));
  1404. $("#isshow_checked3").prop("checked",(strisshow.indexOf("3")>-1));
  1405. }
  1406. }
  1407. });
  1408. /**添加服务信息**/
  1409. function closepanel(n,id){
  1410. $('#servicecity_china').cxSelect({
  1411. selects: ['province', 'city', 'area'],
  1412. required:0
  1413. });
  1414. setLocation(entsel,n);
  1415. if(n){
  1416. //$("#mblocation").html($("#serviceForm").clone().html());
  1417. //图片上传
  1418. makeUpload($("#mblocation .mupload"));
  1419. $('#addModal').modal('show');
  1420. if(id){
  1421. $("#edittitle").html("编辑产品服务信息");
  1422. $("#flagedit").attr("value","edit");
  1423. $.post('/member/service/findservice', {"id":id}, function(data){
  1424. var editentsel= data.data.s_opLocDistrict;
  1425. if(editentsel!= undefined){
  1426. setLocation(editentsel,n);
  1427. }
  1428. $("#mblocation .sid").val(id);
  1429. $("#mblocation .sn").val(data.data.s_name);
  1430. //产品服务类型
  1431. var firstsertype= data.data.s_pservicecode;
  1432. $("#mblocation .firstservicetype option").each(function(){
  1433. if(firstsertype == $(this).val()){
  1434. $(this).attr("selected","selected");
  1435. }
  1436. });
  1437. //加载二级栏目下的内容
  1438. initSecondServiceType(firstsertype);
  1439. //设置选择二级栏目的内容
  1440. var secondsertype= data.data.s_servicecode
  1441. $("#mblocation .secondservicetype option").each(function(){
  1442. if(secondsertype == $(this).val()){
  1443. $(this).attr("selected","selected");
  1444. }
  1445. });
  1446. $("#mblocation .price").val(data.data.f_price);
  1447. var dphone = data.data.s_phone;
  1448. if(dphone==undefined){
  1449. dphone= phone;
  1450. }
  1451. $("#mblocation .phone").val(dphone);
  1452. //给kindereditor赋值
  1453. editor.html(data.data.s_introduction);
  1454. $("#mblocation .imgs").val(data.data.s_images);
  1455. //显示位置设置
  1456. var strisshow = data.data.s_isshow;
  1457. if(strisshow!= undefined){
  1458. $("#isshow_checked1").prop("checked",(strisshow.indexOf("1")>-1));
  1459. $("#mblocation .isshow_checked ").prop("checked",(strisshow.indexOf("2")>-1));
  1460. $("#isshow_checked3").prop("checked",(strisshow.indexOf("3")>-1));
  1461. }
  1462. if(data.data.s_images){
  1463. $("#mblocation .pic").css('display','block');
  1464. var imgurls = data.data.s_images.split(",");
  1465. var in1=0;
  1466. $("#mblocation .pic li").remove();
  1467. for(var i=0;i<imgurls.length;i++){
  1468. if(imgurls[i]){
  1469. in1++;
  1470. $("<li class='imgLi' style='background-color:#eee;width:200px;text-align: center; height:200px;border:1px dashed #000;'><img src='"+imgurls[i]+"' style='width:176px; height:176px;margin:0px 5px;'><div id=tips style='text-align:center;width:196px;position:absolute;cursor: pointer;border:1px solid #ddd;background-color:#808080;padding:8px;color:#fff;font-size:20px;'>图片上传</div></li>").appendTo("#mblocation ul.pic");
  1471. }
  1472. }
  1473. if(in1>=5){
  1474. $("#mblocation .mupload").closest(".row").hide()
  1475. }
  1476. }else{
  1477. $("#mblocation .pic").css('display','none');
  1478. }
  1479. });
  1480. }else{
  1481. $("#mblocation .phone").val(phone);
  1482. }
  1483. }else{
  1484. formclane();
  1485. $("#edittitle").html("添加产品服务信息");
  1486. $('#addModal').modal('hide');
  1487. }
  1488. }
  1489. //编辑服务信息
  1490. function findservice( id ,me){
  1491. //根据服务id 编辑服务信息
  1492. if($(me).attr("data-id")==0){
  1493. alert("不能编辑,请查看是否还有用户没评论或有预约未处理")
  1494. return false
  1495. }else{
  1496. window.location.href="/member/yellowpage/edit/showService/" + id;
  1497. }
  1498. }
  1499. /**删除上传服务中的图片**/
  1500. function delServiceUploadImg(obj,url){
  1501. $(obj).closest("li").remove();
  1502. var valImg=$("#mblocation input.imgs").val();
  1503. if (valImg){
  1504. $("#mblocation input.imgs").val(valImg.replace(url+",",""))
  1505. }
  1506. $("#mblocation .mupload").closest(".row").show()
  1507. }
  1508. }