123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422 |
- $(function() {
- $(".onlogin .headnavbtn li").eq(0).addClass("navcurrent");
- loginStatus();
- var userid = $.cookie("userid");
- var oAuthType=0;
-
- getProfessorData(userid);
-
- queryUnreadConsultFn(userid);
-
- getConsultData(userid);
-
- getReplyData(userid);
-
- getDataResource();
-
- myNews();
-
- $("#myFlatSendReplyBtn").bind("click", newReplySendFn);
-
- $("#lookMyConsult").on("click", function() {
- if(ifuser.authType2 == 0) {
- window.location.href = "myConsult.html";
- } else {
- window.location.href = "consult.html";
- }
- })
-
-
- $("#lookconsu").on("click", function() {
- var consultid = $("#myFlatConsultTime").attr("consultid");
- window.location.href = "consultSure.html?consultid="+consultid;
- })
-
- function getProfessorData(professorId) {
- $.ajax({
- "url": "/ajax/professor/editBaseInfo/" + professorId,
- "type": "get",
- "async": true,
- "success": function(data) {
- if(data.success) {
- oAuthType=data.data.authType;
- if(oAuthType==0){
- $("#ponUm").text("个我正在发布的需求");
- $("#searchDemand").text(">>点击查看");
- demandNumMy();
- }else if(oAuthType==1){
- demandNum();
- }
- $("#nameS").text(data.data.name);
- $("#allConsultCount").text(data.data.consultCount);
-
- var oSty=autho(data.data.authType,data.data.orgAuth,data.data.authStatus);
- $("#nameIcon").addClass(oSty.sty);
- $("#nameIcon").attr("title",oSty.title);
-
- if(data.data.office) {
- if(data.data.title) {
- $("#office").text(data.data.office + ",");
- } else {
- $("#office").text(data.data.office);
- }
- }
- if(data.data.title) {
- $("#title").text(data.data.title);
- }
- if(data.data.department) {
- if(data.data.orgName) {
- $("#department").text(data.data.department + ",");
- } else {
- $("#department").text(data.data.department);
- }
- }
- if(data.data.orgName) {
- $("#organization").text(data.data.orgName);
- }
- if(data.data.address) {
- $("#address").text(data.data.address);
- }
- if(data.data.hasHeadImage) {
- $(".imgProfess").attr("src", "/images/head/" + userid + "_l.jpg");
- } else {
- $(".imgProfess").attr("src", "/images/default-photo.jpg");
- }
- var startLeval = parseInt(data.data.starLevel);
- for(var i = 0; i < startLeval; i++) {
- $(".evastar2").eq(i).addClass("startStyle");
- }
- } else {
- $.MsgBox.Alert("消息", "获取专家数据失败!");
- }
- },
- "error": function() {
- $.MsgBox.Alert('message', '获取专家数据失败')
- }
- })
- }
- function queryUnreadConsultFn(professorId) {
- var params = {
- "professorId": professorId
- };
- $.ajax({
- "url": "/ajax/consult/qaReadStatus",
- "type": "get",
- "async": false,
- "data": params,
- "success": function(response) {
- $("#unreadConsult").html(response["data"]);
- },
- "error": function() {
- $.MsgBox.Alert('message', '总的未读咨询条数请求失败');
- }
- });
- };
- function getConsultData(professorId) {
- var params = {
- "professorId": professorId
- };
- $.ajax({
- "url": "/ajax/consult/qaNewConsult",
- "type": "get",
- "async": false,
- "data": params,
- "success": function(response) {
- if(response.success) {
- if(response.data != null) {
- var newConsultData = response["data"];
- $("#myFlatConsultTime").attr("consultId", newConsultData["consultId"]);
- $("#myFlatProName").text(newConsultData["professor"]["name"]);
- if(newConsultData["professor"]["office"]) {
- $("#myReplyProOffice").html(newConsultData["professor"]["office"] + ",");
- }
- if(newConsultData["professor"]["title"]) {
- $("#myReplyProTitle").html(newConsultData["professor"]["title"]);
- }
- if(newConsultData["professor"]["department"]) {
- $("#myReplyProDepartment").html(newConsultData["professor"]["department"] + ",");
- }
- if(newConsultData["professor"]["orgName"]) {
- $("#myReplyProOrgName").html(newConsultData["professor"]["orgName"]);
- }
- if(newConsultData["professor"]["address"]) {
- $("#myReplyAddress").html(newConsultData["professor"]["address"]);
- }
- $("#myFlatConsultTime").html(newConsultData["createTime"].substr(0, 4) + "-" + newConsultData["createTime"].substr(4, 2) + "-" + newConsultData["createTime"].substr(6, 2) + " " +
- newConsultData["createTime"].substr(8, 2) + ":" + newConsultData["createTime"].substr(10, 2));
- $("#myFlatConsultTitle").html(newConsultData["consultTitle"]);
- $("#myFlatConsultContent").html(newConsultData["consultContant"]);
- if(response.data.professor.hasHeadImage) {
- $("#proImage").attr("src", "images/head/" + response.data.professor.id + "_m.jpg");
- } else {
- $("#proImage").attr("src", "images/default-photo.jpg");
- }
- $("#imgusr").attr("href", "information-brow.html?professorId="+response.data.professor.id);
- } else {
- $("#wbcon1").empty("");
- var height = $("#repalyf").outerHeight(true);
- $("#wbcon1").append('<span id="wbcen">暂无最新咨询消息</span>').css("height", height);
- var oHeight = ($("#wbcon1").height() - $("#wbcen").height()) / 2;
- $("#wbcen").css({
- "color": "#999",
- "display": "block",
- "margin-top": oHeight,
- "text-align": "center"
- });
- }
- } else {
- $.MsgBox.Alert("消息", "最新咨询数据请求失败");
- }
- },
- "error": function() {
- $.MsgBox.Alert('message', '最新咨询数据请求失败');
- }
- })
- }
- function getReplyData(consultantId) {
- var params = {
- "consultantId": consultantId
- };
- $.ajax({
- "url": "/ajax/tidings/qaNewReply",
- "type": "get",
- "async": true,
- "data": params,
- "success": function(response) {
- if(response.success) {
- if(response["data"] != null) {
- var newReplyData = response["data"];
- $("#myFlatRelpyTime").attr("consultId", newReplyData["consult"]["consultId"]);
- $("#myFlatReplyProName").html(newReplyData["professor"]["name"]);
- if(newReplyData["professor"]["office"]) {
- $("#myProOffice").html(newReplyData["professor"]["office"] + ",");
- }
- if(newReplyData["professor"]["title"]) {
- $("#myProTitle").html(newReplyData["professor"]["title"]);
- }
- if(newReplyData["professor"]["department"]) {
- $("#myProDepartment").html(newReplyData["professor"]["department"] + ",");
- }
- if(newReplyData["professor"]["orgName"]) {
- $("#myProOrgName").html(newReplyData["professor"]["orgName"]);
- }
- if(newReplyData["professor"]["address"]) {
- $("#myAddress").html(newReplyData["professor"]["address"]);
- }
- $("#myFlatRelpyTime").html(newReplyData["createTime"].substr(0, 4) + "-" + newReplyData["createTime"].substr(4, 2) + "-" + newReplyData["createTime"].substr(6, 2) + " " +
- newReplyData["createTime"].substr(8, 2) + ":" + newReplyData["createTime"].substr(10, 2));
- $("#myFlatRelpyTitle").html(newReplyData["consult"]["consultTitle"]);
- $("#myFlatRelpyContent").html(newReplyData["tidingsContant"]);
- if(response.data.professor.hasHeadImage) {
- $("#proreplayImage").attr("src", "images/head/" + response.data.professor.id + "_m.jpg");
- } else {
- $("#proreplayImage").attr("src", "images/default-photo.jpg");
- }
- $("#imgusr2").attr("href", "information-brow.html?professorId="+response.data.professor.id);
- } else {
- $("#wbcon2").empty("")
- var height = $("#wbcon1").outerHeight(true);
- $("#wbcon2").append('<span id="wbcent">暂无最新回复消息</span>').css("height", height);
- var oHeight = ($("#wbcon2").height() + 16 - $("#wbcent").height()) / 2;
- $("#wbcent").css({
- "color": "#999",
- "display": "block",
- "margin-top": oHeight,
- "text-align": "center"
- });
- }
- } else {
- $.MsgBox.Alert('message', '最新回复数据请求失败');
- }
- },
- "error": function() {
- $.MsgBox.Alert('message', '最新回复数据请求失败');
- }
- })
- }
- function newReplySendFn() {
- var consultId = $("#myFlatRelpyTime").attr("consultId");
- var consultCon = $("#myFlatReplyCon").val();
- var params = {
- "tidingsContant": consultCon,
- "consultId": consultId,
- "senderId": userid
- }
- $.ajax({
- url: "/ajax/tidings",
- type: "post",
- async: false,
- "contentType": "application/x-www-form-urlencoded",
- data: params,
- success: function(response) {
- getReplyData(userid);
- },
- error: function(error) {
- }
- });
-
- $("#myFlatReplyCon").val("");
- };
- function getDataResource() {
- $.ajax({
- "url": "/ajax/resource/qapro",
- "type": "get",
- "async": true,
- "data": {
- "professorId": userid
- },
- "success": function(data) {
- if(data.success) {
- var add = '';
- $("#consdcen").html("");
- for(var i = 0; i < data.data.length; i++) {
- var add = '<div class="addworkbtn-list"><a href="resourceInfo.html?resourceId=' + data.data[i].resourceId + '"><div class="resoumag">'
- add += '<div class="ResImgBox" style="max-width:200px;width:200px;height: 200px;"><img class="resImg headRadius resourceImg" src="" /></div>'
- add += '<h2>' + data.data[i].resourceName + '</h2>'
- add += '<p>' + data.data[i].supportedServices + '</p>'
- add += '</div></a></div>';
- $add = $(add);
- $("#consdcen").append($add);
- if(data.data[i].subject == undefined) {
- $(".li1").eq(i).css({
- "display": "none"
- });
- }
- $add.find('.resoumag').attr("resourceId", data.data[i].resourceId);
-
- if(data.data[i].images.length) {
- $add.find(".resourceImg").attr("src", "/images/resource/" + data.data[i].resourceId + ".jpg");
- } else {
- $add.find(".resourceImg").attr("src", "/images/default-resource.jpg");
- }
- }
- $(".addworkbtn-list:gt(2)").css({
- "display": "none"
- });
- } else {
- $.MsgBox.Alert('message', "系统异常!");
- }
- },
- "error": function() {
- $.MsgBox.Alert('message', 'failed')
- }
- });
- }
- function myNews() {
- $.ajax({
- "url": "/ajax/article/qaPro",
- "type": "get",
- "async": true,
- "data": {
- "professorId": userid
- },
- "success": function(data) {
- if(data.success) {
- var add = '';
- $("#myNews").html("");
- for(var i = 0; i < data.data.length; i++) {
- var add = '<li><a href="articalInfo.html?articleId=' + data.data[i].articleId + '&professorId=' + data.data[i].professorId + '">'
- add += '<div class="art_topicBox"><div class="art_img" style=""></div>'
- add += '<div class="art_tbox"><h6 id="artical_topic" >' + data.data[i].articleTitle + '</h6></div>'
- add += '</div><div class="tagsBox"><span></span></div>'
- add += '</a></li>';
- $add = $(add);
- $("#myNews").append($add);
- $add.find('.tagsBox span').text(data.data[i].industry);
- if(data.data[i].articleImg) {
- $add.find(".art_img").attr("style", "background: url(/data/article/" + data.data[i].articleImg + ") 0 0 no-repeat;background-size:cover;");
- }
- }
- $("#myNews li:gt(2)").css({
- "display": "none"
- });
- } else {
- $.MsgBox.Alert('消息', "链接服务器超时!");
- }
- },
- "error": function() {
- $.MsgBox.Alert('消息', '链接服务器超时!')
- }
- });
- }
- $("#dett,#searchDemand").click(function(){
-
- if(oAuthType==0){
- location.href="myDemand.html"
- }else if(oAuthType==1){
- location.href="needList.html"
- }
- })
-
- function demandNumMy(){
- $.ajax({
- "url":"/ajax/demand/queryMyPublish" ,
- "type": "get",
- "async": true,
- "data":{
- "demander": userid
- },
- "success": function(data) {
- if(data.success) {
- $("#demandNumber").text(data.data)
- } else {
- $.MsgBox.Alert('消息', data.msg);
- }
- },
- "error": function(x) {
- $.MsgBox.Alert('消息', '链接服务器超时!')
- }
- });
- }
- function demandNum(){
- $.ajax({
- "url":"/ajax/demand/queryPublish" ,
- "type": "get",
- "async": true,
- "success": function(data) {
-
- if(data.success) {
- $("#demandNumber").text(data.data)
- } else {
- $.MsgBox.Alert('消息', data.msg);
- }
- },
- "error": function() {
- $.MsgBox.Alert('消息', '链接服务器超时!')
- }
- });
- }
- });
|