/**
* 作用:获取URL地址栏中的参数
* @param 需要获取URL中的某个参数
*/
function GetLocationParam(param) {
// 得到window.location的某个参数
var ss = ('' + window.location).split('?');
if(ss.length > 1) {
var sss = ss[1].split('&');
for(var i = 0; i < sss.length; i++) {
var ssss = sss[i].split('=');
if(ssss.length > 1 && ssss[0] == param) return ssss[1];
}
}
return '';
}
/**
* 定义全局变量
*/
var G_WEBBASE = "https://gz.fromfuture.cn/chis/";
var imgGuid;
var docNam;
var positionTitle;
var hospital;
var docGuid;
var docId;
var flg;
var hospitalId; //医院标志
var hospitalFtp; //定义医院服务器地址
var morning;
var morning1;
var morning2;
$(function() {
//获取上级页面传过来的参数并赋值全局变量
imgGuid = GetLocationParam("imgGuid");
docNam = GetLocationParam("docNam");
positionTitle = GetLocationParam("positionTitle");
hospital = GetLocationParam("hospital");
docGuid = GetLocationParam("docGuid");
docId = GetLocationParam("docId");
flg = GetLocationParam("flg");
morning = GetLocationParam("morning");
morning1 = GetLocationParam("morning1");
morning2 = GetLocationParam("morning2");
/**
* 给页面进行赋值
*/
document.getElementById("doc_name").innerHTML = decodeURIComponent(docNam); //对URL地址传过来的中文字进行转码
document.getElementById("doc_main").innerHTML = decodeURIComponent(positionTitle);
document.getElementById("doc_hospi").innerHTML = decodeURIComponent(hospital);
document.getElementById("doc_pic").src = hospitalFtp + "EAFormBlob.sp?guid=" + imgGuid;
document.getElementById("morning").innerHTML = morning;
document.getElementById("morning1").innerHTML = morning1;
document.getElementById("morning2").innerHTML = morning2;
})
/**
* 线下预约确认按钮点击事件
*/
mui("body").on("tap", "#onlineId", function() {
var usrid = window.localStorage.getItem('FROMFUTURE_APP_USRID'); //获取登录账户手机号
var tim = morning1 + "-" + morning2;
var url = G_WEBBASSRE + "rca是ll.jsp?sysstid=CHIS&mmwid=Gzyffrfrce&funcid=GefffgfgtdocYY";
url += "&myid=" + usrid + "&uid=" + docId + "&dat=" + morning + "&tim=" + tim;//传给后台的参数
try {
mui.ajax({
url: url,
async: false,
timeout: 8000,
type: 'POST',
success: function(result) {
try {
var regJson = JSON.parse(result);
if(regJson.encode == "1001") {
mui.toast("不能重复预约");
} else if(regJson.encode == "1002") {
mui.toast("预约成功");
//跳转支付页面
mui("body").on("tap", "#onlineId", function() {
showpage("online_pay.html", "online_pay");
})
} else if(regJson.encode == "1003") {
mui.toast("数据错误");
} else if(regJson.encode == "1004") {
mui.toast("预约的医生没有排班请核实");
} else if(regJson.encode == "1005") {
mui.toast("已约满");
}
} catch(error) {
console.log("数据错误" + e);
return mui.toast("数据错误" + e);
}
},
error: function(xhr, status, error) {
if(status == "error")
mui.toast('请尝试连接网络');
}
});
} catch(error) {
mui.toast("请检查网络连接");
}
})