portal html css js resource

resourcePreview.js 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. $(document).ready(function() {
  2. loginStatus(); //判断个人是否登录
  3. valUser();
  4. var userid = $.cookie("userid");
  5. $(".jqzoom").imagezoom();
  6. $("#thumblist").on("click", "li a", function() {
  7. $(this).parents("li").addClass("tb-selected").siblings().removeClass("tb-selected");
  8. $(".jqzoom").attr('src', $(this).find("img").attr("src"));
  9. $(".jqzoom").attr('rel', $(this).find("img").attr("src"));
  10. });
  11. $('.shareWeixin').hover(function() {
  12. $('.shareCode').stop(true, false).fadeToggle();
  13. });
  14. var resourceId = GetQueryString("resourceId");
  15. var professorId = "";
  16. getRecourceMe();
  17. /*获取资源信息*/
  18. function getRecourceMe() {
  19. $.ajax({
  20. "url": "/ajax/resource/queryOne",
  21. "type": "GET",
  22. "success": function(data) {
  23. console.log(data);
  24. if(data.success) {
  25. resourceHtml(data.data);
  26. var resourceName = data.data.resourceName + "-科袖网";
  27. window.setTimeout(function() {
  28. document.title = resourceName;
  29. }, 500);
  30. }
  31. },
  32. "data": {
  33. "resourceId": resourceId
  34. },
  35. dataType: "json",
  36. 'error': function() {
  37. $.MsgBox.Alert('提示', '服务器连接超时!');
  38. }
  39. });
  40. }
  41. /*合作备注及性能参数存储换行格式*/
  42. function outHTML(selecter) {
  43. var getValue = selecter;
  44. var aa = "";
  45. if(getValue) {
  46. var endValue = ((getValue.replace(/<(.+?)>/gi, "&lt;$1&gt;")).replace(/ /gi, "&nbsp;")).replace(/\n/gi, "|");
  47. var cc = endValue.split("|");
  48. for(var i = 0; i < cc.length; i++) {
  49. aa += cc[i] + '<br/>'
  50. }
  51. }
  52. return aa;
  53. }
  54. /*处理资源html代码*/
  55. function resourceHtml($da) {
  56. $("#resourceName").text($da.resourceName); //名字
  57. $("#application").text($da.supportedServices); //应用用途
  58. if($da.editProfessor) {
  59. $("#person").show();
  60. if($da.orgName) { //所属机构
  61. $("#organizationName").text($da.orgName).parents("li").show();
  62. }
  63. $("#nameS").text($da.editProfessor.name); //"office": "", //职位 "title": "", //职称
  64. if($da.editProfessor.title) {
  65. $("#titleOffice").text($da.editProfessor.title);
  66. } else {
  67. if($da.editProfessor.office) {
  68. $("#titleOffice").text($da.editProfessor.office);
  69. }
  70. }
  71. if($da.editProfessor.orgName) {
  72. $("#orgType").text($da.editProfessor.orgName);
  73. }
  74. professorId = $da.editProfessor.id;
  75. /*if(userid!=professorId) {
  76. $(".goSpan").show();
  77. }*/
  78. var professorFlag = autho($da.editProfessor.authType, $da.editProfessor.orgAuth, $da.editProfessor.authStatus);
  79. $("#authFlag").addClass(professorFlag.sty).attr("title", professorFlag.title);
  80. if($da.editProfessor.hasHeadImage == 1) {
  81. $("#headImg").css("background-image", 'url(/images/head/' + $da.editProfessor.id + '_l.jpg)');
  82. }
  83. }else {
  84. $("#enterprise,#resPerson").show();
  85. if($da.organization.hasOrgLogo) {
  86. $("#Qimg").attr("style", "background-image: url(/images/org/" + $da.organization.id + ".jpg);");
  87. }
  88. if($da.organization.authStatus==3){
  89. $("#QauthFlag").addClass("authicon-com-ok").attr("title", "认证企业");
  90. }
  91. $("#Qname").text($da.organization.name);
  92. $("#Qindustry").text($da.organization.subject);
  93. $("#QorgType").text(orgTypeShow[$da.organization.orgType])
  94. }
  95. if($da.spec) { //厂商型号
  96. $("#modelNumber").text($da.spec).parents("li").show();
  97. }
  98. if($da.parameter) { //性能参数
  99. $("#performancePa").html(outHTML($da.parameter)).parents("li").show();
  100. }
  101. if($da.cooperationNotes) { //合作备注
  102. $("#remarkContent").html(outHTML($da.cooperationNotes)).parents("li").show();
  103. }
  104. if($da.subject) {
  105. var oSub = $da.subject.split(",");
  106. var oSt = "";
  107. for(var i = 0; i < oSub.length; i++) {
  108. oSt += '<li><p class="h2Font">' + oSub[i] + '</p></li>'
  109. }
  110. $(".tagList").html(oSt);
  111. }
  112. if($da.descp) { //编辑器
  113. $("#descp").html($da.descp).parents("li").show();
  114. }
  115. //return;
  116. if($da.images.length) {
  117. $("#firstFigure").attr({
  118. "src": "/data/resource/" + $da.images[0].imageSrc,
  119. "rel": "/data/resource/" + $da.images[0].imageSrc
  120. }).parent().attr("href", "/data/resource/" + $da.images[0].imageSrc);
  121. var arr = "";
  122. for(var i = 0; i < $da.images.length; i++) {
  123. if($da.images[i] == $da.images[0]) {
  124. var oString = '<li class="tb-selected">' +
  125. '<div class="tb-pic tb-s66">' +
  126. '<a href="javascript:void(0);">' +
  127. '<img src="/data/resource/' + $da.images[i].imageSrc + '"/>' +
  128. '</a>' +
  129. '</div>' +
  130. '</li>'
  131. } else {
  132. var oString = '<li >' +
  133. '<div class="tb-pic tb-s66">' +
  134. '<a href="javascript:void(0);">' +
  135. '<img src="/data/resource/' + $da.images[i].imageSrc + '"/>' +
  136. '</a>' +
  137. '</div>' +
  138. '</li>'
  139. }
  140. arr += oString;
  141. }
  142. $("#thumblist").html(arr);
  143. }
  144. }
  145. /*点击名字及头像跳转个人浏览页面*/
  146. $("#nameS,#headImg").click(function() {
  147. location.href = "userInforShow.html?professorId=" + professorId;
  148. })
  149. /*点击咨询*/
  150. $("#consultin").on("click", function() {
  151. clickResouceConsultHandler();
  152. });
  153. /*咨询函数*/
  154. function clickResouceConsultHandler() {
  155. if(userid && userid != "null" && userid != null) {
  156. ConsultApply();
  157. concultProInfo(professorId); //专家信息common.js中
  158. //默认选中资源咨询和标题
  159. for(var i = 0; i < $("ul.menucon").children().length; i++) {
  160. $("ul.menucon").children().eq(i).removeClass("clicknow");
  161. $("ul.menucon").children().eq(1).addClass("clicknow");
  162. }
  163. var consultTitleVal = $(".h2Font").text();
  164. $("#consultTitle").val("关于" + consultTitleVal + "的咨询");
  165. //点击的发送
  166. $("#sendConsultBtn").click(function() {
  167. sendConsultHandler(professorId); //common.js中
  168. });
  169. } else {
  170. $.MsgBox.Alert("消息提醒", "请先登录再进行咨询");
  171. $("#mb_btn_ok").val("去登录");
  172. var aele = document.createElement('a');
  173. $("#mb_btnbox").append(aele);
  174. $("#mb_btnbox a").css({
  175. 'display': "block",
  176. 'width': '100%',
  177. 'height': '40px',
  178. 'position': 'absolute',
  179. 'bottom': '-6px',
  180. 'left': '0'
  181. });
  182. aele.setAttribute('href', '../login.html');
  183. }
  184. };
  185. //点击专家关注
  186. $('.attenSpan').click(function(){
  187. if (userid && userid != "null" && userid != null) {
  188. if($(this).is('.attenSpanyes')){
  189. cancelCollectionExpert(professorId,1)
  190. }else{
  191. collectionExpert(professorId,1);
  192. }
  193. }else{
  194. $.MsgBox.Alert('提示',"请先登录再进行关注");
  195. $("#mb_btn_ok").val("去登录");
  196. var aele = document.createElement('a');
  197. $("#mb_btnbox").append(aele);
  198. $("#mb_btnbox a").css({
  199. 'display': "block",
  200. 'width': '100%',
  201. 'height': '40px',
  202. 'position': 'absolute',
  203. 'bottom': '-6px',
  204. 'left': '0'
  205. });
  206. aele.setAttribute('href', '../login.html');
  207. }
  208. })
  209. //点击资源收藏
  210. $('#attention em').click(function(){
  211. if (userid && userid != "null" && userid != null) {
  212. if($(this).is('.icon-collected')){
  213. cancelCollectionExpert(resourceId,2)
  214. }else{
  215. collectionExpert(resourceId,2);
  216. }
  217. }else{
  218. $.MsgBox.Alert('提示',"请先登录再进行收藏");
  219. $("#mb_btn_ok").val("去登录");
  220. var aele = document.createElement('a');
  221. $("#mb_btnbox").append(aele);
  222. $("#mb_btnbox a").css({
  223. 'display': "block",
  224. 'width': '100%',
  225. 'height': '40px',
  226. 'position': 'absolute',
  227. 'bottom': '-6px',
  228. 'left': '0'
  229. });
  230. aele.setAttribute('href', '../login.html');
  231. }
  232. })
  233. /*判断是非关注专家*/
  234. function ifCollection(getid,num) {
  235. var data = {"professorId": userid,"watchObject": getid}
  236. //alert(JSON.stringify(data))
  237. $.ajax({
  238. url:"/ajax/watch/hasWatch",
  239. data:data,
  240. dataType: 'json', //数据格式类型
  241. type: 'get', //http请求类型
  242. timeout: 10000,
  243. async: true,
  244. success: function(data) {
  245. if(num==1){
  246. if(data.success && data.data != null) {
  247. $('.attenSpan').addClass("attenSpanyes");
  248. $('.attenSpan').text('已关注');
  249. zjreturnId = data.data.watchObject;
  250. } else {
  251. $('.attenSpan').removeClass("attenSpanyes");
  252. $('.attenSpan').text('关注');
  253. }
  254. }
  255. if(num==2){
  256. if(data.success && data.data != null) {
  257. $('#attention em').addClass("icon-collected").removeClass("icon-collect");
  258. wzreturnId = data.data.watchObject;
  259. } else {
  260. $('#attention em').removeClass("icon-collected").addClass("icon-collect");
  261. }
  262. }
  263. },
  264. error: function() {
  265. $.MsgBox.Alert('提示',"服务器链接超时");
  266. }
  267. });
  268. }
  269. /*关注专家*/
  270. function collectionExpert(watchObject,num) {
  271. if(num==1){
  272. var data = {"professorId": userid,"watchObject": watchObject,"watchType": 1}
  273. }else{
  274. var data = {"professorId": userid,"watchObject": watchObject,"watchType": 3}
  275. }
  276. $.ajax({
  277. url:"/ajax/watch",
  278. data:data,
  279. dataType: 'json', //数据格式类型
  280. type: 'POST', //http请求类型
  281. timeout: 10000,
  282. async: false,
  283. success: function(data) {
  284. if(num==1){
  285. if(data.success) {
  286. $('.attenSpan').addClass("attenSpanyes");
  287. $('.attenSpan').text('已关注');
  288. zjreturnId = data.data.watchObject;
  289. }
  290. }
  291. if(num==2){
  292. if(data.success) {
  293. $('#attention em').addClass("icon-collected").removeClass("icon-collect");
  294. wzreturnId = data.data.watchObject;
  295. }
  296. }
  297. },
  298. error: function() {
  299. $.MsgBox.Alert('提示',"服务器链接超时");
  300. }
  301. });
  302. }
  303. /*取消收藏专家*/
  304. function cancelCollectionExpert(watchObject,num) {
  305. $.ajax({
  306. url:"/ajax/watch/delete",
  307. data: {
  308. professorId: userid,
  309. watchObject: watchObject
  310. },
  311. dataType: 'json', //数据格式类型
  312. type: 'post', //http请求类型
  313. timeout: 10000,
  314. async: true,
  315. success: function(data) {
  316. console.log(data.success)
  317. if(num==1){
  318. if(data.success) {
  319. $('.attenSpan').removeClass("attenSpanyes");
  320. $('.attenSpan').text('关注');
  321. }
  322. }
  323. if(num==2){
  324. if(data.success) {
  325. $('#attention em').removeClass("icon-collected").addClass("icon-collect");
  326. }
  327. }
  328. },
  329. error: function(data) {
  330. $.MsgBox.Alert('提示',"服务器链接超时");
  331. }
  332. });
  333. }
  334. selUse();
  335. function selUse() {
  336. $.ajax({
  337. url: "/ajax/resource/qaLinkman",
  338. type: "GET",
  339. timeout: 10000,
  340. dataType: "json",
  341. async:true,
  342. data: {
  343. "resourceId": resourceId,
  344. },
  345. success: function(data, textState) {
  346. console.log(data)
  347. if(data.success) {
  348. unauthUser(data.data);
  349. }
  350. },
  351. error: function(XMLHttpRequest, textStats, errorThrown) {
  352. $.MsgBox.Alert('提示', '服务器请求失败')
  353. }
  354. })
  355. }
  356. function unauthUser($res) {
  357. var osting=""
  358. for(var i = 0; i < $res.length; i++) {
  359. var img;
  360. var styC="";
  361. var oClass = autho($res[i].professor.authType, $res[i].professor.orgAuth, $res[i].professor.authStatus);
  362. var oTitle="";
  363. if($res[i].professor.title) {
  364. oTitle=$res[i].professor.title;
  365. }else{
  366. if($res[i].professor.office) {
  367. oTitle=$res[i].professor.office;
  368. }
  369. }
  370. if($res[i].professor.hasHeadImage) {
  371. img = "/images/head/" + $res[i].professor.id + "_l.jpg";
  372. } else {
  373. img = "../images/default-photo.jpg"
  374. }
  375. var oSt = '<li>'
  376. oSt += '<div class="madiaHead useHead" id="userimg" style="background-image: url('+img+');"></div>'
  377. oSt += '<div class = "madiaInfo">'
  378. oSt += '<p class = "ellipsisSty">'
  379. oSt += '<span class = "h1Font" id="name">'+$res[i].professor.name+'</span><em class="authicon '+oClass.sty+'" title="'+oClass.title+'"></em >'
  380. oSt += '</p>'
  381. oSt += '<p class="h2Font ellipsisSty">'+oTitle+'</p>'
  382. oSt += '</div>'
  383. oSt += '<div class="'+styC+'" flag=1></div>'
  384. oSt += '</li>'
  385. osting+=oSt;
  386. }
  387. $("#expertli").html(osting);
  388. }
  389. })