<template>
    <div class="mypage">
        <div class="flex justify-between mb30" style="gap: 30px;">
            <div>
                <div class="title-box flex justify-between mb20">
                    <p class="title">소속 반</p>
                    <div class="flex align-center look-btn">
                        <!-- <p>더보기 </p><svg-icon type="mdi" :path="mdilArrowRight" class=" ml10"></svg-icon> -->
                    </div>
                </div>
                <div class="wrap " style="width: 82rem;">
                    <section class="flex" style="gap: 20px;">
                        <div class="class flex justify-between" style="cursor: default;">
                            <div class="box gd-col2" style="gap: 5px;">
                                <div><img src="../../../resources/img/img176_82t.png" alt=""></div>
                                <div><img src="../../../resources/img/img176_82t.png" alt=""></div>
                                <div><img src="../../../resources/img/img176_82t.png" alt=""></div>
                                <div><img src="../../../resources/img/img176_82t.png" alt=""></div>
                            </div>
                            <div class="text mt10">
                                <p class="title1 mb10">A반</p>
                                <span class="member">20명</span>
                            </div>
                        </div>

                    </section>
                </div>
            </div>
            <div>
                <div class="title-box flex justify-between mb20">
                    <p class="title">사진첩</p>
                </div>
                <div class="photobook">
                    <div class="flex justify-between">
                        <div class="box" style="gap: 5px;">
                            <div><img src="../../../resources/img/img198_12p.png" alt=""></div>
                        </div>
                        <div class="text mt10">
                            <p class="title1 mb10">나의 사진첩</p>
                            <button @click="selectedTab = 'tab4'; goToPage('PhotoBook')" type="button" title="글쓰기"
                                class="new-btn">
                                바로가기
                            </button>

                        </div>
                    </div>

                </div>
            </div>
        </div>
        <div class="title-box flex justify-between mb20">
            <p class="title">가나다학생 랭킹</p>
        </div>
        <div class=" mb30">
            <div class=" flex " style="gap: 50px;">
                <div class="textbook book-red">
                    <div class="text ">
                        <p class="title1" style="color: #fff;">포토북 랭킹</p>
                    </div>
                    <div class="box " style="gap: 10px;">
                        <div><img src="../../../resources/img/img196_12p.png" alt=""></div>
                        <P class="title2 mt10">현재 30명 중 <em class="red">2등</em>입니다.</P>
                    </div>
                </div>
                <div class="textbook ">
                    <div class="text ">
                        <p class="title1" style="color: #fff;">포토북 랭킹</p>
                    </div>
                    <div class="box " style="gap: 10px;">
                        <div><img src="../../../resources/img/img196_12p.png" alt=""></div>
                        <P class="title2 mt10">현재 30명 중 <em class="yellow">2등</em>입니다.</P>
                    </div>
                </div>
                <div class="textbook book-blue">
                    <div class="text ">
                        <p class="title1" style="color: #fff;">포토북 랭킹</p>
                    </div>
                    <div class="box " style="gap: 10px;">
                        <div><img src="../../../resources/img/img196_12p.png" alt=""></div>
                        <P class="title2 mt10">현재 {{ stdCount }}명 중 <em class="blue">{{ rank }}등</em>입니다.</P>
                    </div>
                </div>
                <div class="textbook book-navy">
                    <div class="text ">
                        <p class="title1" style="color: #fff;">포토북 랭킹</p>
                    </div>
                    <div class="box " style="gap: 10px;">
                        <div><img src="../../../resources/img/img196_12p.png" alt=""></div>
                        <P class="title2 mt10">현재 30명 중 <em class="navy">2등</em>입니다.</P>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import SvgIcon from '@jamescoyle/vue-icon';
import { mdiMagnify, } from '@mdi/js';
import { mdilArrowRight } from '@mdi/light-js';
import ProgressBar from '../../component/ProgressBar.vue';
import axios from "axios";


export default {
    data() {
        return {
            stdCount: 0,
            rank: 0,

            mdiMagnify: mdiMagnify,
            mdilArrowRight: mdilArrowRight,
            timer: "00:00",
            progress: 20
        }
    },
    methods: {
        classStdCount: function () {
            const vm = this;
            axios({
                url: "/userclass/classStdCount.json",
                method: "post",
                headers: {
                    "Content-Type": "application/json; charset=UTF-8",
                },
                data: {
                    sclsId: "1"
                }
            })
                .then(function (response) {
                    console.log("classStdCount - response : ", response.data);
                    vm.stdCount = response.data;
                })
                .catch(function (error) {
                    console.log("classStdCount - error : ", error);
                    alert("반 학생 수 조회에 오류가 발생했습니다.");
                });
        },

        photoRankByLikeData: function () {
            const vm = this;
            axios({
                url: "/photo/photoRankByLikeData.json",
                method: "post",
                headers: {
                    "Content-Type": "application/json; charset=UTF-8",
                },
                data: {
                    sclsId: "1",
                    stdId: "1"
                }
            })
                .then(function (response) {
                    console.log("Rank - response : ", response.data);
                    vm.rank = response.data;
                })
                .catch(function (error) {
                    console.log("Rank - error : ", error);
                    alert("학생 사진 랭킹 조회에 오류가 발생했습니다.");
                });
        },

        goToPage(page) {
            this.$router.push({ name: page });
        },
        increaseProgress() {
            if (this.progress < 100) {
                this.progress += 10;
            }
        },
        showConfirm(type) {
            let message = '';
            if (type === 'cancel') {
                message = '삭제하시겠습니까?';
            } else if (type === 'reset') {
                message = '초기화하시겠습니까?';
            } else if (type === 'save') {
                message = '등록하시겠습니까?';
            }

            if (confirm(message)) {
                this.goBack();
            }
        },
    },
    watch: {

    },
    computed: {

    },
    components: {
        SvgIcon,
        ProgressBar
    },
    mounted() {
        console.log('Main2 mounted');
        this.classStdCount();
        this.photoRankByLikeData();
    }
}
</script>
<style scoped>
.mypage .textbook {
    width: 22%;
}
</style>