var request = getRequest(),
    tab = request.tab || 1,
    sessionId = request.sessionId, //续方咨询的sessionId 格式: 居民code+咨询code+咨询类型（ 8 ）
    patiCode,
    patiCode,
    consultCode,
    prescriptionCode,
    jwCode; //基卫那边存储的原处方的code

var docInfo = window.localStorage.getItem("docInfo");
docInfo = JSON.parse(docInfo);

//初始tab的链接
var links = {
    '1': 'prescription-consulting.html?sessionId='+sessionId,
    '2': '',
    '3': '',
    '4': '',
    '5': '',
    '6': '',
    '7':''
};

$(function(){
    if(docInfo.isLeader == '1'){ //团队长显示咨询tab
        $(".nav-tabs").find("li:first-child").removeClass("hidden");
    }
    //根据页面传递的参数显示对应的tab
    $('.nav-tabs li:eq('+(tab-1)+') a').tab('show');

    $('.nav-tabs a').click(function (e) {
        e.preventDefault()
        tab = $(this).data('index');
        $(this).tab('show')
    })

    $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
        // e.target // newly activated tab
        // e.relatedTarget // previous active tab
        console.log("shown")
        var iframe = '<iframe class="J_iframe" name="iframe' + tab + '" width="100%" height="100%" src="' + links[tab] + '" frameborder="0" data-id="iframe' + tab + '" seamless></iframe>';
        var len = $("#tab-"+tab).find("iframe.J_iframe").length;
        if(len > 0){
            $("#tab-"+tab).find("iframe.J_iframe").remove();
        }
        $("#tab-"+tab+' .panel-body').append(iframe);
        
    })
})