123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361 |
- $(function(){
- $(".onlogin .headnavbtn li").eq(0).addClass("navcurrent");
- loginStatus();
- })
- var userid = $.cookie("userid");
- var pageSize = 5;
- var pageNo, isbind, status, timeType, sortType;
- getMyData(pageSize, 1, true, 0, 1, 0);
- myRequirePullDownMenu();
- function getMyData(pageSize, pageNo, isbind, status, timeType, sortType) {
- var params = {
- "consultantId": userid,
- "status": status,
- "timeType": timeType,
- "sortType": sortType,
- "pageSize": pageSize,
- "pageNo": pageNo
- };
- $.ajax({
- url: "/ajax/consult/pqCon",
- type: "get",
- data: params,
- dataType: "json",
- contentType: "application/x-www-form-urlencoded",
- success: function(response) {
-
- if(response["data"]["data"] == null || response["data"]["data"] == undefined || response["data"]["data"] == "") {
- return;
- } else {
-
- var replyStr;
- var allData = response.data;
- var myData = allData.data;
- $("#workContainer2").html("");
- if(myData.length != 0 && myData.length != null) {
- replyStr = handleData(myData, "consultId", "lookBtn");
- $("#workContainer2").append(replyStr);
- } else {
- return false;
- };
-
- if(isbind == true) {
- $(".getReplyPage").createPage({
- pageCount: Math.ceil(allData.total / pageSize),
- current: allData.pageNo,
- backFn: function(p) {
- getMyData(pageSize, p, false, status, timeType, sortType);
- }
- });
- }
- }
- },
- error: function(response) {
-
- $.MsgBox.Alert('提示', "收到回复数据请求失败");
- },
- });
- };
- function handleData(data, attrParams, btnCls) {
- var htmlStr = '';
- var title,
- office,
- orgName,
- department,
- address;
- for(var i = 0; i < data.length; i++) {
-
- var text, state, stateStyle, photoUrl, proModify;
- var modifyclass = '';
- if(data[i]["professor"]) {
- if(data[i]["consultStatus"] == 0) {
- state = "进行中";
- stateStyle = 'status-1';
- text = '回复';
- } else if(data[i]["consultStatus"] == 1) {
- text = "查看";
- state = "已完成";
- stateStyle = 'status-3';
- if(attrParams == 'consultId') {
- if(data[i]["assessStatus"] == 0) {
- state = "待评价";
- stateStyle = 'status-2';
- }
- }
- } else if(data[i]["consultStatus"] == 2) {
- text = "查看";
- state = "待回复";
- stateStyle = 'status-4';
- } else if(data[i]["consultStatus"] == 3) {
- text = "查看";
- state = "被谢绝";
- stateStyle = 'status-5';
- } else if(data[i]["consultStatus"] == undefined) {
- text = "";
- state = "";
- }
-
- if(data[i]["professor"]["hasHeadImage"] == 0) {
- photoUrl = "images/default-photo.jpg"
- } else {
- photoUrl = "images/head/" + data[i]["professor"]["id"] + "_l.jpg"
- };
-
- var oSty=autho(data[i]["professor"].authType,data[i]["professor"].orgAuth,data[i]["professor"].authStatus);
- modifyclass = oSty.sty;
-
- var unread = unreadConsultFn(userid, data[i]["consultId"], i);
- htmlStr += "<div class='workselectitem' id='" + data[i]["consultId"] + "' >" +
- "<table width='100%'><tbody><tr><td width='14%' class='messagebox'>" +
- "<a class='workhead workitimg userRadius'>" +
- "<img class='headPhoto' src='" + photoUrl + "' width='100%' height='100%'>" +
- "</a>" +
- "<span class='msgprompt showUnreadMsg' style='" + unread.style + "' id='" + data[i]["consultId"] + "'>" + unread.unreadCount + "</span>" +
- "</td>" +
- "<td style='position:relative;top:20px;' width='86%'>" +
- "<div class='workinfor worksitcon'><h4><a class='named' id='nameS'> " + data[i]["professor"]["name"] + " </a>" +
- "<a class='authiconNew " + modifyclass + "' title='"+oSty.title+"' style='top:9px;'></a><input type='text' class='assessStar' value='" + data[i]["assessStar"] + "' style='display: none;'></h4><h6 class='h3Font'>";
- if(data[i]["professor"]["title"]) {
- htmlStr += "<span>" + data[i]["professor"]["title"] + "</span>, ";
- };
- if(data[i]["professor"]["office"]) {
- if(data[i]["professor"]["orgName"] || data[i]["professor"]["department"]) {
- htmlStr += "<span>" + data[i]["professor"]["office"] + "</span>, ";
- } else {
- htmlStr += "<span>" + data[i]["professor"]["office"] + "</span>";
- }
- };
- if(data[i]["professor"]["orgName"]) {
- if(data[i]["professor"]["department"]) {
- htmlStr += "<span>" + data[i]["professor"]["orgName"] + "</span>, ";
- } else {
- htmlStr += "<span>" + data[i]["professor"]["orgName"] + "</span>";
- }
- };
- if(data[i]["professor"]["department"]) {
- htmlStr += "<span>" + data[i]["professor"]["department"] + "</span>";
- };
- if(data[i]["professor"]["address"]) {
- htmlStr += ' | ' + "<span>" + data[i]["professor"]["address"] + "</span>";
- };
- htmlStr += "</h6><h6 style='position:relative;'>" +
- "<div class='titList'>咨询主题:<em class='h4Font'> " + data[i]["consultTitle"] + " </em></div>" +
- "<span class='lasttime rightTime'>" + lastReplyFn(userid, data[i]["consultId"])["lastReplyTime"] + "</span>" +
- "<div style='height:70px;'><p class='rebackcon lastReplyCon' >" + lastReplyFn(userid, data[i]["consultId"])["lastReplyCon"] + "</p></div>" +
- "</h6></div>" +
- "<div class='workhandle'>" +
- "<div class='rightopert floatR'>" +
- "<span attrP='" + attrParams + "' class='replybtn " + btnCls + "' id='" + data[i]["consultId"] + "' consultStatus='" + data[i]["consultStatus"] + "' assess='" + data[i]["assessStatus"] + "' thanks='" + data[i]["thanksStatus"] +
- "' onclick='clickLookBtn2(\"" + userid + "\",\"" + attrParams + "\",\"" + data[i]["consultId"] + "\"," + data[i]["consultStatus"] + "," + data[i]["assessStatus"] + "," + data[i]["thanksStatus"] + ");'>" +
- text +
- "</span>" +
- "<span class='moreopert complain'>...</span>" +
- "<ul class='moreopertbtn'>" +
- "<li>投诉</li>" +
- "</ul>" +
- "</div>" +
- "<div class='leftstate floatR'>" +
- "<span class='coultstate " + stateStyle + "'><i>" + state + "</i></span>" +
- "</div>" +
- "<div class='leftstate floatR'>" +
- "<span class='coultstate coulstAim status-4'><i>" + data[i]["consultType"] + "</i></span>" +
- "</div>" +
- "</div>" +
- "</td>" +
- "</tr></tbody></table>" +
- "</div>";
- }
- };
- return htmlStr;
- };
- function unreadConsultFn(senderId, consultId, i) {
- var unreadCount, style;
- var params = {
- "senderId": senderId,
- "consultId": consultId
- };
- $.ajax({
- url: "/ajax/tidings/qaNotReadTidings",
- type: "get",
- async: false,
- data: params,
- success: function(response) {
- unreadCount = response["data"];
- if(unreadCount == 0) {
- style = "display:none;"
- } else {
- style = "display:block;"
- }
- },
- error: function(error) {
- $.MsgBox.Alert('提示', "未读消息请求失败");
- }
- });
- return {
- "unreadCount": unreadCount,
- "style": style
- }
- };
- function lastReplyFn(sendId, consultId) {
- var lastReplyTimeData, lastReplyTime, lastReplyCon;
- $.ajax({
- url: "/ajax/tidings/qaLastRevovery",
- async: false,
- data: {
- "consultId": consultId,
- "senderId": sendId
- },
- success: function(response) {
-
- if(response["data"] == null || response["data"] == "" || response["data"] == undefined) {
- lastReplyTimeData = '';
- lastReplyTime = '';
- lastReplyCon = '';
- } else {
- lastReplyTimeData = response["data"]["createTime"];
- lastReplyTime = lastReplyTimeData.substr(0, 4) + "-" + lastReplyTimeData.substr(4, 2) + "-" + lastReplyTimeData.substr(6, 2) + " " + lastReplyTimeData.substr(8, 2) + ":" + lastReplyTimeData.substr(10, 2)
- lastReplyCon = response["data"]["tidingsContant"];
- }
- },
- error: function(error) {
- $.MsgBox.Alert('提示', "最后回复数据失败");
- }
- });
- return {
- "lastReplyTime": lastReplyTime,
- "lastReplyCon": lastReplyCon
- };
- };
- function myRequirePullDownMenu() {
-
- $(".replyOption ul").find("li").click(function() {
- status = $(this).attr("tip");
- timeType = $("#showTimeSort2").attr("tim");
- sortType = $("#timeSortId2").val();
- $("#workContainer2").remove();
- $("#wode").append('<div id="workContainer2"></div>')
- $(".getReplyPage").remove();
- $("#wode").append('<div class="tcdPageCode getReplyPage"></div>');
-
- getMyData(pageSize, 1, true, status, timeType, sortType);
- });
- $(".timeOption2 ul").find("li").click(function() {
- status = $("#showStatus2").attr("tip");
- timeType = $(this).attr("tim");
- sortType = $("#timeSortId2").val();
- $("#workContainer2").remove();
- $("#wode").append('<div id="workContainer2"></div>')
- $(".getReplyPage").remove();
- $("#wode").append('<div class="tcdPageCode getReplyPage"></div>');
-
- getMyData(pageSize, 1, true, status, timeType, sortType);
- });
- 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;
- };
- status = $("#showStatus2").attr("tip");
- timeType = $("#showTimeSort2").attr("tim");
- sortType = $("#timeSortId2").val();
- $("#workContainer2").remove();
- $("#wode").append('<div id="workContainer2"></div>')
- $(".getReplyPage").remove();
- $("#wode").append('<div class="tcdPageCode getReplyPage"></div>');
-
- getMyData(pageSize, 1, true, status, timeType, sortType);
- });
- };
- function clickLookBtn2(sendId, attrParams, consultId, consultStatus, assessStatus, thanksStatus) {
- window.location.href = "diloags.html?sendId=" + sendId + "&attrParams=" + attrParams + "&consultId=" + consultId + "&consultStatus=" + consultStatus + "&assessStatus=" + assessStatus + "&thanksStatus=" + thanksStatus;
- }
- $("#odemand").on("click",function(){
- $.ajax({
- url:"/ajax/professor/auth",
- dataType: 'json',
- type: 'GET',
- timeout: 10000,
- data: {
- "id": userid
- },
- success: function(data) {
- if(data.success) {
- var $data = data.data;
- if($data.authType){
- location.href="needList.html"
- }else{
- location.href="myDemand.html"
- }
- }
- },
- error: function() {
- plus.nativeUI.toast("服务器链接超时", toastStyle);
- return;
- }
- });
- })
|