|
@ -0,0 +1,252 @@
|
|
|
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<res.data.immunemembers.length; i++){
|
|
|
var item = res.data.immunemembers[i];
|
|
|
keys.push(item.child_code);
|
|
|
values.push(item.name);
|
|
|
}
|
|
|
$("#userName").mobiscroll({
|
|
|
theme: 'ios',
|
|
|
lang:'zh',
|
|
|
customWheels:true,
|
|
|
wheels: [
|
|
|
[
|
|
|
{
|
|
|
keys: keys,
|
|
|
values: values
|
|
|
}
|
|
|
]
|
|
|
],
|
|
|
onSelect: function(valueText, inst){
|
|
|
var dd = eval("[" + valueText + "]");
|
|
|
$("#userName").val(dd[0].values);
|
|
|
$("#userName").attr('data-id',dd[0].keys);
|
|
|
selectData = _.findWhere(res.data.immunemembers, {child_code: dd[0].keys});
|
|
|
//填充身份证号
|
|
|
if(!selectData.idcard || !selectData.ssc){
|
|
|
getPatientInfo();
|
|
|
}else{
|
|
|
$("#idCard").val(selectData.idcard);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
}
|
|
|
}else{
|
|
|
queryFailed(res);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
//获得患者信息
|
|
|
function getPatientInfo(){
|
|
|
var url = "patient/baseinfo";
|
|
|
sendPost(url, {}, 'json', 'get', function(res){
|
|
|
if(res.msg){
|
|
|
dialog({ contentType: 'tipsbox', skin: 'bk-popup', content: res.msg, bottom: true }).show();
|
|
|
}else{
|
|
|
dialog({ contentType: 'tipsbox', skin: 'bk-popup', content: '加载数据失败', bottom: true }).show();
|
|
|
}
|
|
|
|
|
|
}, function(res){
|
|
|
if(res.status == 200){
|
|
|
patientInfo = res.data;
|
|
|
$("#idCard").val(patientInfo.idcardAll);
|
|
|
}else{
|
|
|
dialog({ contentType: 'tipsbox', skin: 'bk-popup', content: res.msg, bottom: true }).show();
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
|
|
|
function bindEvents() {
|
|
|
var scroller1 = new IScrollPullUpDown('wrapper', {
|
|
|
probeType: 2,
|
|
|
bounceTime: 250,
|
|
|
bounceEasing: 'quadratic',
|
|
|
mouseWheel: false,
|
|
|
scrollbars: true,
|
|
|
fadeScrollbars: true,
|
|
|
click: true,
|
|
|
interactiveScrollbars: false
|
|
|
}, null, null);
|
|
|
|
|
|
$("#validateDiv").on("click", function() {
|
|
|
initValidate();
|
|
|
});
|
|
|
|
|
|
$("#mobile").on("focus", function() {
|
|
|
$(".searchbar-clear").css("pointer-events", "none").css("opacity", 0);
|
|
|
if($(this).val()) {
|
|
|
$(this).next().css("pointer-events", "auto").css("opacity", 1);
|
|
|
$(this).next().show();
|
|
|
}
|
|
|
}).on("input", function() {
|
|
|
$(this).next().css("pointer-events", "auto").css("opacity", 1);
|
|
|
$(this).next().show();
|
|
|
});
|
|
|
|
|
|
$(".visit-ul").on("click", ".searchbar-clear", function() {
|
|
|
$(this).prev().val("");
|
|
|
$(this).css("pointer-events", "none").css("opacity", 0);
|
|
|
$(this).prev().focus();
|
|
|
return false;
|
|
|
});
|
|
|
|
|
|
window.addEventListener("resize", function() {
|
|
|
var u = navigator.userAgent;
|
|
|
if(u.indexOf('Android') > -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();
|
|
|
}
|
|
|
}
|