<template>
    <div class="user-profile">
        <el-card :body-style="{ padding: '0px' }">
            <div class="card-body">
                <div class="left-wrap">
                    <userAvatar :user="user" />
                    <div class="user-name">{{ user.userName }}</div>
                    <ul class="ul-wrap">
                        <li :class="{ 'li-wrap': true, 'li-active': tabIndex === 0 }" @click="handleTabClick(0)">
                            <i class="el-icon-user icon"></i>
                            <span class="title">{{ $t('user.index.098976-50') }}</span>
                        </li>
                        <li :class="{ 'li-wrap': true, 'li-active': tabIndex === 1 }" @click="handleTabClick(1)">
                            <i class="el-icon-postcard icon"></i>
                            <span class="title">{{ $t('user.index.098976-51') }}</span>
                        </li>
                        <li :class="{ 'li-wrap': true, 'li-active': tabIndex === 2 }" @click="handleTabClick(2)">
                            <svg-icon icon-class="password" class="icon" />
                            <span class="title">{{ $t('user.index.098976-52') }}</span>
                        </li>
                    </ul>
                </div>
                <div class="right-wrap">
                    <div class="body-wrap" v-show="tabIndex === 0">
                        <div class="header">{{ $t('user.index.098976-50') }}</div>
                        <div class="content">
                            <userInfo :user="user" :postGroup="postGroup" :roleGroup="roleGroup" :wxbind="wxbind" />
                        </div>
                    </div>
                    <div class="body-wrap" v-show="tabIndex === 1">
                        <div class="header">{{ $t('user.index.098976-51') }}</div>
                        <div class="content">
                            <baseInfo :user="user" />
                        </div>
                    </div>
                    <div class="body-wrap" v-show="tabIndex === 2">
                        <div class="header">{{ $t('user.index.098976-52') }}</div>
                        <div class="content">
                            <resetPwd />
                        </div>
                    </div>
                </div>
            </div>
        </el-card>
    </div>
</template>
<script>
import userAvatar from './userAvatar';
import userInfo from './userInfo';
import baseInfo from './baseInfo';
import resetPwd from './resetPwd';
import { getUserProfile } from '@/api/system/user';

export default {
    name: 'Profile',
    components: { userAvatar, userInfo, baseInfo, resetPwd },
    data() {
        return {
            tabIndex: 0,
            user: {},
            roleGroup: '',
            postGroup: '',
            wxbind: '',
        };
    },
    mounted() {
        this.getUser();
    },
    methods: {
        // tab 切换
        handleTabClick(index) {
            this.tabIndex = index;
        },
        getUser() {
            getUserProfile().then((response) => {
                this.user = response.data;
                this.wxbind = response.wxBind;
                this.roleGroup = response.roleGroup;
                this.postGroup = response.postGroup;
            });
        },
    },
};
</script>

<style lang="scss" scoped>
.user-profile {
    padding: 20px;

    .card-body {
        display: flex;
        flex-direction: row;

        .left-wrap {
            width: 230px;
            height: 730px;
            background-color: #f7f7f7;
            text-align: center;
            padding: 40px 20px;

            .user-name {
                margin-top: 10px;
            }

            .ul-wrap {
                list-style: none;
                padding: 0;

                .li-wrap {
                    margin-top: 35px;
                    cursor: pointer;
                    padding: 10px 49px;
                    display: inline-block;
                    line-height: 1;
                    white-space: nowrap;
                    text-align: center;
                    box-sizing: border-box;
                    transition: 0.1s;
                    font-size: 14px;

                    .icon {
                        color: #1890ff;
                    }

                    .title {
                        margin-left: 8px;
                        font-size: 14px;
                    }
                }

                .li-active {
                    border-radius: 20px;
                    color: #fff;
                    background-color: #1890ff;
                    border-color: #1890ff;

                    .icon {
                        color: #fff;
                    }
                }
            }
        }

        .right-wrap {
            flex: 1;

            .body-wrap {
                width: 100%;
                height: 100%;
                padding: 20px;

                .header {
                    padding: 10px 0;
                    font-size: 15px;
                    font-weight: bold;
                    border-bottom: 1px solid #e6ebf5;
                }

                .content {
                    padding: 20px 0;
                }
            }
        }
    }
}

// 自定义二维码样式
.impowerBox .title {
    display: none;
}

.impowerBox .status.status_browser {
    display: none;
}

.impowerBox .qrcode {
    border: none;
    width: 200px;
    height: 200px;
    margin: 0 auto;
}

.impowerBox .status {
    display: none;
}
</style>
