portal html css js resource

myConsult.js 11KB

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