<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 direction="vertical" size="large">
        <a-space size="large">
          <span>📞</span>
          <span>联系电话：0771-5386339</span>
        </a-space>
        <a-space size="large">
          <span>📧</span>
          <span>咨询邮箱：gxjzxzx@126.com</span>
        </a-space>
        <a-space size="large">
          <span>⏰</span>
          <span>服务时间：周一至周五 9:00-17:00</span>
        </a-space>
      </a-space>
      <div style="margin-top: 20px;">
        <a-button size="large" type="primary" @click="navigateTo('/about/consultation')">
          了解咨询服务详情 →
        </a-button>
      </div>
    </div>
  </div>
</template>

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

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

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

const mockServices = [
  {
    id: 1,
    type: 'consult',
    icon: '🏢',
    title: '企业决策咨询',
    description: '为企业提供战略规划、政策解读、市场分析等专业决策咨询服务，助力企业把握发展机遇。',
    tags: ['企业咨询', '战略规划'],
  },
  {
    id: 2,
    type: 'service',
    icon: '📊',
    title: '专题研究报告',
    description: '提供行业专题研究、政策分析报告、区域发展研究等专业研究成果。',
    tags: ['研究报告', '深度分析'],
  },
  {
    id: 3,
    type: 'consult',
    icon: '🎯',
    title: '政策合规指导',
    description: '协助企业理解最新政策法规，确保企业运营符合政策要求，规避合规风险。',
    tags: ['政策合规', '风险规避'],
  },
  {
    id: 4,
    type: 'service',
    icon: '📋',
    title: '专家论证会',
    description: '组织相关领域专家为企业重大决策提供专业论证和咨询建议。',
    tags: ['专家论证', '专业咨询'],
  },
  {
    id: 5,
    type: 'service',
    icon: '🌐',
    title: '数据服务',
    description: '提供决策所需的经济数据、行业数据、区域数据等专业数据服务（仅限会员）。',
    tags: ['数据服务', '会员专享'],
  },
  {
    id: 6,
    type: 'consult',
    icon: '💼',
    title: '培训与讲座',
    description: '为企业及个人提供政策解读、决策方法等专题培训和讲座服务。',
    tags: ['培训讲座', '能力提升'],
  },
]

async function loadServices() {
  loading.value = true
  try {
    // TODO: 接入实际API获取会员服务列表
    // 暂时使用模拟数据
    await new Promise(resolve => setTimeout(resolve, 300))
    const type = activeType.value
    services.value = type ? mockServices.filter(s => s.type === type) : mockServices
  } catch (e: any) {
    message.error('加载失败')
  } finally {
    loading.value = false
  }
}

function handleTypeChange() {
  loadServices()
}

function handleView(service: any) {
  message.info(`服务「${service.title}」详情页开发中，请联系工作人员获取更多信息`)
}

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>
