portal html css js resource

productShow.js 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. $(document).ready(function() {
  2. loginStatus(); //判断个人是否登录
  3. var userid = $.cookie("userid");
  4. var resourceId = GetQueryString("productId");
  5. if(navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)) {
  6. location.href = "http://" + window.location.host + "/e/pr.html?id=" + resourceId;
  7. }
  8. $(".jqzoom").imagezoom();
  9. $("#thumblist").on("click", "li a", function() {
  10. $(this).parents("li").addClass("tb-selected").siblings().removeClass("tb-selected");
  11. $(".jqzoom").attr('src', $(this).find("img").attr("src"));
  12. $(".jqzoom").attr('rel', $(this).find("img").attr("src"));
  13. });
  14. $('.shareWeixin').hover(function() {
  15. $('.shareCode').stop(true, false).fadeToggle();
  16. });
  17. ifcollectionAbout(resourceId, $("#attention").find("em"), 11)
  18. pageViewLog(resourceId, 11)
  19. var professorId = "";
  20. getRecourceMe();
  21. //热门资源
  22. function recentlyRe(par) {
  23. var $info = {};
  24. $info.rows = 6;
  25. $info.owner = par;
  26. $.ajax({
  27. "url": '/ajax/product/publish',
  28. "type": "GET",
  29. "dataType": "json",
  30. "data": $info,
  31. "success": function(data) {
  32. if(data.success) {
  33. var $data = data.data;
  34. var only = false;
  35. if($data.length > 1) {
  36. if($data.length > 1 || ($data.length == 1 && resourceId == $data[0].id))
  37. $(".recentlyList").parents(".currentBlock").removeClass("displayNone");
  38. for(var i = 0; i < $data.length; i++) {
  39. if(resourceId == $data[i].id) {
  40. continue;
  41. }
  42. var resIM = '/data/product' + $data[i].images.split(",")[0];
  43. var str = '<li><a class="flexCenter" style="min-height:46px;" href="productShow.html?productId=' + $data[i].id + '">' +
  44. '<div class="madiaHead resourceHead" style="width:50px;height:36px;margin-top:-18px;background-image: url(' + resIM + ');"></div>' +
  45. '<div class="madiaInfo"><p class="h2Font ellipsisSty-2">' + $data[i].name + '</p></div></a></li>'
  46. $(".recentlyList").append(str);
  47. }
  48. }
  49. }
  50. },
  51. "error": function() {
  52. $.MsgBox.Alert('提示', '链接服务器超时')
  53. }
  54. });
  55. }
  56. /*获取资源信息*/
  57. function getRecourceMe() {
  58. $.ajax({
  59. "url": "/ajax/product/qo",
  60. "type": "GET",
  61. "success": function(data) {
  62. console.log(data);
  63. if(data.success) {
  64. resourceHtml(data.data);
  65. var resourceName = data.data.name + "-科袖网";
  66. document.title = resourceName;
  67. }
  68. },
  69. "data": {
  70. "id": resourceId
  71. },
  72. dataType: "json",
  73. 'error': function() {
  74. $.MsgBox.Alert('提示', '服务器连接超时!');
  75. }
  76. });
  77. }
  78. /*合作备注及性能参数存储换行格式*/
  79. function outHTML(selecter) {
  80. var getValue = selecter;
  81. var aa = "";
  82. if(getValue) {
  83. var endValue = ((getValue.replace(/<(.+?)>/gi, "&lt;$1&gt;")).replace(/ /gi, "&nbsp;")).replace(/\n/gi, "|");
  84. var cc = endValue.split("|");
  85. for(var i = 0; i < cc.length; i++) {
  86. aa += cc[i] + '<br/>'
  87. }
  88. }
  89. return aa;
  90. }
  91. /*处理资源html代码*/
  92. function resourceHtml($da) {
  93. comMess($da.owner);
  94. recentlyRe($da.owner);
  95. $("#resourceName").text($da.name); //名字
  96. $("#application").text($da.cnt); //应用用途
  97. if($da.producingArea) {
  98. $("#productArea").text($da.producingArea).parents("li").show();
  99. }
  100. if($da.price) {
  101. $("#officialPrice").text($da.price).parents("li").show();
  102. }
  103. if($da.spec) { //厂商型号
  104. $("#modelNumber").text($da.spec).parents("li").show();
  105. }
  106. if($da.parameter) { //性能参数
  107. $("#performancePa").html(outHTML($da.parameter)).parents("li").show();
  108. }
  109. if($da.pageViews > 0) {
  110. $("#pageView").html($da.pageViews)
  111. }
  112. if($da.keywords) {
  113. var oSub = $da.keywords.split(",");
  114. var oSt = "";
  115. for(var i = 0; i < oSub.length; i++) {
  116. oSt += '<li><p class="h2Font">' + oSub[i] + '</p></li>'
  117. }
  118. $(".tagList").html(oSt);
  119. }
  120. if($da.descp) { //编辑器
  121. $("#descp").html($da.descp).parents("li").show();
  122. }
  123. var weibotitle = $da.name;
  124. var weibourl = window.location.href;
  125. //return;
  126. if($da.images) {
  127. var weibopic = "http://" + window.location.host + "/data/product" + $da.images.split(',')[0];
  128. $("#firstFigure").attr({
  129. "src": "/data/product" + $da.images.split(',')[0],
  130. "rel": "/data/product" + $da.images.split(',')[0]
  131. }).parent().attr("href", "/data/product" + $da.images.split(',')[0]);
  132. var arr = "";
  133. var images = $da.images.split(',')
  134. for(var i = 0; i < images.length; i++) {
  135. if(i == 0) {
  136. var oString = '<li class="tb-selected">' +
  137. '<div class="tb-pic tb-s66">' +
  138. '<a href="javascript:void(0);">' +
  139. '<img src="/data/product' + images[0] + '"/>' +
  140. '</a>' +
  141. '</div>' +
  142. '</li>'
  143. } else {
  144. var oString = '<li >' +
  145. '<div class="tb-pic tb-s66">' +
  146. '<a href="javascript:void(0);">' +
  147. '<img src="/data/product' + images[i] + '"/>' +
  148. '</a>' +
  149. '</div>' +
  150. '</li>'
  151. }
  152. arr += oString;
  153. }
  154. $("#thumblist").html(arr);
  155. } else {
  156. var weibopic = "http://" + window.location.host + "../images/default-resource.jpg";
  157. $("#firstFigure").attr({
  158. "src": '../images/default-resource.jpg',
  159. "rel": '../images/default-resource.jpg'
  160. });
  161. }
  162. $("#weibo").attr("href", "http://service.weibo.com/share/share.php?appkey=3677230589&title=" + encodeURIComponent(weibotitle) + "&url=" + encodeURIComponent(weibourl) + "&pic=" + encodeURIComponent(weibopic) + "&content=utf-8" + "&ralateUid=6242830109&searchPic=false&style=simple");
  163. }
  164. /*点击名字及头像跳转个人浏览页面*/
  165. $("#nameS,#headImg").click(function() {
  166. location.href = "userInforShow.html?professorId=" + professorId;
  167. })
  168. /*点击咨询*/
  169. $("#consultin").on('click', function() {
  170. if(userid && userid != null && userid != 'null' && userid != undefined && userid != 'undefined') {
  171. location.href = "tidings.html?id=" + professorId
  172. } else {
  173. quickLog();
  174. operatTab();
  175. closeLog();
  176. }
  177. });
  178. $("#expertli").on("click", ".addbtn", function(event) {
  179. if(userid && userid != null && userid != 'null' && userid != undefined && userid != 'undefined') {
  180. var id = $(this).attr("data-id");
  181. location.href = "tidings.html?id=" + id;
  182. } else {
  183. quickLog();
  184. operatTab();
  185. closeLog();
  186. }
  187. event.stopPropagation()
  188. });
  189. $("#enterprise").on("click", '.attenSpan', function() {
  190. if(userid && userid != "null" && userid != null) {
  191. if($(this).is('.attenedSpan')) {
  192. cancelCollectionAbout($(".qiyego").attr('dataid'), $(this), 6)
  193. } else {
  194. collectionAbout($(".qiyego").attr('dataid'), $(this), 6);
  195. }
  196. } else {
  197. quickLog();
  198. operatTab();
  199. closeLog();
  200. }
  201. })
  202. //点击产品收藏
  203. $('#attention em').click(function() {
  204. if(userid && userid != "null" && userid != null) {
  205. if($(this).is('.icon-collected')) {
  206. cancelCollectionAbout(resourceId, $(this), 11)
  207. } else {
  208. collectionAbout(resourceId, $(this), 11)
  209. }
  210. } else {
  211. quickLog();
  212. operatTab();
  213. closeLog();
  214. }
  215. })
  216. selUse();
  217. function selUse() {
  218. $.ajax({
  219. url: "/ajax/product/pro",
  220. type: "GET",
  221. timeout: 10000,
  222. dataType: "json",
  223. async: true,
  224. data: {
  225. "id": resourceId,
  226. },
  227. success: function(data, textState) {
  228. console.log(data)
  229. if(data.success) {
  230. if(data.data.length > 0) {
  231. $("#expertli").parents(".currentBlock").removeClass("displayNone");
  232. } else {
  233. $("#expertli").parents(".currentBlock").addClass("displayNone");
  234. }
  235. var arr = [];
  236. for(var i = 0; i < data.data.length; i++) {
  237. arr.push(data.data[i].professor)
  238. }
  239. console.log(arr)
  240. professorList(arr);
  241. }
  242. },
  243. error: function(XMLHttpRequest, textStats, errorThrown) {
  244. $.MsgBox.Alert('提示', '服务器请求失败')
  245. }
  246. })
  247. }
  248. function professorList(par) {
  249. $.ajax({
  250. url: "/ajax/professor/qm",
  251. type: "GET",
  252. timeout: 10000,
  253. dataType: "json",
  254. async: true,
  255. traditional: true,
  256. data: {
  257. "id": par,
  258. },
  259. success: function(data, textState) {
  260. console.log(data)
  261. if(data.success) {
  262. if(data.data.length) {
  263. unauthUser(data.data);
  264. $("#resPerson").show();
  265. }
  266. }
  267. },
  268. error: function(XMLHttpRequest, textStats, errorThrown) {
  269. $.MsgBox.Alert('提示', '服务器请求失败')
  270. }
  271. })
  272. }
  273. function ajaxRequist(url, obj, type, fn) {
  274. $.ajax({
  275. url: url,
  276. data: obj,
  277. dataType: 'json', //服务器返回json格式数据
  278. type: type, //支持'GET'和'POST'
  279. traditional: true,
  280. success: function(data) {
  281. if(data.success) {
  282. fn(data)
  283. }
  284. },
  285. error: function(xhr, type, errorThrown) {
  286. $.MsgBox.Alert('提示', '服务器请求失败');
  287. }
  288. });
  289. }
  290. function unauthUser($res) {
  291. var osting = ""
  292. for(var i = 0; i < $res.length; i++) {
  293. var img;
  294. var styC = "";
  295. var oClass = autho($res[i].authType, $res[i].orgAuth, $res[i].authStatus);
  296. var oTitle = "";
  297. if($res[i].title) {
  298. oTitle = $res[i].title;
  299. } else {
  300. if($res[i].office) {
  301. oTitle = $res[i].office;
  302. }
  303. }
  304. if($res[i].hasHeadImage) {
  305. img = "/images/head/" + $res[i].id + "_l.jpg";
  306. } else {
  307. img = "../images/default-photo.jpg"
  308. }
  309. var oSt = '<li data-id="' + $res[i].id + '" style="cursor:pointer;">'
  310. oSt += '<div class="madiaHead useHead" id="userimg" style="background-image: url(' + img + ');"></div>'
  311. oSt += '<div class = "madiaInfo">'
  312. oSt += '<p class = "ellipsisSty">'
  313. oSt += '<span class = "h1Font" id="name">' + $res[i].name + '</span><em class="authicon ' + oClass.sty + '" title="' + oClass.title + '"></em >'
  314. oSt += '</p>'
  315. oSt += '<p class="h2Font ellipsisSty">' + oTitle + '</p>'
  316. oSt += '</div>'
  317. if(userid != $res[i].id)
  318. oSt += '<span class="addbtn" data-id="' + $res[i].id + '">联系</span>'
  319. oSt += '</li>'
  320. osting += oSt;
  321. }
  322. $("#expertli").append(osting);
  323. }
  324. function comMess(oid) {
  325. $.ajax({
  326. url: "/ajax/org/" + oid,
  327. type: "GET",
  328. timeout: 10000,
  329. dataType: "json",
  330. async: "true",
  331. success: function(data, textState) {
  332. if(data.success) {
  333. var $da = data.data;
  334. $("#enterprise,#resPerson").show();
  335. if($da.hasOrgLogo) {
  336. $("#companyImg").attr("src", "/images/org/" + $da.id + ".jpg");
  337. } else {
  338. $("#companyImg").attr("src", "/images/default-icon.jpg");
  339. }
  340. if($da.authStatus == 3) {
  341. $("#QauthFlag").addClass("authicon-com-ok").attr("title", "认证企业");
  342. }
  343. $("#Qname").text($da.name);
  344. if($da.industry) {
  345. $("#Qindustry").text($da.industry.replace(/,/gi, " | "));
  346. }
  347. $(".qiyego").attr('dataid', $da.id);
  348. $(".qiyego").attr("href", "cmpInforShow.html?orgId=" + $da.id);
  349. if(userid) {
  350. ifcollectionAbout($da.id, $("#enterprise").find(".attenSpan"), 6)
  351. }
  352. }
  353. },
  354. error: function(XMLHttpRequest, textStats, errorThrown) {
  355. $.MsgBox.Alert('提示', '服务器请求失败')
  356. }
  357. })
  358. }
  359. $("#expertli").on("click",'li', function() {
  360. location.href = "userInforShow.html?professorId=" + $(this).attr("data-id");
  361. })
  362. //纠错反馈
  363. $(".correctSubmit").on("click", function() {
  364. var cntCon = $(this).siblings(".correctCon").val();
  365. var cntUser = "";
  366. if(userid && userid != null && userid != "null") {
  367. cntUser = userid;
  368. }
  369. if(cntCon.length > 500) {
  370. $.MsgBox.Alert('提示', '纠错反馈内容不得超过500个字');
  371. return;
  372. } else {
  373. $.ajax({
  374. "url": "/ajax/feedback/error/product",
  375. "type": "POST",
  376. "dataType": "json",
  377. "async": true,
  378. "data": {
  379. "id": resourceId,
  380. "cnt": cntCon,
  381. "user": cntUser
  382. },
  383. "success": function(data) {
  384. if(data.success) {
  385. backSuccessed();
  386. }
  387. },
  388. "error": function() {
  389. $.MsgBox.Alert('提示', '链接服务器超时')
  390. }
  391. });
  392. }
  393. })
  394. relatedArticles()
  395. /*产品里面相关文章*/
  396. function relatedArticles() {
  397. $.ajax({
  398. "url": "/ajax/article/lq/byProduct",
  399. "type": "GET",
  400. "data": {
  401. "product": resourceId,
  402. "rows": 5
  403. },
  404. dataType: "json",
  405. "success": function(data) {
  406. if(data.success) {
  407. if(data.data.length > 0) {
  408. var $data = data.data;
  409. $("#oArticle").parents(".otherShow").removeClass("displayNone");
  410. for(var i = 0; i < $data.length; i++) {
  411. var str = "",
  412. ovel = "";
  413. /*if($data[i].pageViews) {
  414. ovel="阅读量 "+$data[i].pageViews;
  415. }*/
  416. str += '<li data-id="' + $data[i].articleId + '" data-createTime="' + $data[i].createTime + '" data-shareId="' + $data[i].shareId + '"><a class="flexCenter OflexCenter">'
  417. if($data[i].articleImg) {
  418. str += '<div class="madiaHead artHead" style="background-image: url(/data/article/' + $data[i].articleImg + ')"></div>'
  419. } else {
  420. str += '<div class="madiaHead artHead"></div>'
  421. }
  422. str += '<div class="madiaInfo" style="margin-top:18px;padding-bottom:8px">'
  423. str += '<p class="h1Font ellipsisSty">' + $data[i].articleTitle + '</p>'
  424. str += '<p class="h2Font"><span class=" name" style="margin-right:10px"></span><span class="time" style="margin-right:10px;">' + commenTime($data[i].publishTime) + '</span></p>'
  425. str += '</div></a></li>'
  426. //<span class="yue" style="margin-right:10px">'+ovel+'</span><span class="zan" style="margin-right:10px"></span><span class="leword"></span>
  427. var $str = $(str);
  428. $("#oArticle").append($str);
  429. (function($str, i) {
  430. if($data[i].articleType == "1") {
  431. ajaxRequist("/ajax/professor/baseInfo/" + $data[i].ownerId, {}, "get", function(data) {
  432. $str.find(".name").text(data.data.name);
  433. })
  434. } else if($data[i].articleType == "2") {
  435. ajaxRequist("/ajax/org/" + $data[i].ownerId, {}, "get", function(data) {
  436. if(data.data.forShort) {
  437. $str.find(".name").text(data.data.forShort);
  438. } else {
  439. $str.find(".name").text(data.data.name);
  440. }
  441. })
  442. } else if($data[i].articleType == "3") {
  443. ajaxRequist("/ajax/platform/info", {
  444. id: $data[i].ownerId
  445. }, "get", function(data) {
  446. $str.find(".name").text(data.data.name);
  447. })
  448. }
  449. /*if($data[i].articleAgree) {
  450. $str.find(".zan").text('赞 ' + $data[i].articleAgree);
  451. }
  452. ajaxRequist("/ajax/leavemsg/count" , {sid:$data[i].articleId,stype:1}, "get", function(data) {
  453. if(data.data) {
  454. $str.find(".leword").text('留言 ' + data.data);
  455. }
  456. })*/
  457. })($str, i)
  458. }
  459. }
  460. }
  461. },
  462. 'error': function() {
  463. $.MsgBox.Alert('提示', '服务器连接超时!');
  464. }
  465. });
  466. }
  467. /*文章跳转*/
  468. $("#oArticle").on("click", "li", function() {
  469. var oArticle = {
  470. shareId: $(this).attr("data-shareId"),
  471. createTime: $(this).attr("data-createTime")
  472. };
  473. location.href = "/" + pageUrl('a', oArticle)
  474. })
  475. })