暫無描述

consult.js 29KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043
  1. //用户id
  2. var userid = $.cookie("userid");
  3. //点击主页面咨询
  4. $(".workmenu").on("click","#consultbtn",clickConsultBtn);
  5. //data:需要处理的数据,htmlStr:页面中需要的html字符串拼接,
  6. //attrParams:数据中不同的参数比如:收到咨询是professorId,收到答复:consultantId
  7. function handleData(data,attrParams,btnCls){
  8. var htmlStr = '';
  9. for(var i = 0; i < data.length;i++){
  10. //text:回复/查看,state:进行中/已完成/未评价,photoUrl:头像地址,proModify:专家认证
  11. var text,state,stateStyle,photoUrl,proModify;
  12. if(data[i]["consultStatus"] == 0){
  13. state = "进行中";
  14. stateStyle = 'status-1';
  15. /*$(".coultstate").eq(i).removeClass("status-2,status-3");
  16. $(".coultstate").eq(i).addClass("status-1");*/
  17. text = '回复';
  18. } else if (data[i]["consultStatus"] == 1) {
  19. text = "查看";
  20. /*$(".coultstate").eq(i).removeClass("status-2,status-1");
  21. $(".coultstate").eq(i).addClass("status-3");*/
  22. state = "已完成";
  23. stateStyle = 'status-3';
  24. if(attrParams == 'consultId'){
  25. if(data[i]["assessStatus"] == 0){
  26. /*$(".coultstate").eq(i).removeClass("status-1,status-3");
  27. $(".coultstate").eq(i).addClass("status-2");*/
  28. state = "待评价";
  29. stateStyle = 'status-2';
  30. }
  31. }
  32. }else if(data[i]["consultStatus"] == undefined){
  33. text = "";
  34. state = "";
  35. }
  36. if(data[i]["professor"]["title"] == undefined){
  37. data[i]["professor"]["title"] = '';
  38. }
  39. if(data[i]["professor"]["orgName"] == undefined){
  40. data[i]["professor"]["orgName"] = '';
  41. }
  42. if(data[i]["professor"]["department"] == undefined){
  43. data[i]["professor"]["department"] = '';
  44. }
  45. if(data[i]["professor"]["adress"] == undefined){
  46. data[i]["professor"]["adress"] = '';
  47. };
  48. if(data[i]["professor"]["office"] == undefined){
  49. data[i]["professor"]["office"] = '';
  50. };
  51. //专家头像
  52. if(data[i]["professor"]["hasHeadImage"] == 0){
  53. photoUrl = "images/default-photo.jpg"
  54. }else{
  55. photoUrl = "images/head/"+data[i]["professor"]["id"]+"_m.jpg"
  56. };
  57. //认证
  58. if(data[i]["professor"]["authentication"] == true){
  59. proModify = "display:inline-block;"
  60. }else{
  61. proModify = "display:none;"
  62. }
  63. //未读消息
  64. var unread = unreadConsultFn (userid,data[i]["consultId"],i);
  65. htmlStr +=
  66. "<div class='workselectitem' id='" +data[i]["consultId"] +"' >" +
  67. "<table width='100%'>" +
  68. "<tbody><tr>" +
  69. "<td width='14%' class='messagebox'>" +
  70. "<a class='workhead workitimg headRadius'>" +
  71. "<img class='headPhoto' src='"+photoUrl+"' width='100%' height='100%'>" +
  72. "</a>" +
  73. "<span class='msgprompt showUnreadMsg' style='"+unread.style+"' id='" +data[i]["consultId"] +"'>"+unread.unreadCount+"</span>" +
  74. "</td>" +
  75. "<td style='position:relative;' width='86%'>" +
  76. "<div class='workinfor worksitcon'>" +
  77. "<h4><a class='named' id='nameS'> " + data[i]["professor"]["name"] +" </a><img class='modifyicon' style='"+proModify+"' src='images/onauth.png'><input type='text' class='assessStar' value='"+data[i]["assessStar"] +"' style='display: none;'></h4>" +
  78. "<h6><span>职称 " + data[i]["professor"]["title"] +" </span>,<span>职位"+data[i]["professor"]["office"]+"</span>,<span> " + data[i]["professor"]["orgName"] +" </span>,<span> " + data[i]["professor"]["department"] +" </span>&nbsp;|&nbsp;<span> " + data[i]["professor"]["adress"] +" </span></h6>" +
  79. "<h6>"+
  80. "<span>咨询主题:<em> " + data[i]["consultTitle"] +" </em></span>" +
  81. "&nbsp;&nbsp;&nbsp;&nbsp;" +
  82. "<span>咨询类型:<em> " + data[i]["consultType"] +" </em></span>" +
  83. "&nbsp;&nbsp;&nbsp;&nbsp;<span>" +
  84. "咨询发起时间:<em> " +
  85. data[i]["createTime"].substr(0,4) + "-" + data[i]["createTime"].substr(4,2) + "-" + data[i]["createTime"].substr(6,2) + " " + data[i]["createTime"].substr(8,2)+ ":" +data[i]["createTime"].substr(10,2)+
  86. "</em>" +
  87. "</span></h6>" +
  88. "<p><span class='lasttime'> " +
  89. lastReplyFn(userid,data[i]["consultId"])["lastReplyTime"]+
  90. " </span>" +
  91. "</p>" +
  92. "<p class='rebackcon lastReplyCon' >"+lastReplyFn(userid,data[i]["consultId"])["lastReplyCon"]+"</p>" +
  93. "</div>" +
  94. "<div class='workhandle'>" +
  95. "<div class='rightopert floatR'>" +
  96. "<span attrP='"+attrParams+"' class='replybtn "+btnCls+"' id='"+ data[i]["consultId"]+"' consultStatus='"+ data[i]["consultStatus"]+"' assess='"+ data[i]["assessStatus"]+ "' thanks='"+ data[i]["thanksStatus"]+
  97. "' onclick='clickLookBtn2(\""+userid+"\",\""+attrParams+"\",\""+data[i]["consultId"]+"\","+data[i]["consultStatus"]+","+data[i]["assessStatus"]+","+data[i]["thanksStatus"]+");'>" +
  98. text +
  99. "</span>" +
  100. "<span class='moreopert complain'>...</span>" +
  101. "<ul class='moreopertbtn'>" +
  102. "<li>投诉</li>" +
  103. "</ul>" +
  104. "</div>" +
  105. "<div class='leftstate floatR'>" +
  106. "<span class='coultstate "+stateStyle+"'><i>"+state+"</i></span>" +
  107. "</div>" +
  108. "</div>" +
  109. "</td>" +
  110. "</tr></tbody></table>" +
  111. "</div>";
  112. };
  113. return htmlStr
  114. };
  115. //未读信息接口
  116. function unreadConsultFn (senderId,consultId,i){
  117. var unreadCount,style;
  118. var params = {
  119. "senderId":senderId, //发送者ID
  120. "consultId":consultId //咨询ID
  121. };
  122. $.ajax({
  123. url:"/ajax/tidings/qaNotReadTidings",
  124. type:"get",
  125. async:false,
  126. data:params,
  127. success:function(response){
  128. unreadCount = response["data"];
  129. console.log()
  130. if(unreadCount == 0){
  131. style = "display:none;"
  132. }else{
  133. style = "display:block;"
  134. }
  135. },
  136. error:function(error){
  137. $.MsgBox.Alert('提示',"未读消息请求失败");
  138. }
  139. });
  140. return {"unreadCount":unreadCount,
  141. "style":style
  142. }
  143. };
  144. //列表最后回复
  145. function lastReplyFn(sendId,consultId){
  146. var lastReplyTimeData,lastReplyTime,lastReplyCon;
  147. $.ajax({
  148. url:"/ajax/tidings/qaLastRevovery",
  149. async:false,
  150. data:{
  151. "consultId":consultId, //咨询ID
  152. "senderId":sendId //登录者ID
  153. },
  154. success:function(response){
  155. if(response["data"] == null || response["data"] == "" || response["data"] == undefined){
  156. lastReplyTimeData = '';
  157. lastReplyTime = '';
  158. lastReplyCon = '';
  159. }
  160. else{
  161. lastReplyTimeData = response["data"]["createTime"];
  162. lastReplyTime ="最后回复(" + lastReplyTimeData.substr(0,4) + "-" + lastReplyTimeData.substr(4,2) + "-" + lastReplyTimeData.substr(6,2) + " " + lastReplyTimeData.substr(8,2)+ ":" +lastReplyTimeData.substr(10,2) + ")"
  163. lastReplyCon = response["data"]["tidingsContant"];
  164. }
  165. },
  166. error:function(error){
  167. $.MsgBox.Alert('提示',"最后回复数据失败");
  168. }
  169. });
  170. return {
  171. "lastReplyTime":lastReplyTime,
  172. "lastReplyCon":lastReplyCon
  173. };
  174. };
  175. //咨询点击回复,对话页字符串拼接函数
  176. //data:要处理的数据,htmlStr:需要拼接到页面的元素,position
  177. function dialogContentStrFn(data){
  178. var htmlStr ="";
  179. var dialogitem,float,dilinfobox,dilarrow,dilarrow_bor;
  180. for(var i = 0; i < data.length;i++){
  181. if(data[i]["professor"]["id"] == userid){
  182. dialogitem = "dialogrightitem";
  183. float = "floatR";
  184. dilinfobox = "dilinfobox_r";
  185. dilarrow = "dilarrow_r";
  186. dilarrow_bor="dilarrow_r_bor";
  187. }
  188. else{
  189. dialogitem = "dialogleftitem";
  190. float = "floatL";
  191. dilarrow = "dilarrow_l";
  192. dilinfobox = "dilinfobox_l";
  193. dilarrow_bor="dilarrow_l_bor";
  194. }
  195. htmlStr +=
  196. "<div class='"+dialogitem+"'>" +
  197. "<div class='dilmod'>" +
  198. "<div class='diluser "+float+"'>" +
  199. "<a target='_blank' class='userface headRadius'>" +
  200. "<img src='images/default-photo.jpg' width='100%' height='100%'>" +
  201. "</a>" +
  202. "</div>" +
  203. "<div class='dilinfobox "+ dilinfobox+" "+ float +"'>" +
  204. "<div class='delinfocon clearfix'>" +
  205. "<div class='dilarrow "+ dilarrow+"'></div>" +
  206. "<div class='dilarrow "+dilarrow_bor+"'></div>" +
  207. "<div class='delinfomain "+float+"'>" +
  208. "<div class='cont'>" +
  209. "<p>"+data[i]["tidingsContant"]+"</p>" +
  210. "</div>" +
  211. "</div>" +
  212. "</div>" + //dilinfobox
  213. "</div>" + //dilinfobox
  214. "</div>" + //dilmod
  215. "</div>" + //dialogrightitem
  216. "</div> "
  217. };
  218. return htmlStr;
  219. };
  220. //收到回复
  221. var getMyData = function (pageSize,pageNo,isbind,status,timeType,sortType){
  222. var params = {
  223. "consultantId":userid, //专家ID
  224. "status":status, //查询状态 0-全部,1-进行中,2-未感谢,3-未评价,4-已完成, 可以不传,默认为0
  225. "timeType":timeType, //排序类型 0-按发起时间,1-按最后回复时间,2-按完成时间 默认为0
  226. "sortType":sortType, //排序类型 0-倒序,1-正序 默认为0
  227. "pageSize":pageSize, //每页记录数 默认为5
  228. "pageNo":pageNo //当前页码 默认为1
  229. };
  230. $.ajax({
  231. url:"/ajax/consult/pqCon",//收到回复接口
  232. type:"get",
  233. data :params,
  234. dataType: "json",
  235. contentType: "application/x-www-form-urlencoded",
  236. success:function(response){
  237. if(response["data"]["data"] == null || response["data"]["data"] == undefined || response["data"]["data"] == ""){
  238. return false;
  239. }
  240. else{
  241. //拿到收到回复数据
  242. var replyStr;
  243. var allData = response.data;
  244. var myData = allData.data;
  245. $("#workContainer2").html("");
  246. if(myData.length != 0 && myData.length != null){
  247. replyStr = handleData(myData,"consultId","lookBtn");
  248. $("#workContainer2").append(replyStr);
  249. }else{
  250. return false;
  251. };
  252. //分页
  253. if(isbind == true){
  254. $(".getReplyPage").createPage({
  255. pageCount:Math.ceil(allData.total/pageSize),
  256. current:allData.pageNo,
  257. backFn:function(p){
  258. getMyData(pageSize,p,false,status,timeType,sortType);
  259. }
  260. });
  261. }
  262. }
  263. },
  264. error:function(response){
  265. //收到回复错误返回
  266. $.MsgBox.Alert('提示',"收到回复数据请求失败");
  267. },
  268. });
  269. };
  270. var getConsultData = function (pageSize,pageNo,isbind,status,timeType,sortType){
  271. var params = {
  272. "professorId":userid, //专家ID
  273. "status":status, //查询状态 0-全部,1-进行中,2-未感谢,3-未评价,4-已完成, 可以不传,默认为0
  274. "timeType":timeType, //排序类型 0-按发起时间,1-按最后回复时间,2-按完成时间 默认为0
  275. "sortType":sortType, //排序类型 0-倒序,1-正序 默认为0
  276. "pageSize":pageSize, //每页记录数 默认为5
  277. "pageNo":pageNo //当前页码 默认为1
  278. };
  279. $.ajax({
  280. url:"/ajax/consult/pqPro",
  281. type:"get",
  282. //传值:登陆人id:咨询id
  283. data :params,
  284. async:false,
  285. dataType: "json",
  286. contentType: "application/x-www-form-urlencoded",
  287. success:function(response){
  288. if(response["data"]["data"] == null || response["data"]["data"] == undefined || response["data"]["data"] == ""){
  289. return false;
  290. }
  291. else{
  292. var consultStr;
  293. var allData = response.data;
  294. var myData = allData["data"];
  295. //拿到收到咨询数据
  296. $("#workContainer").html("");
  297. if(myData.length != 0 && myData.length != null){
  298. consultStr = handleData(myData,"professorId","lookBtn");
  299. $("#workContainer").append(consultStr);
  300. }else{
  301. return false;
  302. }
  303. //分页
  304. if(isbind == true){
  305. $(".getConsultPage").createPage({
  306. pageCount:Math.ceil(allData.total/pageSize),
  307. current:allData.pageNo,
  308. backFn:function(p){
  309. getConsultData(pageSize,p,false,status,timeType,sortType);
  310. }
  311. });
  312. }
  313. }
  314. },
  315. error:function(response){
  316. $.MsgBox.Alert('提示',"收到咨询数据请求失败");
  317. },
  318. });
  319. };
  320. //咨询和回复中点击查看或者回复
  321. function clickLookBtn2(sendId,attrParams,consultId,consultStatus,assessStatus,thanksStatus){
  322. //收到咨询
  323. if(attrParams == "professorId"){
  324. //调取页面
  325. $.ajax({
  326. url:"diloags.html",
  327. dataType:"html",
  328. success:function(result){
  329. $(".workcon").html(result);
  330. dialogHeadFn2("/ajax/consult/qapro",attrParams,consultId,thanksStatus);
  331. dialogContentDataHandle2(consultId);
  332. $("#dialog_sendBtn").click(function(){sendDialogContentFn2(sendId,consultId)});
  333. },
  334. error:function(error){
  335. //console.log(data);
  336. //加载对话页面失败
  337. // console.log(error);
  338. },
  339. complete:function(){
  340. //对话页后退按钮
  341. $("#backBtn").click(function(){
  342. $("#consultbtn").css({
  343. color:"#fff",
  344. background:"#f99550"
  345. });
  346. clickConsultBtn();
  347. });
  348. }
  349. })
  350. }
  351. //收到回复
  352. else if(attrParams == "consultId"){
  353. $.ajax({
  354. url:"diloags.html",
  355. dataType:"html",
  356. success:function(result){
  357. //console.log(data);
  358. $(".workcon").html(result);
  359. //进行中
  360. if(consultStatus == 0){
  361. dialogHeadFn2("/ajax/consult/qacon",attrParams,consultId,thanksStatus);
  362. dialogContentDataHandle2(consultId);
  363. $("#dialog_sendBtn").click(function(){sendDialogContentFn2(sendId,consultId)});
  364. }
  365. //完成
  366. else if(consultStatus == 1){
  367. //未评价
  368. if(assessStatus == 0){
  369. assessFn2(consultId,attrParams,thanksStatus)
  370. }else if(assessStatus == 1){
  371. dialogHeadFn2("/ajax/consult/qacon",attrParams,consultId,thanksStatus);
  372. dialogContentDataHandle2(consultId);
  373. $("#dialog_sendBtn").click(function(){sendDialogContentFn2(sendId,consultId)});
  374. }
  375. }
  376. },
  377. error:function(error){
  378. //console.log(data);
  379. //加载对话页面失败
  380. // console.log(error);
  381. },
  382. complete:function(){
  383. //对话页后退按钮
  384. $("#backBtn").click(function(){
  385. $("#consultbtn").css({
  386. color:"#fff",
  387. background:"#f99550"
  388. });
  389. clickConsultBtn();
  390. });
  391. }
  392. })
  393. }
  394. };
  395. //对话页咨询内容展开和收起
  396. var cur_status = "less";
  397. function showMore(){
  398. //alert("show_more_init!");
  399. var charNumbers=$("#dialog_consultContent").html().length;//总字数
  400. var limit = 20;//显示字数
  401. if(charNumbers > limit){
  402. var orgText = $("#dialog_consultContent").html();//原始文本
  403. var orgHeight= $("#dialog_consultContent").height();//原始高度
  404. var showText = orgText.substring(0,limit);//最终显示的文本
  405. var showText = showText + "...";
  406. $("#dialog_consultContent").html(showText);
  407. var contentHeight = $("#dialog_consultContent").height();//截取内容后的高度
  408. $("#dialog_switch").click(function(){
  409. if(cur_status == "less"){
  410. $("#dialog_consultContent").height(contentHeight).html(orgText).animate({ height:orgHeight}, { duration: "slow" });
  411. $(this).html("收起");
  412. cur_status = "more";
  413. }else{
  414. $("#dialog_consultContent").height(orgHeight).html(showText).animate({ height:contentHeight}, { duration: "fast" });
  415. $(this).html("展开");
  416. cur_status = "less";
  417. }
  418. });
  419. }
  420. else{
  421. $("#dialog_switch").hide();
  422. }
  423. };
  424. //返回函数
  425. function backHandle(){
  426. };
  427. //对话标题处理函数
  428. function dialogHeadFn2(url,attrParams,consultId,thanksStatus){
  429. $.ajax({
  430. url:url,//
  431. data:{"consultId":consultId,"readStatus":"1"},
  432. type:"get",
  433. aysnc:false,
  434. success:function(response){
  435. var myData = response["data"];
  436. //咨询
  437. if(attrParams == 'professorId'){
  438. //进行中
  439. if(myData["consultStatus"] == 0){
  440. $("#dil_consultStatus").text("进行中");//咨询状态
  441. $(".dialogfoot").css("display","block");//显示发送对话部分
  442. $("#dialog_consultTitle").text(myData["consultTitle"]);//咨询主题
  443. $("#dialog_consultType").text(myData["consultType"]);//咨询类型
  444. $("#dial_consultName").text(myData["professor"]["name"]);//与@@@对话
  445. $("#dialog_consultContent").html(myData["consultContant"])//咨询内容
  446. }
  447. //咨询已完成
  448. else {
  449. $("#dil_consultStatus").text("完成");//咨询状态
  450. $("#dialog_consultTitle").text(myData["consultTitle"]);//咨询主题
  451. $("#dialog_consultType").text(myData["consultType"]);//咨询类型
  452. $("#dial_consultName").text(myData["professor"]["name"]);//与@@@对话
  453. $("#dialog_consultContent").html(myData["consultContant"])//咨询内容
  454. $(".dialogfoot").css("display","none");//隐藏发送对话部分
  455. //如果评价
  456. if(myData["assessStatus"] == 1){
  457. var startConut = myData["assessStar"];
  458. for(var i = 0; i < startConut; i ++){
  459. $("#showAllAssess .evastar2").eq(i).addClass("addStar");
  460. }
  461. $("#showAllAssess").removeClass("displayNone");//总体评价
  462. $("#dialog_assessContent").removeClass("displayNone");
  463. $("#dialog_assessContentText").html(myData["assessContant"]);
  464. //如果感谢
  465. if(myData["thanksStatus"] == 1){
  466. if(myData["thanksMoney"] != null && myData["thanksMoney"] != undefined && myData["thanksMoney"] != "" && myData["thanksMoney"] != 0 ){
  467. $("#dialog_thanks").removeClass("displayNone");//感谢
  468. $("#dialog_thanksMoney").text(myData["thanksMoney"]);
  469. }
  470. }else {//未感谢
  471. return false;
  472. }
  473. }else {//未评价
  474. return false;
  475. }
  476. }
  477. }
  478. //回复
  479. else if(attrParams == 'consultId'){
  480. //回复进行中
  481. if (myData["consultStatus"] == 0) {
  482. $("#dil_consultStatus").text("进行中");//咨询状态
  483. $(".dialogfoot").css("display","block");//显示发送对话部分
  484. $("#dialog_consultTitle").text(myData["consultTitle"]);//咨询主题
  485. $("#dialog_consultType").text(myData["consultType"]);//咨询类型
  486. $("#dial_consultName").text(myData["professor"]["name"]);//与@@@对话
  487. $("#dialog_consultContent").html(myData["consultContant"])//咨询内容
  488. $("#confirmBtn").removeClass("displayNone");//确认完成按钮显示
  489. //点击确认完成
  490. $("#confirmBtn").click(function(){
  491. clickConfirmFn(consultId,thanksStatus);
  492. })
  493. //发表评论
  494. $("#sendAssessBtn").click(function(){
  495. clickSendAssessBtn2(consultId,attrParams,thanksStatus)
  496. });
  497. //稍后评价
  498. $("#noAssessBtn").click(function(){
  499. noAssessFn2(consultId,attrParams,thanksStatus);
  500. });
  501. //点击关闭
  502. $("#closeAssessBtn").click(function(){
  503. noAssessFn2(consultId,attrParams,thanksStatus);
  504. });
  505. }
  506. //回复完成
  507. else {
  508. $("#dil_consultStatus").text("已完成");//咨询状态
  509. $("#dialog_consultTitle").text(myData["consultTitle"]);//咨询主题
  510. $("#dialog_consultType").text(myData["consultType"]);//咨询类型
  511. $("#dial_consultName").text(myData["professor"]["name"]);//与@@@对话
  512. $("#dialog_consultContent").html(myData["consultContant"])//咨询内容
  513. $(".dialogfoot").css("display","none");//隐藏发送对话部分
  514. //回复完成未评价
  515. if(myData["assessStatus"] == 0){
  516. assessFn2(consultId,attrParams,thanksStatus)
  517. }else {
  518. //评价星级
  519. var startConut = myData["assessStar"];
  520. for(var i = 0; i < startConut; i ++){
  521. $("#showAllAssess .evastar2").eq(i).addClass("addStar");
  522. }
  523. $("#showAllAssess").removeClass("displayNone");//总体评价
  524. // $("#dialog_thanksBtn").removeClass("displayNone");
  525. $("#dialog_assessContent").removeClass("displayNone");
  526. $("#dialog_assessContentText").html(myData["assessContant"]);
  527. //未感谢
  528. if(myData["thanksStatus"] == 0){
  529. // $("#dialog_thanksBtn").removeClass("dispalyNone");
  530. }else {
  531. //感谢金额
  532. // $("#dialog_thanks").removeClass("displayNone");
  533. // $("#dialog_thanksMoney").text(myData["thanksMoney"]);
  534. }
  535. }
  536. }
  537. };
  538. //咨询内容展开收起效果
  539. if($("#dialog_consultContent")){
  540. showMore();
  541. };
  542. },
  543. error:function (error) {
  544. //对话标题信息
  545. }
  546. });
  547. }
  548. //点击确认完成
  549. function clickConfirmFn(consultId,thanksStatus){
  550. finish();
  551. $("#finish").click(function(){
  552. finishFn(consultId)
  553. });
  554. }
  555. //点击确认完成弹窗中完成
  556. function finishFn(consultId,thanksStatus){
  557. //更新咨询状态
  558. $.ajax({
  559. url:"/ajax/consult/finishTime",
  560. type:"post",
  561. data:{
  562. "consultId":consultId, //咨询ID
  563. "consultStatus":"1", //咨询状态 0-进行中,1-已完成
  564. },
  565. success:function(response){
  566. console.log(response);
  567. $(".blackcover").remove();
  568. $("body").css("position","static");
  569. assessFn2(consultId,"consultId",thanksStatus);
  570. },
  571. error:function(error){
  572. //更新咨询状态失败
  573. }
  574. });
  575. };
  576. //============对话内容数据处理函数
  577. function dialogContentDataHandle2(consultId){
  578. $.ajax({
  579. "url":"/ajax/tidings/qacon",//对话内容显示接口
  580. "type":"get",
  581. "data":{"consultId":consultId},
  582. "success":function(response){
  583. $("#dialogContent").empty("");
  584. var dialogConData = response["data"];
  585. var dialogStr;
  586. dialogStr = dialogContentStrFn(dialogConData);
  587. $("#dialogContent").prepend(dialogStr);
  588. $("#dialogContent").removeClass("dialog");
  589. var height=$("#dialogContent").height();
  590. $("#dialogContent").addClass("dialog");
  591. $("#dialogContent").scrollTop(height);
  592. },
  593. error:function(error){
  594. }
  595. });
  596. };
  597. //发送按钮处理函数
  598. function sendDialogContentFn2(sendId,consultId){
  599. var tidingsContant = $("#dialog_sendContent").val();
  600. //console.log(tidingStr);
  601. $.ajax({
  602. "url":"/ajax/tidings",
  603. "type":"post",
  604. "data":{"tidingsContant":tidingsContant,"senderId":sendId,"consultId":consultId},
  605. "success":function(response){
  606. // console.log(response);//返回对话内容的id
  607. if(response.success){
  608. dialogContentDataHandle2(consultId);
  609. }
  610. },
  611. "error":function(error){
  612. //对话发送消息失败
  613. console.log(error);
  614. }
  615. });
  616. $("#dialog_sendContent").val("");
  617. };
  618. //评价
  619. function assessFn2(consultId,attrParams,thanksStatus){
  620. ConsultComment();
  621. //评价星星样式
  622. var start;
  623. function clickStar(){
  624. $(".evastar2").removeClass('addStar');
  625. start=$(this).index()+1;
  626. for(var i=0;i<start;i++){
  627. if(i<start){
  628. $(".evastar2").eq(i).addClass("addStar");
  629. }
  630. else{
  631. $(".evastar2").eq(i).removeClass('addStar');
  632. }
  633. }
  634. $("#startCount").val($(".addStar").length);
  635. };
  636. $(".evastar2").bind("click",clickStar);
  637. //发表评论
  638. $("#sendAssessBtn").click(function(){
  639. clickSendAssessBtn2(consultId,attrParams,thanksStatus)
  640. });
  641. //稍后评价
  642. $("#noAssessBtn").click(function(){
  643. noAssessFn2(consultId,attrParams,thanksStatus)
  644. });
  645. //点击关闭
  646. $("#closeAssessBtn").click(function(){
  647. noAssessFn2(consultId,attrParams,thanksStatus)
  648. });
  649. };
  650. //发送评价
  651. //点击发表评论:保存发表内容和星级
  652. function clickSendAssessBtn2(consultId,attrParams,thanksStatus){
  653. var assessStar = $("#startCount").val();
  654. var assessContant = $("#assessCon").val();
  655. var assessContentStr ={
  656. "consultId":consultId, //咨询ID
  657. "assessStatus":"1", //评价状态 0-未评价,1-已评价
  658. "assessStar":assessStar, //评价星级
  659. "assessContant":assessContant //评价内容
  660. };
  661. //保存
  662. $.ajax({
  663. "url":"/ajax/consult/assess",//点击发表评论接口
  664. "type":"post",
  665. "data":assessContentStr,
  666. "success":function(response){
  667. },
  668. "error":function(error){
  669. //发表评论失败
  670. $.MsgBox.Alert('提示',"评论失败");
  671. },
  672. "complete":function(){
  673. $(".blackcover").remove();
  674. $("body").css("position","static");
  675. //发表评价后进入对话页
  676. $.ajax({
  677. "url":"diloags.html",
  678. "dataType":"html",
  679. "success":function(result){
  680. //console.log(data);
  681. $(".workcon").html(result);
  682. dialogHeadFn2("/ajax/consult/qacon",attrParams,consultId,thanksStatus);
  683. dialogContentDataHandle2(consultId);
  684. },
  685. "error":function(error){
  686. //console.log(data);
  687. //加载对话页面失败
  688. console.log(error);
  689. }
  690. });
  691. }
  692. });
  693. };
  694. //稍后评价、
  695. function noAssessFn2(consultId,attrParams,thanksStatus){
  696. $.ajax({
  697. "url":"diloags.html",
  698. "dataType":"html",
  699. "success":function(result){
  700. //console.log(data);
  701. $(this).attr("id");
  702. $(".workcon").html(result);
  703. $(".blackcover").remove();
  704. $("body").css("position","static");
  705. $.ajax({
  706. url:"/ajax/consult/qacon",//对话标题信息接口
  707. data:{"consultId":consultId,"readStatus":"1"},
  708. type:"get",
  709. aysnc:false,
  710. success:function(response){
  711. var myData = response["data"];
  712. //稍后评价说明已经完成
  713. $("#dil_consultStatus").text("已完成");//咨询状态
  714. $("#dialog_consultTitle").text(myData["consultTitle"]);//咨询主题
  715. $("#dialog_consultType").text(myData["consultType"]);//咨询类型
  716. $("#dial_consultName").text(myData["professor"]["name"]);//与@@@对话
  717. $(".dialogfoot").css("display","none");//隐藏发送对话部分
  718. $("#dialog_assessBtn").removeClass("displayNone");
  719. $("#dialog_assessBtn").click(function(){
  720. assessFn2(consultId,attrParams,thanksStatus);
  721. });
  722. },
  723. error:function(error){
  724. }
  725. });
  726. dialogContentDataHandle2(consultId);
  727. },
  728. "error":function(error){
  729. //加载对话页面失败
  730. $.MsgBox.Alert('提醒',"对话请求错误");
  731. }
  732. });
  733. };
  734. //点击主页面咨询函数
  735. function clickConsultBtn(){
  736. if(userid != "" && userid != null){
  737. $.ajax({
  738. "url":"consult.html",
  739. "dataType" : "html",
  740. "success":function(responseHtml){
  741. $(".workcon").html(responseHtml);
  742. //On Click Event 收到咨询和收到回复tab效果
  743. $(".worksamlltit3").bind("click",tab);
  744. function tab(){
  745. $(".worksamlltit3").removeClass("worksamlltitnow");
  746. $(this).addClass("worksamlltitnow");
  747. $(".workmysrc3").hide();
  748. var activeTab = $(this).attr("href");
  749. $(activeTab).fadeIn();
  750. return false;
  751. };
  752. //收到咨询
  753. getConsultData("5",1,true,0,0,0);
  754. //咨询点击下拉菜单
  755. consultPullDownMenu();
  756. //无咨询 显示我的需求
  757. if($("#workContainer").find(".workselectitem").length == 0){
  758. // alert("无咨询 显示我的需求");
  759. $(".worksubcon .workmysrc3 ").eq(0).css("display","none");
  760. $(".workcontit .worksamlltit3").eq(0).removeClass("worksamlltitnow");
  761. $(".worksubcon .workmysrc3 ").eq(1).css("display","block");
  762. $(".workcontit .worksamlltit3").eq(1).addClass("worksamlltitnow");
  763. //回复
  764. getMyData("5",1,true,0,0,0);
  765. //回复点击下拉菜单
  766. myRequirePullDownMenu();
  767. //无咨询和需求
  768. if($("#workContainer2").find(".workselectitem").length == 0){
  769. // $("#workContainer2").append("<div>无需求</div>");
  770. }
  771. }
  772. //有咨询
  773. else {
  774. // alert("有咨询")
  775. //回复
  776. getMyData("5",1,true,0,0,0);
  777. //回复点击下拉菜单
  778. myRequirePullDownMenu();
  779. }
  780. $(".workcontit .worksamlltit3").eq(0).click(function(){
  781. $("#workContainer").remove();
  782. $(".getConsultPage").remove();
  783. $(".workselectcon").eq(0).append('<div id="workContainer"></div>');
  784. $(".workselectcon").eq(0).append('<div class="tcdPageCode getConsultPage"></div>');
  785. //收到咨询
  786. getConsultData("5",1,true,0,0,0);
  787. //点击下拉菜单
  788. consultPullDownMenu();
  789. });
  790. $(".workcontit .worksamlltit3").eq(1).click(function(){
  791. $("#workContainer2").remove();
  792. $(".getReplyPage").remove();
  793. $(".workselectcon").eq(1).append('<div id="workContainer2"></div>');
  794. $(".workselectcon").eq(1).append('<div class="tcdPageCode getReplyPage"></div>');
  795. //回复
  796. getMyData("5",1,true,0,0,0);
  797. //点击下拉菜单
  798. myRequirePullDownMenu();
  799. });
  800. },
  801. })
  802. }else{
  803. $.MsgBox.Alert('提醒',"您尚未登录");
  804. }
  805. };
  806. //咨询下拉菜单顺序处理函数
  807. function consultPullDownMenu(){
  808. //点击下拉菜单
  809. $(".consultOption ul").find("li").click(function(){
  810. getConsultData("5",1,true,$(this).attr("tip"),$("#showTimeSort").attr("tim"),$("#timeSortId").val());
  811. });
  812. $(".timeOption ul").find("li").click(function(){
  813. getConsultData("5",1,true,$("#showStatus").attr("tip"),$(this).attr("tim"),$("#timeSortId").val());
  814. });
  815. var sortFlag = true;
  816. $("#consultArrow").click(function(){
  817. if(sortFlag == true){
  818. $(this).find("div").css("background-position","-20px 1px");
  819. $("#timeSortId").val("1");
  820. sortFlag = false;
  821. }else{
  822. $(this).find("div").css("background-position","0px 1px");
  823. $("#timeSortId").val("0");
  824. sortFlag=true;
  825. }
  826. getConsultData("5",1,true,$("#showStatus").attr("tip"),$("#showTimeSort").attr("tim"),$("#timeSortId").val());
  827. });
  828. };
  829. //我的需求下拉菜单处理函数
  830. function myRequirePullDownMenu(){
  831. //点击下拉菜单
  832. $(".replyOption ul").find("li").click(function(){
  833. getMyData("5",1,true,$(this).attr("tip"),$("#showTimeSort2").attr("tim"),$("#timeSortId2").val());
  834. });
  835. $(".timeOption2 ul").find("li").click(function(){
  836. getMyData("5",1,true,$("#showStatus2").attr("tip"),$(this).attr("tim"),$("#timeSortId2").val());
  837. });
  838. var sortFlag2 = true;
  839. $("#replyArrow").click(function(){
  840. if(sortFlag2 == true){
  841. $(this).find("div").css("background-position","-20px 1px");
  842. $("#timeSortId2").val("1");
  843. sortFlag2 =false;
  844. }else{
  845. $(this).find("div").css("background-position","0px 1px");
  846. $("#timeSortId2").val("0");
  847. sortFlag2=true;
  848. }
  849. getMyData("5",1,true,$("#showStatus2").attr("tip"),$("#showTimeSort2").attr("tim"),$("#timeSortId2").val());
  850. });
  851. };