<template>
  <DefaultLayout>
    <!-- banner -->
    <section class="banner-section">
      <img src="@assets/contact-banner.png" alt="联系我们" />
    </section>

    <!-- 带背景的内容区域 -->
    <div class="content-with-bg">
      <!-- 联系信息模块 -->
      <section class="contact-info-section">
        <div class="container">
          <div class="contact-info-card">
            <!-- 上半部分：联系信息 -->
            <div class="contact-details">
              <!-- 左侧信息 -->
              <div class="contact-left">
                <div class="contact-item">
                  <img src="@assets/contact-addr.png" alt="地址" class="contact-icon" />
                  <div class="contact-text">
                    <h4>公司地址：</h4>
                    <p>贵州省贵阳市观山湖区贵阳国际金融中心金融MAX-A座</p>
                  </div>
                </div>

                <div class="contact-item">
                  <img src="@assets/contact-phone.png" alt="电话" class="contact-icon" />
                  <div class="contact-text">
                    <h4>联系电话：</h4>
                    <p>座机号：18866568888</p>
                    <p>客服号：18888888666</p>
                  </div>
                </div>

                <div class="contact-item">
                  <img src="@assets/contact-mail.png" alt="邮箱" class="contact-icon" />
                  <div class="contact-text">
                    <h4>公司邮箱：</h4>
                    <p>000000000000</p>
                  </div>
                </div>
              </div>

              <!-- 右侧信息 -->
              <div class="contact-right">
                <div class="qr-codes">
                  <div class="qr-item">
                    <img src="@assets/contact-wx01.png" alt="微信公众号" />
                    <p>微信商务号 <br /> <b>达泽科技-张某</b></p>
                  </div>
                  <div class="qr-item">
                    <img src="@assets/contact-wx02.png" alt="企业微信" />
                    <p>微信商务号 <br /><b>达泽科技-吴某</b></p>
                  </div>
                </div>

                <div class="website-info">
                  <img src="@assets/contact-mail.png" alt="网站" class="contact-icon" />
                  <div class="contact-text">
                    <h4>网站</h4>
                    <p>www.jgdazekg.com</p>
                  </div>
                  <div class="contact-text">
                    <h4>商务合作</h4>
                    <p>www.jgdazekg.com</p>
                  </div>
                </div>
              </div>
            </div>

            <!-- 下半部分：地图 -->
            <div class="map-section">
              <!-- <img src="@assets/contact-map.png" alt="公司位置地图" class="map-image" /> -->
              <iframe style="width: 100%;;height: 350px;border-radius: 10px;" src="https://j.map.baidu.com/ef/0c9k" frameborder="0"></iframe>
            </div>
          </div>
        </div>
      </section>

      <!-- 留言模块 -->
      <section class="message-section">
        <div class="container">
          <div class="message-card">
            <h2 class="section-title">在线留言</h2>

            <form @submit.prevent="submitMessage" class="message-form">
              <div class="form-row">
                <div class="form-group">
                  <label>联系人</label>
                  <input type="text" v-model="messageForm.name" placeholder="请输入联系人" required />
                </div>
                <div class="form-group">
                  <label>联系电话</label>
                  <input type="tel" v-model="messageForm.phone" placeholder="请输入联系电话" required />
                </div>
              </div>

              <div class="form-row">
                <div class="form-group">
                  <label>联系邮箱</label>
                  <input type="email" v-model="messageForm.email" placeholder="请输入联系邮箱" />
                </div>
                <div class="form-group">
                  <label>联系地址</label>
                  <input type="text" v-model="messageForm.address" placeholder="请输入联系地址" />
                </div>
              </div>

              <div class="form-group full-width">
                <label>留言内容</label>
                <textarea v-model="messageForm.content" placeholder="请输入留言内容" rows="6" required></textarea>
              </div>

              <div class="form-actions">
                <button type="submit" class="submit-btn" :disabled="isSubmitting">
                  {{ isSubmitting ? '提交中...' : '提交留言' }}
                </button>
              </div>
            </form>
          </div>
        </div>
      </section>

      <!-- 底部间距，确保背景延伸到footer下方 -->
      <div class="bottom-spacer"></div>
    </div>
  </DefaultLayout>
</template>

<script>
import { ref, reactive } from 'vue'
import DefaultLayout from '@/layouts/DefaultLayout.vue'

export default {
  name: 'ContactPage',
  components: {
    DefaultLayout
  },
  setup() {
    // 留言表单数据
    const messageForm = reactive({
      name: '',
      phone: '',
      email: '',
      address: '',
      content: ''
    })

    const isSubmitting = ref(false)

    // 提交留言
    const submitMessage = async () => {
      isSubmitting.value = true

      try {
        // 这里可以调用API提交留言
        console.log('提交留言:', messageForm)

        // 模拟API调用
        await new Promise(resolve => setTimeout(resolve, 1000))

        alert('留言提交成功！我们会尽快与您联系。')

        // 重置表单
        Object.keys(messageForm).forEach(key => {
          messageForm[key] = ''
        })
      } catch (error) {
        console.error('提交留言失败:', error)
        alert('提交失败，请稍后重试。')
      } finally {
        isSubmitting.value = false
      }
    }

    return {
      messageForm,
      isSubmitting,
      submitMessage
    }
  }
}
</script>

<style lang="scss" scoped>
// banner区域
.banner-section {
  position: relative;

  img {
    width: 100%;
    display: block;
  }
}

