portal html css js resource

workindex.js 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  1. $(function() {
  2. loginStatus();//判断个人是否登录
  3. var userid = $.cookie("userid");
  4. var oAuthType=0;
  5. /*工作台专家的数据*/
  6. getProfessorData(userid);
  7. /*工作台未读的咨询消息*/
  8. queryUnreadConsultFn(userid);
  9. /*工作台最新咨询*/
  10. getConsultData(userid);
  11. /*工作台最新回复*/
  12. getReplyData(userid);
  13. /*工作台我的资源*/
  14. getDataResource();
  15. /*工作台我的文章*/
  16. myNews();
  17. /*最新回复中的发送*/
  18. $("#myFlatSendReplyBtn").bind("click", newReplySendFn);
  19. /*点击未读咨询消息查看*/
  20. $("#lookMyConsult").on("click", function() {
  21. if(ifuser.authType2 == 0) {
  22. window.location.href = "myConsult.html";
  23. } else {
  24. window.location.href = "consult.html";
  25. }
  26. })
  27. /*点击未读咨询消息查看*/
  28. $("#lookconsu").on("click", function() {
  29. var consultid = $("#myFlatConsultTime").attr("consultid");
  30. window.location.href = "consultSure.html?consultid="+consultid;
  31. })
  32. function getProfessorData(professorId) {
  33. $.ajax({
  34. "url": "/ajax/professor/editBaseInfo/" + professorId,
  35. "type": "get",
  36. "async": true,
  37. "success": function(data) {
  38. if(data.success) {
  39. oAuthType=data.data.authType;
  40. if(oAuthType==0){
  41. $("#ponUm").text("个我正在发布的需求")
  42. demandNumMy();
  43. }else if(oAuthType==1){
  44. demandNum();
  45. }
  46. $("#nameS").text(data.data.name);
  47. $("#allConsultCount").text(data.data.consultCount);
  48. if(data.data.authType) {
  49. $(".modifyicon").addClass("authicon authicon-cu");
  50. } else {
  51. if(data.data.authStatus==3) {
  52. if(data.data.authentication == 1) {
  53. $(".modifyicon").addClass("authicon2 authicon-mana");
  54. //$(".modifyicon").html("<span style='top:12px'>科研</span>");
  55. } else if(data.data.authentication == 2) {
  56. $(".modifyicon").addClass("authicon2 authicon-staff");
  57. //$(".modifyicon").html("<span style='top:12px'>企业</span>");
  58. } else {
  59. $(".modifyicon").addClass("authicon2 authicon-stu");
  60. //$(".modifyicon").html("<span style='top:12px'>学生</span>");
  61. }
  62. }
  63. }
  64. if(data.data.office) {
  65. if(data.data.title) {
  66. $("#office").text(data.data.office + ",");
  67. } else {
  68. $("#office").text(data.data.office);
  69. }
  70. }
  71. if(data.data.title) {
  72. $("#title").text(data.data.title);
  73. }
  74. if(data.data.department) {
  75. if(data.data.orgName) {
  76. $("#department").text(data.data.department + ",");
  77. } else {
  78. $("#department").text(data.data.department);
  79. }
  80. }
  81. if(data.data.orgName) {
  82. $("#organization").text(data.data.orgName);
  83. }
  84. if(data.data.address) {
  85. $("#address").text(data.data.address);
  86. }
  87. if(data.data.hasHeadImage) {
  88. $(".imgProfess").attr("src", "/images/head/" + userid + "_l.jpg");
  89. } else {
  90. $(".imgProfess").attr("src", "/images/default-photo.jpg");
  91. }
  92. var startLeval = parseInt(data.data.starLevel);
  93. for(var i = 0; i < startLeval; i++) {
  94. $(".evastar2").eq(i).addClass("startStyle");
  95. }
  96. } else {
  97. $.MsgBox.Alert("消息", "获取专家数据失败!");
  98. }
  99. },
  100. "error": function() {
  101. $.MsgBox.Alert('message', '获取专家数据失败')
  102. }
  103. })
  104. }
  105. function queryUnreadConsultFn(professorId) {
  106. var params = {
  107. "professorId": professorId
  108. };
  109. $.ajax({
  110. "url": "/ajax/consult/qaReadStatus",
  111. "type": "get",
  112. "async": false,
  113. "data": params,
  114. "success": function(response) {
  115. $("#unreadConsult").html(response["data"]);
  116. },
  117. "error": function() {
  118. $.MsgBox.Alert('message', '总的未读咨询条数请求失败');
  119. }
  120. });
  121. };
  122. function getConsultData(professorId) {
  123. var params = {
  124. "professorId": professorId
  125. };
  126. $.ajax({
  127. "url": "/ajax/consult/qaNewConsult",
  128. "type": "get",
  129. "async": false,
  130. "data": params,
  131. "success": function(response) {
  132. if(response.success) {
  133. if(response.data != null) {
  134. var newConsultData = response["data"];
  135. $("#myFlatConsultTime").attr("consultId", newConsultData["consultId"]);
  136. $("#myFlatProName").text(newConsultData["professor"]["name"]);
  137. if(newConsultData["professor"]["office"]) {
  138. $("#myReplyProOffice").html(newConsultData["professor"]["office"] + ",");
  139. }
  140. if(newConsultData["professor"]["title"]) {
  141. $("#myReplyProTitle").html(newConsultData["professor"]["title"]);
  142. }
  143. if(newConsultData["professor"]["department"]) {
  144. $("#myReplyProDepartment").html(newConsultData["professor"]["department"] + ",");
  145. }
  146. if(newConsultData["professor"]["orgName"]) {
  147. $("#myReplyProOrgName").html(newConsultData["professor"]["orgName"]);
  148. }
  149. if(newConsultData["professor"]["address"]) {
  150. $("#myReplyAddress").html(newConsultData["professor"]["address"]);
  151. }
  152. $("#myFlatConsultTime").html(newConsultData["createTime"].substr(0, 4) + "-" + newConsultData["createTime"].substr(4, 2) + "-" + newConsultData["createTime"].substr(6, 2) + " " +
  153. newConsultData["createTime"].substr(8, 2) + ":" + newConsultData["createTime"].substr(10, 2));
  154. $("#myFlatConsultTitle").html(newConsultData["consultTitle"]);
  155. $("#myFlatConsultContent").html(newConsultData["consultContant"]);
  156. if(response.data.professor.hasHeadImage) {
  157. $("#proImage").attr("src", "images/head/" + response.data.professor.id + "_m.jpg");
  158. } else {
  159. $("#proImage").attr("src", "images/default-photo.jpg");
  160. }
  161. $("#imgusr").attr("href", "information-brow.html?professorId="+response.data.professor.id);
  162. } else {
  163. $("#wbcon1").empty("");
  164. var height = $("#repalyf").outerHeight(true);
  165. $("#wbcon1").append('<span id="wbcen">暂无最新咨询消息</span>').css("height", height);
  166. var oHeight = ($("#wbcon1").height() - $("#wbcen").height()) / 2;
  167. $("#wbcen").css({
  168. "color": "#999",
  169. "display": "block",
  170. "margin-top": oHeight,
  171. "text-align": "center"
  172. });
  173. }
  174. } else {
  175. $.MsgBox.Alert("消息", "最新咨询数据请求失败");
  176. }
  177. },
  178. "error": function() {
  179. $.MsgBox.Alert('message', '最新咨询数据请求失败');
  180. }
  181. })
  182. }
  183. function getReplyData(consultantId) {
  184. var params = {
  185. "consultantId": consultantId
  186. };
  187. $.ajax({
  188. "url": "/ajax/tidings/qaNewReply",
  189. "type": "get",
  190. "async": true,
  191. "data": params,
  192. "success": function(response) {
  193. if(response.success) {
  194. if(response["data"] != null) {
  195. var newReplyData = response["data"];
  196. $("#myFlatRelpyTime").attr("consultId", newReplyData["consult"]["consultId"]);
  197. $("#myFlatReplyProName").html(newReplyData["professor"]["name"]);
  198. if(newReplyData["professor"]["office"]) {
  199. $("#myProOffice").html(newReplyData["professor"]["office"] + ",");
  200. }
  201. if(newReplyData["professor"]["title"]) {
  202. $("#myProTitle").html(newReplyData["professor"]["title"]);
  203. }
  204. if(newReplyData["professor"]["department"]) {
  205. $("#myProDepartment").html(newReplyData["professor"]["department"] + ",");
  206. }
  207. if(newReplyData["professor"]["orgName"]) {
  208. $("#myProOrgName").html(newReplyData["professor"]["orgName"]);
  209. }
  210. if(newReplyData["professor"]["address"]) {
  211. $("#myAddress").html(newReplyData["professor"]["address"]);
  212. }
  213. $("#myFlatRelpyTime").html(newReplyData["createTime"].substr(0, 4) + "-" + newReplyData["createTime"].substr(4, 2) + "-" + newReplyData["createTime"].substr(6, 2) + " " +
  214. newReplyData["createTime"].substr(8, 2) + ":" + newReplyData["createTime"].substr(10, 2));
  215. $("#myFlatRelpyTitle").html(newReplyData["consult"]["consultTitle"]);
  216. $("#myFlatRelpyContent").html(newReplyData["tidingsContant"]);
  217. if(response.data.professor.hasHeadImage) {
  218. $("#proreplayImage").attr("src", "images/head/" + response.data.professor.id + "_m.jpg");
  219. } else {
  220. $("#proreplayImage").attr("src", "images/default-photo.jpg");
  221. }
  222. $("#imgusr2").attr("href", "information-brow.html?professorId="+response.data.professor.id);
  223. } else {
  224. $("#wbcon2").empty("")
  225. var height = $("#wbcon1").outerHeight(true);
  226. $("#wbcon2").append('<span id="wbcent">暂无最新回复消息</span>').css("height", height);
  227. var oHeight = ($("#wbcon2").height() + 16 - $("#wbcent").height()) / 2;
  228. $("#wbcent").css({
  229. "color": "#999",
  230. "display": "block",
  231. "margin-top": oHeight,
  232. "text-align": "center"
  233. });
  234. }
  235. } else {
  236. $.MsgBox.Alert('message', '最新回复数据请求失败');
  237. }
  238. },
  239. "error": function() {
  240. $.MsgBox.Alert('message', '最新回复数据请求失败');
  241. }
  242. })
  243. }
  244. function newReplySendFn() {
  245. var consultId = $("#myFlatRelpyTime").attr("consultId");
  246. var consultCon = $("#myFlatReplyCon").val();
  247. var params = {
  248. "tidingsContant": consultCon,
  249. "consultId": consultId,
  250. "senderId": userid
  251. }
  252. $.ajax({
  253. url: "/ajax/tidings",
  254. type: "post",
  255. async: false,
  256. "contentType": "application/x-www-form-urlencoded",
  257. data: params,
  258. success: function(response) {
  259. getReplyData(userid);
  260. },
  261. error: function(error) {
  262. }
  263. });
  264. // $.MsgBox.Alert("消息","回复成功!");
  265. $("#myFlatReplyCon").val("");
  266. };
  267. function getDataResource() {
  268. $.ajax({
  269. "url": "/ajax/resource/qapro",
  270. "type": "get",
  271. "async": true,
  272. "data": {
  273. "professorId": userid
  274. },
  275. "success": function(data) {
  276. if(data.success) {
  277. var add = '';
  278. $("#consdcen").html("");
  279. for(var i = 0; i < data.data.length; i++) {
  280. var add = '<div class="addworkbtn-list"><a href="resourceInfo.html?resourceId=' + data.data[i].resourceId + '"><div class="resoumag">'
  281. add += '<div class="ResImgBox" style="max-width:200px;width:200px;height: 200px;"><img class="resImg headRadius resourceImg" src="" /></div>'
  282. add += '<h2>' + data.data[i].resourceName + '</h2>'
  283. add += '<p>' + data.data[i].supportedServices + '</p>'
  284. add += '</div></a></div>';
  285. $add = $(add);
  286. $("#consdcen").append($add);
  287. if(data.data[i].subject == undefined) {
  288. $(".li1").eq(i).css({
  289. "display": "none"
  290. });
  291. }
  292. $add.find('.resoumag').attr("resourceId", data.data[i].resourceId);
  293. //$('.resoumag').eq(i+1).attr("resourceId",data.data[i].resourceId);
  294. if(data.data[i].images.length) {
  295. $add.find(".resourceImg").attr("src", "/images/resource/" + data.data[i].resourceId + ".jpg");
  296. } else {
  297. $add.find(".resourceImg").attr("src", "/images/default-resource.jpg");
  298. }
  299. }
  300. $(".addworkbtn-list:gt(2)").css({
  301. "display": "none"
  302. });
  303. } else {
  304. $.MsgBox.Alert('message', "系统异常!");
  305. }
  306. },
  307. "error": function() {
  308. $.MsgBox.Alert('message', 'failed')
  309. }
  310. });
  311. }
  312. function myNews() {
  313. $.ajax({
  314. "url": "/ajax/article/qaPro",
  315. "type": "get",
  316. "async": true,
  317. "data": {
  318. "professorId": userid
  319. },
  320. "success": function(data) {
  321. if(data.success) {
  322. var add = '';
  323. $("#myNews").html("");
  324. for(var i = 0; i < data.data.length; i++) {
  325. var add = '<li><a href="articalInfo.html?articleId=' + data.data[i].articleId + '&professorId=' + data.data[i].professorId + '">'
  326. add += '<div class="art_topicBox"><div class="art_img" style=""></div>'
  327. add += '<div class="art_tbox"><h6 id="artical_topic" >' + data.data[i].articleTitle + '</h6></div>'
  328. add += '</div><div class="tagsBox"><span></span></div>'
  329. add += '</a></li>';
  330. $add = $(add);
  331. $("#myNews").append($add);
  332. $add.find('.tagsBox span').text(data.data[i].industry);
  333. if(data.data[i].articleImg) {
  334. $add.find(".art_img").attr("style", "background: url(/data/article/" + data.data[i].articleImg + ") 0 0 no-repeat;background-size:cover;");
  335. }
  336. }
  337. $("#myNews li:gt(2)").css({
  338. "display": "none"
  339. });
  340. } else {
  341. $.MsgBox.Alert('消息', "链接服务器超时!");
  342. }
  343. },
  344. "error": function() {
  345. $.MsgBox.Alert('消息', '链接服务器超时!')
  346. }
  347. });
  348. }
  349. $("#dett,#searchDemand").click(function(){
  350. if(oAuthType==0){
  351. location.href="myDemand.html"
  352. }else if(oAuthType==1){
  353. location.href="needList.html"
  354. }
  355. })
  356. /*登录者需求的数量*/
  357. function demandNumMy(){
  358. $.ajax({
  359. "url":"/ajax/demand/queryMyPublish" ,
  360. "type": "get",
  361. "async": true,
  362. "data":{
  363. "demander": userid
  364. },
  365. "success": function(data) {
  366. if(data.success) {
  367. $("#demandNumber").text(data.data)
  368. } else {
  369. $.MsgBox.Alert('消息', data.msg);
  370. }
  371. },
  372. "error": function(x) {
  373. $.MsgBox.Alert('消息', '链接服务器超时!')
  374. }
  375. });
  376. }
  377. function demandNum(){
  378. $.ajax({
  379. "url":"/ajax/demand/queryPublish" ,
  380. "type": "get",
  381. "async": true,
  382. "success": function(data) {
  383. if(data.success) {
  384. $("#demandNumber").text(data.data)
  385. } else {
  386. $.MsgBox.Alert('消息', data.msg);
  387. }
  388. },
  389. "error": function() {
  390. $.MsgBox.Alert('消息', '链接服务器超时!')
  391. }
  392. });
  393. }
  394. });