<template>
    <div class="head">
        <div class="banner">
            <div class="text">{{info.now_str}}</div>
            <div class="text">第{{info.current_week}}周</div>
            <div class="text">星期{{day}}</div>
            <span class="star" v-if="info.score"><i class="icon1 icon-wujiaoxingshi"></i>{{info.score}}</span>
        </div>
        <div class="info">
            <div>
                <img class="avatar" :src="info.photo || headImg" @click="toMy">
                <div class="tips">个人中心</div>
            </div>
            <div class="name-box">
                <span class="name">{{info.real_name}}老师</span>
                <span
                    class="attendance"
                    @click="$router.push({name: 'InductionAndPositionSign'})"
                    v-if="info.period_name && !info.status_name"
                >{{info.period_name}}：未考勤<x-icon type="ios-arrow-right" class="icon-right" size="16"></x-icon></span>
            </div>
        </div>
    </div>
</template>

<script>
import headImg from '@/assets/images/head.png'
export default {
    name: 'HeadInfo',
    props: ['info'],
    data () {
        const week = '日一二三四五六'
        return {
            headImg,
            day: week[new Date().getDay()]
        }
    },
    watch: {
        info (info) {
            if (info.now_str) this.info.now_str = info.now_str.replace('-', '年').replace('-', '月') + '日'
        }
    },
    methods: {
        // 跳转到个人中心
        toMy () {
            location.href = this.$common.exportHostName() + '/Weixin/App/Teacher/UserCenterV2/MyUserInfo.aspx'
        }
    }
}
</script>

<style lang="less" scoped>
.head {
    margin-bottom: 8px;
    background-color: #fff;
}
.banner {
    position: relative;
    height: 190px;
    padding: 20px;
    background: url('~@/assets/images/3301.jpg') no-repeat center / cover;
    .text {
        color: #fff;
        font-size: 22px;
        line-height: 30px;
    }
    .star {
        position: absolute;
        top: 50px;
        right: 20px;
        padding: 0 8px;
        line-height: 30px;
        color: #333;
        background-color: #fff;
        border-radius: 6px;
        i {
            color: #FFB800;
            font-size: 18px;
            margin-right: 5px;
        }
    }
}
.info {
    height: 62px;
    padding: 0 10px 5px 15px;
    display: flex;
    .avatar {
        width: 68px;
        height: 68px;
        vertical-align: top;
        border: 2px solid #fff;
        border-radius: 4px;
        margin-top: -34px;
        position: relative;
        z-index: 1;
    }
    .tips {
        font-size: 14px;
        text-align: center;
        color: #999;
    }
    .name-box {
        flex-grow: 1;
        padding-left: 10px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        height: 40px;
        .name {
            font-size: 18px;
        }
        .attendance {
            color: #dd524d;
            font-size: 14px;
            .vux-x-icon {
                fill: #999;
                vertical-align: middle;
            }
        }
    }
}
</style>
