var d1 = dialog({contentType:'load', skin:'bk-popup'});
var d = dialog({contentType:'load', skin:'bk-popup', content:'提交签约信息,请稍后...'});
var Request = new Object();
Request = GetRequest();
var doctor = Request["doctor"];
var doctorName = Request["doctorName"];
var hospitalName = Request["hospitalName"];
var idcard = Request["idcard"];
var code = Request["code"];
var level =Request["level"];
var is_renew = window.localStorage.getItem("is_renew");
if(code){
closeWindow();
}
// 从医生主页传递的签约邀请code
var signInvitationCode = Request["inviCode"];
var patientCode = Request["patientCode"];
if(!patientCode || patientCode=="undefined") {
patientCode = "";
}
$(function(){
if(level==2){
$(".bottom-title").html(decodeURI(doctorName)+"医生为全科医生,与其签约后,"+decodeURI(doctorName)+"医生将为您选择一个健管师,共同为您提供各项健康服务");
}else{
$(".bottom-title").html(decodeURI(doctorName)+"医生为健管师,与其签约后,"+decodeURI(doctorName)+"医生将为您选择一个全科医生,共同为您提供各项健康服务");
}
if (decodeURI(doctorName)) {
document.getElementById("doctorName").innerText = decodeURI(doctorName);
}
if (decodeURI(hospitalName)) {
document.getElementById("hospitalName").innerText = decodeURI(hospitalName);
}
if(signInvitationCode&&signInvitationCode!="undefined") {
$('#name_label').text('代理家人');
$(".div-family-remark").show();
}
query();
$("#idcard").on("blur", function() {
var value = $(this).val();
validateIdcard(value);
});
})
//查询用户信息
function query() {
d1.show();
var data={};
if(signInvitationCode&&signInvitationCode!="undefined") {
sendPost('patient/getPatientByInviLogCode', {invilogCode: signInvitationCode}, 'json', 'post', queryFailed, querySuccess);
} else {
sendPost('patient/baseinfo', data, 'json', 'post', queryFailed, querySuccess);
}
}
function queryFailed(res) {
d1.close();
if (res && res.msg) {
dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg}).show();
} else {
dialog({contentType:'tipsbox', skin:'bk-popup' , content:'用户信息获取失败'}).show();
}
}
function querySuccess(res) {
if (res.status == 200) {
var data = res.data;
var name = data.name;
var mobile = data.mobile;
var idcard = data.idcard;
var idcardAll = data.idcardAll;
var ssc = data.ssc;
var medicareNumber = data.medicareNumber;
if(!name) name = "";
if(!mobile) mobile = "";
if(!ssc) ssc = "";
if(!idcard) idcard = "";
document.getElementById("name").value = name;
document.getElementById("mobile").value = mobile;
document.getElementById("ssc").value = ssc;
document.getElementById("idcard").value = idcard;
document.getElementById("medicareNumber").value = medicareNumber || "";
$('#committee').text(data.countryName);
$('#committee').attr('data-code',data.countryCode);
$(".userName").html(name);
$('#idcard').attr('data-idcard',idcardAll);
if(!ssc || ssc ==""){
dialog({
content: '对不起,未办理医保卡或在2016年6月之后办理医保卡的居民暂不能进行签约。请保证在您的帐户中(我的资料)正确录入您的医保卡号,然后再重试!',
cancelValue: '我知道了',
cancel: function () {
wx.closeWindow();
}
}).showModal();
}
//选择居委会
selectCommittee()
//如果是改签,获取改签原因列表
if(parseInt(is_renew) == 1){
var url = "/patient/sign/getRenewChangeReason";
sendPost(url, {}, 'json', 'get', queryFailed, function(res1){
if(res1.status == 200){
$("#renewReason").show();
initSelectData(res1);
d1.close();
}else{
queryFailed(res1);
}
});
}else{
d1.close();
}
} else {
queryFailed(res);
}
}
//填充下拉框数据
function initSelectData(res){
var arr_key = [],
arr_value = [];
for(i=0; i医生通过后即可为您的家人提供家庭医生服务',
okValue:'我知道了',
ok: function() {
wx.closeWindow();
}
}).showModal();
}else{
window.location.href = "../../ssgg/html/doctor-homepage-new.html?waitSign=1&state=" + doctor;
}
// window.location.href = "doctor-home-page.html?doctor=" + doctor;
} else {
//非200则为失败
operateFailed(res);
}
}
//续签申请成功后页面跳转
function operateSuccesss2(res) {
if (res.status == 200) {
d.close();
dialog({
content: '续签申请已提交,请耐心等待,
医生通过后即可为您的家人提供家庭医生服务',
okValue:'我知道了',
ok: function() {
window.location.replace("../../qygl/html/signing_management.html");
}
}).showModal();
} else {
//非200则为失败
operateFailed(res);
}
}
function closeWindow() {
var Request = new Object();
Request = GetRequest();
var code = Request["code"];
//从后台那边获取签名等信息
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
});
}
}
});
}