portal html css js resource

sevricePreview.js 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. $(document).ready(function() {
  2. loginStatus(); //判断个人是否登录
  3. var userid = $.cookie("userid");
  4. var sevriceId = GetQueryString("sevriceId");
  5. if(navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)) {
  6. location.href = "http://" + window.location.host + "/e/r.html?id=" + sevriceId;
  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. function ajaxRequist(url, obj, type, fn) {
  18. $.ajax({
  19. url: url,
  20. data: obj,
  21. dataType: 'json', //服务器返回json格式数据
  22. type: type, //支持'GET'和'POST'
  23. traditional: true,
  24. success: function(data) {
  25. if(data.success) {
  26. fn(data)
  27. }
  28. },
  29. error: function(xhr, type, errorThrown) {
  30. $.MsgBox.Alert('提示', '服务器请求失败');
  31. }
  32. });
  33. }
  34. ifcollectionAbout(sevriceId, $("#attention").find("em"), 2)
  35. var professorId = "";
  36. getRecourceMe();
  37. //热门资源
  38. /*获取服务信息*/
  39. function getRecourceMe() {
  40. $.ajax({
  41. "url": "/ajax/ware/qo",
  42. "type": "GET",
  43. "success": function(data) {
  44. if(data.success) {
  45. resourceHtml(data.data);
  46. var resourceName = data.data.name + "-科袖网";
  47. document.title = resourceName;
  48. }
  49. },
  50. "data": {
  51. "id": sevriceId
  52. },
  53. dataType: "json",
  54. 'error': function() {
  55. $.MsgBox.Alert('提示', '服务器连接超时!');
  56. }
  57. });
  58. }
  59. /*合作备注及性能参数存储换行格式*/
  60. function outHTML(selecter) {
  61. var getValue = selecter;
  62. var aa = "";
  63. if(getValue) {
  64. var endValue = ((getValue.replace(/<(.+?)>/gi, "&lt;$1&gt;")).replace(/ /gi, "&nbsp;")).replace(/\n/gi, "|");
  65. var cc = endValue.split("|");
  66. for(var i = 0; i < cc.length; i++) {
  67. aa += cc[i] + '<br/>'
  68. }
  69. }
  70. return aa;
  71. }
  72. /*处理资源html代码*/
  73. function resourceHtml($da) {
  74. $("#resourceName").text($da.name); //名字
  75. if($da.cnt){
  76. $("#application").text($da.cnt); //应用用途
  77. }else{
  78. $("#application").parent().hide();
  79. }
  80. if($da.category == 1) {
  81. ajaxRequist("/ajax/professor/baseInfo/" + $da.owner, {}, "get", function(data) {
  82. $da.editProfessor = data.data;
  83. $("#person").show();
  84. if($da.orgName) { //所属机构
  85. $("#organizationName").text($da.orgName).parents("li").show();
  86. }
  87. $("#nameS").text($da.editProfessor.name);
  88. if($da.editProfessor.title) {
  89. $("#titleOffice").text($da.editProfessor.title);
  90. } else {
  91. if($da.editProfessor.office) {
  92. $("#titleOffice").text($da.editProfessor.office);
  93. }
  94. }
  95. if($da.editProfessor.orgName) {
  96. $("#orgType").text($da.editProfessor.orgName);
  97. }
  98. professorId = $da.editProfessor.id;
  99. if(userid != professorId) {
  100. ifcollectionAbout(professorId, $("#person").find(".attenSpan"), 1)
  101. $(".goSpan").show();
  102. }
  103. var professorFlag = autho($da.editProfessor.authType, $da.editProfessor.orgAuth, $da.editProfessor.authStatus);
  104. $("#authFlag").addClass(professorFlag.sty).attr("title", professorFlag.title);
  105. if($da.editProfessor.hasHeadImage == 1) {
  106. $("#headImg").css("background-image", 'url(/images/head/' + $da.editProfessor.id + '_l.jpg)');
  107. } else {
  108. $("#headImg").css("background-image", 'url(../images/default-photo.jpg)');
  109. }
  110. })
  111. } else {
  112. ajaxRequist("/ajax/org/" + $da.owner, {}, "get", function(data) {
  113. $da.organization = data.data;
  114. $("#enterprise").show();
  115. if($da.organization.hasOrgLogo) {
  116. $("#companyImg").attr("src", "/images/org/" + $da.organization.id + ".jpg");
  117. } else {
  118. $("#companyImg").attr("src", "/images/default-icon.jpg");
  119. }
  120. if($da.organization.authStatus == 3) {
  121. $("#QauthFlag").addClass("authicon-com-ok").attr("title", "认证企业");
  122. }
  123. if($da.organization.forShort) {
  124. $("#Qname").text($da.organization.forShort).attr("href", "cmpInforShow.html?orgId=" + $da.organization.id);
  125. } else {
  126. $("#Qname").text($da.organization.name).attr("href", "cmpInforShow.html?orgId=" + $da.organization.id);
  127. }
  128. if($da.organization.industry) {
  129. $("#Qindustry").text($da.organization.industry.replace(/,/gi, " | "));
  130. }
  131. if(userid) {
  132. ifcollectionAbout($da.organization.id, $("#enterprise").find(".attenSpan"), 6)
  133. }
  134. })
  135. }
  136. if($da.cooperation) { //合作备注
  137. $("#remarkContent").html(outHTML($da.cooperation)).parents("li").show();
  138. }
  139. if($da.keywords) {
  140. var oSub = $da.keywords.split(",");
  141. var oSt = "";
  142. for(var i = 0; i < oSub.length; i++) {
  143. oSt += '<li><p class="h2Font">' + oSub[i] + '</p></li>'
  144. }
  145. $(".tagList").html(oSt);
  146. }
  147. if($da.descp) { //编辑器
  148. $("#descp").html($da.descp).parents("li").show();
  149. }
  150. //return;
  151. if($da.images) {
  152. if($da.images.split(",").length) {
  153. var weibopic = "http://" + window.location.host + "/data/ware" + $da.images.split(",")[0];
  154. $("#firstFigure").attr({
  155. "src": "/data/ware" + $da.images.split(",")[0],
  156. "rel": "/data/ware" + $da.images.split(",")[0]
  157. }).parent().attr("href", "/data/ware" + $da.images.split(",")[0]);
  158. var arr = "";
  159. for(var i = 0; i < $da.images.split(",").length; i++) {
  160. if($da.images.split(",")[i] == $da.images.split(",")[0]) {
  161. var oString = '<li class="tb-selected">' +
  162. '<div class="tb-pic tb-s66">' +
  163. '<a href="javascript:void(0);">' +
  164. '<img src="/data/ware' + $da.images.split(",")[i] + '"/>' +
  165. '</a>' +
  166. '</div>' +
  167. '</li>'
  168. } else {
  169. var oString = '<li >' +
  170. '<div class="tb-pic tb-s66">' +
  171. '<a href="javascript:void(0);">' +
  172. '<img src="/data/ware' + $da.images.split(",")[i] + '"/>' +
  173. '</a>' +
  174. '</div>' +
  175. '</li>'
  176. }
  177. arr += oString;
  178. }
  179. $("#thumblist").html(arr);
  180. }
  181. } else {
  182. var weibopic = "http://" + window.location.host + "../images/default-service.jpg";
  183. $("#firstFigure").attr({
  184. "src": '../images/default-service.jpg',
  185. "rel": '../images/default-service.jpg'
  186. });
  187. }
  188. }
  189. //关键词标签点击进去搜索
  190. $(".tagList").on("click", "li", function() {
  191. var tagText = $(this).find("p").text();
  192. location.href = "searchNew.html?searchContent=" + tagText + "&tagflag=7";
  193. })
  194. seresource()
  195. /*感兴趣的资源*/
  196. function seresource() {
  197. $.ajax({
  198. "url": "/ajax/ware/res",
  199. "type": "GET",
  200. "data": {
  201. "id": sevriceId
  202. },
  203. "traditional": true,
  204. dataType: "json",
  205. "success": function(data) {
  206. if(data.success) {
  207. if(data.data.length == 0) {
  208. return;
  209. }
  210. $("#oResource").parents(".otherShow").removeClass("displayNone");
  211. for(var i = 0; i < data.data.length; i++) {
  212. (function(n) {
  213. ajaxRequist("/ajax/resource/queryOne", {
  214. "resourceId": data.data[n].resource
  215. }, "get", function(data) {
  216. sevrResource(data.data);
  217. })
  218. })(i)
  219. }
  220. }
  221. },
  222. 'error': function() {
  223. $.MsgBox.Alert('提示', '服务器连接超时!');
  224. }
  225. });
  226. }
  227. /*感兴趣资源的html*/
  228. function sevrResource($respond) {
  229. var imgL = "../images/default-resource.jpg";
  230. if($respond.images.length) {
  231. imgL = '/data/resource/' + $respond.images[0].imageSrc
  232. }
  233. var oURL;
  234. if($respond.resourceType == 1) {
  235. oURL = "/ajax/professor/baseInfo/" + $respond.professorId;
  236. } else {
  237. oURL = "/ajax/org/" + $respond.orgId;
  238. }
  239. $.ajax({
  240. "url": oURL,
  241. "type": "GET",
  242. 'dataType': "json",
  243. "success": function(data) {
  244. if(data.success) {
  245. var add = document.createElement("li");
  246. add.className = "mui-table-view-cell";
  247. add.setAttribute("data-id", $respond.resourceId);
  248. var itemlist = '<a class="flexCenter OflexCenter"><div class="madiaHead resourceHead" style="background-image:url(' + imgL + ')"></div>';
  249. itemlist += '<div class="madiaInfo OmadiaInfo">';
  250. itemlist += '<p class="ellipsisSty h1Font" id="usertitle">' + $respond.resourceName + '</p>';
  251. itemlist += '<p class="ellipsisSty-2 h2Font">用途:' + $respond.supportedServices + '</p>';
  252. itemlist += '</div></a>';
  253. add.innerHTML = itemlist;
  254. document.getElementById("oResource").appendChild(add);
  255. }
  256. },
  257. 'error': function() {
  258. $.MsgBox.Alert('提示', '服务器连接超时!');
  259. }
  260. });
  261. }
  262. /*点击资源列表*/
  263. $("#oResource").on("click", "li", function() {
  264. location.href = "resourceShow.html?resourceId=" + $(this).attr("data-id");
  265. })
  266. selUse();
  267. function selUse() {
  268. $.ajax({
  269. url: "/ajax/ware/pro",
  270. type: "GET",
  271. timeout: 10000,
  272. dataType: "json",
  273. async: true,
  274. data: {
  275. "id": sevriceId,
  276. },
  277. success: function(data, textState) {
  278. if(data.success) {
  279. if(data.data.length > 0) {
  280. $("#expertli").parents(".currentBlock").removeClass("displayNone");
  281. unauthUser(data.data);
  282. } else {
  283. $("#expertli").parents(".currentBlock").addClass("displayNone");
  284. }
  285. }
  286. },
  287. error: function(XMLHttpRequest, textStats, errorThrown) {
  288. $.MsgBox.Alert('提示', '服务器请求失败')
  289. }
  290. })
  291. }
  292. function unauthUser(data) {
  293. for(var i = 0; i < data.length; i++) {
  294. (function(i) {
  295. ajaxRequist("/ajax/professor/baseInfo/" + data[i].professor, {}, "get", function(data) {
  296. var $res=data.data;
  297. var osting = ""
  298. var img;
  299. var styC = "";
  300. var oClass = autho($res.authType, $res.orgAuth, $res.authStatus);
  301. var oTitle = "";
  302. if($res.title) {
  303. oTitle = $res.title;
  304. } else {
  305. if($res.office) {
  306. oTitle = $res.office;
  307. }
  308. }
  309. if($res.hasHeadImage) {
  310. img = "/images/head/" + $res.id + "_l.jpg";
  311. } else {
  312. img = "../images/default-photo.jpg"
  313. }
  314. var oSt = '<li class="flexCenter">'
  315. oSt += '<div class="madiaHead useHead" id="userimg" style="background-image: url(' + img + ');"></div>'
  316. oSt += '<div class = "madiaInfo">'
  317. oSt += '<p class = "ellipsisSty">'
  318. oSt += '<span class = "h1Font" id="name">' + $res.name + '</span><em class="authiconNew ' + oClass.sty + '" title="' + oClass.title + '"></em >'
  319. oSt += '</p>'
  320. oSt += '<p class="h2Font ellipsisSty">' + oTitle + '</p>'
  321. oSt += '</div>'
  322. oSt += '</li>'
  323. osting += oSt;
  324. $("#expertli").html(osting);
  325. })
  326. })(i)
  327. }
  328. }
  329. })