<template>
  <div class="membership-page">
    <div class="page-header">
      <h1 class="page-title">会员服务</h1>
      <p class="page-desc">为企业会员和个人会员提供专业、高效的咨询服务</p>
    </div>

    <!-- 分类标签 -->
    <div class="category-tabs">
      <a-radio-group v-model:value="activeType" button-style="solid" @change="handleTypeChange">
        <a-radio-button value="">全部</a-radio-button>
        <a-radio-button value="consult">企业咨询</a-radio-button>
        <a-radio-button value="service">专项服务</a-radio-button>
      </a-radio-group>
    </div>

    <!-- 服务列表 -->
    <div class="service-grid">
      <div v-for="service in services" :key="service.id" class="service-card" @click="handleView(service)">
        <div class="service-icon">{{ service.icon }}</div>
        <h3 class="service-title">{{ service.title }}</h3>
        <p class="service-desc">{{ service.description }}</p>
        <div class="service-tags">
          <a-tag v-for="tag in service.tags" :key="tag" color="blue">{{ tag }}</a-tag>
        </div>
      </div>

      <div v-if="loading" class="loading-placeholder">
        <a-spin size="large" />
      </div>

      <div v-if="!loading && services.length === 0" class="empty-placeholder">
        <a-empty description="暂无服务" />
      </div>
    </div>

    <!-- 联系我们 -->
    <div class="contact-section">
      <h2>联系我们</h2>
      <p>如有疑问或需要帮助，请随时与我们联系</p>
      <a-space size="large">
        <span>📞 联系电话：0771-1234567</span>
        <span>📧 邮箱：service@jczxw.org</span>
      </a-space>
    </div>
  </div>
</template>

<script setup lang="ts">
import { message } from 'ant-design-vue'

useHead({ title: '会员服务 - 决策咨询网' })

const router = useRouter()

const activeType = ref((useRoute().query.type as string) || '')
const loading = ref(false)
const services = ref<any[]>([])

async function loadServices() {
  loading.value = true
  try {
    // TODO: 接入实际API
  } catch (e: any) {
    message.error('加载失败')
  } finally {
    loading.value = false
  }
}

function handleTypeChange() {
  loadServices()
}

function handleView(service: any) {
  router.push(`/membership/${service.id}`)
}

onMounted(() => {
  loadServices()
})
</script>

<style scoped>
.membership-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 20px;
}

.page-header {
  text-align: center;
  margin-bottom: 40px;
}

.page-title {
  font-size: 32px;
  font-weight: 700;
  color: #1f2937;
  margin: 0 0 12px;
}

.page-desc {
  font-size: 16px;
  color: #6b7280;
  margin: 0;
}

.category-tabs {
  margin-bottom: 32px;
  text-align: center;
}

.service-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.service-card {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  cursor: pointer;
  transition: all 0.2s;
}

.service-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  transform: translateY(-4px);
}

.service-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.service-title {
  font-size: 18px;
  font-weight: 600;
  color: #1f2937;
  margin: 0 0 8px;
}

.service-desc {
  font-size: 14px;
  color: #6b7280;
  margin: 0 0 16px;
  line-height: 1.6;
}

.service-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.contact-section {
  margin-top: 60px;
  padding: 40px;
  background: #f9fafb;
  border-radius: 16px;
  text-align: center;
}

.contact-section h2 {
  font-size: 20px;
  font-weight: 600;
  color: #1f2937;
  margin: 0 0 8px;
}

.contact-section p {
  font-size: 14px;
  color: #6b7280;
  margin: 0 0 16px;
}

.loading-placeholder,
.empty-placeholder {
  grid-column: 1 / -1;
  padding: 60px 0;
  text-align: center;
}

@media (max-width: 1024px) {
  .service-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .service-grid {
    grid-template-columns: 1fr;
  }
}
</style>
