var patient,hospitalId,deptId,doctorId,type,id = null,xtCode;
mui.init();
mui.plusReady(function(){
var doctorInfo;
var self = plus.webview.currentWebview();
patient = self.patient;
hospitalId = self.hospitalId;
deptId = self.deptId;
doctorId = self.doctorId;
xtCode = self.xtCode;
type = self.type;
id = self.dataid;
initData();
bindEvents();//注册事件
//协同
if(xtCode){
$('#no_appoint').show()
$('#no_appoint').on('click',function(){
mui.openWindow({
id: "xietongfuwu-deal",
url: "../../xtfw/html/xietongfuwu-deal.html",
extras: {
type:1,
code:xtCode
}
})
})
}
});
function initData(){
getDoctorInfo();
}
function getDoctorInfo(){
var params ={};
params.city="350200";
params.doctorId = doctorId;
params.hospitalId = hospitalId;
params.hosDeptId = deptId;
sendPost("third/guahao/GetDoctorInfo",params,queryFailed,queryDoctorSuc);
}
function getDocWorkTimeInfo(){
var params ={};
params.OrgCode = hospitalId;
params.DeptCode = deptId;
params.DocCode = doctorId;
sendPost("wlyy_service/third/smjk/RegDeptSpeDoctorSectionList",params,queryFailed,queryWorkTimeSuc);
}
function queryFailed(res){
if (res && res.msg) {
mui.toast(res.msg);
} else {
mui.toast("加载失败!");
}
}
function queryDoctorSuc(res){
if(res.status==200){
showDocInfo(res.data);
}else{
queryFailed(res);
}
}
function queryWorkTimeSuc(res){
if(res.status==200){
showWorkTimeList(res.data);
}else{
queryFailed(res);
}
}
function showDocInfo(data){
$("#name").html(data.name);
$("#jobName").html(data.title);
$("#hospitalName").html(data.hospitalName);
$("#introduce").html(data.introduce);
if(data.sex==2){
// $("#photo").attr("src","../../../images/d-female.png");
$("#photo").attr("src","../../../images/d-male.png");
}else{
$("#photo").attr("src","../../../images/d-male.png");
}
doctorInfo = data;
getDocWorkTimeInfo();
}
function showWorkTimeList(data){
var timeList = "";
for(var j in data){
var detail = data[j];
var dateTime = detail.date+"";
var date= dateTime.split(" ")[0];
var week = getWeek(date);
var riqi = date.split("/");
riqi = riqi[1]+"-"+riqi[2];
var used = detail.used;
var max = detail.max;
var isMo = detail.time;
var detailTitle = "";
if(isMo =="a"){
isMo ="上午";
}else{
isMo ="下午";
}
var status = detail.status;
var statusHtml ="";
if(status==2){
statusHtml= '
';
}else{
statusHtml= '';
}
var liHtml = appendLi(detail);
var titleColor = 'c-323232';
if(data[j].regType != undefined){
// debugger
if(data[j].regType.indexOf('vip')>-1 || data[j].regType.indexOf('VIP')>-1 || data[j].fee == '300'){
titleColor = 'c-FF9526';
}
}else{
if(data[j].fee == '300'){
titleColor = 'c-FF9526';
data[j].regType = "VIP门诊";
}else{
data[j].regType = "普通门诊";
}
}
timeList+= ''+
'
'+
'
'+
'
'+
'
'+
'
'+
date+
'
'+
'
'+
week+" "+isMo+
'
'+
'
'+
'
'+
'
'+
data[j].regType+
'
'+
'
'+
'诊查费:'+detail.fee+'元'+
'
'+
'
'+
'
'+
statusHtml+
'
'+
'
'+
'
'+
'
'+
'
'+
'
'+
'
';
}
$("#tice_list").append(timeList);
init();//页面初始化
}
function appendLi(detail){
var sections = detail.sections;
var liHtml = "";
for(var j in sections){
var data = sections[j];
if(j%3==0){
if(j!=0){
liHtml+='';
}
liHtml+='';
}
var start = data.startTime;
var end = data.endTime;
var max = data.max;
var used = data.used;
var clazz = "div-time-enable";
if(max==used){
clazz = "div-time-disable";
}
liHtml+=''+getTime(start)+"-"+getTime(end)+'
';
if(j==(sections.length-1)){
liHtml+='';
}
}
return liHtml;
}
function getWeek(d){
var dateArray = d.split("/");
var year = dateArray[0], month = dateArray[1], date = dateArray[2];
var dt = new Date(year, month-1, date);
var weekDay = ["周天", "周一", "周二", "周三", "周四", "周五", "周六"];
return weekDay[dt.getDay()]
}
function getTime(dateTime){
var tempStrs = dateTime.split(" ");
var timeStrs = tempStrs[1].split(":");
var hour = timeStrs [0];
var minute = timeStrs [1];
var second = timeStrs [2];
return hour+":"+minute;
}
function init(){
if(type==1 || type==""){//显示医生简介
$("#doctorLi").addClass("hit");
$(".div-doctor-info").show();
}else{//显示门诊预约
$("#deptyuyueLi").addClass("hit");
$(".div-dept-info").show();
}
if($('.member-sel[data-id='+id+']').length>0){
$('.member-sel[data-id='+id+']').siblings("ul").removeClass("c-hide");
$('.member-sel[data-id='+id+']').find(".arrow-shou").addClass("active");
var offset = $('.member-sel[data-id='+id+']').offset();
window.scrollTo(offset.left,offset.top);
}
}
function bindEvents(){
//分组展开收起
$(".div-dept-info").on('click', '.member-sel', function() {
if(!$(this).siblings("ul").hasClass("c-hide")){
$(this).find(".arrow-shou").removeClass("active");
$(this).siblings("ul").addClass("c-hide");
}else{
$(".member-list").addClass("c-hide");
$(".member-sel").find(".arrow-shou").removeClass("active");
$(this).siblings("ul").removeClass("c-hide");
$(this).find(".arrow-shou").addClass("active");
}
});
$(".pt-tab").on("click","li",function(){
var activeId = $(this).attr("id");
$(".pt-tab li").removeClass("hit");
$(this).addClass("hit");
if(activeId=="doctorLi"){//医生简介
$(".div-doctor-info").show();
$(".div-dept-info").hide();
}else{//门诊预约
$(".div-doctor-info").hide();
$(".div-dept-info").show();
}
})
$(".div-dept-info").on("click",".div-time-enable",function(){
$(".div-time-enable").removeClass("active");
$(this).addClass("active");
var arrangeDate = $(this).attr("data-attr");
window.localStorage.setItem("arrangeDate",arrangeDate);
window.localStorage.setItem("doctorTemp",JSON.stringify(doctorInfo));
openWebviewExtras("info-confirm.html",{patient:patient,xtCode:xtCode});
});
}