portal html css js resource

workindex.js 12KB

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