mui.init(); var patient = null; var docInfo = null; var pageIndex = 1; var pageSize = 10; var self; mui.plusReady(function(){ self = plus.webview.currentWebview(); docInfo = JSON.parse(plus.storage.getItem("docInfo")); patient = self.patient; queryInit(); }) function queryInit(){ plus.nativeUI.showWaiting(); initData(); bindEvents(); function bindEvents(){ $(".c-list").on("click",".n-list-li,.n-list-content",function(event){ //该患者跟医生无签约关系时不可看详细信息 if(self.qyRelation == 0) return; var parentLi = $(this).closest("li"); var id = parentLi.attr("data-id"); openWebviewExtras("detail-appointment.html",{dataId:id}); }).on("click",".div-again",function(){ var parentLi = $(this).closest("li"); var id = parentLi.attr("data-id"); var doctorCode = parentLi.attr("data-doctorCode"); var orgCode = parentLi.attr("data-orgCode"); var deptCode = parentLi.attr("data-deptCode"); var params = {}; params.id=id; params.doctorId=doctorCode; params.hospitalId=orgCode; params.deptId = deptCode; params.type=2; params.patient = patient; openWebviewExtras("doctor-detail.html",params); }) $(".div-add-btn").on("click",function(){ openWebview("appointment-register.html"); }) scroller1 = $("#wrapper2").initScroll( { pullDownAction: function(){ location.reload(); },pullUpAction: function() { getMyAppo(); } } ); } function initData(){ $(".c-list").html(""); pageIndex = 1; getMyAppo(); } function getMyAppo(){ var data={}; data.patient = patient; data.doctor = docInfo.code; data.pageIndex = pageIndex; data.pageSize = pageSize; sendPost('third/guahao/GetPatientReservationList', data, getListFail, successFun); } function successFun(res){ plus.nativeUI.closeWaiting(); if(res.status==200){ updatePullUpText(scroller1,res.data); /*res.data = [{ doctorName: "aa", startTime: "2016-06-06 06:06:06" }]*/ if(res.data&&res.data.length>0){ pageIndex=pageIndex+1; appendMyAppo(res.data); }else{ if(pageIndex==1){ $(".main").hide(); $(".div-no-info").show(); $("#footer").show(); }else{ mui.toast("无更多数据"); } } }else{ getListFail(res); } } function getListFail(res){ plus.nativeUI.closeWaiting(); if (res && res.msg) { mui.toast(res.msg); } else { mui.toast("加载失败!"); } } function appendMyAppo(dataList){ var appoHtml =""; for(var j in dataList){ var data = dataList[j]; //status:0 已撤销 1 预约成功 2 已就诊 3已停诊 var clazz1 = "cb-47ABEF"; var clazz2 = "c-47ABEF"; var statusNm = "预约成功" if(data.status=="0"){ clazz1 = "cb-FF6A56"; clazz2 = "c-FF6A56"; statusNm = "已撤销"; }else if(data.status=="2"){ clazz1 = "cb-74BF00"; clazz2 = "c-74BF00"; statusNm = "已就诊"; }else if(data.status=="3"){ clazz1 = "cb-909090"; clazz2 = "c-909090"; statusNm = "已停诊"; } appoHtml+='
  • '+ '
    '+ '
    '+ '
    '+ '
    '+ ''+ '
    '+ '
    '+ '
    '+ '
    '+ ''+data.doctorName+''+ '('+data.doctorJob+')'+ ''+data.deptName+''+ '
    '+ '
    '+data.orgName+'
    '+ '
    '+ '
    '+ '
    '+ '就诊时间:'+data.startTime.toString().substring(0,16)+''+ '代预约:'+data.dname+''+ '
    '+ '
    '; if(self.qyRelation==1){ appoHtml += '
    '+ '
    '+ '
    再次预约
    '+ ''+ '
    '+ '
    '; } appoHtml += '
  • '; } $(".c-list").append(appoHtml); $(".main").show(); $("#footer").show(); } var updatePullUpText= function(scroller,list) { var $wrap = $(scroller.wrapper), $pullupLabel = $wrap.find('.pullUpLabel'); $(".pullUp").removeClass("loading"); if(!list || !list.length) { $pullupLabel.text('没有更多'); } else { $pullupLabel.text('上拉加载更多'); } scroller.on('refresh',function() { if(!list || !list.length) { $pullupLabel.text('没有更多'); } else { $pullupLabel.text('上拉加载更多'); } }); } } window.addEventListener('update', function(e) { queryInit(); });