|
$(function() {
loginStatus(); //判断个人是否登录
var userid = $.cookie("userid");
var orgId = GetQueryString("orgId");
var oName = "";
var watchType=0;
if(orgId) {
getCmpInfo(orgId); //获取详细信息
getResource( 10,1, true); //获取发布的资源
getArticle(10, 1, true); //获取发布的文章
getDemands(10,1,true)//获取发布的需求
relevantarticalList();//相关文章
likeExperts();//感兴趣专家
attentMy();
ifcollectionAbout(orgId,$(".goSpan").find(".attenSpan"),6);
$(".navconBox").on("click","li",function(){
$(this).addClass("liNow").siblings().removeClass("liNow");
$(".leftconBox .leftconItem").eq($(".navconBox li").index(this)).show().siblings().hide();
})
$(".navconBox>.mainNavUl").on("click","li:not('.rightbtn')",function(){
$(".moreNav").hide();
})
$(".navconBox>.mainNavUl").on("click","li.rightbtn",function(){
$(".moreNav").show();
})
$(".moreNavUl").on("click","li",function(){//获取关注对象类型标志
watchType=$(this).attr("data-num");
$("#item7user>.coninfobox").show();
attentMy()
})
$("#attendmyGo").on("click",function(){
$(".mainNavUl li.rightbtn").addClass("liNow").siblings().removeClass("liNow");
$(".navconBox .moreNav").show();
$("#item7user").show().siblings().hide();
$(".moreNavUl li.attendMy").addClass("liNow").siblings().removeClass("liNow");
$("#item7user>.coninfobox").eq(7).show().siblings().hide();
attentMy();
})
//点击关注按钮
$("#attentBtn").on('click', function() {
if(userid && userid != null && userid != "null") {
if($(this).is('.attenedSpan')){
cancelCollectionAbout(orgId,$(this),6)
} else {
collectionAbout(orgId,$(this), 6);
}
guanzhuNum();
attentMy();
}else{
quickLog();
operatTab();
closeLog();
}
});
//点击查看全部资源
$(".coninfobox").on("click", "#seeMoreR", function() {
document.body.scrollTop = document.documentElement.scrollTop = 0;
$(".navconBox ul>li").eq(1).addClass("liNow").siblings().removeClass("liNow");
$("#item1user").hide();
$("#item2user").show();
})
//点击查看全部文章
$(".coninfobox").on("click", "#seeMoreA", function() {
document.body.scrollTop = document.documentElement.scrollTop = 0;
$(".navconBox ul>li").eq(2).addClass("liNow").siblings().removeClass("liNow");
$("#item1user").hide();
$("#item3user").show();
})
}
function subjectShow(data) {
console.log(data)
if(data != undefined && data.length != 0) {
var subs = new Array();
if(data.indexOf(',')) {
subs = data.split(',');
} else {
subs[0] = data;
}
if(subs.length > 0) {
for(var i = 0; i < subs.length; i++) {
$("#subjectShow").append("<li>" + subs[i] + "</li>");
};
}
}
}
function qualificationShow(data) {
if(data != undefined && data.length != 0) {
var subs = new Array();
if(data.indexOf(',')) {
subs = data.split(',');
} else {
subs[0] = data;
}
if(subs.length > 0) {
for(var i = 0; i < subs.length; i++) {
$("#qualification").append("<li><div class='h4tit'>" + subs[i] + "</div></li>");
};
}
}
}
//企业详细信息
function getCmpInfo(orgId) {
$.ajax({
type: "get",
url: "/ajax/org/" + orgId,
async: false,
success: function(data) {
var $info = data.data;
//console.log($info)
if(data.success) {
if($info.hasOrgLogo) {
$("#proHead").attr("src", "/images/org/" + $info.id + ".jpg");
}else{
$("#proHead").attr("src", "/images/default-icon.jpg");
}
if($info.forShort) {
$("#proName").text($info.forShort);
} else {
$("#proName").text($info.name);
}
oName = $info.name;
if($info.authStatus == "3") {
$("#proAuth").addClass("authicon-com-ok");
$("#proAuth").attr("title", "科袖认证企业");
}
if($info.city) {
$("#proAddress").html($info.city + "<span style='margin-right:10px;'></span>");
}
var proOther = "";
if($info.industry) {
proOther = $info.industry.replace(/,/gi, " | ");
}
$("#proOther").text(proOther);
if($info.orgType == "2") {
$("#proTit").html(orgTypeShow[$info.orgType] + "<span style='margin-right:10px;'></span>");
}
var llqtitle = $info.name + "-" + proOther + "科袖网"; //修改浏览器title信息
document.title = llqtitle;
//简介
if($info.descp) {
$("#item1user>.nodatabox").addClass("displayNone");
$("#descpS").parents(".coninfobox").removeClass("displayNone");
$("#descpS").text($info.descp);
} else {
$("#descpS").parents(".coninfobox").addClass("displayNone");
}
//学术领域
if($info.subject) {
$("#item1user>.nodatabox").addClass("displayNone");
$("#subjectShow").parents(".coninfobox").removeClass("displayNone");
subjectShow($info.subject);
} else {
$("#subjectShow").parents(".coninfobox").addClass("displayNone");
}
//企业资质
if($info.qualification) {
qualificationShow($info.qualification);
} else {
$("#qualification").parents(".coninfobox").hide();
}
//企业详情
$("#orgName").text($info.name);
if($info.orgSize) {
//console.log(typeof($info.orgSize),orgSizeShow[$info.orgSize])
$("#orgSize").text(orgSizeShow[$info.orgSize]);
} else {
$("#orgSize").parent("li").hide();
}
if($info.industry) {
$("#orgIndustry").text($info.industry);
} else {
$("#orgIndustry").parent("li").hide();
}
if($info.city) {
$("#orgCity").text($info.city);
} else {
$("#orgCity").parent("li").hide();
}
if($info.orgType) {
$("#orgType").text(orgTypeShow[$info.orgType]);
} else {
$("#orgType").parent("li").hide();
}
if($info.foundTime) {
$("#foundTime").text(TimeTr($info.foundTime));
} else {
$("#foundTime").parent("li").hide();
}
if($info.orgUrl) {
$("#orgUrl").text($info.orgUrl);
} else {
$("#orgUrl").parent("li").hide();
}
if($info.addr) {
$("#cmpAddress").text($info.addr);
} else {
$("#cmpAddress").parent("li").hide();
}
var weibotitle = $info.name;
var weibourl = window.location.href;
var weibopic = "http://" + window.location.host + "/images/org/" + $info.id + ".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");
}
},
error: function() {
$.MsgBox.Alert('提示', '链接服务器超时')
}
});
}
//获取资源
function getResource(pageSize, pageNo, isbind) {
$.ajax({
"url": "/ajax/resource/pqOrgPublish",
"type": "get",
"async": false,
"data": {
"orgId": orgId,
"pageSize": pageSize,
"pageNo": pageNo
},
"success": function(data) {
//console.log(data);
if(data.success) {
$("#proResource").html("");
if(data.data.data.length > 0) {
$("#showResource").parents(".coninfobox").removeClass("displayNone");
$("#item1user>.nodatabox").addClass("displayNone");
for(var i = 0; i < data.data.data.length; i++) {
var madiaHead = '';
if(data.data.data[i].images.length) {
madiaHead = '/data/resource/' + data.data.data[i].images[0].imageSrc;
} else {
madiaHead = '/images/default-resource.jpg';
}
var strAdd = '';
strAdd += '<li><a href="resourceShow.html?resourceId=' + data.data.data[i].resourceId + '" class="flexCenter urlgo">';
strAdd += '<div class="madiaHead resouseHead" style="background-image:url(' + madiaHead + ')"></div>';
strAdd += '<div class="madiaInfo"><p class="h1Font ellipsisSty-2">' + data.data.data[i].resourceName + '</p><p class="h2Font ellipsisSty">应用用途:' + data.data.data[i].supportedServices + '</p></div>';
strAdd += '</a></li>';
var $strAdd = $(strAdd);
$("#proResource").append(strAdd);
if(isbind==true && i==0){
var $strAddO=$(strAdd);
$("#showResource").html("");
$("#showResource").append($strAddO);
}
}
if(isbind == true) {
$(".resoucePageCode").off("click").createPage({
pageCount: Math.ceil(data.data.total / 10),
current: data.data.pageNo,
backFn: function(p) {
$("#proResource").html("");
getResource(10, p, false);
//document.body.scrollTop = document.documentElement.scrollTop = 0;
}
});
}
} else {
$("#item2user .nodatabox").show();
$("#item2user .nodatabox").find(".noContip").text("企业尚未发布任何资源");
}
}
},
"error": function() {
$.MsgBox.Alert("提示", "服务器连接超时")
}
});
}
//获取文章
function getArticle(pageSize, pageNo, isbind) {
$.ajax({
url: "/ajax/article/pqOrgPublish",
dataType: 'json', //数据格式类型
type: 'GET', //http请求类型
data: {
"orgId": orgId,
"pageSize": pageSize,
"pageNo": pageNo
},
timeout: 10000, //超时设置
success: function(data) {
if(data.success) {
$("#proArticel").html("");
if(data.data.data.length > 0) {
$("#showArticle").parents(".coninfobox").removeClass("displayNone");
$("#item1user>.nodatabox").addClass("displayNone");
for(var i = 0; i < data.data.data.length; i++) {
var madiaHead = '/images/default-artical.jpg';
if(data.data.data[i].articleImg) {
madiaHead = '/data/article/' + data.data.data[i].articleImg;
}
var sowU='';
if(data.data.data[i].pageViews!=0){
if(data.data.data[i].articleAgree!=0){
sowU='<li><span>阅读量 '+data.data.data[i].pageViews+'</span></li><li><span>赞 '+data.data.data[i].articleAgree+'</span></li>'
}else{
sowU='<li><span>阅读量 '+data.data.data[i].pageViews+'</span></li>'
}
}
var strAdd = '';
strAdd += '<li><a href="articalShow.html?articleId=' + data.data.data[i].articleId + '" class="flexCenter urlgo">';
strAdd += '<div class="madiaHead artHead" style="background-image:url(' + madiaHead + ')"></div>';
strAdd += '<div class="madiaInfo"><p class="h1Font ellipsisSty-2">' + data.data.data[i].articleTitle + '</p>';
strAdd += '<ul class="h2Font clearfix">';
strAdd += '<li><span class="time">' + commenTime(data.data.data[i].publishTime) + '</span></li>';
strAdd += sowU
strAdd += '<li><span class="comment"></span></li>';
strAdd += '</ul></div>';
strAdd += '</a></li>';
var $strAdd = $(strAdd);
$("#proArticel").append($strAdd);
commentnum(data.data.data[i].articleId, $strAdd) //文章评论数
if(isbind==true && i==0){
var $strAddO = $(strAdd);
$("#showArticle").append($strAddO);
commentnum(data.data.data[0].articleId,$strAddO)
}
}
if(isbind == true) {
$(".expertPageCode").off("click").createPage({
pageCount: Math.ceil(data.data.total / 10),
current: data.data.pageNo,
backFn: function(p) {
$("#proArticel").html("");
getArticle(10, p, false);
//document.body.scrollTop = document.documentElement.scrollTop = 0;
}
});
}
} else {
$("#item3user .nodatabox").show();
$("#item3user .nodatabox").find(".noContip").text("企业尚未发布任何文章");
var i = 0;
$("#item1user").find('.coninfobox').each(function() {
if($(this).css("display") == "none") {
i++;
}
})
if(i == 4) {
$("#item1user").hide();
$(".navconBox ul>li").eq(3).addClass("liNow").siblings().removeClass("liNow");
$("#item6user").show();
}
}
}
},
error: function() {
return;
}
});
}
//查文章评论数
function commentnum(articleId, $itemlist) {
$.ajax({
"url": "/ajax/leaveWord/lwCount",
"type": "GET",
"dataType": "json",
"async": false,
"data": {
"articleId": articleId
},
"success": function(data) {
if(data.success) {
if(data.data>0){
$itemlist.find(".comment").text("留言 " + data.data);
}
}
},
"error": function() {
$.MsgBox.Alert('提示', '链接服务器超时')
}
});
}
//关注企业数量
function guanzhuNum() {
$.ajax({
"url": "/ajax/watch/countProfessor",
"type": "GET",
"dataType": "json",
"async": true,
"data": {
"id": orgId,
"type": 6
},
"success": function(data) {
if(data.success) {
$("#attenNum").text(data.data);
}
},
"error": function() {
$.MsgBox.Alert('提示', '链接服务器超时')
}
});
}
guanzhuNum();
function comNum() {
$.ajax({
"url": "/ajax/org/regInfo",
"type": "get",
"dataType": "json",
"data": {
"name": oName
},
"success": function(data) {
if(data.success) {
if(data.data) {
var $data = data.data;
var str = "";
if($data.num) {
str += "<li>工商注册号:" + $data.num + "</li>"
}
if($data.code) {
str += "<li>组织机构代码:" + $data.code + "</li>"
}
if($data.creditCode) {
str += "<li>统一信用代码:" + $data.creditCode + "</li>"
}
if($data.type) {
str += "<li>企业类型:" + $data.type + "</li>"
}
if($data.industry) {
str += "<li>行业:" + $data.industry + "</li>"
}
if($data.operatingPeriod) {
str += "<li>营业期限:" + $data.operatingPeriod + "</li>"
}
if($data.dayOfApproval) {
str += "<li>核准日期:" + $data.dayOfApproval + "</li>"
}
if($data.manager) {
str += "<li>登记机关:" + $data.manager + "</li>"
}
if($data.addr) {
str += "<li>注册地址:" + $data.addr + "</li>"
}
if($data.scopeOfBusiness) {
str += "<li>经营范围:" + $data.scopeOfBusiness + "</li>"
}
$("#comMes").html(str);
}else {
$("#comMes").parents(".coninfobox").hide();
}
}else{
$("#comMes").parents(".coninfobox").hide();
}
},
"error": function() {
$.MsgBox.Alert('提示', '链接服务器超时')
}
});
}
comNum();
industryCommerce();
function industryCommerce() {
$.ajax({
"url": "/ajax/org/incPageViews",
"type": "POST",
"dataType": "json",
"async": true,
"data": {
"id": orgId,
},
"success": function(data) {
if(data.success) {
console.log(data);
}
},
"error": function() {
$.MsgBox.Alert('提示', '链接服务器超时')
}
});
}
//相关文章信息
function relevantarticalList(){
$.ajax({
"url" : "/ajax/article/byAssOrg",
"type" : "GET" ,
"dataType" : "json",
"data" :{"id":orgId},
//"async":false,
"traditional": true, //传数组必须加这个
"success" : function(data) {
console.log(data);
if (data.success && data.data!=""){
$("#relateArt").parents(".conBlock").removeClass("displayNone");
var itemlist = '';
$("#relateArt").html("");
for(var i = 0; i < data.data.length; i++) {
var itemlist = '<li class="flexCenter"><a target="_blank" href="articalShow.html?articleId='+ data.data[i].articleId +'" class="urlgo">';
itemlist += '<p class="h2Font ellipsisSty-2"><em class="circlePre"></em>'+data.data[i].articleTitle+'</p>';
itemlist += '</a></li>';
$itemlist = $(itemlist);
$("#relateArt").append($itemlist);
}
}
},
"error":function(){
$.MsgBox.Alert('提示','链接服务器超时')
}
});
}
//感兴趣
function likeExperts(){
$.ajax({
"url": "/ajax/org/ralateOrgs",
"type": "get",
"dataType" : "json",
"data" :{"orgId":orgId},
"success": function(data) {
if(data.success && data.data) {
console.log(data)
var lengthT;
if(data.data.length>5){
lengthT=5;
}else{
lengthT=data.data.length
}
for(var i = 0; i < lengthT; i++) {
var ExpId = data.data[i].id;
likeExpertsList(ExpId);
}
}
},
"error": function() {
$.MsgBox.Alert('提示', '链接服务器超时')
}
});
}
//感兴趣信息
function likeExpertsList(Id){
$.ajax({
"url" : "/ajax/org/"+Id,
"type" : "GET" ,
"dataType" : "json",
"success" : function(data) {
if (data.success && data.data!=""){
$("#relateCmp").parents(".conBlock").removeClass("displayNone");
var itemlist = '<li class="flexCenter"><a target="_blank" href="" class="urlgo">';
itemlist += '<div class="madiaHead cmpHead cmpHead2"><div class="boxBlock">';
itemlist += '<img class="boxBlockimg" id="userimg" src="" /></div></div>';
itemlist += '<div class="madiaInfo">';
itemlist += '<p class="clearfix"><span class="h1Font ellipsisSty floatL" style="display:block;max-width:136px" id="userName"></span><em class="authiconNew floatL" title=""></em></p>';
itemlist += '<p class="ellipsisSty h2Font" id="usertitle"></p>';
itemlist += '</div></a></li>';
$itemlist = $(itemlist);
$("#relateCmp").append($itemlist);
if(data.data.forShort){
$itemlist.find("#userName").text(data.data.forShort);
}else{
$itemlist.find("#userName").text(data.data.name);
}
$itemlist.find(".urlgo").attr("href", "cmpInforShow.html?orgId="+data.data.id);
if(data.data.authStatus==3){
$itemlist.find(".authiconNew").addClass("authicon-com-ok");
$itemlist.find(".authiconNew").attr("title","科袖认证企业")
}
if(data.data.industry){
$itemlist.find("#usertitle").text(data.data.industry.replace(/,/gi, " | "));
}
if(data.data.hasOrgLogo == 1) {
$itemlist.find("#userimg").attr("src", "/images/org/" + data.data.id + ".jpg");
}else{
$itemlist.find("#userimg").attr("src","images/default-icon.jpg");
}
}
},
"error":function(){
$.MsgBox.Alert('提示','链接服务器超时')
}
});
}
//获取需求
function getDemands(pageSize, pageNo,isbind) {
$.ajax({
url: "/ajax/demand/pq",
type: "GET",
timeout: 10000,
dataType: "json",
data: {
"state":'1',
"oid":orgId,
"pageNo": pageNo,
"pageSize":pageSize
},
beforeSend: function() {
$("#showDemand").append('<img src="../images/loading.gif" class="loading" />');
},
success: function(data) {
if(data.success) {
$("#showDemand").html(" ");
var $info = data.data.data;
if($info.length > 0){
$("#showDemand").parents(".needinfobox").removeClass("displayNone");
$("#item1user>.nodatabox").addClass("displayNone");
for(var i = 0; i < $info.length; i++) {
var liStr=$("<li></li>").appendTo("#showDemand");
demandHtml($info[i],liStr);
}
}else{
$("#showDemand").parents(".needinfobox").addClass("displayNone");
}
}
$(".loading").remove();
},
error: function() {
$.MsgBox.Alert('提示', '链接服务器超时')
}
})
}
function demandHtml($data,liStr) {
var sowU="";
if($data.pageViews!=0){
sowU='<li><span>浏览量 '+$data.pageViews +'</span></li>'
}
var strCon='';
strCon+='<a class="" target="_blank" href="demandShow.html?demandId='+$data.id+'" class="madiaInfo">'
strCon+='<p class="h1Font ellipsisSty">'+ $data.title +'</p>'
strCon+='<ul class="showliTop h3Font clearfix">'
strCon+='<li><span>发布于 '+TimeTr($data.createTime)+'</span></li>'
strCon+= sowU
strCon+='</ul>'
strCon+='<p class="h2Font ellipsisSty-2">'+$data.descp+'</p>'
strCon+='<ul class="showli clearfix h3Font">'
if($data.city){ strCon+='<li>所在城市:'+$data.city+'</li>' }
if($data.duration!=0){ strCon+='<li>预期时长:'+demandDuration[$data.duration]+'</li>' }
if($data.cost!=0){ strCon+='<li>费用预算:'+demandCost[$data.cost]+'</li>' }
if($data.invalidDay){ strCon+='<li>有效期至:'+TimeTr($data.invalidDay)+'</li>' }
strCon+='</ul>'
strCon+='</a>'
$(strCon).appendTo(liStr);
}
//收藏与关注
function attentMy(){
var num=watchType;
$.ajax({
url: "/ajax/watch/qaWatch",
dataType: 'json', //数据格式类型
type: 'GET', //http请求类型
data: {
"watchObject": orgId,
},
timeout: 10000, //超时设置
success: function(data) {
if(data.success) {
document.getElementById("attendMy").innerHTML="";
document.getElementById("attendMy").parentNode.querySelector(".nodatabox").classList.add("displayNone");
if(data.data.length>0){
var datalist = data.data;
for(var i = 0; i < datalist.length; i++) {
var liItem = document.createElement("li");
liItem.className="mui-table-view-cell";
document.getElementById("attendMy").appendChild(liItem);
detailPro(datalist[i],liItem);
}
}else{
document.getElementById("attendMy").parentNode.querySelector(".nodatabox").classList.remove("displayNone");
}
}
},
error: function() {
return;
}
});
}
function detailPro(datalist,liItem) {
var userType = autho(datalist.professor.authType, datalist.professor.orgAuth, datalist.professor.authStatus);
var os = "";
if(datalist.professor.title) {
if(datalist.professor.orgName) {
os = datalist.professor.title + "," + datalist.professor.orgName;
} else {
os = datalist.professor.title;
}
} else {
if(datalist.professor.office) {
if(datalist.professor.orgName) {
os = datalist.professor.office + "," + datalist.professor.orgName;
} else {
os = datalist.professor.office;
}
} else {
if(datalist.professor.orgName) {
os = datalist.professor.orgName;
}
}
}
var baImg = "../images/default-photo.jpg";
if(datalist.professor.hasHeadImage == 1) {
baImg = "/images/head/" + datalist.professor.id + "_l.jpg";
}
var strAdd = '';
strAdd += '<a target="_blank" href="userInforShow.html?professorId='+ datalist.professor.id +'" class="flexCenter urlgo">';
strAdd += '<div class="madiaHead useHead" style="width: 80px;height: 80px;margin-top: -40px;background-image:url(' + baImg + ')"></div>';
strAdd += '<div class="madiaInfo" style="padding-left:92px"><p class="h1Font ellipsisSty">' + datalist.professor.name + '</span><em class="authicon ' + userType.sty + '" title="科袖认证专家"></em></p>';
strAdd += '<p class="h2Font ellipsisSty">' + os + '</p>';
strAdd += '</div>';
strAdd += '</a>';
liItem.innerHTML = strAdd
}
//纠错反馈
$(".correctSubmit").on("click",function(){
var cntCon=$(this).siblings(".correctCon").val();
var cntUser="";
if(userid && userid != null && userid != "null") {
cntUser = userid;
}
if(cntCon.length>500){
$.MsgBox.Alert('提示', '纠错反馈内容不得超过500个字');
return;
}else{
$.ajax({
"url": "/ajax/feedback/error/org",
"type": "POST",
"dataType": "json",
"async": true,
"data": {
"id": orgId,
"cnt":cntCon,
"user":cntUser
},
"success": function(data) {
if(data.success) {
backSuccessed();
}
},
"error": function() {
$.MsgBox.Alert('提示', '链接服务器超时')
}
});
}
})
})
|