123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- var d = dialog({contentType:'load', skin:'bk-popup'});
- var pagetype = 23;
- $(function(){
- var request = GetRequest();
- var id = request["id"];
- var orgCode = request["orgCode"];
- var doctorCode = "";
- var deptCode = "";
- var toUser = request["toUser"];
- var openid = request["openid"];
- var toName = decodeURIComponent(Request["toName"]);
- var represented = Request["represented"];
- var userAgent = window.localStorage.getItem(agentName);
-
- //注册事件
- bindEvents();
-
- //初始化数据
- initData();
-
- function initData(){
- if(!userAgent) {
- localStorage.setItem("toUser",toUser);
- localStorage.setItem("id",id);
- window.location.href = server + "wx/html/home/html/login.html?openid=" + openid+"&type=23";
- 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));
- nextInitData();
- })
- }
-
- 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{
- nextInitData();
- }
- }
- initFamilyData();
- }
- function nextInitData(){
- d.show();
- var data={};
- var loginUser = JSON.parse(window.localStorage.getItem(agentName));
- data.regCode = id;
- data.orgCode = orgCode;
- data.patientCode = loginUser.represented?loginUser.represented:loginUser.uid;
- sendPost('third/guahao/GetPatientReservationXm', data, 'json', 'post', getListFail, successFun);
- }
-
- function getCanceler(data) {
- var name = data.cancelerName;
- if(!name) return "";
-
- if(data.cancelerType=='1') {
- return name+'(专科医生)';
- } else if(data.cancelerType=='2') {
- return name+'(全科医生)';
- } else if(data.cancelerType=='3') {
- return name+'(健康管理师)';
- } else if(data.cancelerType=='4') {
- return name+'(临时专科)';
- } else if(data.cancelerType=='5') {
- return name;
- }
- return name;
- }
- function successFun(res){
- if(res.status==200){
- var data = res.data;
- //status:0 已撤销 1,2预约成功 3 已就诊 4已停诊
- var clazz1 = "cb-47ABEF";
- var clazz2 = "c-47ABEF";
- var statusNm = "预约成功";
-
- if(data.status=="0"){
- clazz1 = "cb-FF6A56";
- clazz2 = "c-FF6A56";
- statusNm = "已撤销";
- var operator = getCanceler(data);
- if(operator) {
- $('.div-operator').show();
- $('#operator_name').text(operator);
- }
- $(".div-cancel-btn").hide();
- $(".div-tongkeshi-btn").removeClass("c-24").addClass("c-50");
- $(".div-again-yuyue").removeClass("c-38").addClass("c-50");
- }else if(data.status=="3"){
- clazz1 = "cb-74BF00";
- clazz2 = "c-74BF00";
- statusNm = "已就诊";
- }else if(data.status=="4"){
- clazz1 = "cb-909090";
- clazz2 = "c-909090";
- statusNm = "已停诊";
- }else{//1,2
-
- // TODO 如果预约开始时间早于当前时间,则不显示”取消预约“按钮
- var jzStartTimeStr = data.startTime.replace(/-/g,'/');
- var jsStartTime = new Date(jzStartTimeStr).getTime();
- var curTime = new Date().getTime();
- if(curTime>jsStartTime) {
- $(".div-cancel-btn").hide();
- } else {
- $(".div-cancel-btn").show();
- $(".div-tongkeshi-btn").removeClass("c-50").addClass("c-24");
- $(".div-again-yuyue").removeClass("c-50").addClass("c-38");
- }
- }
- var jiuzhenTime = data.startTime.replace(/\//g,'-').substring(0);//就诊时间
- if(data.endTime){
- jiuzhenTime = jiuzhenTime + "~"+data.endTime.replace(/\//g,'-').substring(9);
- }
-
-
- $(".left-yuan").addClass(clazz1);
- $(".left-status").addClass(clazz2).html(statusNm);
- $(".guahao-time").html(data.czrq.substring(0,16));
- $(".jiuzheng-time").html(jiuzhenTime);
- $(".hospital-name").html(data.orgName);
- $(".users-name").html(data.name);
- $(".dept-name").html(data.deptName);
- $(".doctor-name").html(data.doctorName);
- $(".idcard").html(data.idcard);
- $(".yibao-num").html(data.ssc);
- $(".iphone-num").html(data.phone);
-
- doctorCode = data.doctorCode;
- orgCode = data.orgCode;
- deptCode = data.deptCode;
-
- }else{
- getListFail(res);
- }
-
- $(".main").show();
- $("#footer").show();
- d.close();
- }
-
- 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 bindEvents(){
- //同科室医生
- $(".div-tongkeshi-btn").on("click",function(){
- location.href = "select-doctor.html?hospitalId="+orgCode+"&deptId="+deptCode;
- });
-
- //撤销预约
- $(".div-cancel-btn").on("click",function(){
- dialog({
- content: '是否撤销该预约?',
- okValue:'确认',
- ok: function (){
- d.show();
- sendPost('patient/guahao/CancelOrder', {orderId:id,ssc:$(".yibao-num").text()}, 'json', 'post', getListFail, successCancleFun);
- },
- cancelValue: '取消',
- cancel: function () {
- return ;
- }
- }).showModal();
-
- });
-
- //再次预约
- $(".div-again-yuyue").on("click",function(){
- location.href = "doctor-detail.html?type=2&id="+id+"&doctorId="+doctorCode+"&hospitalId="+orgCode+"&hosDeptId="+deptCode;
- });
- }
-
- function successCancleFun(res){
- if(res.status==200){
- dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg,bottom:true}).show();
- //撤销预约成功后跳转到我的预约页面
- location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+appId+"&redirect_uri="+wxurl+"%2fwdyy%2fhtml%2fmy-appointment.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
- }
- }
-
-
-
-
- });
|