Nenhuma Descrição

consult.js 30KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055
  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,chatImg;
  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. if(data[i]["professor"]["hasHeadImage"] == 0){
  189. chatImg = 'images/default-photo.jpg';
  190. }else {
  191. chatImg = "images/head/"+data[i]["professor"]["id"]+"_s.jpg";
  192. }
  193. }
  194. else{
  195. dialogitem = "dialogleftitem";
  196. float = "floatL";
  197. dilarrow = "dilarrow_l";
  198. dilinfobox = "dilinfobox_l";
  199. dilarrow_bor="dilarrow_l_bor";
  200. //判断对方 是否有头像
  201. if(data[i]["professor"]["hasHeadImage"] == 0){
  202. chatImg = 'images/default-photo.jpg';
  203. }else {
  204. chatImg = "images/head/"+data[i]["professor"]["id"]+"_s.jpg";
  205. }
  206. }
  207. htmlStr +=
  208. "<div class='"+dialogitem+"'>" +
  209. "<div class='dilmod'>" +
  210. "<div class='diluser "+float+"'>" +
  211. "<a target='_blank' class='userface headRadius'>" +
  212. "<img src='"+chatImg+"' width='100%' height='100%'>" +
  213. "</a>" +
  214. "</div>" +
  215. "<div class='dilinfobox "+ dilinfobox+" "+ float +"'>" +
  216. "<div class='delinfocon clearfix'>" +
  217. "<div class='dilarrow "+ dilarrow+"'></div>" +
  218. "<div class='dilarrow "+dilarrow_bor+"'></div>" +
  219. "<div class='delinfomain "+float+"'>" +
  220. "<div class='cont'>" +
  221. "<p>"+data[i]["tidingsContant"]+"</p>" +
  222. "</div>" +
  223. "</div>" +
  224. "</div>" + //dilinfobox
  225. "</div>" + //dilinfobox
  226. "</div>" + //dilmod
  227. "</div>" + //dialogrightitem
  228. "</div> "
  229. };
  230. return htmlStr;
  231. };
  232. //收到回复
  233. var getMyData = function (pageSize,pageNo,isbind,status,timeType,sortType){
  234. var params = {
  235. "consultantId":userid, //专家ID
  236. "status":status, //查询状态 0-全部,1-进行中,2-未感谢,3-未评价,4-已完成, 可以不传,默认为0
  237. "timeType":timeType, //排序类型 0-按发起时间,1-按最后回复时间,2-按完成时间 默认为0
  238. "sortType":sortType, //排序类型 0-倒序,1-正序 默认为0
  239. "pageSize":pageSize, //每页记录数 默认为5
  240. "pageNo":pageNo //当前页码 默认为1
  241. };
  242. $.ajax({
  243. url:"/ajax/consult/pqCon",//收到回复接口
  244. type:"get",
  245. data :params,
  246. dataType: "json",
  247. contentType: "application/x-www-form-urlencoded",
  248. success:function(response){
  249. if(response["data"]["data"] == null || response["data"]["data"] == undefined || response["data"]["data"] == ""){
  250. return false;
  251. }
  252. else{
  253. //拿到收到回复数据
  254. var replyStr;
  255. var allData = response.data;
  256. var myData = allData.data;
  257. $("#workContainer2").html("");
  258. if(myData.length != 0 && myData.length != null){
  259. replyStr = handleData(myData,"consultId","lookBtn");
  260. $("#workContainer2").append(replyStr);
  261. }else{
  262. return false;
  263. };
  264. //分页
  265. if(isbind == true){
  266. $(".getReplyPage").createPage({
  267. pageCount:Math.ceil(allData.total/pageSize),
  268. current:allData.pageNo,
  269. backFn:function(p){
  270. getMyData(pageSize,p,false,status,timeType,sortType);
  271. }
  272. });
  273. }
  274. }
  275. },
  276. error:function(response){
  277. //收到回复错误返回
  278. $.MsgBox.Alert('提示',"收到回复数据请求失败");
  279. },
  280. });
  281. };
  282. var getConsultData = function (pageSize,pageNo,isbind,status,timeType,sortType){
  283. var params = {
  284. "professorId":userid, //专家ID
  285. "status":status, //查询状态 0-全部,1-进行中,2-未感谢,3-未评价,4-已完成, 可以不传,默认为0
  286. "timeType":timeType, //排序类型 0-按发起时间,1-按最后回复时间,2-按完成时间 默认为0
  287. "sortType":sortType, //排序类型 0-倒序,1-正序 默认为0
  288. "pageSize":pageSize, //每页记录数 默认为5
  289. "pageNo":pageNo //当前页码 默认为1
  290. };
  291. $.ajax({
  292. url:"/ajax/consult/pqPro",
  293. type:"get",
  294. //传值:登陆人id:咨询id
  295. data :params,
  296. async:false,
  297. dataType: "json",
  298. contentType: "application/x-www-form-urlencoded",
  299. success:function(response){
  300. if(response["data"]["data"] == null || response["data"]["data"] == undefined || response["data"]["data"] == ""){
  301. return false;
  302. }
  303. else{
  304. var consultStr;
  305. var allData = response.data;
  306. var myData = allData["data"];
  307. //拿到收到咨询数据
  308. $("#workContainer").html("");
  309. if(myData.length != 0 && myData.length != null){
  310. consultStr = handleData(myData,"professorId","lookBtn");
  311. $("#workContainer").append(consultStr);
  312. }else{
  313. return false;
  314. }
  315. //分页
  316. if(isbind == true){
  317. $(".getConsultPage").createPage({
  318. pageCount:Math.ceil(allData.total/pageSize),
  319. current:allData.pageNo,
  320. backFn:function(p){
  321. getConsultData(pageSize,p,false,status,timeType,sortType);
  322. }
  323. });
  324. }
  325. }
  326. },
  327. error:function(response){
  328. $.MsgBox.Alert('提示',"收到咨询数据请求失败");
  329. },
  330. });
  331. };
  332. //咨询和回复中点击查看或者回复
  333. function clickLookBtn2(sendId,attrParams,consultId,consultStatus,assessStatus,thanksStatus){
  334. //收到咨询
  335. if(attrParams == "professorId"){
  336. //调取页面
  337. $.ajax({
  338. url:"diloags.html",
  339. dataType:"html",
  340. success:function(result){
  341. $(".workcon").html(result);
  342. dialogHeadFn2("/ajax/consult/qapro",attrParams,consultId,thanksStatus);
  343. dialogContentDataHandle2(consultId);
  344. $("#dialog_sendBtn").click(function(){sendDialogContentFn2(sendId,consultId)});
  345. },
  346. error:function(error){
  347. //console.log(data);
  348. //加载对话页面失败
  349. // console.log(error);
  350. },
  351. complete:function(){
  352. //对话页后退按钮
  353. $("#backBtn").click(function(){
  354. $("#consultbtn").css({
  355. color:"#fff",
  356. background:"#f99550"
  357. });
  358. clickConsultBtn();
  359. });
  360. }
  361. })
  362. }
  363. //收到回复
  364. else if(attrParams == "consultId"){
  365. $.ajax({
  366. url:"diloags.html",
  367. dataType:"html",
  368. success:function(result){
  369. //console.log(data);
  370. $(".workcon").html(result);
  371. //进行中
  372. if(consultStatus == 0){
  373. dialogHeadFn2("/ajax/consult/qacon",attrParams,consultId,thanksStatus);
  374. dialogContentDataHandle2(consultId);
  375. $("#dialog_sendBtn").click(function(){sendDialogContentFn2(sendId,consultId)});
  376. }
  377. //完成
  378. else if(consultStatus == 1){
  379. //未评价
  380. if(assessStatus == 0){
  381. assessFn2(consultId,attrParams,thanksStatus)
  382. }else if(assessStatus == 1){
  383. dialogHeadFn2("/ajax/consult/qacon",attrParams,consultId,thanksStatus);
  384. dialogContentDataHandle2(consultId);
  385. $("#dialog_sendBtn").click(function(){sendDialogContentFn2(sendId,consultId)});
  386. }
  387. }
  388. },
  389. error:function(error){
  390. //console.log(data);
  391. //加载对话页面失败
  392. // console.log(error);
  393. },
  394. complete:function(){
  395. //对话页后退按钮
  396. $("#backBtn").click(function(){
  397. $("#consultbtn").css({
  398. color:"#fff",
  399. background:"#f99550"
  400. });
  401. clickConsultBtn();
  402. });
  403. }
  404. })
  405. }
  406. };
  407. //对话页咨询内容展开和收起
  408. var cur_status = "less";
  409. function showMore(){
  410. //alert("show_more_init!");
  411. var charNumbers=$("#dialog_consultContent").html().length;//总字数
  412. var limit = 20;//显示字数
  413. if(charNumbers > limit){
  414. var orgText = $("#dialog_consultContent").html();//原始文本
  415. var orgHeight= $("#dialog_consultContent").height();//原始高度
  416. var showText = orgText.substring(0,limit);//最终显示的文本
  417. var showText = showText + "...";
  418. $("#dialog_consultContent").html(showText);
  419. var contentHeight = $("#dialog_consultContent").height();//截取内容后的高度
  420. $("#dialog_switch").click(function(){
  421. if(cur_status == "less"){
  422. $("#dialog_consultContent").height(contentHeight).html(orgText).animate({ height:orgHeight}, { duration: "slow" });
  423. $(this).html("收起");
  424. cur_status = "more";
  425. }else{
  426. $("#dialog_consultContent").height(orgHeight).html(showText).animate({ height:contentHeight}, { duration: "fast" });
  427. $(this).html("展开");
  428. cur_status = "less";
  429. }
  430. });
  431. }
  432. else{
  433. $("#dialog_switch").hide();
  434. }
  435. };
  436. //返回函数
  437. function backHandle(){
  438. };
  439. //对话标题处理函数
  440. function dialogHeadFn2(url,attrParams,consultId,thanksStatus){
  441. $.ajax({
  442. url:url,//
  443. data:{"consultId":consultId,"readStatus":"1"},
  444. type:"get",
  445. aysnc:false,
  446. success:function(response){
  447. var myData = response["data"];
  448. //咨询
  449. if(attrParams == 'professorId'){
  450. //进行中
  451. if(myData["consultStatus"] == 0){
  452. $("#dil_consultStatus").text("进行中");//咨询状态
  453. $(".dialogfoot").css("display","block");//显示发送对话部分
  454. $("#dialog_consultTitle").text(myData["consultTitle"]);//咨询主题
  455. $("#dialog_consultType").text(myData["consultType"]);//咨询类型
  456. $("#dial_consultName").text(myData["professor"]["name"]);//与@@@对话
  457. $("#dialog_consultContent").html(myData["consultContant"])//咨询内容
  458. }
  459. //咨询已完成
  460. else {
  461. $("#dil_consultStatus").text("完成");//咨询状态
  462. $("#dialog_consultTitle").text(myData["consultTitle"]);//咨询主题
  463. $("#dialog_consultType").text(myData["consultType"]);//咨询类型
  464. $("#dial_consultName").text(myData["professor"]["name"]);//与@@@对话
  465. $("#dialog_consultContent").html(myData["consultContant"])//咨询内容
  466. $(".dialogfoot").css("display","none");//隐藏发送对话部分
  467. //如果评价
  468. if(myData["assessStatus"] == 1){
  469. var startConut = myData["assessStar"];
  470. for(var i = 0; i < startConut; i ++){
  471. $("#showAllAssess .evastar2").eq(i).addClass("addStar");
  472. }
  473. $("#showAllAssess").removeClass("displayNone");//总体评价
  474. $("#dialog_assessContent").removeClass("displayNone");
  475. $("#dialog_assessContentText").html(myData["assessContant"]);
  476. //如果感谢
  477. if(myData["thanksStatus"] == 1){
  478. if(myData["thanksMoney"] != null && myData["thanksMoney"] != undefined && myData["thanksMoney"] != "" && myData["thanksMoney"] != 0 ){
  479. $("#dialog_thanks").removeClass("displayNone");//感谢
  480. $("#dialog_thanksMoney").text(myData["thanksMoney"]);
  481. }
  482. }else {//未感谢
  483. return false;
  484. }
  485. }else {//未评价
  486. return false;
  487. }
  488. }
  489. }
  490. //回复
  491. else if(attrParams == 'consultId'){
  492. //回复进行中
  493. if (myData["consultStatus"] == 0) {
  494. $("#dil_consultStatus").text("进行中");//咨询状态
  495. $(".dialogfoot").css("display","block");//显示发送对话部分
  496. $("#dialog_consultTitle").text(myData["consultTitle"]);//咨询主题
  497. $("#dialog_consultType").text(myData["consultType"]);//咨询类型
  498. $("#dial_consultName").text(myData["professor"]["name"]);//与@@@对话
  499. $("#dialog_consultContent").html(myData["consultContant"])//咨询内容
  500. $("#confirmBtn").removeClass("displayNone");//确认完成按钮显示
  501. //点击确认完成
  502. $("#confirmBtn").click(function(){
  503. clickConfirmFn(consultId,thanksStatus);
  504. })
  505. //发表评论
  506. $("#sendAssessBtn").click(function(){
  507. clickSendAssessBtn2(consultId,attrParams,thanksStatus)
  508. });
  509. //稍后评价
  510. $("#noAssessBtn").click(function(){
  511. noAssessFn2(consultId,attrParams,thanksStatus);
  512. });
  513. //点击关闭
  514. $("#closeAssessBtn").click(function(){
  515. noAssessFn2(consultId,attrParams,thanksStatus);
  516. });
  517. }
  518. //回复完成
  519. else {
  520. $("#dil_consultStatus").text("已完成");//咨询状态
  521. $("#dialog_consultTitle").text(myData["consultTitle"]);//咨询主题
  522. $("#dialog_consultType").text(myData["consultType"]);//咨询类型
  523. $("#dial_consultName").text(myData["professor"]["name"]);//与@@@对话
  524. $("#dialog_consultContent").html(myData["consultContant"])//咨询内容
  525. $(".dialogfoot").css("display","none");//隐藏发送对话部分
  526. //回复完成未评价
  527. if(myData["assessStatus"] == 0){
  528. assessFn2(consultId,attrParams,thanksStatus)
  529. }else {
  530. //评价星级
  531. var startConut = myData["assessStar"];
  532. for(var i = 0; i < startConut; i ++){
  533. $("#showAllAssess .evastar2").eq(i).addClass("addStar");
  534. }
  535. $("#showAllAssess").removeClass("displayNone");//总体评价
  536. // $("#dialog_thanksBtn").removeClass("displayNone");
  537. $("#dialog_assessContent").removeClass("displayNone");
  538. $("#dialog_assessContentText").html(myData["assessContant"]);
  539. //未感谢
  540. if(myData["thanksStatus"] == 0){
  541. // $("#dialog_thanksBtn").removeClass("dispalyNone");
  542. }else {
  543. //感谢金额
  544. // $("#dialog_thanks").removeClass("displayNone");
  545. // $("#dialog_thanksMoney").text(myData["thanksMoney"]);
  546. }
  547. }
  548. }
  549. };
  550. //咨询内容展开收起效果
  551. if($("#dialog_consultContent")){
  552. showMore();
  553. };
  554. },
  555. error:function (error) {
  556. //对话标题信息
  557. }
  558. });
  559. }
  560. //点击确认完成
  561. function clickConfirmFn(consultId,thanksStatus){
  562. finish();
  563. $("#finish").click(function(){
  564. finishFn(consultId)
  565. });
  566. }
  567. //点击确认完成弹窗中完成
  568. function finishFn(consultId,thanksStatus){
  569. //更新咨询状态
  570. $.ajax({
  571. url:"/ajax/consult/finishTime",
  572. type:"post",
  573. data:{
  574. "consultId":consultId, //咨询ID
  575. "consultStatus":"1", //咨询状态 0-进行中,1-已完成
  576. },
  577. success:function(response){
  578. console.log(response);
  579. $(".blackcover").remove();
  580. $("body").css("position","static");
  581. assessFn2(consultId,"consultId",thanksStatus);
  582. },
  583. error:function(error){
  584. //更新咨询状态失败
  585. }
  586. });
  587. };
  588. //============对话内容数据处理函数
  589. function dialogContentDataHandle2(consultId){
  590. $.ajax({
  591. "url":"/ajax/tidings/qacon",//对话内容显示接口
  592. "type":"get",
  593. "data":{"consultId":consultId},
  594. "success":function(response){
  595. $("#dialogContent").empty("");
  596. var dialogConData = response["data"];
  597. var dialogStr;
  598. dialogStr = dialogContentStrFn(dialogConData);
  599. $("#dialogContent").prepend(dialogStr);
  600. $("#dialogContent").removeClass("dialog");
  601. var height=$("#dialogContent").height();
  602. $("#dialogContent").addClass("dialog");
  603. $("#dialogContent").scrollTop(height);
  604. },
  605. error:function(error){
  606. }
  607. });
  608. };
  609. //发送按钮处理函数
  610. function sendDialogContentFn2(sendId,consultId){
  611. var tidingsContant = $("#dialog_sendContent").val();
  612. //console.log(tidingStr);
  613. $.ajax({
  614. "url":"/ajax/tidings",
  615. "type":"post",
  616. "data":{"tidingsContant":tidingsContant,"senderId":sendId,"consultId":consultId},
  617. "success":function(response){
  618. // console.log(response);//返回对话内容的id
  619. if(response.success){
  620. dialogContentDataHandle2(consultId);
  621. }
  622. },
  623. "error":function(error){
  624. //对话发送消息失败
  625. console.log(error);
  626. }
  627. });
  628. $("#dialog_sendContent").val("");
  629. };
  630. //评价
  631. function assessFn2(consultId,attrParams,thanksStatus){
  632. ConsultComment();
  633. //评价星星样式
  634. var start;
  635. function clickStar(){
  636. $(".evastar2").removeClass('addStar');
  637. start=$(this).index()+1;
  638. for(var i=0;i<start;i++){
  639. if(i<start){
  640. $(".evastar2").eq(i).addClass("addStar");
  641. }
  642. else{
  643. $(".evastar2").eq(i).removeClass('addStar');
  644. }
  645. }
  646. $("#startCount").val($(".addStar").length);
  647. };
  648. $(".evastar2").bind("click",clickStar);
  649. //发表评论
  650. $("#sendAssessBtn").click(function(){
  651. clickSendAssessBtn2(consultId,attrParams,thanksStatus)
  652. });
  653. //稍后评价
  654. $("#noAssessBtn").click(function(){
  655. noAssessFn2(consultId,attrParams,thanksStatus)
  656. });
  657. //点击关闭
  658. $("#closeAssessBtn").click(function(){
  659. noAssessFn2(consultId,attrParams,thanksStatus)
  660. });
  661. };
  662. //发送评价
  663. //点击发表评论:保存发表内容和星级
  664. function clickSendAssessBtn2(consultId,attrParams,thanksStatus){
  665. var assessStar = $("#startCount").val();
  666. var assessContant = $("#assessCon").val();
  667. var assessContentStr ={
  668. "consultId":consultId, //咨询ID
  669. "assessStatus":"1", //评价状态 0-未评价,1-已评价
  670. "assessStar":assessStar, //评价星级
  671. "assessContant":assessContant //评价内容
  672. };
  673. //保存
  674. $.ajax({
  675. "url":"/ajax/consult/assess",//点击发表评论接口
  676. "type":"post",
  677. "data":assessContentStr,
  678. "success":function(response){
  679. },
  680. "error":function(error){
  681. //发表评论失败
  682. $.MsgBox.Alert('提示',"评论失败");
  683. },
  684. "complete":function(){
  685. $(".blackcover").remove();
  686. $("body").css("position","static");
  687. //发表评价后进入对话页
  688. $.ajax({
  689. "url":"diloags.html",
  690. "dataType":"html",
  691. "success":function(result){
  692. //console.log(data);
  693. $(".workcon").html(result);
  694. dialogHeadFn2("/ajax/consult/qacon",attrParams,consultId,thanksStatus);
  695. dialogContentDataHandle2(consultId);
  696. },
  697. "error":function(error){
  698. //console.log(data);
  699. //加载对话页面失败
  700. console.log(error);
  701. }
  702. });
  703. }
  704. });
  705. };
  706. //稍后评价、
  707. function noAssessFn2(consultId,attrParams,thanksStatus){
  708. $.ajax({
  709. "url":"diloags.html",
  710. "dataType":"html",
  711. "success":function(result){
  712. //console.log(data);
  713. $(this).attr("id");
  714. $(".workcon").html(result);
  715. $(".blackcover").remove();
  716. $("body").css("position","static");
  717. $.ajax({
  718. url:"/ajax/consult/qacon",//对话标题信息接口
  719. data:{"consultId":consultId,"readStatus":"1"},
  720. type:"get",
  721. aysnc:false,
  722. success:function(response){
  723. var myData = response["data"];
  724. //稍后评价说明已经完成
  725. $("#dil_consultStatus").text("已完成");//咨询状态
  726. $("#dialog_consultTitle").text(myData["consultTitle"]);//咨询主题
  727. $("#dialog_consultType").text(myData["consultType"]);//咨询类型
  728. $("#dial_consultName").text(myData["professor"]["name"]);//与@@@对话
  729. $(".dialogfoot").css("display","none");//隐藏发送对话部分
  730. $("#dialog_assessBtn").removeClass("displayNone");
  731. $("#dialog_assessBtn").click(function(){
  732. assessFn2(consultId,attrParams,thanksStatus);
  733. });
  734. },
  735. error:function(error){
  736. }
  737. });
  738. dialogContentDataHandle2(consultId);
  739. },
  740. "error":function(error){
  741. //加载对话页面失败
  742. $.MsgBox.Alert('提醒',"对话请求错误");
  743. }
  744. });
  745. };
  746. //点击主页面咨询函数
  747. function clickConsultBtn(){
  748. if(userid != "" && userid != null){
  749. $.ajax({
  750. "url":"consult.html",
  751. "dataType" : "html",
  752. "success":function(responseHtml){
  753. $(".workcon").html(responseHtml);
  754. //On Click Event 收到咨询和收到回复tab效果
  755. $(".worksamlltit3").bind("click",tab);
  756. function tab(){
  757. $(".worksamlltit3").removeClass("worksamlltitnow");
  758. $(this).addClass("worksamlltitnow");
  759. $(".workmysrc3").hide();
  760. var activeTab = $(this).attr("href");
  761. $(activeTab).fadeIn();
  762. return false;
  763. };
  764. //收到咨询
  765. getConsultData("5",1,true,0,0,0);
  766. //咨询点击下拉菜单
  767. consultPullDownMenu();
  768. //无咨询 显示我的需求
  769. if($("#workContainer").find(".workselectitem").length == 0){
  770. // alert("无咨询 显示我的需求");
  771. $(".worksubcon .workmysrc3 ").eq(0).css("display","none");
  772. $(".workcontit .worksamlltit3").eq(0).removeClass("worksamlltitnow");
  773. $(".worksubcon .workmysrc3 ").eq(1).css("display","block");
  774. $(".workcontit .worksamlltit3").eq(1).addClass("worksamlltitnow");
  775. //回复
  776. getMyData("5",1,true,0,0,0);
  777. //回复点击下拉菜单
  778. myRequirePullDownMenu();
  779. //无咨询和需求
  780. if($("#workContainer2").find(".workselectitem").length == 0){
  781. // $("#workContainer2").append("<div>无需求</div>");
  782. }
  783. }
  784. //有咨询
  785. else {
  786. // alert("有咨询")
  787. //回复
  788. getMyData("5",1,true,0,0,0);
  789. //回复点击下拉菜单
  790. myRequirePullDownMenu();
  791. }
  792. $(".workcontit .worksamlltit3").eq(0).click(function(){
  793. $("#workContainer").remove();
  794. $(".getConsultPage").remove();
  795. $(".workselectcon").eq(0).append('<div id="workContainer"></div>');
  796. $(".workselectcon").eq(0).append('<div class="tcdPageCode getConsultPage"></div>');
  797. //收到咨询
  798. getConsultData("5",1,true,0,0,0);
  799. //点击下拉菜单
  800. consultPullDownMenu();
  801. });
  802. $(".workcontit .worksamlltit3").eq(1).click(function(){
  803. $("#workContainer2").remove();
  804. $(".getReplyPage").remove();
  805. $(".workselectcon").eq(1).append('<div id="workContainer2"></div>');
  806. $(".workselectcon").eq(1).append('<div class="tcdPageCode getReplyPage"></div>');
  807. //回复
  808. getMyData("5",1,true,0,0,0);
  809. //点击下拉菜单
  810. myRequirePullDownMenu();
  811. });
  812. },
  813. })
  814. }else{
  815. $.MsgBox.Alert('提醒',"您尚未登录");
  816. }
  817. };
  818. //咨询下拉菜单顺序处理函数
  819. function consultPullDownMenu(){
  820. //点击下拉菜单
  821. $(".consultOption ul").find("li").click(function(){
  822. getConsultData("5",1,true,$(this).attr("tip"),$("#showTimeSort").attr("tim"),$("#timeSortId").val());
  823. });
  824. $(".timeOption ul").find("li").click(function(){
  825. getConsultData("5",1,true,$("#showStatus").attr("tip"),$(this).attr("tim"),$("#timeSortId").val());
  826. });
  827. var sortFlag = true;
  828. $("#consultArrow").click(function(){
  829. if(sortFlag == true){
  830. $(this).find("div").css("background-position","-20px 1px");
  831. $("#timeSortId").val("1");
  832. sortFlag = false;
  833. }else{
  834. $(this).find("div").css("background-position","0px 1px");
  835. $("#timeSortId").val("0");
  836. sortFlag=true;
  837. }
  838. getConsultData("5",1,true,$("#showStatus").attr("tip"),$("#showTimeSort").attr("tim"),$("#timeSortId").val());
  839. });
  840. };
  841. //我的需求下拉菜单处理函数
  842. function myRequirePullDownMenu(){
  843. //点击下拉菜单
  844. $(".replyOption ul").find("li").click(function(){
  845. getMyData("5",1,true,$(this).attr("tip"),$("#showTimeSort2").attr("tim"),$("#timeSortId2").val());
  846. });
  847. $(".timeOption2 ul").find("li").click(function(){
  848. getMyData("5",1,true,$("#showStatus2").attr("tip"),$(this).attr("tim"),$("#timeSortId2").val());
  849. });
  850. var sortFlag2 = true;
  851. $("#replyArrow").click(function(){
  852. if(sortFlag2 == true){
  853. $(this).find("div").css("background-position","-20px 1px");
  854. $("#timeSortId2").val("1");
  855. sortFlag2 =false;
  856. }else{
  857. $(this).find("div").css("background-position","0px 1px");
  858. $("#timeSortId2").val("0");
  859. sortFlag2=true;
  860. }
  861. getMyData("5",1,true,$("#showStatus2").attr("tip"),$("#showTimeSort2").attr("tim"),$("#timeSortId2").val());
  862. });
  863. };