var d = dialog({contentType:'load', skin:'bk-popup'}); var pagetype = 20; $(function(){ checkUserAgent(); }) appendFamilyMember($('#memberContainer'),function(){ $(".div-no-info").hide(); initData(); },function(){ //判断有授权家人,修改样式 if($('#memberContainer').is(':hidden')){ $('#wrapper2').css('top','0px'); }else{ $('#wrapper2').css('top','90px'); $('.div-no-info').css('padding-top','150px'); } }); function queryInit(){ var pageIndex = 1; var pageSize = 10; var request = GetRequest(); var toUser = request["toUser"]; var openid = request["openid"]; var toName = decodeURIComponent(Request["toName"]); var represented = Request["represented"]; var userAgent = window.localStorage.getItem(agentName); if(!userAgent) { localStorage.setItem("toUser",toUser); window.location.href = server + "wx/html/home/html/login.html?openid=" + openid+"&type="+pagetype; return false; } var newUaObj = JSON.parse(window.localStorage.getItem(agentName)) //判断关系 function hasFamilyRelation(a,b){ return new Promise(function(resolve, reject) { var data={ patient:a, familyMember:b } sendPost("patient/family/is_authorize", data, "json", "get", function(res){ dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请求家庭成员关系失败'}).show(); }, function(res){ if(res.status == 200) { window.localStorage.setItem('nowPatientName',res.data.name); resolve(res) }else if(res.status == 100) { dialog({ content:'对不起,'+res.data.name+'未授权给您,如需查看,请切换'+res.data.name+'账号登录', okValue:'切换账号', ok: function() { window.localStorage.setItem(pageName, JSON.stringify({pageurl: location.href})) window.location.href = "../../grzx/html/change-login.html?type=0&openid="+ Request["openid"]; }, cancelValue: '我不看了', cancel: function () { wx.closeWindow(); } }).showModal(); }else{ relogin(); } }) }) } //重新登录操作 function relogin(){ dialog({ content:'对不起,该消息是发给'+toName+',如需查看,请切换'+toName+'账号登录', okValue:'切换账号', ok: function() { window.localStorage.setItem(pageName, JSON.stringify({pageurl: location.href})) window.location.href = "../../grzx/html/change-login.html?type=0&openid="+ Request["openid"]; }, cancelValue: '我不看了', cancel: function () { wx.closeWindow(); } }).showModal(); } //保存信息 function saveUserInfo(a,b){ Promise.all([hasFamilyRelation(a,b)]).then(function () { newUaObj.represented = represented; window.localStorage.setItem(agentName,JSON.stringify(newUaObj)); initData(); bindEvents(); }) } function initFamilyData () { //从微信模板消息进入 if(represented && userAgent && toUser){ if(toUser == represented){ saveUserInfo(represented,newUaObj.uid) }else if(toUser != represented && represented == newUaObj.uid){ //本人代理 saveUserInfo(represented,newUaObj.uid) }else if(toUser != represented && toUser == newUaObj.uid){ //需要判定关系 200有授权 100家人 1无关系 saveUserInfo(represented,newUaObj.uid) }else{ //重新登录 relogin(); } }else{ initData(); bindEvents(); } } initFamilyData(); } function bindEvents(){ $(".c-list").on("click",".n-list-li,.n-list-content",function(event){ var parentLi = $(this).closest("li"); var id = parentLi.attr("data-id"); var orgCode = parentLi.attr("data-orgCode"); location.href = "detail-appointment.html?id="+id+"&orgCode="+orgCode; }).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"); location.href = "doctor-detail.html?type=2&id="+id+"&doctorId="+doctorCode+"&hospitalId="+orgCode+"&hosDeptId="+deptCode; }) $(".div-add-btn").on("click",function(){ // $(this).hide(); // $(".div-dialog-content").show(); // $(".modal-overlay").addClass("modal-overlay-visible"); location.href = "appointment-register.html"; }) //点击免疫预约事件 $(".mianyi-icon").on("click",function(){ $(this).addClass("active"); location.href = "immune-appointment.html"; }); //点击普通预约事件 $(".putong-icon").on("click",function(){ $(this).addClass("active"); location.href = "appointment-register.html"; }); } function initData(){ $(".c-list").html(""); pageIndex = 1; getMyAppo(); } function getMyAppo(){ d.show(); var data={}; var loginUser = JSON.parse(window.localStorage.getItem(agentName)); data.patient=loginUser['represented']?loginUser['represented']:loginUser['uid']; sendPost('third/guahao/GetRegList', data, 'json', 'post', getListFail, successFun); } function successFun(res){ if(res.status==200){ 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{ dialog({contentType:'tipsbox', skin:'bk-popup' , content:'无更多数据!',bottom:true}).show(); } d.close(); } }else{ getListFail(res); } } function getListFail(res){ d.close(); if (res && res.msg) { if((res.msg).indexOf("SOAP")>=0){ dialog({contentType:'tipsbox', skin:'bk-popup' , content:"医院接口访问异常,请刷新后重试!",bottom:true}).show(); return false; } dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg,bottom:true}).show(); } else { dialog({contentType:'tipsbox', skin:'bk-popup' , content:'加载失败',bottom:true}).show(); } } 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 = "已撤销"; }if(data.status=="1"){ 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-74BF00"; clazz2 = "c-74BF00"; statusNm = "已就诊"; } else if(data.status=="4"){ clazz1 = "cb-909090"; clazz2 = "c-909090"; statusNm = "已停诊"; } appoHtml = template("doctor_list_tmp", {data:data}); $(".c-list").append(appoHtml); } setTimeout(function(){ scroller1.myScroll.refresh(); },500) d.close(); $(".main").show(); $("#footer").show(); } //下拉刷新 function pullDownAction(theScrollerTemp) { // $(".main").hide(); // $("#footer").hide(); // $(".pullDown").show(); // initData(); // setTimeout(function () { // $(".pullDown").hide(); // }, 1000); } //将scroller1的初始化代码放到外面来,不然从微信授权重定向过来这个页面的时候, //iscroll-pull-up-down 里监听的window的load方法不会触发,导致scroller初始化代码没有执行 var scroller1 = new IScrollPullUpDown('wrapper2',{ probeType:2, bounceTime: 250, bounceEasing: 'quadratic', mouseWheel:false, scrollbars:true, fadeScrollbars:true, click:true, interactiveScrollbars:false },pullDownAction,null);