portal html css js resource

workindex.js 12KB

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