<template>
    <Cn-page :loading="loading">
        <view slot="body">
            <view class="index">
                <view>成功注销后所有的账号信息将会被删除且无法找回，原账号将无法登陆，请谨慎操作。</view>
                <view class="btn-wrap">
                    <view class="btn-wrap-item" @click="submit"> 注销</view>
                </view>
            </view>
        </view>
    </Cn-page>
</template>
<script>
import { apiDeleteUser } from '@/common/api/user.js'
export default {
    data() {
        return {
            loading: false,
        }
    },
    methods: {
        submit() {
            uni.showModal({
                title: '注销提示',
                content: '确认注销账号吗？',
                success: (res) => {
                    if (res.confirm) {
                        apiDeleteUser().then((res) => {
                            uni.showToast({
                                title: '注销成功',
                                icon: 'none',
                            })
                            setTimeout(() => {
                                uni.reLaunch({
                                    url: `/pages/user/login`,
                                })
                            }, 1000)
                        })
                    }
                },
            })
        },
    },
}
</script>
<style lang="scss">
.index {
    padding: 34rpx;
    font-size: 28rpx;
    .btn-wrap {
        margin-top: 40rpx;
        display: flex;
        align-items: center;
        justify-content: space-between;

        .btn-wrap-item {
            display: flex;
            align-items: center;
            justify-content: center;
            flex: 1;
            background: $uni-theme-color;
            color: #fff;
            height: 80rpx;
            border-radius: 12rpx;
        }
    }
}
</style>
