portal html css js resource

consult.js 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. //用户id
  2. var userid = $.cookie("userid");
  3. //getConsultData参数
  4. var pageSize = 5;
  5. var pageNo, isbind, status, timeType, sortType;
  6. getConsultData(pageSize, 1, true, 0, 1, 0);
  7. consultPullDownMenu();
  8. function getConsultData(pageSize, pageNo, isbind, status, timeType, sortType) {
  9. var params = {
  10. "professorId": userid, //专家ID
  11. "status": status, //查询状态 0-全部,1-进行中,2-未感谢,3-未评价,4-已完成, 可以不传,默认为0
  12. "timeType": timeType, //排序目的 0-按发起时间,1-按最后回复时间,2-按完成时间 默认为0
  13. "sortType": sortType, //排序目的 0-倒序,1-正序 默认为0
  14. "pageSize": pageSize, //每页记录数 默认为5
  15. "pageNo": pageNo //当前页码 默认为1
  16. };
  17. // console.log(params);
  18. $.ajax({
  19. url: "/ajax/consult/pqPro",
  20. type: "get",
  21. //传值:登陆人id:咨询id
  22. data: params,
  23. async: false,
  24. dataType: "json",
  25. contentType: "application/x-www-form-urlencoded",
  26. success: function(response) {
  27. // console.log(response);
  28. //数据为空时
  29. if(response.success) {
  30. if(response["data"]["data"] == null || response["data"]["data"] == undefined || response["data"]["data"] == "") {
  31. return;
  32. } else {
  33. var consultStr;
  34. var allData = response.data;
  35. var myData = allData["data"];
  36. // console.log(myData);
  37. //拿到收到咨询数据
  38. $("#workContainer").html(""); //清空数据
  39. if(myData.length != 0 && myData.length != null) {
  40. consultStr = handleData(myData, "professorId", "lookBtn");
  41. // console.log(consultStr)
  42. $("#workContainer").append(consultStr);
  43. } else {
  44. return;
  45. }
  46. //分页
  47. if(isbind == true) {
  48. $(".getConsultPage").createPage({
  49. pageCount: Math.ceil(allData.total / pageSize),
  50. current: allData.pageNo,
  51. backFn: function(p) {
  52. getConsultData(pageSize, p, false, status, timeType, sortType);
  53. }
  54. });
  55. }
  56. }
  57. }
  58. },
  59. error: function(response) {
  60. $.MsgBox.Alert('提示', "收到咨询数据请求失败");
  61. },
  62. complete: function() {
  63. }
  64. });
  65. };
  66. //data:需要处理的数据,htmlStr:页面中需要的html字符串拼接,
  67. //attrParams:数据中不同的参数比如:收到咨询是professorId,收到答复:consultantId
  68. function handleData(data, attrParams, btnCls) {
  69. var htmlStr = '';
  70. var title,
  71. office,
  72. orgName,
  73. department,
  74. address;
  75. for(var i = 0; i < data.length; i++) {
  76. //text:回复/查看,state:进行中/已完成/未评价,photoUrl:头像地址,proModify:专家认证
  77. var text, state, stateStyle, photoUrl, proModify;
  78. var modifyclass = '';
  79. if(data[i]["professor"]) { //过滤没有专家对象的数据
  80. if(data[i]["consultStatus"] == 0) {
  81. state = "进行中";
  82. stateStyle = 'status-1';
  83. text = '回复';
  84. } else if(data[i]["consultStatus"] == 1) {
  85. text = "查看";
  86. state = "已完成";
  87. stateStyle = 'status-3';
  88. if(attrParams == 'consultId') {
  89. if(data[i]["assessStatus"] == 0) {
  90. state = "待评价";
  91. stateStyle = 'status-2';
  92. }
  93. }
  94. } else if(data[i]["consultStatus"] == 2) {
  95. text = "查看";
  96. state = "新咨询";
  97. stateStyle = 'status-2';
  98. } else if(data[i]["consultStatus"] == 3) {
  99. text = "查看";
  100. state = "已谢绝";
  101. stateStyle = 'status-5';
  102. } else if(data[i]["consultStatus"] == undefined) {
  103. text = "";
  104. state = "";
  105. }
  106. //专家头像
  107. if(data[i]["professor"]["hasHeadImage"] == 0) {
  108. photoUrl = "images/default-photo.jpg"
  109. } else {
  110. photoUrl = "images/head/" + data[i]["professor"]["id"] + "_l.jpg"
  111. };
  112. //认证
  113. // if(data[i]["professor"]["authentication"] == true){
  114. // proModify = "display:inline-block;"
  115. // }else{
  116. // proModify = "display:none;"
  117. // }
  118. if(data[i]["professor"].authType) { //专家
  119. modifyclass = 'authicon authicon-cu';
  120. } else { //普通用户
  121. if(data[i]["professor"].authStatus == 3) {
  122. if(data[i]["professor"].authentication == 1) { //科研工作者
  123. modifyclass = "authicon2 authicon-mana";
  124. } else if(data[i]["professor"].authentication == 2) { //企业专家
  125. modifyclass = "authicon2 authicon-staff";
  126. } else { //学生
  127. modifyclass = "authicon2 authicon-stu";
  128. }
  129. }
  130. };
  131. //未读消息
  132. var unread = unreadConsultFn(userid, data[i]["consultId"], i);
  133. htmlStr += "<div class='workselectitem' id='" + data[i]["consultId"] + "' >" +
  134. "<table width='100%'><tbody><tr><td width='14%' class='messagebox'>" +
  135. "<a class='workhead workitimg headRadius'>" +
  136. "<img class='headPhoto' src='" + photoUrl + "' width='100%' height='100%'>" +
  137. "</a>" +
  138. "<span class='msgprompt showUnreadMsg' style='" + unread.style + "' id='" + data[i]["consultId"] + "'>" + unread.unreadCount + "</span>" +
  139. "</td>" +
  140. "<td style='position:relative;top:20px;' width='86%'>" +
  141. "<div class='workinfor worksitcon'><h4><a class='named' id='nameS'> " + data[i]["professor"]["name"] + " </a>" +
  142. "<a class='modifyicon " + modifyclass + "'></a><input type='text' class='assessStar' value='" + data[i]["assessStar"] + "' style='display: none;'></h4><h6 class='h3Font'>";
  143. if(data[i]["professor"]["title"]) {
  144. htmlStr += "<span>" + data[i]["professor"]["title"] + "</span>, ";
  145. };
  146. if(data[i]["professor"]["office"]) {
  147. if(data[i]["professor"]["orgName"] || data[i]["professor"]["department"]) {
  148. htmlStr += "<span>" + data[i]["professor"]["office"] + "</span>, ";
  149. } else {
  150. htmlStr += "<span>" + data[i]["professor"]["office"] + "</span>";
  151. }
  152. };
  153. if(data[i]["professor"]["orgName"]) {
  154. if(data[i]["professor"]["department"]) {
  155. htmlStr += "<span>" + data[i]["professor"]["orgName"] + "</span>, ";
  156. } else {
  157. htmlStr += "<span>" + data[i]["professor"]["orgName"] + "</span>";
  158. }
  159. };
  160. if(data[i]["professor"]["department"]) {
  161. htmlStr += "<span>" + data[i]["professor"]["department"] + "</span>";
  162. };
  163. if(data[i]["professor"]["address"]) {
  164. htmlStr += ' | ' + "<span>" + data[i]["professor"]["address"] + "</span>";
  165. };
  166. htmlStr += "</h6><h6 style='position:relative;'>" +
  167. "<div class='titList'>咨询主题:<em class='h4Font'> " + data[i]["consultTitle"] + " </em></div>" +
  168. "<span class='lasttime rightTime'>" + lastReplyFn(userid, data[i]["consultId"])["lastReplyTime"] + "</span>" +
  169. "<div style='height:70px;'><p class='rebackcon lastReplyCon' >" + lastReplyFn(userid, data[i]["consultId"])["lastReplyCon"] + "</p></div>" +
  170. "</h6></div>" +
  171. "<div class='workhandle'>" +
  172. "<div class='rightopert floatR'>" +
  173. "<span attrP='" + attrParams + "' class='replybtn " + btnCls + "' id='" + data[i]["consultId"] + "' consultStatus='" + data[i]["consultStatus"] + "' assess='" + data[i]["assessStatus"] + "' thanks='" + data[i]["thanksStatus"] +
  174. "' onclick='clickLookBtn2(\"" + userid + "\",\"" + attrParams + "\",\"" + data[i]["consultId"] + "\"," + data[i]["consultStatus"] + "," + data[i]["assessStatus"] + "," + data[i]["thanksStatus"] + ");'>" +
  175. text +
  176. "</span>" +
  177. "<span class='moreopert complain'>...</span>" +
  178. "<ul class='moreopertbtn'>" +
  179. "<li>投诉</li>" +
  180. "</ul>" +
  181. "</div>" +
  182. "<div class='leftstate floatR'>" +
  183. "<span class='coultstate " + stateStyle + "'><i>" + state + "</i></span>" +
  184. "</div>" +
  185. "<div class='leftstate floatR'>" +
  186. "<span class='coultstate coulstAim status-4'><i>" + data[i]["consultType"] + "</i></span>" +
  187. "</div>" +
  188. "</div>" +
  189. "</td>" +
  190. "</tr></tbody></table>" +
  191. "</div>";
  192. }
  193. };
  194. return htmlStr;
  195. };
  196. //未读信息接口
  197. function unreadConsultFn(senderId, consultId, i) {
  198. var unreadCount, style;
  199. var params = {
  200. "senderId": senderId, //发送者ID
  201. "consultId": consultId //咨询ID
  202. };
  203. $.ajax({
  204. url: "/ajax/tidings/qaNotReadTidings",
  205. type: "get",
  206. async: false,
  207. data: params,
  208. success: function(response) {
  209. unreadCount = response["data"];
  210. console.log()
  211. if(unreadCount == 0) {
  212. style = "display:none;"
  213. } else {
  214. style = "display:block;"
  215. }
  216. },
  217. error: function(error) {
  218. $.MsgBox.Alert('提示', "未读消息请求失败");
  219. }
  220. });
  221. return {
  222. "unreadCount": unreadCount,
  223. "style": style
  224. }
  225. };
  226. //列表最后回复
  227. function lastReplyFn(sendId, consultId) {
  228. var lastReplyTimeData, lastReplyTime, lastReplyCon;
  229. $.ajax({
  230. url: "/ajax/tidings/qaLastRevovery",
  231. async: false,
  232. data: {
  233. "consultId": consultId, //咨询ID
  234. "senderId": sendId //登录者ID
  235. },
  236. success: function(response) {
  237. // console.log(response)
  238. if(response["data"] == null || response["data"] == "" || response["data"] == undefined) {
  239. lastReplyTimeData = '';
  240. lastReplyTime = '';
  241. lastReplyCon = '';
  242. } else {
  243. lastReplyTimeData = response["data"]["createTime"];
  244. lastReplyTime = lastReplyTimeData.substr(0, 4) + "-" + lastReplyTimeData.substr(4, 2) + "-" + lastReplyTimeData.substr(6, 2) + " " + lastReplyTimeData.substr(8, 2) + ":" + lastReplyTimeData.substr(10, 2)
  245. lastReplyCon = response["data"]["tidingsContant"];
  246. }
  247. },
  248. error: function(error) {
  249. $.MsgBox.Alert('提示', "最后回复数据失败");
  250. }
  251. });
  252. return {
  253. "lastReplyTime": lastReplyTime,
  254. "lastReplyCon": lastReplyCon
  255. };
  256. };
  257. //咨询下拉菜单顺序处理函数
  258. function consultPullDownMenu() { //点击下拉菜单
  259. $(".consultOption ul").find("li").click(function() {
  260. status = $(this).attr("tip");
  261. timeType = $("#showTimeSort").attr("tim");
  262. sortType = $("#timeSortId").val();
  263. $("#workContainer").remove();
  264. $("#shoudao").append('<div id="workContainer"></div>')
  265. $(".getConsultPage").remove();
  266. $("#shoudao").append('<div class="tcdPageCode getConsultPage"></div>');
  267. console.log(status + timeType + sortType);
  268. getConsultData(pageSize, 1, true, status, timeType, sortType);
  269. });
  270. $(".timeOption ul").find("li").click(function() {
  271. status = $("#showStatus").attr("tip");
  272. timeType = $(this).attr("tim");
  273. sortType = $("#timeSortId").val();
  274. $("#workContainer").remove();
  275. $("#shoudao").append('<div id="workContainer"></div>')
  276. $(".getConsultPage").remove();
  277. $("#shoudao").append('<div class="tcdPageCode getConsultPage"></div>');
  278. console.log(status + timeType + sortType);
  279. getConsultData(pageSize, 1, true, status, timeType, sortType);
  280. });
  281. var sortFlag = true;
  282. $("#consultArrow").click(function() {
  283. if(sortFlag == true) {
  284. $(this).find("div").css("background-position", "-20px 1px");
  285. $("#timeSortId").val("1");
  286. sortFlag = false;
  287. } else {
  288. $(this).find("div").css("background-position", "0px 1px");
  289. $("#timeSortId").val("0");
  290. sortFlag = true;
  291. }
  292. status = $("#showStatus").attr("tip");
  293. timeType = $("#showTimeSort").attr("tim");
  294. sortType = $("#timeSortId").val();
  295. $("#workContainer").remove();
  296. $("#shoudao").append('<div id="workContainer"></div>')
  297. $(".getConsultPage").remove();
  298. $("#shoudao").append('<div class="tcdPageCode getConsultPage"></div>');
  299. console.log(status + timeType + sortType);
  300. getConsultData(pageSize, 1, true, status, timeType, sortType);
  301. });
  302. };
  303. //咨询和回复中点击查看或者回复
  304. function clickLookBtn2(sendId, attrParams, consultId, consultStatus, assessStatus, thanksStatus) {
  305. if(consultStatus == 2) {
  306. window.location.href = "consultSure.html?consultId=" + consultId
  307. } else {
  308. window.location.href = "diloags.html?sendId=" + sendId + "&attrParams=" + attrParams + "&consultId=" + consultId + "&consultStatus=" + consultStatus + "&assessStatus=" + assessStatus + "&thanksStatus=" + thanksStatus;
  309. }
  310. }