portal html css js resource

myConsult.js 11KB

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