123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642 |
- $(document).ready(function() {
- var articleId = GetQueryString("articleId");
- var professorId = GetQueryString("professorId");
- var oFlag = GetQueryString("oFlag");
- loginStatus();
- var userid = $.cookie("userid");
- if(userid == "null"||userid==undefined) {
- $(".goMsgbox").hide();
- } else {
- $("#login").hide();
- }
-
- var industryShow = function(data, $id) {
- if(data != undefined && data.length != 0) {
- var subs = new Array();
- if(data.indexOf(',')) {
- subs = data.split(',');
- } else {
- subs[0] = data;
- }
- if(subs.length > 0) {
- var html = [];
- for(var i = 0; i < subs.length; i++) {
- html.push("<li>" + subs[i] + "</li>");
- };
- document.getElementById($id).innerHTML = html.join('');
- }
- }
- }
- function proInfoMain() {
- $.ajax({
- url: "/ajax/article/query",
- dataType: 'json',
- type: 'GET',
- data: {
- "articleId": articleId
- },
- timeout: 10000,
- success: function(data) {
- var $info = data.data || {};
- if(data.success && data.data) {
- console.log(data);
-
- var oTime=timeGeshi($info.createTime);
- $("#creTime").text(oTime);
- $("#articleName").text($info.articleTitle);
- $(".message1").text($info.articleAgree);
- if($info.subject) {
- industryShow($info.subject, "subjectList");
- } else {
- $("#subjectList").parent().hide();
- }
- if($info.industry) {
- industryShow($info.industry, "industryList");
- } else {
- $("#industryList").parent().hide();
- }
- if(!$info.subject&&!$info.industry){
- $(".resAbout").hide();
- }
- var proTitle = document.getElementById("proTitle");
- var proOffice = document.getElementById("proOffice");
- var proOrg = document.getElementById("proOrg");
- var proAddress = document.getElementById("proAddress");
- if($info.articleContent) {
- $("#main_content").html($info.articleContent);
- var oImg = $("#main_content").find("img");
- for(var i = 0; i < oImg.length; i++) {
- (function(n) {
- $("#main_content").find("img").eq(n).load(function() {
- var imgWidth = $("#main_content").find("img").eq(n).width();
- var pWidth = $("#main_content").find("p").width();
- if(imgWidth > pWidth) {
- $("#main_content").find("img").eq(n).css({
- "width": "100%"
- });
- }
- })
- })(i);
- }
- }
-
- var articletitle = $info.articleTitle + "-科袖网";
- window.setTimeout(function() {
- document.title = articletitle;
- }, 500);
- }
- },
- error: function() {
- return;
- }
- });
- }
- var proArticle = function() {
- var $f=new Object();
- if(oFlag==1){
- $f.orgId=professorId;
- }else{
- $f.professorId=professorId;
- }
-
- $.ajax({
- url: (oFlag==1)?"/ajax/article/qaOrg":"/ajax/article/qaPro",
- dataType: 'json',
- type: 'GET',
- data: $f,
- timeout: 10000,
- success: function(data) {
- if(data.success) {
- var $data = data.data;
- if($data.length == 1) {
- $("div:contains('相关文章')").parents(".rightBlock").hide();
- return;
- }
- var oNu=Math.min(data.data.length,3);
- for(var i = 0; i < oNu; i++) {
- if(articleId != $data[i].articleId) {
- var articleImg = $data[i].articleImg;
- (!articleImg) ? articleImg = "../images/default-artical.jpg": articleImg = '/data/article/' + $data[i].articleImg;
-
- if($data[i].industry) {
- var subs = new Array();
- if($data[i].industry.indexOf(',')) {
- subs = $data[i].industry.split(',');
- } else {
- subs[0] = $data[i].industry;
- }
- if(subs.length > 0) {
- var indu = "";
- for(var n = 0; n < subs.length; n++) {
- indu += "<span>" + subs[n] + "</span>";
- }
- }
- } else {
- var indu = "";
- }
- var add = '<li>'
- if(oFlag==1){
- add += '<a href="articalInfo.html?oFlag=1&articleId=' + $data[i].articleId + '&professorId=' + professorId + '">'
- }else{
- add += '<a href="articalInfo.html?articleId=' + $data[i].articleId + '&professorId=' + professorId + '">'
- }
- add += '<div class="art_topicBox">'
- add += '<div class="art_img"style="background-image:url(' + articleImg + ')"></div>'
- add += '<div class="art_tbox">'
- add += '<h6 id="artical_topic" >' + $data[i].articleTitle + '</h6>'
- add += '</div>'
- add += '</div>'
- add += '<div class="tagsBox">'
- add += indu
- add += '</div>'
- add += '</a>'
- add += '</li>'
- $(".otherRes").append(add);
- }
- }
- }
- },
- error: function() {
- return;
- }
- });
- }
- function message() {
- $.ajax({
- url: "/ajax/leaveWord/ql",
- dataType: 'json',
- type: 'GET',
- data: {
- "articleId": articleId
- },
- timeout: 10000,
- success: function(data) {
- var $info = data.data || {};
- if(data.success && data.data) {
- $(".commentList").html("");
- $(".message").text($info.length);
- for(var i = 0; i < $info.length; i++) {
-
- var time=timeGeshi($info[i].createTime)
- if($info[i].professor.hasHeadImage){
- var img='/images/head/' + $info[i].professor.id + '_l.jpg'
- }else{
- var img='../images/default-photo.jpg'
- }
- var string = '<li>'
- string += '<a class="proinfor clearfix">'
- string += '<div class="headblock floatL" style="width: 60px;"><img class="headimg userRadius" src="'+img+'" width="100%"></div>'
- string += '<div class="media-body floatL">'
- string += '<div><span class="listtit">'+$info[i].professor.name+'</span><span class="thistime">'+time+'</span></div>'
- string += '<p class="listtit3">'+$info[i].content+'</p>'
- if(userid==$info[i].professor.id){
- string += '<p class="listtit3" style="text-align:right;"><span style="cursor:pointer;" data-id="'+$info[i].id+'">删除</span></p>'
- }
- string += '</div></a></li>'
- $(".commentList").append(string);
- }
- }
- },
- error: function() {
- return;
- }
- });
- }
- function userInformation(){
- if(oFlag==1){
- $.ajax({
- url: "/ajax/org/" + professorId,
- type: "GET",
- timeout: 10000,
- dataType: "json",
- beforeSend: function() {},
- success: function(data, textState) {
- if(data.success) {
- var $data = data.data;
- $("#nameS").text($data.name);
- $("#proName").text($data.name);
- if($data.authStatus == 3) {
- $("#authFlag,#proTitle").replaceWith("<em class='authiconNew authicon-com-ok' title='认证企业'></em>");
- } else {
- $("#authFlag,#proTitle").replaceWith("");
- }
- if($data.hasOrgLogo) {
- $("#headImg,#proHead").attr("src", "/images/org/" + $data.id + ".jpg").addClass("headRadius").removeClass("userRadius");
- } else {
- $("#headImg,#proHead").attr("src", "images/default-icon.jpg").addClass("headRadius").removeClass("userRadius");
- }
- if($data.city) {
- $("#ocity").text($data.city);
- }
-
- if($data.orgSize) {
- switch($data.orgSize) {
- case '1':
- $("#qualificationList").text("50人以内")
- break;
- case '2':
- $("#qualificationList").text("50-100人")
- break;
- case '3':
- $("#qualificationList").text("100-200人")
- break;
- case '4':
- $("#qualificationList").text("200-500人")
- break;
- case '5':
- $("#qualificationList").text("500-1000人")
- break;
- default:
- $("#qualificationList").text("1000人以上")
- break;
- }
- }
- if($data.orgType) {
- switch($data.orgType) {
- case '2':
- $("#orgType").text("国有企业");
- break;
- case '3':
- $("#orgType").text("上市企业");
- break;
- case '4':
- $("#orgType").text("合资企业");
- break;
- case '5':
- $("#orgType").text("私人企业");
- break;
- case '6':
- $("#orgType").text("外资企业");
- break;
- default:
- $("#orgType").text("初创企业");
- break;
- }
- }
-
- }
- },
- error: function(XMLHttpRequest, textStats, errorThrown) {
- $.MsgBox.Alert('提示', '服务器请求失败')
- }
- })
- }else{
- $.ajax({
- url: "/ajax/professor/editBaseInfo/"+professorId,
- dataType: 'json',
- type: 'GET',
- timeout: 10000,
- success: function(data) {
- console.log(data);
- if(data.success && data.data) {
-
- $("#limg").attr("src","/images/head/" + data.data.id + "_l.jpg")
- }*/
- var $profesor=data.data;
- $("#nameS,#proName").text($profesor.name);
- var oString = todStr($profesor.title, $profesor.office, $profesor.department);
- $("#proTitle").text(oString);
- if($profesor.title) {
- if($profesor.office) {
- $("#orgType").text($profesor.title + " , "+$profesor.office);
- } else {
- $("#orgType").text($profesor.title);
- }
- }else{
- if($profesor.office) {
- $("#orgType").text($profesor.office);
- }
- }
- if($profesor.department) {
- $("#qualificationList").text($profesor.department);
- }
- if($profesor.orgName){
- $("#createTime").text($profesor.orgName)
- }
- if($profesor.address) {
- $("#ocity").text($profesor.address);
- }
- if($profesor.hasHeadImage) {
- $("#headImg,#proHead").attr("src", "/images/head/" + $profesor.id + "_l.jpg").addClass("userRadius").removeClass("headRadius")
- }else{
- $("#headImg,#proHead").attr("src", "images/default-photo.jpg").addClass("userRadius").removeClass("headRadius")
- }
- }
- },
- error: function(XMLHttpRequest) {
- $.MsgBox.Alert('提示', '服务器请求失败')
- }
- });
- }
- }
-
- function todStr() {
- var arr = new Array(),
- i;
- for(i in arguments) {
- if(arguments[i]) {
- arr.push(arguments[i])
- }
- }
- return arr.join();
- }
-
- function timeGeshi(otm) {
- var ti=otm.substring(4, 5);
- var otme;
- if(ti=="0"){
- otme =otm.substring(5, 6) + "月" + otm.substring(6, 8)+"日 "+otm.substring(8, 10)+":"+otm.substring(10, 12);
- }else{
- otme =otm.substring(4, 6) + "月" + otm.substring(6, 8)+"日 "+otm.substring(8, 10)+":"+otm.substring(10, 12);
- }
-
- return otme;
- }
- function article() {
- $.ajax({
- url:"/ajax/leaveWord",
- dataType: 'json',
- type: 'POST',
- data: {
- "articleId": articleId,
- "sender": userid,
- "content": $("textarea").val(),
- },
- timeout: 10000,
- success: function(data) {
- var $info = data.data || {};
- if(data.success && data.data) {
- document.getElementsByTagName("textarea")[0].value = "";
- document.getElementById("meSend").style.background="#dadada";
- message();
- }
- },
- error: function() {
- $.MsgBox.Alert('提示', '服务器请求失败')
- }
- });
- }
- function trim(str) {
-
- return str.replace(/(^\s*)|(\s*$)/g, "");
- }
- document.getElementsByTagName("textarea")[0].addEventListener("keyup", function() {
- var valueLength = document.getElementsByTagName("textarea")[0].value;
- var length = trim(valueLength);
- if(length) {
- $("#meSend").addClass("colorAdd");
- document.getElementById("meSend").style.background="#ff9900";
- } else {
- $("#meSend").removeClass("colorAdd");
- document.getElementById("meSend").style.background="#dadada";
- }
- });
- $(".goMsgbox").on('click', '.colorAdd', function() {
- article();
- });
- function luser(){
- $.ajax({
- url: "/ajax/professor/editBaseInfo/"+userid,
- dataType: 'json',
- type: 'GET',
- timeout: 10000,
- success: function(data) {
- if(data.success && data.data) {
- if(data.data.hasHeadImage==1){
- $("#limg").attr("src","/images/head/" + data.data.id + "_l.jpg")
- }
-
- }
- },
- error: function(XMLHttpRequest) {
- $.MsgBox.Alert('提示', '服务器请求失败');
- }
- });
- }
- proInfoMain();
- proArticle();
- message();
- userInformation();
- luser();
-
- $(".commentList").on("click","span:contains('删除')",function(){
- var oDid=$(this).attr("data-id");
- var $this=$(this);
- $.ajax({
- url: "/ajax/leaveWord/delete",
- dataType: 'json',
- type: 'POST',
- timeout: 10000,
- data:{
- "id":oDid
- },
- success: function(data) {
- if(data.success) {
- $this.parents('li').remove();
- var oNum=$(".message").eq(0).text();
- $(".message").text(oNum-1);
- }
- },
- error: function(XMLHttpRequest) {
- $.MsgBox.Alert('提示', '服务器请求失败')
- }
- });
- })
-
- $("#details").click(function(){
- if(oFlag==1){
- location.href="companybrowinfor.html?orgId="+professorId;
- }else{
- location.href="information-brow.html?professorId="+professorId;
- }
-
- })
-
- var oIsGree = {
-
- inquiry: function() {
- $.ajax({
- url: "/ajax/article/isAgree",
- dataType: 'json',
- type: 'GET',
- timeout: 10000,
- data: {
- operateId:userid,
- articleId:articleId
- },
- success: function(data) {
- if(data.success) {
- if(data.data==null){
- $(".plus").attr("data-flag","0");
- }else{
- $(".plus").attr("data-flag","1");
- $(".plus").css("background-position-y","-26px");
- }
- }
- },
- error: function(XMLHttpRequest) {
- $.MsgBox.Alert('提示', '服务器请求失败');
- }
- });
- },
-
- favour:function() {
- $(".plus").click(function(){
- if(userid == "null"||userid==undefined){
- location.href="login.html";
- return;
- }
- var isgree=$(this).attr("data-flag");
- if(isgree==0){
- oIsGree.articleIsAgree();
- }else{
- oIsGree.articleNoIsAgree();
- }
- });
- },
-
- articleIsAgree:function(){
- $.ajax({
- url: "/ajax/article/agree",
- dataType: 'json',
- type: 'POST',
- timeout: 10000,
- data: {
- operateId:userid,
- articleId:articleId
- },
- success: function(data) {
- if(data.success) {
- $(".plus").attr("data-flag","1");
- $(".plus").css("background-position-y","-26px");
- $(".message1").text(parseInt($(".message1").html())+1);
- }
- },
- error: function(XMLHttpRequest) {
- $.MsgBox.Alert('提示', '服务器请求失败');
- }
- });
- },
-
- articleNoIsAgree:function(){
- $.ajax({
- url: "/ajax/article/unAgree",
- dataType: 'json',
- type: 'POST',
- timeout: 10000,
- data: {
- operateId:userid,
- articleId:articleId
- },
- success: function(data) {
- if(data.success) {
- $(".plus").attr("data-flag","0");
- $(".plus").css("background-position-y","0px");
- $(".message1").text(parseInt($(".message1").html())-1);
- }
- },
- error: function(XMLHttpRequest) {
- $.MsgBox.Alert('提示', '服务器请求失败');
- }
- });
- }
- }
- oIsGree.inquiry();
- oIsGree.favour();
- var collection={
-
- inquiry:function(){
- $.ajax({
- url: "/ajax/watch/hasWatch",
- dataType: 'json',
- type: 'GET',
- timeout: 10000,
- data: {
- professorId:userid,
- watchObject:articleId
- },
- success: function(data) {
- if(data.success) {
- if(data.data==null){
- $("#attention").attr("data-flag","0");
- }else{
- $("#attention").attr("data-flag","1").css({"background":"url(../images/favoricon.png) 0 -26px no-repeat","background-size": "100% auto"});
- }
- }
- },
- error: function(XMLHttpRequest) {
- $.MsgBox.Alert('提示', '服务器请求失败');
- }
- });
- },
-
- attention:function() {
- $("#attention").click(function(){
- if(userid == "null"||userid==undefined){
- location.href="login.html";
- return;
- }
- var attFlag=$(this).attr("data-flag");
- if(attFlag==0){
- collection.attentionYes();
- }else{
- collection.attentionNo();
- }
- });
- },
-
- attentionYes:function(){
- $.ajax({
- url: "/ajax/watch",
- dataType: 'json',
- type: 'POST',
- timeout: 10000,
- data: {
- professorId:userid,
- watchObject:articleId,
- watchType:3
- },
- success: function(data) {
- if(data.success) {
- $("#attention").attr("data-flag","1").css({"background":"url(../images/favoricon.png) 0 -26px no-repeat","background-size": "100% auto"});
- }
- },
- error: function(XMLHttpRequest) {
- $.MsgBox.Alert('提示', '服务器请求失败');
- }
- });
- },
-
- attentionNo:function(){
- $.ajax({
- url: "/ajax/watch/delete",
- dataType: 'json',
- type: 'POST',
- timeout: 10000,
- data: {
- professorId:userid,
- watchObject:articleId
- },
- success: function(data) {
- if(data.success) {
- $("#attention").attr("data-flag","0").css({"background":"url(../images/favoricon.png) 0 -50px no-repeat","background-size": "100% auto"});
- }
- },
- error: function(XMLHttpRequest) {
- $.MsgBox.Alert('提示', '服务器请求失败');
- }
- });
- }
- };
- collection.inquiry();
- collection.attention();
- })
|