<template>
  <view class="container">
   

    <!-- 问诊服务 -->
   

    <!-- 特色专科医师 -->
    <view class="doctors-section">
      <view class="section-header">
        <view class="section-title-wrapper">
         
          <view class="section-title">特色专科医师</view>
        </view>
        <view class="more-link" @click="navigateToAllDoctors">更多</view>
      </view>

      <view class="doctors-grid">
        <view 
          v-for="doctor in doctors" 
          :key="doctor.id"
          class="doctor-card"
          @click="selectDoctor(doctor)"
        >
          <view class="doctor-avatar-wrapper">
            <image :src="doctor.avatar" class="doctor-avatar" mode="aspectFill"></image>
            <view class="avatar-frame"></view>
          </view>
          <view class="doctor-name">{{ doctor.name }}</view>
          <view class="doctor-title">{{ doctor.title }}</view>
          <view class="doctor-dept">{{ doctor.department || '内科' }}</view>
        </view>
      </view>
    </view>


  </view>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { getCurrentInstance } from 'vue'

const { proxy } = getCurrentInstance()

const doctors = ref([])
const loading = ref(false)

const selectDoctor = (doctor) => {
  uni.navigateTo({
    url: `/pages/order/index?doctorId=${doctor.id}&doctorName=${doctor.name}`
  })
}

const navigateToExperts = () => {
  uni.navigateTo({
    url: '/pages/experts/index'
  })
}

const navigateToConsultation = () => {
  uni.navigateTo({
    url: '/pages/consultation/index'
  })
}

const navigateToQuickConsult = () => {
  uni.navigateTo({
    url: '/pages/quick-consult/index'
  })
}

const navigateToAllDoctors = () => {
  uni.navigateTo({
    url: '/pages/doctors/index'
  })
}

const navigateToHome = () => {
  // 已在首页
}

const navigateToMessages = () => {
  uni.navigateTo({
    url: '/pages/messages/index'
  })
}

const navigateToProfile = () => {
  uni.navigateTo({
    url: '/pages/profile/index'
  })
}

const fetchDoctors = async () => {
  loading.value = true
  try {
    const response = await proxy.apiUrl({
      url: '/api/doctor/lists',
      method: 'GET',
      data: {
        page_no: 1,
        page_size: 10
      }
    })
    
    if (response && response.code === 1) {
      const data = response.data
      const doctorList = data.lists || []
      doctors.value = doctorList
    } else {
      console.warn('获取医生列表失败:', response?.msg)
    }
  } catch (error) {
    console.error('请求异常:', error)
  } finally {
    loading.value = false
  }
}

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

<style scoped lang="scss">
.container {
  background: #f5f3f0;
  min-height: 100vh;
  padding-bottom: 120rpx;
}

// 古典卷轴横幅
.scroll-banner {
  margin: 24rpx 16rpx;
  display: flex;
  align-items: center;
  position: relative;
}