// 带背景的内容区域
.content-with-bg {
  background: url('@assets/contact-bg.png') no-repeat center 185px;
  background-size: cover;
  position: relative;
  // 确保背景延伸到footer下方
  margin-bottom: -137px; // 负边距让背景延伸到footer下方
  padding-bottom: 137px; // 对应的内边距保持内容位置
}

// 联系信息模块
.contact-info-section {
  position: relative;
  margin-top: -185px; // 向上覆盖banner
  z-index: 10;
  padding: 0 20px 60px;

  .container {
    max-width: 1200px;
    margin: 0 auto;
  }
}

// 底部间距
.bottom-spacer {
  height: 100px; // 额外的间距确保背景覆盖footer下方
}

.contact-info-card {
  background: linear-gradient(0deg, #fff 0%, #fff 50%, rgba(255,255,255,.0) 100%);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  padding: 40px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.contact-details {
  display: flex;
  gap: 60px;
  margin-bottom: 40px;

  @media (max-width: 768px) {
    flex-direction: column;
    gap: 30px;
  }
}

.contact-left {
  flex: 1;

  .contact-item {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    margin-bottom: 30px;

    &:last-child {
      margin-bottom: 0;
    }
  }

  .contact-icon {
    width: 24px;
    height: 24px;
    margin-top: 2px;
    flex-shrink: 0;
  }

  .contact-text {
    h4 {
      color: #333;
      font-size: 16px;
      font-weight: 600;
      margin: 0 0 8px 0;
    }

    p {
      color: #666;
      font-size: 14px;
      line-height: 1.5;
      margin: 0 0 4px 0;

      &:last-child {
        margin-bottom: 0;
      }
    }
  }
}

.contact-right {
  flex: 1;

  .qr-codes {
    display: flex;
    gap: 60px;
    margin-bottom: 30px;
    justify-content: flex-start;

    .qr-item {
      text-align: left;

      img {
        width: 174px;
        height: 174px;
        border-radius: 8px;
        margin-bottom: 8px;
      }

      p {
        color: #666;
        font-size: 16px;
        margin: 0;
        b{
          margin-top: 12px;
          display: block;
        }
      }
    }
  }

  .website-info {
    display: flex;
    align-items: flex-start;
    gap: 15px;

    .contact-icon {
      width: 24px;
      height: 24px;
      margin-top: 2px;
      flex-shrink: 0;
    }

    .contact-text {
      flex: 1;

      h4 {
        color: #333;
        font-size: 16px;
        font-weight: 600;
        margin: 0 0 8px 0;
      }

      p {
        color: #666;
        font-size: 14px;
        line-height: 1.5;
        margin: 0 0 4px 0;

        &:last-child {
          margin-bottom: 0;
        }
      }

      &+.contact-text {
        margin-left: 30px;
      }
    }
  }
}

.map-section {
  border-top: 1px solid #eee;
  padding-top: 30px;

  .map-image {
    width: 100%;
    height: 300px;
    object-fit: cover;
    border-radius: 8px;
  }
}

// 留言模块
.message-section {
  padding: 0 20px 60px;

  .container {
    max-width: 1200px;
    margin: 0 auto;
  }
}

.message-card {
  background: white;
  border-radius: 12px;
  padding: 40px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}

.section-title {
  text-align: center;
  font-size: 28px;
  font-weight: 600;
  color: #333;
  margin: 0 0 40px 0;
  position: relative;

  &::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, #4A90E2, #7B68EE);
    border-radius: 2px;
  }
}

.message-form {
  .form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;

    @media (max-width: 768px) {
      flex-direction: column;
      gap: 0;
    }
  }

  .form-group {
    flex: 1;
    margin-bottom: 20px;

    &.full-width {
      width: 100%;
    }

    label {
      display: block;
      color: #333;
      font-size: 14px;
      font-weight: 500;
      margin-bottom: 8px;
    }

    input,
    textarea {
      width: 100%;
      padding: 12px 16px;
      border: 1px solid #ddd;
      border-radius: 6px;
      font-size: 14px;
      transition: all 0.3s ease;
      box-sizing: border-box;

      &:focus {
        outline: none;
        border-color: #4A90E2;
        box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
      }

      &::placeholder {
        color: #999;
      }
    }

    textarea {
      resize: vertical;
      min-height: 120px;
      font-family: inherit;
    }
  }

  .form-actions {
    text-align: center;
    margin-top: 30px;
  }

  .submit-btn {
    background: linear-gradient(90deg, #4A90E2, #7B68EE);
    color: white;
    border: none;
    padding: 14px 40px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 140px;

    &:hover:not(:disabled) {
      transform: translateY(-2px);
      box-shadow: 0 8px 20px rgba(74, 144, 226, 0.3);
    }

    &:disabled {
      opacity: 0.6;
      cursor: not-allowed;
    }
  }
}

// 响应式设计
@media (max-width: 768px) {
  .content-with-bg {
    // 移动端可能需要调整背景图位置
    background-position: center top;
    margin-bottom: -30px;
    padding-bottom: 30px;
  }

  .contact-info-section {
    margin-top: -80px;
    padding: 0 15px 40px;
  }

  .contact-info-card {
    padding: 30px 20px;
  }

  .contact-right .qr-codes {
    gap: 20px;

    .qr-item img {
      width: 60px;
      height: 60px;
    }
  }

  .message-section {
    padding: 40px 15px;
  }

  .message-card {
    padding: 30px 20px;
  }

  .section-title {
    font-size: 24px;
  }

  .bottom-spacer {
    height: 50px; // 移动端减少间距
  }
}
</style>