<template>
  <view class="privacy-page">
    <view class="setting-section">
      <view class="setting-item" @click="toggleItem('showPhone')">
        <view class="setting-left">
          <text class="setting-text">公开手机号</text>
        </view>
        <switch :checked="settings.showPhone" @change="toggleItem('showPhone')" />
      </view>

      <view class="setting-item" @click="toggleItem('showEmail')">
        <view class="setting-left">
          <text class="setting-text">公开邮箱</text>
        </view>
        <switch :checked="settings.showEmail" @change="toggleItem('showEmail')" />
      </view>

      <view class="setting-item" @click="toggleItem('allowSearch')">
        <view class="setting-left">
          <text class="setting-text">允许通过手机号搜索</text>
        </view>
        <switch :checked="settings.allowSearch" @change="toggleItem('allowSearch')" />
      </view>
    </view>

    <view class="setting-section">
      <view class="setting-item" @click="toggleItem('showActivity')">
        <view class="setting-left">
          <text class="setting-text">公开活动状态</text>
        </view>
        <switch :checked="settings.showActivity" @change="toggleItem('showActivity')" />
      </view>

      <view class="setting-item" @click="toggleItem('showLocation')">
        <view class="setting-left">
          <text class="setting-text">公开位置信息</text>
        </view>
        <switch :checked="settings.showLocation" @change="toggleItem('showLocation')" />
      </view>
    </view>

    <view class="tip-section">
      <text class="tip-text">关闭后，其他用户将无法查看您的相关信息</text>
    </view>
  </view>
</template>

<script setup lang="ts">
import { ref } from 'vue'

const settings = ref({
  showPhone: false,
  showEmail: false,
  allowSearch: true,
  showActivity: true,
  showLocation: false
})

const toggleItem = (key: keyof typeof settings.value) => {
  settings.value[key] = !settings.value[key]
  uni.showToast({ title: '设置已保存', icon: 'success' })
}
</script>

<style lang="scss" scoped>
.privacy-page {
  min-height: 100vh;
  background: $uni-bg-color-grey;
  padding: 24rpx;
}

.setting-section {
  background: #fff;
  border-radius: $uni-border-radius-base;
  overflow: hidden;
  margin-bottom: 24rpx;
}

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 32rpx 24rpx;
  border-bottom: 1rpx solid $uni-border-color-light;

  &:last-child {
    border-bottom: none;
  }

  .setting-left {
    flex: 1;

    .setting-text {
      font-size: 28rpx;
      color: $uni-text-color;
    }
  }
}

.tip-section {
  padding: 24rpx;

  .tip-text {
    font-size: 24rpx;
    color: $uni-text-color-placeholder;
    line-height: 1.6;
  }
}
</style>
