var d = dialog({ contentType: 'load', skin: 'bk-popup' }); var imgKey = null; var selectData = ''; //用户信息 var orgInfo, //前一个页面保存在localStorage的数据 arrangeDate, //前一个页面保存在localStorage的数据 patientInfo; //如果儿童没有身份证号和社保卡号,则使用当前用户的身份证号和社保卡号 $(function() { // checkUserAgent(); queryInit(); }); function queryInit(){ orgInfo = window.localStorage.getItem("orgInfo"); if(orgInfo && orgInfo != "") { orgInfo = JSON.parse(orgInfo); $("#hospitalName").text(orgInfo.name); } else { dialog({contentType:'tipsbox', skin:'bk-popup' , content:'机构数据异常重新选择!',bottom:true}).show(); return; } arrangeDate = window.localStorage.getItem("arrangeDate"); if(arrangeDate && arrangeDate != "") { arrangeDate = JSON.parse(arrangeDate); $("#yyTime").text(arrangeDate.timeStr); } else { dialog({contentType:'tipsbox', skin:'bk-popup' , content:'预约日期异常请返回重新选择!',bottom:true}).show(); return; } initValidate(); getImmuneMembers(); bindEvents(); } function initValidate() { var serurl = "patient/captcha"; var posttype = "get"; if(imgKey != null) { serurl = serurl + "/" + imgKey; posttype = "post"; } sendPost(serurl, {}, "json", posttype, function(res) { dialog({ contentType: 'tipsbox', skin: 'bk-popup', content: "验证码获取失败!", bottom: true }).show(); }, function(res) { if(res.status == 200) { imgKey = res.data.key; $("#validateDiv").attr("src", "data:image/png;base64," + res.data.image); } else { dialog({ contentType: 'tipsbox', skin: 'bk-popup', content: "验证码获取失败!", bottom: true }).show(); } }) } //获得接种儿童信息 function getImmuneMembers(){ var url = "/patient/family/members"; sendPost(url, {}, 'json', 'get', queryFailed, function(res){ if(res.status == 200){ if(res.data.immunemembers.length > 0){ var keys = [], values = []; for(i=0; i -1 || u.indexOf('Linux') > -1) { var self = document.getElementById("validateCode"); setTimeout(function() { self.scrollIntoView({ block: "end", behavior: "smooth" }); }, 150); } }); //保存 $("#confirmBtn").on('click', function(){ var $this = $(this); if($this.hasClass("disabled")){ return false; } var childName = $("#userName").val(), idCard = $("#idCard").val(), mobile = $("#mobile").val(), validateCode = $("#validateCode").val(); if(!isphone(mobile)){ dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'手机号格式不正确'}).show(); return; } $("#validateCode").blur(); $("#mobile").blur(); $this.addClass("disabled"); //校验验证码是否正确 d.show(); sendPost("patient/captcha/"+imgKey,{"text":validateCode},"json","get",function(res){ d.close(); dialog({ contentType:'tipsbox', skin:'bk-popup' , content:"验证码校验失败!", bottom:true }).show(); initValidate(); $this.removeClass("disabled"); },function(res){ if(res.status==200){ if(res.pass==true){ imgKey = null; //发送确认请求 var url = "/patient/guahao/imm/RegisterImmune", params = { OrgCode: orgInfo.code, SectionType: arrangeDate.time, strStart: arrangeDate.startTime, BarCode: selectData.barcode, SSID: selectData.ssc ? selectData.ssc : patientInfo.ssc, PatientName: selectData.name, PatientID: selectData.idcard ? selectData.idcard : patientInfo.ssc, PatientPhone: mobile }; sendPost(url, params, 'JSON', 'POST', queryFailed, submitSuccess); }else{ d.close(); dialog({contentType:'tipsbox', skin:'bk-popup' , content:"验证码错误,请重新输入!",bottom:true}).show(); $this.removeClass("disabled"); } }else{ d.close(); dialog({contentType:'tipsbox', skin:'bk-popup' , content:"验证码校验失败!",bottom:true}).show(); $this.removeClass("disabled"); } }); }); } function submitSuccess(res) { d.close(); if(res.status == 200) { $("#confirmBtn").removeClass("disabled"); dialog({ contentType: 'tipsbox', skin: 'bk-popup', content: '预约成功!', bottom: true }).show(); setTimeout(function() { 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"; }, 200); } else { $("#confirmBtn").removeClass("disabled"); queryFailed(res); } } function queryFailed(res) { d.close(); $("#confirmBtn").removeClass("disabled"); 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(); } }