<template>
    <view class="app-container">
        <view class="mine-AI">AI+就业服务程序</view>
        <view class="mine-userinfo">
            <view class="userindo-head">
                <image class="userindo-head-img" v-if="userInfo.age === '0'" src="/static/icon/boy.png"></image>
                <image class="userindo-head-img" v-else src="/static/icon/girl.png"></image>
            </view>
            <view class="userinfo-ls">
                <view class="userinfo-ls-name">{{ userInfo.name || '暂无用户名' }}</view>
                <view class="userinfo-ls-resume" v-if="isAbove90(Completion)">
                    简历完成度 {{ Completion }}，建议优化
                </view>
                <view class="userinfo-ls-resume" v-else>简历完成度 {{ Completion }}</view>
            </view>
        </view>
        <view class="mine-tab">
            <view class="tab-item" @click="navTo('/packageA/pages/myResume/myResume')">
                <image class="item-img" src="/static/icon/resume.png"></image>
                <view class="item-text">我的简历</view>
            </view>
            <view class="tab-item" @click="navTo('/packageA/pages/collection/collection')">
                <image class="item-img" src="/static/icon/collect.png"></image>
                <view class="item-text">我的收藏</view>
            </view>
            <view class="tab-item" @click="navTo('/packageA/pages/browseJob/browseJob')">
                <image class="item-img" src="/static/icon/browse.png"></image>
                <view class="item-text">我的浏览</view>
            </view>
            <view class="tab-item" @click="navTo('/packageA/pages/Intendedposition/Intendedposition')">
                <image class="item-img" src="/static/icon/quaters.png"></image>
                <view class="item-text">意向岗位</view>
            </view>
        </view>
        <view class="mine-options">
            <view class="mine-options-item">实名认证</view>
            <view class="mine-options-item">素质测评</view>
            <view class="mine-options-item">AI面试</view>
            <!-- <view class="mine-options-item">账号与安全</view> -->
            <view class="mine-options-item">通知与提醒</view>
            <view class="mine-logout" @click="logOut">退出登录</view>
        </view>
        <uni-popup ref="popup" type="dialog">
            <uni-popup-dialog
                mode="base"
                title="确定退出登录吗？"
                type="info"
                :duration="2000"
                :before-close="true"
                @confirm="confirm"
                @close="close"
            ></uni-popup-dialog>
        </uni-popup>
    </view>
</template>

<script setup>
import { reactive, inject, watch, ref, onMounted } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
const { $api, navTo } = inject('globalFunction');
import useUserStore from '@/stores/useUserStore';
const userInfo = ref({});
const Completion = ref({});
const popup = ref(null);
onShow(() => {
    userInfo.value = useUserStore().userInfo;
    Completion.value = useUserStore().Completion;
});

function logOut() {
    popup.value.open();
}

function close() {
    popup.value.close();
}

function confirm() {
    useUserStore().logOut();
}

const isAbove90 = (percent) => parseFloat(percent) < 90;
</script>

<style lang="stylus" scoped>
.app-container
    width: 100%;
    min-height: calc(100vh - var(--window-top) - var(--status-bar-height) - var(--window-bottom));
    background: linear-gradient( 180deg, #4778EC 0%, #002979 100%);
    display: flex;
    flex-direction: column;
    .mine-AI
        height: 42rpx;
        font-family: Inter, Inter;
        font-weight: 400;
        font-size: 35rpx;
        color: #FFFFFF;
        line-height: 41rpx;
        padding: 85rpx 0 0 30rpx;
    .mine-userinfo
        display: flex;
        justify-content: flex-start;
        align-items: center;
        padding: 64rpx;
        .userindo-head
            width: 101rpx;
            height: 101rpx;
            background: #D9D9D9;
            border-radius: 50%
            overflow: hidden
            margin-right: 40rpx;
            .userindo-head-img
                width: 100%;
                height: 100%;
        .userinfo-ls
            display: flex;
            flex-direction: column;
            align-items: flex-start;
            .userinfo-ls-name
                font-size: 42rpx;
                color: #FFFFFF;
            .userinfo-ls-resume
                font-size: 21rpx;
                color: #D9D9D9;
    .mine-tab
        margin: 0 30rpx;
        height: calc(155rpx - 30rpx);
        background: #FFFFFF;
        border-radius: 17rpx 17rpx 17rpx 17rpx;
        display: flex;
        padding: 15rpx;
        .tab-item
            display: flex;
            flex-direction: column;
            width: calc(100% / 4);
            align-items: center;
            justify-content: center;
            position: relative;
            .item-img
                height: 55rpx;
                width: 50rpx;
            .item-text
                font-size: 21rpx;
                color: #000000;
                line-height: 25rpx;
                text-align: center;
                margin-top: 10rpx;
        .tab-item::after
            position: absolute;
            right: 0;
            content: '';
            width: 0rpx;
            height: 96rpx;
            border-radius: 0rpx 0rpx 0rpx 0rpx;
            border-right: 2rpx solid #4778EC;
        .tab-item:last-child::after
            border-right: 0;
        .tab-item:nth-child(2)>.item-img
            width: 51rpx;
            height: 45rpx;
            margin-top: 6rpx;
            margin-bottom: 4rpx;
        .tab-item:nth-child(3)>.item-img
            width: 62rpx;
            height: 41rpx;
            margin-top: 6rpx
            margin-bottom: 10rpx;
        .tab-item:nth-child(4)>.item-img
            width: 45rpx;
            height: 47rpx;
            margin-bottom: 8rpx;
    .mine-options
        margin: 43rpx 30rpx;
        min-height: 155rpx;
        background: #FFFFFF;
        border-radius: 17rpx 17rpx 17rpx 17rpx;
        display: flex;
        padding: 24rpx 45rpx;
        display: flex;
        flex-direction: column;
        min-height: min-content;
        .mine-options-item
            height: 80rpx;
            font-size: 28rpx;
            color: #000000;
            line-height: 80rpx;
            border-bottom: 2rpx solid #4778EC;
            padding: 0 30rpx;
        .mine-logout
            margin: 250rpx auto 0 auto;
            width: 399rpx;
            height: 96rpx;
            background: #FFAD47;
            border-radius: 17rpx 17rpx 17rpx 17rpx;
            text-align: center;
            line-height: 96rpx;
            color: #FFFFFF;
            font-size: 35rpx;
</style>
