123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627 |
- $(document).ready(function() {
- loginStatus();
- var userid = $.cookie("userid");
- $(".jqzoom").imagezoom();
- $("#thumblist").on("click", "li a", function() {
- $(this).parents("li").addClass("tb-selected").siblings().removeClass("tb-selected");
- $(".jqzoom").attr('src', $(this).find("img").attr("src"));
- $(".jqzoom").attr('rel', $(this).find("img").attr("src"));
- });
- $('.shareWeixin').hover(function() {
- $('.shareCode').stop(true, false).fadeToggle();
- });
- var resourceId = GetQueryString("resourceId");
- ifCollection(resourceId, 2)
- var professorId = "";
- getRecourceMe();
-
- function getRecourceMe() {
- $.ajax({
- "url": "/ajax/resource/queryOne",
- "type": "GET",
- "success": function(data) {
- console.log(data);
- if(data.success) {
- resourceHtml(data.data);
- var resourceName = data.data.resourceName + "-科袖网";
- window.setTimeout(function() {
- document.title = resourceName;
- }, 500);
- }
- },
- "data": {
- "resourceId": resourceId
- },
- dataType: "json",
- 'error': function() {
- $.MsgBox.Alert('提示', '服务器连接超时!');
- }
- });
- }
-
- function outHTML(selecter) {
- var getValue = selecter;
- var aa = "";
- if(getValue) {
- var endValue = ((getValue.replace(/<(.+?)>/gi, "<$1>")).replace(/ /gi, " ")).replace(/\n/gi, "|");
- var cc = endValue.split("|");
- for(var i = 0; i < cc.length; i++) {
- aa += cc[i] + '<br/>'
- }
- }
- return aa;
- }
-
- function resourceHtml($da) {
- $("#resourceName").text($da.resourceName);
- $("#application").text($da.supportedServices);
- if($da.editProfessor) {
- $("#person").show();
- if($da.orgName) {
- $("#organizationName").text($da.orgName).parents("li").show();
- }
- $("#nameS").text($da.editProfessor.name);
- if($da.editProfessor.title) {
- $("#titleOffice").text($da.editProfessor.title);
- } else {
- if($da.editProfessor.office) {
- $("#titleOffice").text($da.editProfessor.office);
- }
- }
- if($da.editProfessor.orgName) {
- $("#orgType").text($da.editProfessor.orgName);
- }
- professorId = $da.editProfessor.id;
- console.log(professorId);
- console.log(userid);
- if(userid != professorId) {
- ifCollection(professorId, 1)
- $(".goSpan").show();
- }
- var professorFlag = autho($da.editProfessor.authType, $da.editProfessor.orgAuth, $da.editProfessor.authStatus);
- $("#authFlag").addClass(professorFlag.sty).attr("title", professorFlag.title);
- if($da.editProfessor.hasHeadImage == 1) {
- $("#headImg").css("background-image", 'url(/images/head/' + $da.editProfessor.id + '_l.jpg)');
- }
- }else{
- $("#enterprise,#resPerson").show();
- $(".qiyego").attr("href","userInforShow.html?orgId="+$da.organization.id);
- if($da.organization.hasOrgLogo) {
- $("#Qimg").attr("style", "background-image: url(/images/org/" + $da.organization.id + ".jpg);");
- }
- if($da.organization.authStatus==3){
- $("#QauthFlag").addClass("authicon-com-ok").attr("title", "认证企业");
- }
- if($da.organization.forShort) {
- $("#Qname").text($da.organization.forShort).attr("href","cmpInforShow.html?orgId="+$da.organization.id);
- }else{
- $("#Qname").text($da.organization.name).attr("href","cmpInforShow.html?orgId="+$da.organization.id);
- }
-
- $("#Qindustry").text($da.organization.subject);
- $("#QorgType").text(orgTypeShow[$da.organization.orgType])
- }
- if($da.spec) {
- $("#modelNumber").text($da.spec).parents("li").show();
- }
- if($da.parameter) {
- $("#performancePa").html(outHTML($da.parameter)).parents("li").show();
- }
- if($da.cooperationNotes) {
- $("#remarkContent").html(outHTML($da.cooperationNotes)).parents("li").show();
- }
- if($da.subject) {
- var oSub = $da.subject.split(",");
- if($da.resourceType==1) {
- interestingResources(oSub,$da.professorId,0);
- }else{
- interestingResources(oSub,$da.orgId,1);
- }
- var oSt = "";
- for(var i = 0; i < oSub.length; i++) {
- oSt += '<li><p class="h2Font">' + oSub[i] + '</p></li>'
- }
- $(".tagList").html(oSt);
- } else {
- $(".aboutTit:contains('您可能感兴趣的资源')").parent().hide();
- }
- if($da.descp) {
- $("#descp").html($da.descp).parents("li").show();
- }
- var weibotitle = $da.resourceName;
- var weibourl = window.location.href;
-
- if($da.images.length) {
- var weibopic = "http://" + window.location.host + "/data/resource/" + $da.images[0].imageSrc;
- $("#firstFigure").attr({
- "src": "/data/resource/" + $da.images[0].imageSrc,
- "rel": "/data/resource/" + $da.images[0].imageSrc
- }).parent().attr("href", "/data/resource/" + $da.images[0].imageSrc);
- var arr = "";
- for(var i = 0; i < $da.images.length; i++) {
- if($da.images[i] == $da.images[0]) {
- var oString = '<li class="tb-selected">' +
- '<div class="tb-pic tb-s66">' +
- '<a href="javascript:void(0);">' +
- '<img src="/data/resource/' + $da.images[i].imageSrc + '"/>' +
- '</a>' +
- '</div>' +
- '</li>'
- } else {
- var oString = '<li >' +
- '<div class="tb-pic tb-s66">' +
- '<a href="javascript:void(0);">' +
- '<img src="/data/resource/' + $da.images[i].imageSrc + '"/>' +
- '</a>' +
- '</div>' +
- '</li>'
- }
- arr += oString;
- }
- $("#thumblist").html(arr);
- } else {
- var weibopic = "http://" + window.location.host + "../images/default-resource.jpg";
- $("#firstFigure").attr({
- "src": '../images/default-resource.jpg',
- "rel": '../images/default-resource.jpg'
- });
- }
- $("#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");
- }
-
- $("#nameS,#headImg").click(function() {
- location.href = "userInforShow.html?professorId=" + professorId;
- })
-
- $(".tagList").on("click","li",function(){
- var tagText = $(this).find("p").text();
- location.href = "searchNew.html?searchContent=" + tagText + "&tagflag=2";
- })
-
- function relatedArticles() {
- $.ajax({
- "url": "/ajax/resource/articles",
- "type": "GET",
- "success": function(data) {
- console.log(data);
- if(data.success) {
- if(data.data.length == 0) {
- $("#oArticle").parent().hide();
- $(".aboutTit:contains('相关文章')").hide();
- return;
- }
- relatedArticlesHtml(data.data);
- }
- },
- "data": {
- "resourceId": resourceId,
- "rows": 5
- },
- dataType: "json",
- 'error': function() {
- $.MsgBox.Alert('提示', '服务器连接超时!');
- }
- });
- }
- relatedArticles();
-
- function relatedArticlesHtml($html) {
- for(var i = 0; i < $html.length; i++) {
- (function(n) {
- var oURL;
- if($html[i].article.articleType==1) {
- oURL="/ajax/professor/baseInfo/" + $html[i].article.professorId;
- }else{
- oURL="/ajax/org/" + $html[i].article.orgId;
- }
- $.ajax({
- "url":oURL,
- "type": "GET",
- "success": function(data) {
- if(data.success) {
- if($html[n].article.articleType==1) {
- var stl = autho(data.data.authType, data.data.orgAuth, data.data.authStatus);
- }else {
- var stl={};
- stl.sty="";
- stl.title="";
- if(data.data.authStatus==3) {
- stl.sty="authicon-com-ok";
- stl.title="认证企业";
- }
- }
- var str = ""
- str += '<li data-id="' + $html[n].article.articleId + '">'
- if($html[n].article.articleImg) {
- str += '<div class="madiaHead artHead" style="background-image: url(/data/article/' + $html[n].article.articleImg + ')"></div>'
- } else {
- str += '<div class="madiaHead artHead"></div>'
- }
- str += '<div class="madiaInfo" style="margin-top:18px;padding-bottom:8px">'
- str += '<p class="h1Font ellipsisSty">' + $html[n].article.articleTitle + '</p>'
- str += '<p><span class="h2Font">' + data.data.name + '</span><em class="authiconNew ' + stl.sty + '" title="' + stl.title + '"></em></p>'
- str += '</div></li>'
- $("#oArticle").append(str);
- }
- },
- 'dataType': "json",
- 'error': function() {
- $.MsgBox.Alert('提示', '服务器连接超时!');
- }
- });
- })(i);
- }
- }
-
- $("#oArticle").on("click", "li", function() {
- location.href = "articalShow.html?articleId=" + $(this).attr("data-id");
- })
-
- function interestingResources(arry,oId,oNu) {
- var oUrl;
- var $in={};
- $in.keys= arry;
- $in.resourceId= resourceId;
-
- if(oNu==0) {
- $in.professorId= oId;
- oUrl="/ajax/resource/ralateRes";
- }else {
- $in.orgId= oId;
- oUrl="/ajax/resource/orgRalateRes";
- }
- $.ajax({
- "url": oUrl,
- "type": "GET",
- "success": function(data) {
- console.log(data);
- if(data.success) {
- if(data.data.length == 0) {
- $(".aboutTit:contains('您可能感兴趣的资源')").parent().hide();
- return;
- }
- interestingResourcesHtml(data.data);
- }
- },
- "data":$in,
- "traditional": true,
- dataType: "json",
- 'error': function() {
- $.MsgBox.Alert('提示', '服务器连接超时!');
- }
- });
- }
-
- function interestingResourcesHtml($respond) {
- for(var i = 0; i < $respond.length; i++) {
- if($respond[i].organization) {
- var stl={};
- stl.sty="";
- stl.title="";
- if($respond[i].organization.authStatus==3) {
- stl.sty="authicon-com-ok";
- stl.title="认证企业";
- }
- var name= $respond[i].organization.name;
- }else {
- var stl = autho($respond[i].editProfessor.authType, $respond[i].editProfessor.orgAuth, $respond[i].editProfessor.authStatus);
- var name= $respond[i].editProfessor.name;
- }
-
- var oStr = '';
- if($respond[i].images.length) {
- oStr += '<li data-id="' + $respond[i].resourceId + '"><div class="madiaHead resouseHead"style="background-image: url(/data/resource/' + $respond[i].images[0].imageSrc + ')"></div>'
- } else {
- oStr += '<li data-id="' + $respond[i].resourceId + '"><div class="madiaHead resouseHead"></div>'
- }
- oStr += '<div class="madiaInfo">'
- oStr += '<p class="h1Font">' + $respond[i].resourceName + '</p>'
- oStr += '<p class="h2Font ellipsisSty">用途:<span>' + $respond[i].supportedServices + '</span></p>'
- oStr += '<p><span class="h2Font">' + name + '</span><em class="authiconNew ' + stl.sty + '" title="' + stl.title + '"></em></p>'
- oStr += '</div></li>'
- $("#resourceList").append(oStr);
- }
- }
-
- $("#resourceList").on("click", "li", function() {
- location.href = "resourceShow.html?resourceId=" + $(this).attr("data-id");
- })
-
- $("#consultin").on("click", function() {
- clickResouceConsultHandler();
- });
- $("#expertli").on("click", ".addbtn", function() {
- var $this = $(this);
- clickResouceConsultHandler($this);
- })
-
- function clickResouceConsultHandler($this) {
- if(userid && userid != "null" && userid != null) {
- ConsultApply();
- if(!professorId) {
- concultProInfo($this.attr("data-id"));
- } else {
- concultProInfo(professorId);
- }
-
- for(var i = 0; i < $("ul.menucon").children().length; i++) {
- $("ul.menucon").children().eq(i).removeClass("clicknow");
- $("ul.menucon").children().eq(1).addClass("clicknow");
- }
- var consultTitleVal = $("#resourceName").text();
- $("#consultTitle").val("关于" + consultTitleVal + "的咨询");
-
- $("#sendConsultBtn").click(function() {
- sendConsultHandler(professorId);
- });
- } else {
- $.MsgBox.Alert("消息提醒", "请先登录再进行咨询");
- $("#mb_btn_ok").val("去登录");
- var aele = document.createElement('a');
- $("#mb_btnbox").append(aele);
- $("#mb_btnbox a").css({
- 'display': "block",
- 'width': '100%',
- 'height': '40px',
- 'position': 'absolute',
- 'bottom': '-6px',
- 'left': '0'
- });
- aele.setAttribute('href', '../login.html');
- }
- };
-
- $('.attenSpan').click(function() {
- if(userid && userid != "null" && userid != null) {
- if($(this).is('.attenSpanyes')) {
- cancelCollectionExpert(professorId, 1)
- } else {
- collectionExpert(professorId, 1);
- }
- } else {
- $.MsgBox.Alert('提示', "请先登录再进行关注");
- $("#mb_btn_ok").val("去登录");
- var aele = document.createElement('a');
- $("#mb_btnbox").append(aele);
- $("#mb_btnbox a").css({
- 'display': "block",
- 'width': '100%',
- 'height': '40px',
- 'position': 'absolute',
- 'bottom': '-6px',
- 'left': '0'
- });
- aele.setAttribute('href', '../login.html');
- }
- })
-
- $('#attention em').click(function() {
- if(userid && userid != "null" && userid != null) {
- if($(this).is('.icon-collected')) {
- cancelCollectionExpert(resourceId, 2)
- } else {
- collectionExpert(resourceId, 2);
- }
- } else {
- $.MsgBox.Alert('提示', "请先登录再进行收藏");
- $("#mb_btn_ok").val("去登录");
- var aele = document.createElement('a');
- $("#mb_btnbox").append(aele);
- $("#mb_btnbox a").css({
- 'display': "block",
- 'width': '100%',
- 'height': '40px',
- 'position': 'absolute',
- 'bottom': '-6px',
- 'left': '0'
- });
- aele.setAttribute('href', '../login.html');
- }
- })
-
- function ifCollection(getid, num) {
- var data = {
- "professorId": userid,
- "watchObject": getid
- }
-
- $.ajax({
- url: "/ajax/watch/hasWatch",
- data: data,
- dataType: 'json',
- type: 'get',
- timeout: 10000,
- async: true,
- success: function(data) {
- if(num == 1) {
- if(data.success && data.data != null) {
- $('.attenSpan').addClass("attenSpanyes");
- $('.attenSpan').addClass("attenedSpan");
- $('.attenSpan').text('已关注');
- zjreturnId = data.data.watchObject;
- } else {
- $('.attenSpan').removeClass("attenSpanyes");
- $('.attenSpan').removeClass("attenedSpan");
- $('.attenSpan').text('关注');
- }
- }
- if(num == 2) {
- if(data.success && data.data != null) {
- $('#attention em').addClass("icon-collected").removeClass("icon-collect");
- wzreturnId = data.data.watchObject;
- } else {
- $('#attention em').removeClass("icon-collected").addClass("icon-collect");
- }
- }
- },
- error: function() {
- $.MsgBox.Alert('提示', "服务器链接超时");
- }
- });
- }
-
- function collectionExpert(watchObject, num) {
- if(num == 1) {
- var data = {
- "professorId": userid,
- "watchObject": watchObject,
- "watchType": 1
- }
- } else {
- var data = {
- "professorId": userid,
- "watchObject": watchObject,
- "watchType": 2
- }
- }
- $.ajax({
- url: "/ajax/watch",
- data: data,
- dataType: 'json',
- type: 'POST',
- timeout: 10000,
- async: false,
- success: function(data) {
- if(num == 1) {
- if(data.success) {
- $('.attenSpan').addClass("attenSpanyes");
- $('.attenSpan').addClass("attenedSpan");
- $('.attenSpan').text('已关注');
- zjreturnId = data.data.watchObject;
- }
- }
- if(num == 2) {
- if(data.success) {
- $('#attention em').addClass("icon-collected").removeClass("icon-collect");
- wzreturnId = data.data.watchObject;
- }
- }
- },
- error: function() {
- $.MsgBox.Alert('提示', "服务器链接超时");
- }
- });
- }
-
- function cancelCollectionExpert(watchObject, num) {
- $.ajax({
- url: "/ajax/watch/delete",
- data: {
- professorId: userid,
- watchObject: watchObject
- },
- dataType: 'json',
- type: 'post',
- timeout: 10000,
- async: true,
- success: function(data) {
- console.log(data.success)
- if(num == 1) {
- if(data.success) {
- $('.attenSpan').removeClass("attenSpanyes");
- $('.attenSpan').removeClass("attenedSpan");
- $('.attenSpan').text('关注');
- }
- }
- if(num == 2) {
- if(data.success) {
- $('#attention em').removeClass("icon-collected").addClass("icon-collect");
- }
- }
- },
- error: function(data) {
- $.MsgBox.Alert('提示', "服务器链接超时");
- }
- });
- }
-
- function pageViewsVal() {
- $.ajax({
- "url": "/ajax/resource/pageViews",
- "type": "POST",
- "dataType": "json",
- "data": {
- "resourceId": resourceId
- },
- "success": function(data) {
- console.log(data);
- if(data.success) {}
- },
- "error": function() {
- $.MsgBox.Alert('提示', '链接服务器超时')
- }
- });
- }
- pageViewsVal();
- selUse();
- function selUse() {
- $.ajax({
- url: "/ajax/resource/qaLinkman",
- type: "GET",
- timeout: 10000,
- dataType: "json",
- async: true,
- data: {
- "resourceId": resourceId,
- },
- success: function(data, textState) {
- console.log(data)
- if(data.success) {
- unauthUser(data.data);
- }
- },
- error: function(XMLHttpRequest, textStats, errorThrown) {
- $.MsgBox.Alert('提示', '服务器请求失败')
- }
- })
- }
- function unauthUser($res) {
- var osting = ""
- for(var i = 0; i < $res.length; i++) {
- var img;
- var styC = "";
- var oClass = autho($res[i].professor.authType, $res[i].professor.orgAuth, $res[i].professor.authStatus);
- var oTitle = "";
- if($res[i].professor.title) {
- oTitle = $res[i].professor.title;
- } else {
- if($res[i].professor.office) {
- oTitle = $res[i].professor.office;
- }
- }
- if($res[i].professor.hasHeadImage) {
- img = "/images/head/" + $res[i].professor.id + "_l.jpg";
- } else {
- img = "../images/default-photo.jpg"
- }
- var oSt = '<li class="flexCenter">'
- oSt += '<div class="madiaHead useHead" id="userimg" style="background-image: url(' + img + ');"></div>'
- oSt += '<div class = "madiaInfo">'
- oSt += '<p class = "ellipsisSty">'
- oSt += '<span class = "h1Font" id="name">' + $res[i].professor.name + '</span><em class="authiconNew ' + oClass.sty + '" title="' + oClass.title + '"></em >'
- oSt += '</p>'
- oSt += '<p class="h2Font ellipsisSty">' + oTitle + '</p>'
- oSt += '</div>'
- oSt += '<span class="addbtn" data-id="' + $res[i].professor.id + '">咨询</span>'
- oSt += '</li>'
- osting += oSt;
- }
- $("#expertli").html(osting);
- }
- })
|