<template>
    <view class="Cn-page" :class="{ 'no-padding': noPadding }">
        <template v-if="showLoginMsk && !login">
            <navigator url="/pages/user/login" hover-class="none" class="page-login-btn">登录</navigator>
        </template>
        <template v-else>
            <zero-loading v-if="loading" mask></zero-loading>
            <slot name="body" v-if="beforeRender|| !loading "></slot>
        </template>
    </view>
</template>

<script>
export default {
    name: 'Cn-page',
    props: {
        loading: {
            type: Boolean,
            default: false,
        },
        beforeRender: {
            type: Boolean,
            default: false,
        },
        showLoginMsk: Boolean,
        noPadding: Boolean,
    },
    data() {
        return {
            login: false,
        }
    },
    created() {
        this.login = uni.getStorageSync('Authorization')
    },
}
</script>

<style lang="scss">
.Cn-page {
    box-sizing: border-box;
    padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
}

.no-padding {
    padding-bottom: 0;
}

.page-login-btn {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    height: 80rpx;
    width: 200rpx;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #449dff;
    color: #fff;
    border-radius: 4rpx;
}
</style>
