<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>
            <view class="loading" v-if="loading">
                <zero-loading v-if="loading"></zero-loading>
            </view>
            <template v-else>
                <slot name="body"></slot>
            </template>
        </template>
    </view>
</template>

<script >
export default {
    name: 'Cn-page',
    props: {
        loading: {
            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(30rpx + 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>
