<!--
 * @Author: PoJun
 * @Date: 2023-09-28 10:38:11
 * @LastEditors: PoJun
 * @LastEditTime: 2024-01-04 16:44:27
 * @Message: 账号注销
-->
<template>
    <view class="cancel-account">
        <view class="cancel-account-head">
            <uv-icon name="error-circle-fill" size="50" color="#f9ae3d"></uv-icon>
            <view class="cancel-account-head-text">注销账号将永久失效且不可恢复，并将放弃以下权益与服务</view>
        </view>
        <view class="cancel-account-cont">
            <view class="cancel-account-cont-item">1、账号将无法登录；</view>
            <view class="cancel-account-cont-item">2、已认证身份将永久失效；</view>
            <view class="cancel-account-cont-item">3、供应商产生记录与数据将被清空；</view>
            <view class="cancel-account-cont-item">4、个人资料等内容永久失效；</view>
        </view>
        <view class="cancel-account-tips">
            <view class="cancel-account-tips-title">温馨提示:</view>
            <view class="cancel-account-tips-text">
                注销账号后，您的所有数据和账号信息将全部丢失，账号一旦注销不可恢复，为避免您的个人损失，请谨慎操作！
            </view>
        </view>
        <view class="cancel-account-check">
            <view class="cancel-account-check-box">
                <view>
                    <uv-checkbox-group v-model="checkboxValue">
                        <uv-checkbox name="check" activeColor="#FF1010"></uv-checkbox>
                    </uv-checkbox-group>
                </view>
                <view class="cancel-account-check-text">
                    我确认已阅读并了解以上信息，且自愿放弃账号内全部数据、权益资产与服务
                </view>
            </view>

            <view class="cancel-account-check-btn">
                <uv-button
                    :disabled="checkboxValue.length == 0"
                    type="error"
                    text="确认注销"
                    @click="btnClick"
                    color="linear-gradient(to right, #FF1010, #f9ae3d)"
                ></uv-button>
            </view>
        </view>
    </view>
</template>

<script>
import { cancelUser } from "@/config/http.js";
import { logoutApp } from "@/utils/utils.js";
export default {
    data() {
        return {
            checkboxValue: [],
        };
    },
    onLoad() {},
    methods: {
        btnClick() {
            uni.showModal({
                title: "提示",
                content: "注销账号后会清空您的所有数据和账号信息,您是否确认注销?",
                cancelText: "我再想想",
                success: res => {
                    if (res.confirm) {
                        this.doCancel();
                    }
                },
            });
        },
        async doCancel() {
            uni.showLoading({ mask: true });
            await cancelUser();
            try {
                await uni.$uv.sleep(500);
                logoutApp(this);
            } finally {
                uni.hideLoading();
            }
        },
    },
};
</script>

<style lang="scss">
.cancel-account {
    padding: 44rpx;
    height: calc(100vh - var(--status-bar-height) - 44px);
    /* #ifdef APP-PLUS */
    height: 100vh;
    /* #endif */
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    &-head {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        &-text {
            text-align: center;
            font-size: 18px;
            font-weight: bold;
            margin-top: 26rpx;
        }
    }
    &-cont {
        box-shadow: 0px 0 15px 1px #eee;
        padding: 40rpx;
        border-radius: 10px;
        &-item {
            color: $uv-content-color;
            font-size: 14px;
            padding: 10rpx 0;
        }
    }
    &-tips {
        &-title {
            color: $uv-content-color;
            font-size: 14px;
        }
        &-text {
            padding: 25rpx;
            border-radius: 10px;
            background-color: $uv-bg-color;
            margin-top: 16rpx;
            font-size: 14px;
            color: $uv-tips-color;
        }
    }
    &-check {
        &-box {
            display: flex;
            flex-direction: row;
            align-items: center;
        }
        &-text {
            flex: 1;
            font-size: 14px;
            margin-left: 14rpx;
            color: $uv-tips-color;
        }
        &-btn {
            margin-top: 20px;
        }
    }
}
</style>
