portal html css js resource

myConsult.js 11KB

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