var d = dialog({contentType:'load', skin:'bk-popup', content:'加载中...'}); var mySwiper; var pagetype = 33; var signStatus; var Request = GetRequest(); var userAgent = localStorage.getItem(agentName); var changeDoctor = Request.changeDoctor || 0; //标记是否是医生发起的模板消息,1-医生发起的 $(function(){ var toUser = Request["toUser"]; var toName = decodeURIComponent(Request["toName"]); var openid = Request["openid"]; var represented = Request["represented"]; if(!userAgent) { window.location.href = server + "wx/html/home/html/login.html?type=" + pagetype + "&openid=" + openid; return false; } var newUaObj = JSON.parse(userAgent) //判断关系 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)); userAgent = JSON.parse(localStorage.getItem(agentName)); queryInit() }) } 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{ userAgent = JSON.parse(userAgent); queryInit() } } initFamilyData(); $('.swiper-slide,.swiper-container').css({ height: $(window).height() }); $(window).on('resize',function(){ $('.swiper-slide,.swiper-container').css({ height: $(window).height() }); }); }); function queryInit(){ var date = new Date(); getStatistics(); //获得统计数据 bindEvents(); getWeixinSign(); } function reqFailed(res){ d.close(); if(res.msg){ dialog({ contentType:'tipsbox', bottom:true, skin:'bk-popup', content: res.msg }).show(); }else{ dialog({ contentType:'tipsbox', bottom:true, skin:'bk-popup', content: "请求失败,请重试" }).show(); } } function initSwiper(){ mySwiper = new Swiper('.swiper-container',{ setWrapperSize :true, direction:"vertical", speed : 1000, longSwipesRatio : 0.3, grabCursor:true, nextButton:'.next-btn', prevButton:'.pre-btn', mousewheelControl : true, lazyLoading : true, lazyLoadingInPrevNext : true, lazyLoadingOnTransitionStart : true, onInit: function(swiper){ setTimeout(function(){ $("#loading").remove(); $(".swiper-container").css({"opacity":"1"}); swiperAnimateCache(swiper); swiperAnimate(swiper); },1000); }, onSlideChangeEnd: function(swiper){ swiperAnimate(swiper); }, onTransitionEnd: function(swiper){ swiperAnimate(swiper); } }); } function getStatistics(){ d.show(); var url = "/patient/family_contract/getSignCountInfoInYear", params = {patient: userAgent.represented?userAgent.represented:userAgent.uid}; sendPost(url, params, "JSON", "get", reqFailed, function(res){ if(res.status == 200){ d.close(); var data = res.data, consultTotal = data.consultTotal, articleCount = data.articleResult[0].articleCount, guidanceCount = data.guidanceResult[0].guidanceCount, reservationCount = data.reservationResult[0].reservationCount, totalCount = articleCount + guidanceCount + reservationCount; if(consultTotal == 0 && totalCount == 0){ $(".result-info").html("您没有该年度的服务记录"); $("#directBtn").text("了解更多授权续签"); $("#directBtn").parent().show(); $("#directBtn").attr("href", "agreement.html?changeDoctor="+changeDoctor); return; } $("#skip").show(); $(".page1-text-1").text(res.data.consultTotal); var len = res.data.consultResult.length; var newRs = _.sortBy(res.data.consultResult, function(o){ return -o.consultCount; }); var page1html = ""; for(i=0; i 0){ mt = "mt10"; } if(i < 3){ page1html += '
'+ ''+item.doctorName+''+ ''+ ''+item.consultCount+'
'; }else{ page1html += '
' break; } } $(".swiper-slide1").append(page1html); //第二页内容填充 var page2html = '

今年'; var docLen = res.data.doctors.length; if(docLen == 0){ page2html += '没有'; } for(j=0; j 0){ page2html += ''; } page2html += ''+item.name+''; } page2html += '医生

'; $(".page2-div1").append(page2html); $(".page2-text-3").text(totalCount); $(".page2-text-4").text(reservationCount); $(".page2-text-5").text(guidanceCount); $(".page2-text-6").text(articleCount); initSwiper(); }else{ if(res.status == -1){ //请求判断是和情况 var url = "/patient/family_contract/checkCanRenew", params = {patient: userAgent.represented?userAgent.represented:userAgent.uid}; sendPost(url, params, "json", "post", reqFailed , function(res){ if(res.status == 200){ var code = res.data.code, msg = "您没有签约关系
请前往签约管理页面签约医生", enable = true; switch (parseInt(code)){ case -4: msg = "您当前无可续签的家庭医生
可在签约管理页面签约医生"; enable = false; break; case -2: msg = "您已完成新年度的签约
不能再次签约"; enable = false; break; case -1: msg = "当前时间段不允许续签
可前往签约管理页面签约医生"; enable = false; break; } $(".result-info").html(msg); $("#directBtn").text("我知道了"); $("#directBtn").parent().show(); $("#directBtn").attr("href", "../../qygl/html/signing_management.html"); }else{ $(".result-info").html("您没有签约关系
请前往签约管理页面签约医生"); $("#directBtn").text("我知道了"); $("#directBtn").parent().show(); $("#directBtn").attr("href", "../../qygl/html/signing_management.html"); } d.close(); }); } } }); } function bindEvents(){ $(".more-btn").on('tap', function(){ window.location.href = "agreement.html?signStatus="+signStatus+"&changeDoctor="+changeDoctor; }); $("#skip").on("tap", function(){ window.location.href = "agreement.html?signStatus="+signStatus+"&changeDoctor="+changeDoctor; }) } function getWeixinSign(){ var params = {}; params.pageUrl = window.location.href; $.ajax(server + "weixin/getSign", { data: params, dataType: "json", type: "post", success: function(res) { if(res.status == 200) { var t = res.data.timestamp; var noncestr = res.data.noncestr; var signature = res.data.signature; wx.config({ //debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 appId: appId, // 必填,公众号的唯一标识 timestamp: t, // 必填,生成签名的时间戳 nonceStr: noncestr, // 必填,生成签名的随机串 signature: signature, // 必填,签名,见附录1 jsApiList: [ 'closeWindow' ] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2 }); } } }); }