123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613 |
- var content1 = document.querySelectorAll('.mui-content')[0];
- var content2 = document.querySelectorAll('.mui-content')[1];
- var pageIndex = 1;
- var allPages = 1;
- var table = document.body.querySelector("#table");
- var oneedval = document.getElementById("needval");
- var otypeval = document.getElementById("typeval");
- var ostateval = document.getElementById("stateval");
- var osortval = document.getElementById("sortval");
- window.addEventListener('logined', function(event) {
- var userId = event.detail.id;
- content1.style.display = 'block';
- content2.style.display = 'none';
- initdata();
- if(plus.nativeUI.showWaiting()){
- console.log("showWaiting")
- plus.nativeUI.closeWaiting();
- }
- });
- window.addEventListener('exited', function(event) {
- var userId = event.detail.id;
- content1.style.display = 'none';
- content2.style.display = 'block';
- });
- mui.plusReady(function() {
- var regBtn = document.getElementById("regBtn");
- var logBtn = document.getElementById("logBtn");
- regBtn.addEventListener('tap',function(){
- mui.openWindow({
- url: '../html/reg.html',
- id: '../html/reg.html',
- show: {
- aniShow: "slide-in-right"
- }
- });
-
- });
-
-
- logBtn.addEventListener('tap',function(){
- mui.openWindow({
- url: '../html/login.html',
- id: '../html/login.html',
- show: {
- aniShow: "slide-in-right"
- }
- });
-
- });
- });
- mui.plusReady(function() {
- var self = plus.webview.currentWebview();
- console.log('当前咨询列表页id==='+self.id);
- })
- mui.init({
- pullRefresh: {
- container: '#zixunpullrefresh',
-
- auto: true,
- contentdown : "下拉可以刷新",
- contentover : "释放立即刷新",
- contentrefresh : "正在刷新...",
- callback: pulldownRefresh
- },*/
- up: {
- contentrefresh: '正在加载...',
- callback: pullupRefresh
- }
- }
- });
-
- * 下拉刷新具体业务实现
- */
- function pulldownRefresh() {
- pageIndex = 1;
- console.log('下拉刷新');
-
- setTimeout(function() {
- getaData();
- mui('#zixunpullrefresh').pullRefresh().endPulldownToRefresh();
- mui('#zixunpullrefresh').pullRefresh().refresh(true);
- }, 1000);
- }
- function pullupRefresh() {
- pageIndex = ++pageIndex;
- console.log('第'+pageIndex+'页');
- console.log('上拉加载更多');
- setTimeout(function() {
- getaData();
- }, 1000);
- };
- if(mui.os.plus) {
- mui.plusReady(function() {
- setTimeout(function() {
- mui('#zixunpullrefresh').pullRefresh().pulldownLoading();
- }, 500);
- });
- } else {
- mui.ready(function() {
- mui('#zixunpullrefresh').pullRefresh().pulldownLoading();
- });
- };
- function checkedFun(i){
- mui("#middlePopover"+i).on('tap','.mui-navigate-right',function(e){
- allPages = 1;
- pageIndex = 1;
- plus.nativeUI.showWaiting();
- document.getElementById("headck"+i).innerHTML = this.innerHTML;
- var value = this.getAttribute("ck"+i);
- document.getElementById("headck"+i).setAttribute('headck',value);
- document.querySelector('.mui-backdrop').style.display = 'none';
- document.getElementById("middlePopover"+i).style.display = 'none';
-
-
- document.getElementById("middlePopover"+i).classList.remove('mui-active');
-
-
- otypeval.value = document.getElementById("headck2").getAttribute('headck');
- if(otypeval.value == 0) {
- otypeval.value = '';
- }else {
- otypeval.value = document.getElementById("headck2").innerHTML;
- }
- oneedval.value = document.getElementById("headck1").getAttribute('headck');
- ostateval.value = document.getElementById("headck3").getAttribute('headck');
- osortval.value = document.getElementById("headck4").getAttribute('headck');
-
- initdata();
- plus.nativeUI.closeWaiting();
- });
-
- };
- checkedFun(1);
- checkedFun(2);
- checkedFun(3);
- checkedFun(4);
-
- function getaData() {
- mui.plusReady(function() {
- var userid = plus.storage.getItem('userid');
-
- console.log('加载页'+pageIndex)*/
- mui.ajax(baseUrl+'/ajax/consult/pq', {
- data: {
- "professorId":userid,
- "consultOrNeed":oneedval.value ,
- "consultType":otypeval.value,
- "status":ostateval.value,
- "timeType":osortval.value,
- "pageSize":10,
- "pageNo":pageIndex
- },
- dataType: 'json',
- type: 'get',
- timeout: 10000,
-
- success: function(data) {
-
- if (data.success) {
- var datalist = data.data.data;
- var total = data.data.total;
- var pageSize = data.data.pageSize;
-
- var result = '';
- allPages = Math.ceil(total / pageSize);
-
- if (allPages == 1) {
- table.innerHTML = '';
- }
-
- eachData(userid,datalist);
-
- if(pageIndex < allPages){
- mui('#zixunpullrefresh').pullRefresh().endPullupToRefresh(false);
- }else{
- mui('#zixunpullrefresh').pullRefresh().endPullupToRefresh(true);
- }
- }
- },
- error: function(xhr, type, errerThrown) {
- mui.toast('网络异常,请稍候再试');
- plus.nativeUI.closeWaiting();
- mui('#zixunpullrefresh').pullRefresh().endPullupToRefresh(true);
- }
- });
- });
- };
- // alert('重新登陆')
- userId = event.detail.id;
- console.log(userId);
- initdata();
- if(plus.nativeUI.showWaiting()){
- console.log("showWaiting")
- plus.nativeUI.closeWaiting();//关闭等待框
- }
- });*/
- initdata();
- function initdata() {
-
- mui.plusReady(function() {
-
- var userid = plus.storage.getItem('userid');
- if(otypeval.value == 0){
- otypeval.value ='';
- }
- console.log()
- plus.nativeUI.showWaiting();
- mui.ajax(baseUrl+'/ajax/consult/pq', {
- data: {
- "professorId":userid,
- "consultOrNeed":oneedval.value ,
- "consultType":otypeval.value,
- "status":ostateval.value,
- "timeType":osortval.value,
- "pageSize":10,
- "pageNo":1
- },
- dataType: 'json',
- type: 'get',
- timeout: 10000,
- success: function(data) {
- table.innerHTML = '';
- if (data.success && data.data.data != '') {
- var datalist = data.data.data;
- eachData(userid,datalist);
- mui('#zixunpullrefresh').pullRefresh().refresh(true);
- plus.nativeUI.closeWaiting();
- }else {
- plus.nativeUI.closeWaiting();
-
- mui('#zixunpullrefresh').pullRefresh().disablePullupToRefresh();
- }
- },
- error: function(xhr, type, errerThrown) {
- mui.toast('网络异常,请稍候再试');
- plus.nativeUI.closeWaiting();
- }
- });
- });
- };
- function isChat(consultId,userid) {
- var length = 0;
- mui.ajax(baseUrl+'/ajax/tidings/qacon',{
- data:{
- "consultId":consultId
- },
- async:false,
- dataType:'json',
- type:'get',
- timeout:10000,
- success:function(data){
- var myData = data.data;
- for(var i = 0; i < myData.length; i++ ){
- if(myData[i]['professor']['id'] !=userid){
- length++;
- }
- }
-
- },
- error:function(xhr,type,errorThrown){
-
- plus.nativeUI.toast("服务器链接超时", toastStyle);
- }
- });
- return length;
- }
- function setReadState(consultId) {
- mui.ajax(baseUrl+'/ajax/consult/readStatus',{
- data:{"consultId":consultId},
- dataType:'json',
- type:'post',
- timeout:10000,
- success:function(data){
- },
- error:function(xhr,type,errorThrown){
-
- }
- });
- }
- mui(".mui-table-view").on('tap','.itemBtn',function(){
- var o_this = this;
- mui.plusReady(function() {
- var nwaiting = plus.nativeUI.showWaiting();
-
- setReadState(o_this.getAttribute("consultId"));
- webviewShow = plus.webview.create("../html/chats.html",'chats.html',{},
- {'consultId':o_this.getAttribute("consultId"),'consultantId':o_this.getAttribute("consultantId"),'readState':1});
-
- webviewShow.addEventListener("loaded", function() {
-
- }, false);
-
- });
-
- });
- window.addEventListener('backlist',function(event){
-
- var self = plus.webview.currentWebview();
- var consultId = event.detail.consultId;
- var status = event.detail.status;
-
- mui('.status').each(function(index,item){
- if(this.getAttribute('consultId') == consultId) {
- if(status == 'myNeedAssessStatus=0'){
- this.classList.remove('status-1');
- this.classList.add('status-2');
- this.innerHTML = '待评价';
- }else if(status == 'myNeedAssessStatus=1'){
- this.classList.remove('status-1');
- this.classList.add('status-3');
- this.innerHTML = '已完成';
- }
- };
-
- });
-
- mui('.readstate').each(function(index,item){
- if(this.getAttribute('class').indexOf('displayBlock') != -1){
- console.log(this.getAttribute('consultId'));
- if(this.getAttribute('consultId') == consultId){
- this.classList.remove('displayBlock');
- this.classList.add('displayNone');
- console.log(this.classList);
- }
- }
- });
-
- });
-
- function eachData(userid,datalist) {
-
- mui.each(datalist, function(index, item) {
- var title,
- zhicehng,
- zhiwei,
- orgName,
- address,
- lastReply,
- status,
- statusStyle,
- lastReplyTime,
- lastReplyCon,
- unreadCount,
- unreadStyle,
- proModify,
- photoUrl,
- consultType,
- chatlength;
-
- chatlength = isChat(item['consultId'],userid);
- if(chatlength == 0){
- title = item["consultTitle"];
- }else{
- title = "回复:" + item["consultTitle"];
- }
-
- if(item['consultantId'] != userid){
- if(item["consultStatus"] == 0){
- status = "进行中";
- statusStyle = 'status-1';
- }else if(item["consultStatus"] == 1){
- status = "已完成";
- statusStyle = 'status-3';
- }
- }else if(item['consultantId'] == userid){
- if(item["consultStatus"] == 0){
- status = "进行中";
- statusStyle = 'status-1';
- }else if(item["consultStatus"] == 1){
- if(item["assessStatus"] == 0){
- status = '待评价';
- statusStyle = 'status-2';
- }else {
- status = '已完成';
- statusStyle = 'status-3';
- }
- }
- };
-
- if(item["professor"] == undefined){
- return ;
- }
-
- (item["professor"]["authentication"] == true)? proModify = 'authicon' : proModify = 'unauthicon';
- (item["professor"]["hasHeadImage"] == 0) ? photoUrl = "../images/default-photo.jpg":photoUrl = baseUrl + "/images/head/" + item["professor"].id + "_m.jpg";
-
-
- zhicehng = '';
- }else {
- zhicehng = item["professor"]["title"];
- }
- if(item["professor"]["office"] == undefined || item["professor"]["office"] == null || item["professor"]["office"] == ''){
- zhiwei = '';
- }else {
- if(zhicehng != ''){
- zhiwei = ', '+item["professor"]["office"];
- }else{
- zhiwei = item["professor"]["office"];
- }
- }
- if(item["professor"]["orgName"] == undefined || item["professor"]["orgName"] == null || item["professor"]["orgName"] == ''){
- orgName = '';
- }else {
- if(zhicehng != '' || zhiwei != ''){
- orgName = ', '+item["professor"]["orgName"];
- }else {
- orgName = item["professor"]["orgName"];
- }
- }
- if(item["professor"]["address"] == undefined || item["professor"]["address"] == null || item["professor"]["address"] == ''){
- address = '';
- }else {
- if(zhicehng != '' || zhiwei != '' || orgName !=''){
- address = ' | ' + item["professor"]["address"];
- }else {
- address = item["professor"]["address"];
- }
- }*/
-
-
-
-
-
-
- if(item["consultType"]) {
- consultType = item["consultType"].substr(0,2);
- }
-
-
- lastReplyTime = lastReplyFn(userid,item["consultId"]).lastReplyTime;
- lastReplyCon = lastReplyFn(userid,item["consultId"]).lastReplyCon;
-
- if(lastReplyCon == undefined){
- lastReplyCon = '';
- }
- if(lastReplyTime == undefined){
- lastReplyTime = '';
- }
-
- unreadCount = unreadConsultFn(userid,item["consultId"],index).unreadCount;
- unreadStyle = unreadConsultFn(userid,item["consultId"],index).style;
-
- var li = document.createElement('li');
- li.className = 'mui-table-view-cell mui-media';
-
- var str = '';
- str += '<div class="coutopicbox"><span class="coutheme mui-ellipsis mui-pull-left">'+title+'</span>'
- + '<div class="coustatus mui-pull-right"><span class="aimlabel">'+consultType+'</span>'
- + '<span class="'+statusStyle+' status" consultId="'+item["consultId"]+'">'+status+'</span></div></div>'
- + '<a class="proinfor itemBtn" consultId="'+item["consultId"]+'" consultantId="'+item["consultantId"]+'" >'
- + '<span class="mui-badge mui-badge-danger readstate '+unreadStyle+'" consultId="'+item["consultId"]+'">'+unreadCount+'</span>'
- + '<img class="mui-media-object mui-pull-left headimg headRadius" src="'+photoUrl+'">'
- + '<div class="mui-media-body">'
- + '<span class="listtit">'+item["professor"]["name"]+'<em class="mui-icon iconfont icon-vip '+proModify+'"></em><span class="thistime">'+lastReplyTime+'</span></span>';
- str += '<p class="listtit2">';
- if(item["professor"]["title"]){
- str += '<span>'+item["professor"]["title"]+'</span>, ';
- };
- if(item["professor"]["office"]){
- str += '<span>'+item["professor"]["office"]+'</span>, ';
- };
- if(item["professor"]["orgName"]){
- str += '<span>'+item["professor"]["orgName"]+'</span>';
- };
- if(item["professor"]["address"]){
- str += '<span> | '+item["professor"]["address"]+'</span>';
- };
-
- str +='</p><p class="listtit3 onlyone">'+lastReplyCon+'</p></div></a>';
-
- li.innerHTML = str;
-
-
-
- + '<span class="coutheme mui-ellipsis mui-pull-left">'+title+'</span>'
- + '<div class="coustatus mui-pull-right"><span class="aimlabel">'+consultType+'</span>'
- + '<span class="'+statusStyle+' status" consultId="'+item["consultId"]+'">'+status+'</span></div></div>'
- + '<a class="proinfor itemBtn" consultId="'+item["consultId"]+'" consultantId="'+item["consultantId"]+'" >'
- + '<span class="mui-badge mui-badge-danger readstate '+unreadStyle+'" consultId="'+item["consultId"]+'">'+unreadCount+'</span>'
- + '<img class="mui-media-object mui-pull-left headimg headRadius" src="'+photoUrl+'">'
- + '<div class="mui-media-body">'
- + '<span class="listtit">'+item["professor"]["name"]+'<em class="mui-icon iconfont icon-vip '+proModify+'"></em><span class="thistime">'+lastReplyTime+'</span></span>'
- + '<p class="listtit2"><span>'+zhicehng+'</span><span>'+zhiwei+'</span><span>'+orgName+'</span><span>'+address+'</span></p>'
- + '<p class="listtit3 onlyone">'+lastReplyCon+'</p>'
- + '</div></a>';*/
-
- table.appendChild(li,table.firstChild);
- });
-
- };
- function lastReplyFn(sendId,consultId){
- var lastReplyTimeData,lastReplyTime,lastReplyCon;
- mui.ajax(baseUrl + '/ajax/tidings/qaLastRevovery',{
- data:{
- "consultId":consultId,
- "senderId":sendId
- },
- dataType:'json',
- type:'get',
- timeout:10000,
- async:false,
- success:function(data){
-
- if(data["data"] == null || data["data"] == "" || data["data"] == undefined){
- lastReplyTimeData = '';
- lastReplyTime = '';
- lastReplyCon = '';
- }
- else{
- lastReplyTimeData = data["data"]["createTime"];
- lastReplyTime =lastReplyTimeData.substr(0,4) + "-" + lastReplyTimeData.substr(4,2) + "-" + lastReplyTimeData.substr(6,2) + " " + lastReplyTimeData.substr(8,2)+ ":" +lastReplyTimeData.substr(10,2);
- lastReplyCon = data["data"]["tidingsContant"];
- }
- },
- error:function(xhr,type,errorThrown){
-
- }
- });
- return {
- "lastReplyTime":lastReplyTime,
- "lastReplyCon":lastReplyCon
- };
- };
- function unreadConsultFn (senderId,consultId,i){
- var unreadCount,style;
- mui.ajax(baseUrl +'/ajax/tidings/qaNotReadTidings',{
- data:{
- "senderId":senderId,
- "consultId":consultId
- },
- dataType:'json',
- type:'get',
- timeout:10000,
- async:false,
- success:function(data){
- unreadCount = data["data"];
- if(unreadCount == 0){
- style = 'displayNone';
- }else{
- style = 'displayBlock';
-
- }
- },
- error:function(xhr,type,errorThrown){
-
- }
- });
-
- return {"unreadCount":unreadCount,
- "style":style
- }
- };
|