var d = dialog({
contentType: 'load',
skin: 'bk-popup'
});
var userAgent = localStorage.getItem(agentName);
if(userAgent){
userAgent = JSON.parse(userAgent);
}
var request = GetRequest(),
code = request.id,
renew = request.renew;
var doctorName = "";
$(function() {
getDocInfo();
});
function getDocInfo(){
d.show();
var url = "family_contract/homepage/homepage",
params = {doctor: code};
// url2 = "patient/family_contract/getPatientSign",
// params2 = {homePageDoctorCode: code, invitePatientCode: userAgent.uid};
sendPost(url, params, 'json', 'post', queryFailed, querySuccess);
sendPost("patient/consult/evaluate/doctor/label", params, 'json', 'get', queryFailed, success2);
// getReqPromises();
}
function success2(res) {
var html='';
if(res.list.length > 0){
$.each(res.list, function(i,v) {
html += '
'+v.content+'';
});
}else{
html = '暂无标签';
}
$('#tag_group').append(html);
d.close();
}
function queryFailed(res) {
d.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){
d.close();
var data = res.data;
doctorName = res.data.name;
$(".doc-photo").attr("src", getImgUrl(data.photo));
$("#docName").text(data.name);
$("#docJob").text(data.jobName);
$("#docHospital").text(data.hospital);
$("#intro").text(data.intro);
$("#expertise").text(data.expertise);
if(data.evaluateScore == 0){
$("#docScore").text('暂无评分');
}else{
$("#docScore").text(data.evaluateScore);
}
//判断签约状态
var sign = res.data.sign;
if(sign == 0) { // 待签约
$('#btnSign').show();
}
d.close();
} else {
queryFailed(res);
}
}
function cancelSign() {
var url = 'patient/family_contract/unsign',
msg = '您确定取消和' + doctorName + '医生的签约申请吗?';
if(renew){
url = 'patient/family_contract/unsignRenew';
msg = '您确定取消和' + doctorName + '医生的续签申请吗?'
}
dialog({
content: msg,
ok: function() {
d.showModal();
var data = {};
var userAgent = localStorage.getItem(agentName);
data.patientCode = JSON.parse(userAgent).represented?JSON.parse(userAgent).represented:JSON.parse(userAgent).uid;
data.doctor = code;
sendPost(url , data, 'json', 'post', submitFailed, submitSuccess);
},
cancel: function() {
return;
}
}).showModal();
}
function submitFailed(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 submitSuccess(res) {
if(res.status == 200) {
d.close();
dialog({
content: '您已成功取消了与'+doctorName+'医生的签约申请,是否需要选择其他医生签约?',
okValue:'选择其他医生',
ok: function() {
window.location.href = "select-doctor.html";
},
cancelValue: "不了,谢谢",
cancel: function(){
history.go(-1);
}
}).showModal();
} else {
submitFailed(res);
}
}