Nenhuma Descrição

consultFlat.js 48KB

    /** * */ //ajax封装函数 //创建构造函数类 function Conslut(){ }; Conslut.prototype = { init:function(consultanatId,professorId){ var userid = $.cookie("userid"); this.consultanatId = { "consultantId":userid }; this.professorId = { "professorId":userid }; }, getConsultData:function(url,type,params,successConsultFn,errorMsg){ $.ajax({ "url":url, "type" : type, "data" :params, "success":successConsultFn, "error":function(){ $.MsgBox.Alert(errorMsg); } }); }, getReplyData:function(url,type,params,successRelyFn,errorMsg){ $.ajax({ "url":url, "type" : type, "data" :params, "success":successRelyFn, "error":function(){ $.MsgBox.Alert(errorMsg); } }); }, getConsultHtml:function(url,type,params,successHtmlFn,errorMsg){ $.ajax({ "url":url, "type" : type, "data" :params, "success":successHtmlFn, "error":function(){ $.MsgBox.Alert(errorMsg); } }); }, } //登陆人id var userid = $.cookie("userid"); //收到咨询数据成功函数 function successRelyFn(response){ }; //data:需要处理的数据,htmlStr:页面中需要的html字符串拼接, //attrParams:数据中不同的参数比如:收到咨询是professorId,收到答复:consultantId function handleData(data,htmlStr,attrParams,text,btnCls){ htmlStr = ''; for(var i = 0; i < data.length;i++){ if(data[i]["consultStatus"] == 0){ data[i]["consultStatus"] = "进行中"; }; if(data[i]["consultStatus"] == 1){ data[i]["consultStatus"] = "完成"; }; if(data[i]["assessStatus"] == 0){ data[i]["assessStatus"] = "未评价"; } if(data[i]["assessStatus"] == 1){ data[i]["assessStatus"] = "已评价"; } if(data[i]["thanksStatus"] == 0){ data[i]["thanksStatus"] = "未感谢"; } if(data[i]["thanksStatus"] == 1){ data[i]["thanksStatus"] = "已感谢"; } htmlStr += "<div class='workselectitem' id='" +data[i]["consultId"] +"' >" + "<table width='100%'>" + "<tbody><tr>" + "<td width='14%' class='messagebox'>" + "<a class='workhead workitimg' href='information.html'>" + "<img src='images/default-photo.jpg' width='100%' height='100%'>" + "</a>" + "<span class='msgprompt'>1</span>" + "</td>" + "<td style='position:relative;' width='86%'>" + "<div class='workinfor worksitcon'>" + "<h4><a href='' class='named' id='nameS'> " + data[i]["professor"]["name"] +" </a><img class='modifyicon' src='images/rz.png' width='30'><input type='text' class='assessStar' value='"+data[i]["assessStar"] +"' style='display: none;'></h4>" + "<h6><span>职称 " + data[i]["professor"]["title"] +" </span>,<span>职位 " + data[i]["consultId"] +" </span>,<span> " + data[i]["professor"]["orgName"] +" </span>,<span> " + data[i]["professor"]["department"] +" </span>&nbsp;|&nbsp;<span> " + data[i]["professor"]["adress"] +" </span></h6>" + "<h6>"+ "<span>咨询主题:<em> " + data[i]["consultTitle"] +" </em></span>" + "&nbsp;&nbsp;&nbsp;&nbsp;" + "<span>咨询类型:<em> " + data[i]["consultType"] +" </em></span>" + "&nbsp;&nbsp;&nbsp;&nbsp;<span>" + "咨询发起时间:<em> " + 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)+ "</em>" + "</span></h6>" + "<p>最后回复<span class='lasttime'> ( " + data[i]["revoveryTime"].substr(0,4) + "-" + data[i]["revoveryTime"].substr(4,2) + "-" + data[i]["revoveryTime"].substr(6,2) + " " + data[i]["revoveryTime"].substr(8,2)+ ":" +data[i]["revoveryTime"].substr(10,2) + ") </span>" + "</p>" + "<p class='rebackcon'> " + data[i]["consultContant"] +" </p>" + "</div>" + "<div class='workhandle'>" + "<div class='rightopert floatR'>" + "<span class='replybtn "+btnCls+"' id='"+ data[i]["consultId"]+ "'>" +text +"</span>" + "<span class='moreopert'>...</span>" + "<ul class='moreopertbtn'>" + "<li>投诉</li>" + "</ul>" + "</div>" + "<div class='leftstate floatR'>" + "<span class='coultstate'><i class='coultState'>" +data[i]["consultStatus"]+"/ </i><i class='assessStatus'> "+data[i]["assessStatus"]+" / </i><i class='thanksStatus' >"+data[i]["thanksStatus"]+"</i></span>" + "</div>" + "</div>" + "</td>" + "</tr></tbody></table>" + "</div>"; }; return htmlStr }; //咨询点击回复,对话页字符串拼接函数 //data:要处理的数据,htmlStr:需要拼接到页面的元素,position function dialogContentStrFn(data){ var htmlStr =""; var dialogitem,float,dilinfobox,dilarrow,dilarrow_bor; for(var i = 0; i < data.length;i++){ if(data[i]["professor"]["id"] == userid){ dialogitem = "dialogrightitem"; float = "floatR"; dilinfobox = "dilinfobox_r"; dilarrow = "dilarrow_r"; dilarrow_bor="dilarrow_r_bor"; } else{ dialogitem = "dialogleftitem"; float = "floatL"; dilarrow = "dilarrow_l"; dilinfobox = "dilinfobox_l"; dilarrow_bor="dilarrow_l_bor"; } htmlStr += "<div class='"+dialogitem+"'>" + "<div class='dilmod'>" + "<div class='diluser "+float+"'>" + "<a href='' target='_blank' class='userface'>" + "<img src='images/default-photo.jpg' width='100%' height='100%'>" + "</a>" + "</div>" + "<div class='dilinfobox "+ dilinfobox+" "+ float +"'>" + "<div class='delinfocon clearfix'>" + "<div class='dilarrow "+ dilarrow+"'></div>" + "<div class='dilarrow "+dilarrow_bor+"'></div>" + "<div class='delinfomain "+float+"'>" + "<div class='cont'>" + "<p>"+data[i]["tidingsContant"]+"</p>" + "</div>" + "</div>" + "</div>" + //dilinfobox "</div>" + //dilinfobox "</div>" + //dilmod "</div>" + //dialogrightitem "</div> " }; return htmlStr; }; //点击星星函数 /*var starStart; function clickStar(selector){ $(selector+" .evastar2").removeClass('addStar'); starStart=$(this).index()+1; for(var i=0;i<starStart;i++){ if(i<starStart){ $(".evastar2").eq(i).addClass("addStar"); } else{ $(".evastar2").eq(i).removeClass('addStar'); } } $("#startCount").val($(".addStar").length); };*/ //点击:正序倒叙函数:只改变了样式 var sortFlag2 = true; function clickSortFn(){ if(sortFlag2 == true){ $(this).find("div").css("background-position","-20px 1px"); $("#timeSortId2").val("1"); sortFlag2 =false; }else{ $(this).find("div").css("background-position","0px 1px"); $("#timeSortId2").val("0"); sortFlag2=true; }; }; $(document).ready(function(){ //用于判断是否收到咨询传值 var professorIdStrByconsult = { "professorId":userid }; //用于收到回复传值 var consultIdStrByReply = { "consultantId":userid, "pageSize":"5", "pageNo":"1" }; // console.log(localStorage.getItem("professorId")); $(".workmenu").on("click","#consultbtn",function(){ //1.先ajax请求,判断是否有收到咨询消息,然后ajax-html,然后渲染数据 // console.log(professorIdStrByconsult); //检查用户是否登录 if(userid != "" && userid != null){ $.ajax({ "url":"/ajax/consult/pqpro",//判断是否有无咨询 "type" : "get", //传值:登陆人id:专家id "data" :professorIdStrByconsult, "contentType" : "application/x-www-form-urlencoded", "beforeSend":function(response){ // console.log(response) }, "success":function(consultResponse){ // console.log(consultResponse); //如果没有咨询数据 隐藏收到咨询 if(consultResponse["data"]["total"] == 0){ // alert("未收到咨询"); //ajax页面 $.ajax({ "url":"consult.html", "dataType" : "html", "beforeSend":function(response){ // console.log(response) }, "success":function(responseHtml){ $(".workcon").html(responseHtml); $(".worksamlltit3:first").hide(); $(".workmysrc3:first").hide(); $(".workmysrc3:last").fadeIn(); var replyTrHtml; var pageNo; //======================================没有咨询情况下 ajax请求收到回复====================== $.ajax({ "url":"/ajax/consult/pqcon",//收到回复接口 "type":"get", "data":consultIdStrByReply, "dataType" : "json", "beforeSend":function(response){ // console.log(response) }, "success":function(replyResponse){ console.log(replyResponse) var allData = replyResponse.data; var replyData = allData["data"]; if(replyData.length != 0 && replyData.length != null){ replyTrHtml = handleData(replyData,replyTrHtml,"consultantId","查看","lookBtn"); // $(".tcdPageCode:last").before(replyTrHtml); $("#workContainer2").prepend(replyTrHtml); }else{ return false; } }, "error":function(response){ //收到回复失败 // console.log(response) }, }); //==========================================只有收到回复时,下拉菜单改变 ajax开始================== //点击正序倒序 var sortFlag2 = true; $("#replyArrow").click(function(){ if(sortFlag2 == true){ $(this).find("div").css("background-position","-20px 1px"); $("#timeSortId2").val("1"); sortFlag2 =false; }else{ $(this).find("div").css("background-position","0px 1px"); $("#timeSortId2").val("0"); sortFlag2=true; } }); // $("#replyArrow").on("clcik",clickSortFn); var timeType2,sortType2,replyStatus,consultId; replyStatus = $("#replySelectId").val();//回复状态值 timeType2 = $("#timeTypeId2").val();//时间类型值 sortType2 = $("#timeSortId2").val();//排序值; //console.log(consultStatus,timeType,sortType+"res333"); //默认传值: var replyInfo = { "consultantId":userid, "status":replyStatus, "timeType":timeType2, "sortType":sortType2 }; function replyStatusFn(){ //改变后,要传的值 replyStatus = $("#replySelectId").val();//咨询状态值 timeType2 = $("#timeTypeId2").val();//时间类型值 sortType2 = $("#timeSortId2").val();//排序值; replyInfo = { "consultantId":userid, "status":replyStatus, "timeType":timeType2, "sortType":sortType2 }; // console.log("ajax中的值:"+ replyInfo.replyStatus + replyInfo.timeType + replyInfo.sortType +replyInfo.consultantId); //=====================================只有收到回复时 更新下拉菜单============== $.ajax({ "url":"/ajax/consult/pqcon",//更新下拉菜单接口 "type":"get", "data":replyInfo, "beforeSend":function(response){ console.log(response); }, "success":function(response){ $("#workContainer2 .workselectitem").remove(); var allData = response.data; var replyData = allData["data"]; replyTrHtml = handleData(replyData,replyTrHtml,"consultantId","查看","lookBtn"); console.log(replyTrHtml); // $(".tcdPageCode:last").before(replyTrHtml); $("#workContainer2").prepend(replyTrHtml); }, "error":function(response){ // console.log(response) //更新下拉菜单失败 } }); };//更新下拉菜单处理函数结束 //绑定回复状态事件 $(".replyOption ul").bind("click", "li",replyStatusFn); //绑定回复状态事件 $(".timeOption2 ul").bind("click", "li",replyStatusFn); $("#replyArrow").bind("click",replyStatusFn); }, "error":function(response){ //请求页面失败 // console.log(response) }, }) }else{ // alert("收到咨询"); //ajax页面 $.ajax({ "url":"consult.html", "dataType" : "html", "success":function(responseHtml){ $(".workcon").html(responseHtml); //ajax 收到咨询数据和收到回复数据 //ajax收到咨询 consultResponse 收到咨询返回值 var consultTrHtml; var allData = consultResponse.data; var consultData = allData["data"]; // console.log(consultData.length); consultTrHtml = handleData(consultData,consultTrHtml,"professorId","回复","replyBtn"); // $(".tcdPageCode:first").before(consultTrHtml); $("#workContainer").prepend(consultTrHtml); //================================================有咨询时,下拉菜单改===变 ajax========================== // 排列顺序(正序、倒序) var sortFlag = true;//正倒排序标记 $(".orderedbtn").click(function(){ if(sortFlag == true){ $(this).find("div").css("background-position","-20px 1px"); $("#timeSortId").val("1"); sortFlag =false; }else{ $(this).find("div").css("background-position","0px 1px"); $("#timeSortId").val("0"); sortFlag=true; } }); var timeType,sortType,consultStatus,consultId; consultStatus = $("#consultSelectId").val();//咨询状态值 timeType = $("#timeTypeId").val();//时间类型值 sortType = $("#timeSortId").val();//排序值; // console.log(consultStatus,timeType,sortType+"res333"); //默认传值: var consultInfo = { "professorId":userid, "status":consultStatus, "timeType":timeType, "sortType":sortType }; // console.log("默认值:"+consultInfo.status + consultInfo.timeType + consultInfo.sortType + consultInfo.professorId); //收到咨询信息改变下拉菜单 function consultStatusFn(){ //改变后,要传的值 consultStatus = $("#consultSelectId").val();//咨询状态值 timeType = $("#timeTypeId").val();//时间类型值 sortType = $("#timeSortId").val();//排序值; //要传的值: consultInfo = { "professorId":userid, "status":consultStatus, "timeType":timeType, "sortType":sortType }; // console.log("ajax中的值:"+ consultInfo.status + consultInfo.timeType + consultInfo.sortType + consultInfo.consultantId); //更新下拉菜单 $.ajax({ "url":"/ajax/consult/pqpro",//更新下拉菜单接口 "data":consultInfo, "type":"get", "beforeSend":function(response){ // console.log(response); }, "success":function(response){ $("#workContainer .workselectitem").remove(); // $(".tcdPageCode:first").before().empty(); var allData = response.data; var consultData = allData["data"]; console.log(consultData.length); consultTrHtml = handleData(consultData,consultTrHtml,"professorId","回复","replyBtn"); // $(".tcdPageCode:first").before(consultTrHtml); $("#workContainer").prepend(consultTrHtml); //给咨询页回复绑定事件 $("#workContainer .workselectitem").find(".replyBtn").bind("click",clickReplyFn); }, "error":function(response){ // console.log(response) //更新下拉菜单失败 } }); };//更新咨询下拉菜单处理函数结束 //绑定咨询状态事件 $(".consultOption ul").bind("click", "li",consultStatusFn); //绑定咨询状态事件 $(".timeOption ul").bind("click", "li",consultStatusFn); $(".orderedbtn").bind("click",consultStatusFn); //============================================点击咨询页面中回复按钮===================== function clickReplyFn(){ var consultId = $.trim($(this).attr("id"));//咨询id var assessStatus = $.trim($(this).find(".coultState").text());//评价状态 0-未评价,1-已评价 var consultStatus = $.trim($(this).find(".assessStatus").text());//咨询状态 0-进行中,1-已完成 var thanksStatus = $.trim($(this).find(".thanksStatus").text());//感谢状态 0-未感谢,1-已感谢 var assessStar = $.trim($(this).find(".assessStar").val());//星级,几颗星 用隐藏域做 //点击确认完成的传值:consultId,咨询状态 var confirmFinishStr = { "consultId":consultId, "consultStatus":consultStatus }; //对话标题 传值, var consultIdStr = { "consultId":consultId } //ajax加载对话页面 $.ajax({ "url":"diloags.html", "dataType":"html", "success":function(result){ //console.log(data); $(this).attr("id"); $(".workcon").html(result); //===========================================dialog数据================== //=========对话头部 //对话头部数据渲染 function dialogHeadDataHandleFn(){ //星星评级 var starStart; function clickStar(){ $(".evastar2").removeClass('addStar'); starStart=$(this).index()+1; for(var i=0;i<starStart;i++){ if(i<starStart){ $(".evastar2").eq(i).addClass("addStar"); } else{ $(".evastar2").eq(i).removeClass('addStar'); } } $("#startCount").val($(".addStar").length); }; $.ajax({ "url":"/ajax/consult/qapro",//从收到咨询点击回复接口 "type":"get", "data":consultIdStr, "success":function(response){ console.log("点击回复返回数据"); console.log(response) var consultantData = response["data"]; //对话框标题信息 //进行中, if(consultantData["consultStatus"] == 0){ consultantData["consultStatus"] = "进行中"; $("#dial_confirmFinishConsult").css("display","none");//确认完成按钮显示 $("#dialog_thanksBtn").css("display","none"); $("#dialog_assessBtn").css("display","none"); $("#showAllAssess").css("display","none");//总体评价 $(".dialogfoot").css("display","block");//显示发送对话部分 $("#dialog_thanks").css("display","none");//隐藏感谢 $("#dial_consultName").text(consultantData["professor"]["name"]);//与@@@对话 $("#dil_consultStatus").text(consultantData["consultStatus"]);//咨询状态 $("#dialog_consultTitle").text(consultantData["consultTitle"]);//咨询主题 $("#dialog_consultType").text(consultantData["consultType"]);//咨询类型 } //已完成 if(consultantData["consultStatus"] == 1 || consultantData["consultStatus"] == 2 ||consultantData["consultStatus"] == 3 || consultantData["consultStatus"] == 4){ consultantData["consultStatus"] = "已完成"; $("#dil_consultStatus").text(consultantData["consultStatus"]);//咨询状态 //已完成,未感谢: if(consultantData["thanksStatus"] == 0){ //未感谢,未评价 if(consultantData["assessStatus"] == 0){ $("#dial_confirmFinishConsult").css("display","none");//隐藏确认完成按钮 $("#dialog_thanksBtn").css("display","none"); $("#dialog_assessBtn").css("display","none"); $("#showAllAssess").css("display","none");//隐藏评价 $("#dialog_thanks").css("display","none");//隐藏感谢 $("#dial_consultName").text(consultantData["professor"]["name"]);//与@@@对话 $("#dialog_consultTitle").text(consultantData["consultTitle"]);//咨询主题 $("#dialog_consultType").text(consultantData["consultType"]);//咨询类型 } //未感谢,已评价 else{ $("#dial_confirmFinishConsult").css("display","none");//隐藏确认完成按钮 $("#dialog_thanksBtn").css("display","none"); $("#dialog_assessBtn").css("display","none"); $("#showAllAssess").css("display","block"); var starCount = consultantData["assessStar"]; for(var i=0;i<starCount;i++){ $("#showAllAssess .evastar2").eq(i).addClass("addStar"); } $("#showAllAssess").css("display","block");//显示星级 $("#dialog_thanks").css("display","none");//隐藏感谢 $("#dial_consultName").text(consultantData["professor"]["name"]);//与@@@对话 $("#dialog_consultTitle").text(consultantData["consultTitle"]);//咨询主题 $("#dialog_consultType").text(consultantData["consultType"]);//咨询类型 } } //已完成,已感谢:评价星级,感谢金额 if(consultantData["thanksStatus"] == 1){ $("#dial_confirmFinishConsult").css("display","none");//隐藏确认完成按钮 $("#dialog_thanksBtn").css("display","none"); $("#dialog_assessBtn").css("display","none"); $(".dialogfoot").css("display","none");//隐藏发送对话部分 $("#showAllAssess").css("display","block"); var starCount = consultantData["assessStar"]; for(var i=0;i<starCount;i++){ $("#showAllAssess .evastar2").eq(i).addClass("addStar"); }; $("#dialog_thanks").css("display","block");//显示感谢 $("#showAllAssess").css("display","block");//显示星级 $("#dial_consultName").text(consultantData["professor"]["name"]);//与@@@对话 $("#dil_consultStatus").text(consultantData["consultStatus"]);//咨询状态 $("#dialog_consultTitle").text(consultantData["consultTitle"]);//咨询主题 $("#dialog_consultType").text(consultantData["consultType"]);//咨询类型 } } }, "error":function(error){ //对话框头部信息请求失败 } }); }; dialogHeadDataHandleFn(); //============对话内容数据处理函数 function dialogContentDataHandle(){ $.ajax({ "url":"/ajax/tidings/qacon",//对话内容显示接口 "type":"get", "data":consultIdStr, "beforeSend":function(response){ //对话发送消息失败 //console.log(response); }, "success":function(response){ console.log() var dialogConData = response["data"]; console.log(dialogConData); var dialogStr; dialogStr = dialogContentStrFn(dialogConData); $("#dialogContent").prepend(dialogStr); // }, "error":function(error){ //对话框内容信息请求失败 } }); }; dialogContentDataHandle(); //=============================对话页面底部发送 //发送按钮处理函数 function sendDialogContentFn(){ var tidingsContant = $("#dialog_sendContent").val(); var tidingStr = { "tidingsContant":tidingsContant, "senderId":userid, "consultId":consultId }; //console.log(tidingStr); $.ajax({ "url":"/ajax/tidings", "type":"post", "data":tidingStr, "beforeSend":function(response){ //对话发送消息失败 console.log(response); }, "success":function(response){ console.log(response);//返回对话内容的id $("#dialogContent").empty(); dialogContentDataHandle(); }, "error":function(error){ //对话发送消息失败 console.log(error); } }); $("#dialog_sendContent").val(""); }; $("#dialog_sendBtn").bind("click",sendDialogContentFn); //==============点击确认完成 function confirmFinishFn(){ ConsultComment(); if($(this).attr("id") == "dialog_thanksBtn"){ $(".overcomment").css("display","block");//显示感谢 } if($(this).attr("id") == "dialog_assessBtn"){ $(".addcomment2").css("display","block");//显示评价 } //评价星星样式 var start; function clickStar(){ $(".evastar2").removeClass('addStar'); start=$(this).index()+1; for(var i=0;i<start;i++){ if(i<start){ $(".evastar2").eq(i).addClass("addStar"); } else{ $(".evastar2").eq(i).removeClass('addStar'); } } $("#startCount").val($(".addStar").length); }; $(".evastar2").bind("click",clickStar); //发表评论 $("#sendAssessBtn").bind("click",clickSendAssessBtn); }; //绑定对话页面确认完成咨询 $("#dial_confirmFinishConsult").bind("click",confirmFinishFn); //点击发表评论:保存发表内容和星级 function clickSendAssessBtn(){ var assessStar = $("#startCount").val(); var assessContant = $(".resouinforcon").find("textarea").val(); //评价状态 0-未评价,1-已评价 //确认完成后,发表评论传值 var assessContentStr ={ "consultId":consultId, //咨询ID "assessStatus":"1", //评价状态 0-未评价,1-已评价 "assessStar":assessStar, //评价星级 "assessContant":assessContant //评价内容 }; console.log(assessContentStr); //如果未评论,提示未评论 if(assessStar == "" || assessStar == null || assessStar == undefined){ if(assessContant == "" || assessContant == null || assessContant == undefined){ $.MsgBox.Alert('提示',"未评论,是否退出评论"); } $.MsgBox.Alert('提示',"未选择星级"); }; $.ajax({ "url":"/ajax/consult/assess",//点击发表评论接口 "type":"post", "data":assessContentStr, "success":function(response){ console.log(response); $(".blackcover").remove(); $("body").css("overflow","auto"); $.MsgBox.Alert('提示',"评论成功"); //评价状态改变,所以头部信息改变 dialogHeadDataHandleFn(); }, "error":function(error){ //发表评论失败 console.log(error); } }); }; }, "error":function(error){ //console.log(data); //加载对话页面失败 console.log(error); } }) }; //给咨询页回复绑定事件 $("#workContainer .workselectitem").find(".replyBtn").bind("click",clickReplyFn); //收到咨询和收到回复切换 $(".worksamlltit3:first").addClass("active").show(); $(".workmysrc3:first").show(); //On Click Event 收到咨询和收到回复tab效果 $(".worksamlltit3").click(function() { $(".worksamlltit3").removeClass("worksamlltitnow"); $(this).addClass("worksamlltitnow"); $(".workmysrc3").hide(); var activeTab = $(this).attr("href"); $(activeTab).fadeIn(); return false; }); //=============================有咨询和回复时:ajax收到回复数据============================= $.ajax({ "url" : "/ajax/consult/pqcon",//收到回复接口 "type" : "get", //传值:登陆人id:咨询id "data" :consultIdStrByReply, "dataType" : "json", "contentType" : "application/x-www-form-urlencoded", "beforeSend":function(response){ // console.log(response) }, "success":function(replyResponse){ //拿到收到回复数据 // console.log(replyResponse); var replyTrHtml; var allData = replyResponse.data; var replyData = allData["data"]; // console.log(replyData.length); if(replyData.length != 0 && replyData.length != null){ replyTrHtml = handleData(replyData,replyTrHtml,"consultantId","查看","lookBtn"); // $(".tcdPageCode:last").before(replyTrHtml); $("#workContainer2").prepend(replyTrHtml); $("#workContainer2 .workselectitem").find(".lookBtn").bind("click",clickLookBtn); }else{ return false; } }, "error":function(response){ //收到回复错误返回 // console.log(response) }, }); //==========================================咨询和收到回复,下拉菜单改变 ajax开始================== //收到咨询和收到回复下拉菜单点击函数 //排列顺序(正序、倒序) var sortFlag1 = true;//正倒排序标记 $("#replyArrow").click(function(){ if(sortFlag1 == true){ $(this).find("div").css("background-position","-20px 1px"); $("#timeSortId2").val("1"); sortFlag1 =false; }else{ $(this).find("div").css("background-position","0px 1px"); $("#timeSortId2").val("0"); sortFlag1=true; } }); var timeType2,sortType2,replyStatus,consultId; replyStatus = $("#replySelectId").val();//回复状态值 timeType2 = $("#timeTypeId2").val();//时间类型值 sortType2 = $("#timeSortId2").val();//排序值; //console.log(consultStatus,timeType,sortType+"res333"); //默认传值: var replyInfo = { "consultantId":userid, "status":replyStatus, "timeType":timeType2, "sortType":sortType2 }; //回复下拉菜单改变 function replyStatusFn(){ //改变后,要传的值 replyStatus = $("#replySelectId").val();//咨询状态值 timeType2 = $("#timeTypeId2").val();//时间类型值 sortType2 = $("#timeSortId2").val();//排序值; //要传的值: replyInfo = { "consultantId":userid, "status":replyStatus, "timeType":timeType2, "sortType":sortType2 }; // console.log("ajax中的值:"+ replyInfo.replyStatus + replyInfo.timeType + replyInfo.sortType +replyInfo.consultantId); $.ajax({ "url":"/ajax/consult/pqcon",//更新下拉菜单接口 "type":"get", "data":replyInfo, "beforeSend":function(response){ console.log(response); }, "success":function(response){ $("#workContainer2 .workselectitem").remove(); // $(".tcdPageCode:first").before().empty(); var allData = response.data; var replyData = allData["data"]; var replyTrHtml; replyTrHtml = handleData(replyData,replyTrHtml,"consultantId","查看","lookBtn"); // $(".tcdPageCode:last").before(replyTrHtml); $("#workContainer2").prepend(replyTrHtml); $("#workContainer2 .workselectitem").find(".lookBtn").bind("click",clickLookBtn); }, "error":function(response){ // console.log(response) //更新下拉菜单失败 } }); };//更新下拉菜单处理函数结束 //绑定回复状态事件 $(".replyOption ul").bind("click", "li",replyStatusFn); //绑定回复状态事件 $(".timeOption2 ul").bind("click", "li",replyStatusFn); $("#replyArrow").bind("click",replyStatusFn); //=======================================================点击回复中查看 function clickLookBtn(){ var consultId = $.trim($(this).attr("id"));//咨询id var assessStatus = $.trim($(this).find(".coultState").text());//评价状态 0-未评价,1-已评价 var consultStatus = $.trim($(this).find(".assessStatus").text());//咨询状态 0-进行中,1-已完成 var thanksStatus = $.trim($(this).find(".thanksStatus").text());//感谢状态 0-未感谢,1-已感谢 var assessStar = $.trim($(this).find(".assessStar").val());//星级,几颗星 用隐藏域做 //点击确认完成的传值:consultId,咨询状态 var confirmFinishStr = { "consultId":consultId, "consultStatus":consultStatus }; //对话标题 传值, var consultIdStr = { "consultId":consultId } //ajax加载对话页面 $.ajax({ "url":"diloags.html", "dataType":"html", "success":function(result){ //console.log(data); $(this).attr("id"); $(".workcon").html(result); //===========================================dialog数据================== //=========对话头部 //对话头部数据渲染 function lookDialogHeadDataHandleFn(){ //星星评级 var starStart; function clickStar(){ $(".evastar2").removeClass('addStar'); starStart=$(this).index()+1; for(var i=0;i<starStart;i++){ if(i<starStart){ $(".evastar2").eq(i).addClass("addStar"); } else{ $(".evastar2").eq(i).removeClass('addStar'); } } $("#startCount").val($(".addStar").length); }; $.ajax({ "url":"/ajax/consult/qacon",//从收到回复点击查看接口 "type":"get", "data":consultIdStr, "success":function(response){ console.log("点击查看返回数据"); console.log(response) var consultantData = response["data"]; //对话框标题信息 //进行中, if(consultantData["consultStatus"] == 0){ consultantData["consultStatus"] = "进行中"; $("#dil_consultStatus").text(consultantData["consultStatus"]);//咨询状态 $("#dial_confirmFinishConsult").css("display","block");//确认完成按钮显示 $("#showAllAssess").css("display","none");//总体评价 $(".dialogfoot").css("display","block");//显示发送对话部分 $("#dialog_thanks").css("display","none");//隐藏感谢 $("#dial_consultName").text(consultantData["professor"]["name"]);//与@@@对话 $("#dialog_consultTitle").text(consultantData["consultTitle"]);//咨询主题 $("#dialog_consultType").text(consultantData["consultType"]);//咨询类型 } //已完成 if(consultantData["consultStatus"] == 1 || consultantData["consultStatus"] == 2 ||consultantData["consultStatus"] == 3 || consultantData["consultStatus"] == 4){ consultantData["consultStatus"] = "已完成"; $("#dil_consultStatus").text(consultantData["consultStatus"]);//咨询状态 //已完成,未感谢: if(consultantData["thanksStatus"] == 0){ $("#dialog_thanksBtn").css("display","block");//显示感谢按钮 //未感谢,未评价 if(consultantData["assessStatus"] == 0){ $("#dialog_assessBtn").css("display","block");//显示评价按钮 $("#showAllAssess").css("display","none");//隐藏总体评价 $("#dialog_thanks").css("display","none");//隐藏感谢 $("#dial_consultName").text(consultantData["professor"]["name"]);//与@@@对话 $("#dialog_consultTitle").text(consultantData["consultTitle"]);//咨询主题 $("#dialog_consultType").text(consultantData["consultType"]);//咨询类型 } //未感谢,已评价 else{ // $("#dialog_thanksBtn").css("display","block");//显示感谢按钮 var starCount = consultantData["assessStar"]; for(var i=0;i<starCount;i++){ $("#showAllAssess .evastar2").eq(i).addClass("addStar"); } $("#showAllAssess").css("display","block");//显示星级 $("#dialog_thanks").css("display","none");//隐藏感谢 $("#dial_consultName").text(consultantData["professor"]["name"]);//与@@@对话 $("#dialog_consultTitle").text(consultantData["consultTitle"]);//咨询主题 $("#dialog_consultType").text(consultantData["consultType"]);//咨询类型 } } //已完成,已感谢:评价星级,感谢金额 if(consultantData["thanksStatus"] == 1){ $(".dialogfoot").css("display","none");//隐藏发送对话部分 var starCount = consultantData["assessStar"]; for(var i=0;i<starCount;i++){ $("#showAllAssess .evastar2").eq(i).addClass("addStar"); }; $("#showAllAssess").css("display","block");//显示星级 $("#dial_consultName").text(consultantData["professor"]["name"]);//与@@@对话 $("#dialog_consultTitle").text(consultantData["consultTitle"]);//咨询主题 $("#dialog_consultType").text(consultantData["consultType"]);//咨询类型 $("#dialog_thanksMoney").text(consultantData["thanksMoney"]); } } }, "error":function(error){ //对话框头部信息请求失败 } }); }; lookDialogHeadDataHandleFn(); //============对话内容数据处理函数 function dialogContentDataHandle(){ $.ajax({ "url":"/ajax/tidings/qacon",//对话内容显示接口 "type":"get", "data":consultIdStr, "beforeSend":function(response){ //对话发送消息失败 //console.log(response); }, "success":function(response){ console.log() var dialogConData = response["data"]; console.log(dialogConData); var dialogStr; dialogStr = dialogContentStrFn(dialogConData); $("#dialogContent").prepend(dialogStr); // }, "error":function(error){ //对话框内容信息请求失败 } }); }; dialogContentDataHandle(); //=============================对话页面底部发送 //发送按钮处理函数 function sendDialogContentFn(){ var tidingsContant = $("#dialog_sendContent").val(); var tidingStr = { "tidingsContant":tidingsContant, "senderId":userid, "consultId":consultId }; //console.log(tidingStr); $.ajax({ "url":"/ajax/tidings", "type":"post", "data":tidingStr, "beforeSend":function(response){ //对话发送消息失败 console.log(response); }, "success":function(response){ console.log(response);//返回对话内容的id $("#dialogContent").empty(); dialogContentDataHandle(); }, "error":function(error){ //对话发送消息失败 console.log(error); } }); $("#dialog_sendContent").val(""); }; $("#dialog_sendBtn").bind("click",sendDialogContentFn); //==============点击确认完成 function confirmFinish(){ ConsultComment(); //评价星星样式 var start; function clickStar(){ $(".evastar2").removeClass('addStar'); start=$(this).index()+1; for(var i=0;i<start;i++){ if(i<start){ $(".evastar2").eq(i).addClass("addStar"); } else{ $(".evastar2").eq(i).removeClass('addStar'); } } $("#startCount").val($(".addStar").length); }; $(".evastar2").bind("click",clickStar); //发表评论 $("#sendAssessBtn").bind("click",clickSendAssessBtn); }; //绑定对话页面确认完成咨询 $("#dial_confirmFinishConsult").bind("click",confirmFinishFn); $("#dialog_assessBtn").bind("click",confirmFinishFn); //点击发表评论:保存发表内容和星级 function clickSendAssessBtn(){ var assessStar = $("#startCount").val(); var assessContant = $(".resouinforcon").find("textarea").val(); //评价状态 0-未评价,1-已评价 //确认完成后,发表评论传值 var assessContentStr ={ "consultId":consultId, //咨询ID "assessStatus":"1", //评价状态 0-未评价,1-已评价 "assessStar":assessStar, //评价星级 "assessContant":assessContant //评价内容 }; console.log(assessContentStr); //如果未评论,提示未评论 if(assessStar == "" || assessStar == null || assessStar == undefined){ if(assessContant == "" || assessContant == null || assessContant == undefined){ $.MsgBox.Alert('提示',"未评论,是否退出评论"); } $.MsgBox.Alert('提示',"未选择星级"); }; $.ajax({ "url":"/ajax/consult/assess",//点击发表评论接口 "type":"post", "data":assessContentStr, "success":function(response){ console.log(response); $(".blackcover").remove(); $("body").css("overflow","auto"); $.MsgBox.Alert('提示',"评论成功"); //评价状态改变,所以头部信息改变 lookDialogHeadDataHandleFn(); }, "error":function(error){ //发表评论失败 console.log(error); } }); }; }, "error":function(error){ //console.log(data); //加载对话页面失败 console.log(error); } }) };//收到回复点击查看函数结束 }, }) } }, "complete":function(response){ // console.log(response) }, "error":function(response){ //收到咨询页面失败 // console.log(response) }, }); }else{ $.MsgBox.Alert('提醒',"您尚未登录"); } }) })