<template>
    <view class="container">
        <!-- 自定义头部 -->
        <view class="custom-header">
            <view class="header-left" @click="navBack">
                <image class="back-icon" src="/static/icons/chevron_right_dark.svg" style="transform: rotate(180deg);"></image>
            </view>
            <text class="header-title">设置</text>
            <view class="header-right"></view>
        </view>
        <view class="header-placeholder"></view>

        <!-- 个人信息组 -->
        <view class="group-card">
            <view class="list-item" @click="navTo('profile')">
                <text class="item-title">个人资料</text>
                <image class="arrow-icon" src="/static/icons/chevron_right.svg"></image>
            </view>
            <view class="list-item" @click="navTo('auth')">
                <text class="item-title">认证信息</text>
                <image class="arrow-icon" src="/static/icons/chevron_right.svg"></image>
            </view>
            <view class="list-item" @click="navTo('bank')">
                <text class="item-title">银行卡信息</text>
                <view class="item-right">
                    <view class="tag-status">已完善</view>
                    <image class="arrow-icon" src="/static/icons/chevron_right.svg"></image>
                </view>
            </view>
            <view class="list-item no-border" @click="navTo('security')">
                <text class="item-title">账号与安全</text>
                <image class="arrow-icon" src="/static/icons/chevron_right.svg"></image>
            </view>
        </view>

        <!-- 应用设置组 -->
        <view class="group-card">
            <view class="list-item" @click="navTo('push')">
                <text class="item-title">推送通知</text>
                <view class="item-right">
                    <text class="item-value">部分开启</text>
                    <image class="arrow-icon" src="/static/icons/chevron_right.svg"></image>
                </view>
            </view>
            <view class="list-item">
                <view class="item-row-left">
                    <text class="item-title">位置上报</text>
                    <text class="item-subtitle">每隔20分钟自动上报位置</text>
                </view>
                <switch checked color="#FF5722" style="transform:scale(0.8)"/>
            </view>
            <view class="list-item" @click="clearCache">
                <text class="item-title">清理缓存</text>
                <view class="item-right">
                    <text class="item-value">105.14MB</text>
                    <image class="arrow-icon" src="/static/icons/chevron_right.svg"></image>
                </view>
            </view>
            <view class="list-item no-border" @click="navTo('about')">
                <text class="item-title">关于我们</text>
                 <view class="item-right">
                    <text class="item-value">v2.0.6</text>
                    <image class="arrow-icon" src="/static/icons/chevron_right.svg"></image>
                </view>
            </view>
        </view>

    </view>
</template>

<script>
export default {
    data() {
        return {}
    },
    methods: {
        navBack() {
             uni.navigateBack({
                delta: 1
            });
        },
        navTo(type) {
            let url = '';
            switch(type) {
                case 'profile':
                    url = '/pages/mine/settings/profile/index';
                    break;
                case 'auth':
                    url = '/pages/mine/settings/auth/index';
                    break;
                case 'bank':
                    url = '/pages/mine/settings/bank/index';
                    break;
                case 'security':
                    url = '/pages/mine/settings/security/index';
                    break;
                case 'push':
                    url = '/pages/mine/settings/notification/index';
                    break;
                case 'about':
                    url = '/pages/mine/settings/about/index';
                    break;
                default:
                    console.log('Navigate to:', type);
                    return;
            }
            uni.navigateTo({ url });
        },
        clearCache() {
            uni.showToast({ title: '缓存已清理', icon: 'none' });
        }
    }
}
</script>

<style>
page {
    background-color: #F8F8F8;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
.custom-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 88rpx;
    padding-top: var(--status-bar-height);
    background-color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-left: 30rpx;
    padding-right: 30rpx;
    box-sizing: content-box; /* Exclude padding from height calculation if needed, or adjust */
    z-index: 100;
}
.header-placeholder {
    height: calc(88rpx + var(--status-bar-height));
}
.back-icon {
    width: 40rpx;
    height: 40rpx;
}
.header-title {
    font-size: 28rpx; /* 14pt */
    font-weight: bold;
    color: #333;
}
.header-right {
    width: 40rpx;
}

.container {
    padding: 20rpx 30rpx;
}
.group-card {
    background-color: #fff;
    border-radius: 20rpx;
    padding: 0 30rpx;
    margin-bottom: 30rpx;
}
.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100rpx;
    border-bottom: 1px solid #F5F5F5;
}
.list-item.no-border {
    border-bottom: none;
}
.item-title {
    font-size: 28rpx; /* 14pt */
    color: #333;
}
.item-right {
    display: flex;
    align-items: center;
}
.arrow-icon {
    width: 28rpx;
    height: 28rpx;
    opacity: 0.5;
    margin-left: 10rpx;
}
.tag-status {
    font-size: 22rpx;
    color: #4CAF50;
    background-color: #F1F8E9;
    padding: 4rpx 10rpx;
    border-radius: 6rpx;
    margin-right: 6rpx;
}
.item-value {
    font-size: 28rpx; /* Changed to 14pt (28rpx) */
    color: #999;
}
.item-column {
    display: flex;
    flex-direction: column;
}
.item-row-left {
    display: flex;
    align-items: center;
}
.item-subtitle {
    font-size: 24rpx; /* Changed to 12pt (24rpx) for better legibility */
    color: #999;
    margin-left: 20rpx; /* Moved to right of title */
    margin-top: 0;
}
</style>
