portal html css js resource

demand.js 11KB

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