<template>
  <div>
    <NavMenu v-if="isContactPage"></NavMenu>

    <div class="contact-view">
      <div class="contact-view-bg">
        <div class="contact-form-container">
          <div class="contact-title">
            <span class="chinese-title">联系我们</span>
            <span class="english-title">Send us a message</span>
          </div>
          <form action="https://formspree.io/f/mrbzdeeg" class="contact-form">
            <div class="contact-form-group">
              <label for="name">昵称 <span> Enter your name </span></label>
              <input type="text" id="name" />
            </div>
            <div class="contact-form-group">
              <label for="email">邮箱 <span> Enter your email </span></label>
              <input type="email" id="email" />
            </div>
            <div class="contact-form-group">
              <label for="message">留言 <span>Your message </span></label>
              <textarea id="message"></textarea>
            </div>
            <button type="submit" class="submit-button">发送</button>
          </form>
          <p class="response-text">
            我们将尽快给您回复 We will respond as soon as possible
          </p>
        </div>
        <div class="footer-social">
        <a :href="contactLinks.telegram" target="_blank">
          <img src="../assets/icon/Send.webp" alt="telegram" />
        </a>
        <a :href="contactLinks.phone" target="_blank">
          <img src="../assets/icon/Phone.webp" alt="phone" />
        </a>
        <a :href="contactLinks.wechat" target="_blank">
          <img src="../assets/icon/Wexin.webp" alt="wechat" />
        </a>
        <a :href="contactLinks.facebook" target="_blank">
          <img src="../assets/icon/Facebook.webp" alt="facebook" />
        </a>
        <a :href="contactLinks.email" target="_blank">
          <img src="../assets/icon/Email.webp" alt="email" />
        </a>
      </div>
      </div>

    </div>

    <FooterMenu v-if="isContactPage"></FooterMenu>
  </div>
</template>

<script>
import NavMenu from "../components/NavMenu.vue";
import FooterMenu from "../components/FooterMenu.vue";
import { contactLinks } from "../static/js/contact_link.js";
import {updateTDK} from "../assets/js/dynamic-tdk.js";

export default {
  components: {
    NavMenu,
    FooterMenu,
  },
  mounted() {
    fetch("/TDK/tdk.json")
      .then((res) => res.json())
      .then((tdkData) => {
        const pageName = this.$route.name || "contactUs";
        const tdk = tdkData[pageName] || tdkData["index"];
        updateTDK(tdk);
      })
      .catch((err) => console.error("Error loading TDK:", err));
  },
  computed: {
    // Use computed property to check if the current route is '/contactUs'
    isContactPage() {
      return this.$route.path === "/contactUs";
    },
    contactLinks() {
      return contactLinks;
    },
  },
};
</script>

<style scoped>
.contact-view-bg {
  width: 100%;
  min-height: 100vh;
  background: url("../assets/back/ri.webp") no-repeat;
  background-size: 100% 100%;
  display: flex;
  justify-content: left;
  padding: 0 clamp(2rem, 10vw, 16rem);
  align-items: center;
}
.footer-social img {
  width: 60px;
  height: 60px;
  margin-left: 20px;
}
.footer-social {
  display: flex;
  justify-content: flex-start;
  align-self: end;
  margin-bottom: 15%;
  min-height: 58%;
}
.contact-form-container {
  background-color: rgba(255, 255, 255, 0.8); /* 半透明白色背景 */
  padding: 40px;
  min-width: 30%;
  max-width: 40%;
  width: clamp(30%, 40vw, 40%);
  border-radius: 10px;
  min-height: 58%;
}

.contact-title {
  text-align: left;
  margin-bottom: 20px;
}

.chinese-title {
  font-size: 1.8rem;
  color: #ff6702;
  display: block;
}

.english-title {
  font-size: 1.2rem;
  color: #ff6702;
}

.contact-form {
  display: flex;
  flex-direction: column;
}

.contact-form-group {
  margin-bottom: 20px;
}

.contact-form-group label {
  font-size: 1.2rem;
  color: #ff6702;
  display: block;
  margin-bottom: 5px;
}

.contact-form-group label span {
  font-size: 1rem;
  color: #333;
  margin-bottom: 5px;
}

.contact-form-group input,
.contact-form-group textarea {
  width: 100%;
  padding: 10px;
  font-size: 1rem;
  border: 1px solid #ff6702;
  border-radius: 5px;
}

.contact-form-group textarea {
  height: 120px;
}

.contact-form-group input:focus,
.contact-form-group textarea:focus {
  border-color: #ff6702; /* 设置选中时的边框颜色 */
  outline: none; /* 去除默认的聚焦框 */
}

.submit-button {
  background-color: #ff6702;
  color: white;
  padding: 10px;
  font-size: 1rem;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s;
}

.submit-button:hover {
  background-color: #e45a00;
}

.response-text {
  text-align: center;
  font-size: 1rem;
  color: #333;
  margin-top: 20px;
}

@media (max-width: 850px) {
  .contact-view-bg {
    background: url("../assets/back/ri2.webp") no-repeat;
    background-size: 100% 100%;
    padding: 0;
  }

  .contact-form-container {
    width: 90%;
    margin: 0 auto;
    height: 68%;
    min-width: 90%;
    max-width: 90%;
  }
  .footer-social{
    display: none;
  }
}
</style>
