(function(){
    Vue.component('team-info',{
        template: '<div>\
            <div class="pt15" id="teamInfoBox">\
                <div class="plr15 pb20">\
                <span class="c-f14 c-bold c-333">团队名称：</span>\
                <span class="c-f14 c-333">{{team.name}}</span>\
            </div>\
            <div class="plr15 pb20">\
                <span class="c-f14 c-bold c-333">所在社区：</span>\
                <span class="c-f14 c-333">{{team.hospitalName}}</span>\
            </div>\
            <div class="plr15 pb20">\
                <span class="c-f14 c-bold c-333">团队长：</span>\
                <span class="c-f14 c-333">{{team.leaderName}}</span>\
            </div>\
            <div class="plr15 pb20">\
                <span class="c-f14 c-bold c-333">团队成员(<span class="span-team-count">{{memberLength}}</span>人)：</span>\
                <p class="c-f14 c-333 mt10">\
                    <span v-for="(member, index) in members">{{index==0? "": " 、"}}{{member.name}}</span>\
                </p>\
            </div>\
        </div>',
        props:['teamId'],
        data: function(){
            return {
                team: {},
                members: [],
                memberLength: 0
            }
        },
        mounted: function(){
            console.log(this.teamId);
            var vm = this;
            getTeamInfo(vm);
        }
    });
    
    function getTeamInfo(vm){
        var params = {
            teamId: vm.teamId
        };
        statisticAPI.getTeamInfo(params).then(function(res){
            if(res.status == 200){
                vm.team = res.data.team;
                vm.members = res.data.members;
                vm.memberLength = res.data.members.length;
            }else{
                console.log(res.msg);
            }
        })
    }
})()