.scroll-rod {
  width: 32rpx;
  height: 160rpx;
  background: linear-gradient(180deg, #8B7355 0%, #6B5644 50%, #8B7355 100%);
  border-radius: 16rpx;
  position: relative;
  box-shadow: 0 4rpx 8rpx rgba(0, 0, 0, 0.2);
  
  &::before {
    content: '';
    position: absolute;
    top: 16rpx;
    left: 50%;
    transform: translateX(-50%);
    width: 40rpx;
    height: 40rpx;
    background: radial-gradient(circle, #D4AF37 0%, #B8941E 100%);
    border-radius: 50%;
    box-shadow: 0 2rpx 6rpx rgba(0, 0, 0, 0.3);
  }
  
  &::after {
    content: '';
    position: absolute;
    bottom: 16rpx;
    left: 50%;
    transform: translateX(-50%);
    width: 40rpx;
    height: 40rpx;
    background: radial-gradient(circle, #D4AF37 0%, #B8941E 100%);
    border-radius: 50%;
    box-shadow: 0 2rpx 6rpx rgba(0, 0, 0, 0.3);
  }
}

.scroll-rod-left {
  margin-right: -8rpx;
  z-index: 2;
}

.scroll-rod-right {
  margin-left: -8rpx;
  z-index: 2;
}

.scroll-content {
  flex: 1;
  background: linear-gradient(135deg, #F5E6D3 0%, #E8D7C3 100%);
  border: 3rpx solid #8B7355;
  border-radius: 12rpx;
  padding: 24rpx;
  box-shadow: inset 0 2rpx 8rpx rgba(139, 115, 85, 0.2);
  position: relative;
  
  &::before {
    content: '';
    position: absolute;
    top: 12rpx;
    left: 12rpx;
    right: 12rpx;
    bottom: 12rpx;
    border: 1rpx solid rgba(139, 115, 85, 0.3);
    border-radius: 8rpx;
    pointer-events: none;
  }
}

.scroll-inner {
  display: flex;
  align-items: center;
  gap: 20rpx;
  position: relative;
  z-index: 1;
}

.scroll-text {
  flex: 1;
}

.scroll-title {
  font-size: 32rpx;
  font-weight: bold;
  color: #3E2723;
  margin-bottom: 8rpx;
  font-family: 'STKaiti', 'KaiTi', serif;
}

.scroll-subtitle {
  font-size: 24rpx;
  color: #5D4037;
  font-family: 'STKaiti', 'KaiTi', serif;
}

.scroll-image {
  width: 200rpx;
  height: 120rpx;
  border-radius: 8rpx;
  border: 2rpx solid #8B7355;
}

// 问诊服务
.services-section {
  padding: 32rpx 16rpx;
}

.section-title {
  font-size: 32rpx;
  font-weight: bold;
  color: #3E2723;
  margin-bottom: 24rpx;
  font-family: 'STKaiti', 'KaiTi', serif;
  position: relative;
  padding-left: 16rpx;
  
  &::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 6rpx;
    height: 28rpx;
    background: linear-gradient(180deg, #D4AF37 0%, #B8941E 100%);
    border-radius: 3rpx;
  }
}

.services-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16rpx;
}

.service-card {
  border-radius: 20rpx;
  padding: 24rpx 16rpx;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  min-height: 320rpx;
  box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);
}

.card-bg {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  opacity: 0.15;
  z-index: 0;
}

.bg-decoration {
  width: 100%;
  height: 100%;
}

.card-content {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.service-expert {
  background: linear-gradient(135deg, #FFF8DC 0%, #F5E6D3 100%);
  border: 2rpx solid #E8D7C3;
}

.service-health {
  background: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 100%);
  border: 2rpx solid #A5D6A7;
}

.service-quick {
  background: linear-gradient(135deg, #E0F2F1 0%, #B2DFDB 100%);
  border: 2rpx solid #80CBC4;
}

.service-title {
  font-size: 28rpx;
  font-weight: bold;
  color: #3E2723;
  margin-bottom: 12rpx;
  font-family: 'STKaiti', 'KaiTi', serif;
}

.service-desc {
  font-size: 22rpx;
  color: #5D4037;
  line-height: 1.5;
  margin-bottom: 16rpx;
  flex: 1;
}

.service-icon {
  font-size: 56rpx;
  text-align: center;
  margin: 16rpx 0;
  opacity: 0.8;
}

.service-btn {
  color: #fff;
  padding: 16rpx 24rpx;
  border-radius: 32rpx;
  font-size: 24rpx;
  font-weight: bold;
  text-align: center;
  box-shadow: 0 4rpx 8rpx rgba(0, 0, 0, 0.15);
  position: relative;
  z-index: 1;
}

.btn-orange {
  background: linear-gradient(135deg, #D2691E 0%, #CD853F 100%);
}

.btn-green {
  background: linear-gradient(135deg, #2E7D32 0%, #388E3C 100%);
}

.btn-purple {
  background: linear-gradient(135deg, #4A148C 0%, #6A1B9A 100%);
}

// 特色专科医师
.doctors-section {
  padding: 32rpx 16rpx;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24rpx;
}

.section-title-wrapper {
  display: flex;
  align-items: center;
  gap: 8rpx;
}

.title-icon {
  font-size: 28rpx;
}

.more-link {
  font-size: 24rpx;
  color: #D4AF37;
  font-weight: 500;
}

.doctors-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16rpx;
}

.doctor-card {
  background: #fff;
  border-radius: 16rpx;
  padding: 20rpx;
  text-align: center;
  box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);
}

.doctor-avatar-wrapper {
  position: relative;
  margin-bottom: 16rpx;
  display: flex;
  justify-content: center;
}

.doctor-avatar {
  width: 120rpx;
  height: 120rpx;
  border-radius: 50%;
  border: 3rpx solid #E8E8E8;
}

.avatar-frame {
  position: absolute;
  top: -4rpx;
  left: 50%;
  transform: translateX(-50%);
  width: 128rpx;
  height: 128rpx;
  border: 2rpx solid rgba(212, 175, 55, 0.3);
  border-radius: 50%;
  pointer-events: none;
}

.doctor-name {
  font-size: 26rpx;
  font-weight: bold;
  color: #3E2723;
  margin-bottom: 6rpx;
}

.doctor-title {
  font-size: 22rpx;
  color: #757575;
  margin-bottom: 4rpx;
}

.doctor-dept {
  font-size: 20rpx;
  color: #9E9E9E;
}

// 底部导航
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1rpx solid #E8E8E8;
  display: flex;
  justify-content: space-around;
  padding: 16rpx 0 24rpx 0;
  box-shadow: 0 -2rpx 8rpx rgba(0, 0, 0, 0.05);
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6rpx;
  flex: 1;
  
  &.active {
    .nav-icon {
      font-size: 40rpx;
    }
    
    .nav-text {
      color: #D4AF37;
      font-weight: bold;
    }
  }
}

.nav-icon {
  font-size: 36rpx;
  transition: all 0.3s ease;
}

.nav-text {
  font-size: 22rpx;
  color: #757575;
  transition: all 0.3s ease;
}
</style>
