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