portal html css js resource

sevricePreview.js 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  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. $("#Qindustry").text($da.organization.industry);
  129. $("#QorgType").text(orgTypeShow[$da.organization.orgType])
  130. if(userid) {
  131. ifcollectionAbout($da.organization.id, $("#enterprise").find(".attenSpan"), 6)
  132. }
  133. })
  134. }
  135. if($da.cooperation) { //合作备注
  136. $("#remarkContent").html(outHTML($da.cooperation)).parents("li").show();
  137. }
  138. if($da.keywords) {
  139. var oSub = $da.keywords.split(",");
  140. var oSt = "";
  141. for(var i = 0; i < oSub.length; i++) {
  142. oSt += '<li><p class="h2Font">' + oSub[i] + '</p></li>'
  143. }
  144. $(".tagList").html(oSt);
  145. }
  146. if($da.descp) { //编辑器
  147. $("#descp").html($da.descp).parents("li").show();
  148. }
  149. //return;
  150. if($da.images) {
  151. if($da.images.split(",").length) {
  152. var weibopic = "http://" + window.location.host + "/data/ware" + $da.images.split(",")[0];
  153. $("#firstFigure").attr({
  154. "src": "/data/ware" + $da.images.split(",")[0],
  155. "rel": "/data/ware" + $da.images.split(",")[0]
  156. }).parent().attr("href", "/data/ware" + $da.images.split(",")[0]);
  157. var arr = "";
  158. for(var i = 0; i < $da.images.split(",").length; i++) {
  159. if($da.images.split(",")[i] == $da.images.split(",")[0]) {
  160. var oString = '<li class="tb-selected">' +
  161. '<div class="tb-pic tb-s66">' +
  162. '<a href="javascript:void(0);">' +
  163. '<img src="/data/ware' + $da.images.split(",")[i] + '"/>' +
  164. '</a>' +
  165. '</div>' +
  166. '</li>'
  167. } else {
  168. var oString = '<li >' +
  169. '<div class="tb-pic tb-s66">' +
  170. '<a href="javascript:void(0);">' +
  171. '<img src="/data/ware' + $da.images.split(",")[i] + '"/>' +
  172. '</a>' +
  173. '</div>' +
  174. '</li>'
  175. }
  176. arr += oString;
  177. }
  178. $("#thumblist").html(arr);
  179. }
  180. } else {
  181. var weibopic = "http://" + window.location.host + "../images/default-service.jpg";
  182. $("#firstFigure").attr({
  183. "src": '../images/default-service.jpg',
  184. "rel": '../images/default-service.jpg'
  185. });
  186. }
  187. }
  188. //关键词标签点击进去搜索
  189. $(".tagList").on("click", "li", function() {
  190. var tagText = $(this).find("p").text();
  191. location.href = "searchNew.html?searchContent=" + tagText + "&tagflag=7";
  192. })
  193. seresource()
  194. /*感兴趣的资源*/
  195. function seresource() {
  196. $.ajax({
  197. "url": "/ajax/ware/res",
  198. "type": "GET",
  199. "data": {
  200. "id": sevriceId
  201. },
  202. "traditional": true,
  203. dataType: "json",
  204. "success": function(data) {
  205. if(data.success) {
  206. if(data.data.length == 0) {
  207. return;
  208. }
  209. $("#oResource").parents(".otherShow").removeClass("displayNone");
  210. for(var i = 0; i < data.data.length; i++) {
  211. (function(n) {
  212. ajaxRequist("/ajax/resource/queryOne", {
  213. "resourceId": data.data[n].resource
  214. }, "get", function(data) {
  215. sevrResource(data.data);
  216. })
  217. })(i)
  218. }
  219. }
  220. },
  221. 'error': function() {
  222. $.MsgBox.Alert('提示', '服务器连接超时!');
  223. }
  224. });
  225. }
  226. /*感兴趣资源的html*/
  227. function sevrResource($respond) {
  228. var imgL = "../images/default-resource.jpg";
  229. if($respond.images.length) {
  230. imgL = '/data/resource/' + $respond.images[0].imageSrc
  231. }
  232. var oURL;
  233. if($respond.resourceType == 1) {
  234. oURL = "/ajax/professor/baseInfo/" + $respond.professorId;
  235. } else {
  236. oURL = "/ajax/org/" + $respond.orgId;
  237. }
  238. $.ajax({
  239. "url": oURL,
  240. "type": "GET",
  241. 'dataType': "json",
  242. "success": function(data) {
  243. if(data.success) {
  244. var add = document.createElement("li");
  245. add.className = "mui-table-view-cell";
  246. add.setAttribute("data-id", $respond.resourceId);
  247. var itemlist = '<a class="flexCenter OflexCenter"><div class="madiaHead resourceHead" style="background-image:url(' + imgL + ')"></div>';
  248. itemlist += '<div class="madiaInfo OmadiaInfo">';
  249. itemlist += '<p class="ellipsisSty h1Font" id="usertitle">' + $respond.resourceName + '</p>';
  250. itemlist += '<p class="ellipsisSty-2 h2Font">用途:' + $respond.supportedServices + '</p>';
  251. itemlist += '</div></a>';
  252. add.innerHTML = itemlist;
  253. document.getElementById("oResource").appendChild(add);
  254. }
  255. },
  256. 'error': function() {
  257. $.MsgBox.Alert('提示', '服务器连接超时!');
  258. }
  259. });
  260. }
  261. /*点击资源列表*/
  262. $("#oResource").on("click", "li", function() {
  263. location.href = "resourceShow.html?resourceId=" + $(this).attr("data-id");
  264. })
  265. selUse();
  266. function selUse() {
  267. $.ajax({
  268. url: "/ajax/ware/pro",
  269. type: "GET",
  270. timeout: 10000,
  271. dataType: "json",
  272. async: true,
  273. data: {
  274. "id": sevriceId,
  275. },
  276. success: function(data, textState) {
  277. if(data.success) {
  278. if(data.data.length > 0) {
  279. $("#expertli").parents(".currentBlock").removeClass("displayNone");
  280. unauthUser(data.data);
  281. } else {
  282. $("#expertli").parents(".currentBlock").addClass("displayNone");
  283. }
  284. }
  285. },
  286. error: function(XMLHttpRequest, textStats, errorThrown) {
  287. $.MsgBox.Alert('提示', '服务器请求失败')
  288. }
  289. })
  290. }
  291. function unauthUser(data) {
  292. for(var i = 0; i < data.length; i++) {
  293. (function(i) {
  294. ajaxRequist("/ajax/professor/baseInfo/" + data[i].professor, {}, "get", function(data) {
  295. var $res=data.data;
  296. var osting = ""
  297. var img;
  298. var styC = "";
  299. var oClass = autho($res.authType, $res.orgAuth, $res.authStatus);
  300. var oTitle = "";
  301. if($res.title) {
  302. oTitle = $res.title;
  303. } else {
  304. if($res.office) {
  305. oTitle = $res.office;
  306. }
  307. }
  308. if($res.hasHeadImage) {
  309. img = "/images/head/" + $res.id + "_l.jpg";
  310. } else {
  311. img = "../images/default-photo.jpg"
  312. }
  313. var oSt = '<li class="flexCenter">'
  314. oSt += '<div class="madiaHead useHead" id="userimg" style="background-image: url(' + img + ');"></div>'
  315. oSt += '<div class = "madiaInfo">'
  316. oSt += '<p class = "ellipsisSty">'
  317. oSt += '<span class = "h1Font" id="name">' + $res.name + '</span><em class="authiconNew ' + oClass.sty + '" title="' + oClass.title + '"></em >'
  318. oSt += '</p>'
  319. oSt += '<p class="h2Font ellipsisSty">' + oTitle + '</p>'
  320. oSt += '</div>'
  321. oSt += '</li>'
  322. osting += oSt;
  323. $("#expertli").html(osting);
  324. })
  325. })(i)
  326. }
  327. }
  328. })