<script setup lang="ts">
let pageTitle: any = ref("Contact Us - Shenzhen Hotking Electronics Co., Ltd.");
useHead(() => ({
  title: pageTitle.value,
}));
import banner from "@/assets/img/about-us/banner.png";
import { useAll } from "~/api/pubAll/service";
const { getContent, addGuestbook } = useAll();
let pageData: any = ref([]);
const { data: ssrGetContent } = await useAsyncData<any>("getContentsdfsf", () =>
  getContent({
    language: 2,
    code: 8,
  })
);
let params: any = ref({
  phone: "",
  username: "",
  messageContents: "",
  companyName: "",
  companyType: "",
  country: "",
  jobTitle: "",
  languageType: 0,
  mailbox: "",
  queryType: "",
  state: 0,
  trade: "",
});
setData(ssrGetContent.value);
async function addGuestbookFun() {
  if (!params.value.username) {
    return ElMessage.error("Please enter your name");
  } else if (!params.value.phone) {
    return ElMessage.error("Please enter your contact number");
  } else if (!params.value.messageContents) {
    return ElMessage.error("Please enter your message");
  }
  let res: any = await addGuestbook(params.value);
  if (res.httpCode == 200) {
    ElMessage.success("Submitted successfully");
    params.value = {
      phone: "",
      username: "",
      messageContents: "",
      companyName: "",
      companyType: "",
      country: "",
      jobTitle: "",
      languageType: 0,
      mailbox: "",
      queryType: "",
      state: 0,
      trade: "",
    };
  } else {
    ElMessage.error("Submission failed");
  }
}
function setData(res: any) {
  console.log(res);
  if (res.httpCode == 200) {
    pageData.value = res?.data;
  }
}
</script>
<template>
  <div class="page-wrapper">
    <div class="page-main">
      <section class="section banner-wrap" style="margin-bottom: 0;" :style="'background-image:url(https://hotking.oss-cn-hongkong.aliyuncs.com/hkt/adpos/pic/hbBanner.png)'">
      </section>
      <!-- 面包屑 -->
      <div class="breadcrumb-wrap section">
        <div class="breadcrumb">
          Current Location: <NuxtLink to="/">Home</NuxtLink>&nbsp;> Contact Us
        </div>
      </div>

      <div class="container">
        <h2>Contact Us</h2>
        <!-- 联系信息卡片 -->
        <div class="contact-card">
          <div class="contact-info">
            <h4>For Trade Inquiries</h4>
            <p><img src="@/assets/img/contact/tel.png" />Tel: +86 0755 82565333 ext. 8016</p>
            <p><img src="@/assets/img/contact/phone.png" />Mobile: 13670157820</p>
            <p><img src="@/assets/img/contact/email.png" />Email: hkt@heketai.com</p>
            <p><img src="@/assets/img/contact/address.png" />Address: 8F, Building 7, Kangli City, 66 Pingji Avenue, Longgang District, Shenzhen</p>
            <h4 class="mt20">For OEM Customization</h4>
            <p><img src="@/assets/img/contact/phone.png" />Mr. Yang: 13652389305</p>
            <p><img src="@/assets/img/contact/phone.png" />Mr. Shen: 13538060488</p>
            <p><img src="@/assets/img/contact/phone.png" />Mr. Chen: 18244986001</p>
          </div>
          <img class="contact-img" src="@/assets/img/contact/contact-img.png" alt="Customer service representative">
        </div>
        <!-- 在线留言卡片 -->
        <div class="message-card">
          <h3>Online Message</h3>
          <form class="message-form">
            <div class="form-group">
              <label for="content">Message:</label>
              <el-input class="bt" type="textarea" :rows="3" v-model.trim="params.messageContents" placeholder="Please enter your message"></el-input>
            </div>
            <div class="form-group">
              <label for="name">Your Name:</label>
              <el-input class="bt" v-model.trim="params.username" placeholder="Please enter your name"></el-input>

            </div>
            <div class="form-group">
              <label for="contact">Contact Number:</label>
              <el-input class="bt" v-model.trim="params.phone" placeholder="Please enter your contact number"></el-input>
            </div>
            <button type="button" class="submit-btn" @click="addGuestbookFun">Submit Now</button>
          </form>
        </div>
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.main-width {
  margin: 0 auto;
  max-width: 1600px;
  width: 90%;
  padding: 0px 20px;
}
.banner-wrap {
  height: 350px;
  width: 100%;
  position: relative;
  background: url(@/assets/img/about-us/banner.png) no-repeat center center;
  background-size: auto 100%;
  .banner-con {
    display: flex;
    justify-content: space-between;
    padding: 80px 32px 0 32px;
    flex-direction: column;
    ul {
      display: flex;
      margin-top: 50px;
    }
    li {
      color: #fff;
      h3 {
        font-weight: bold;
        line-height: 70px;
        height: 70px;
        font-size: 60px;
        letter-spacing: 3px;
        span {
          font-size: 36px;
          margin-left: 5px;
        }
      }
      p {
        font-size: 16px;
        font-weight: 400;
      }
    }
    .title-tip {
      font-size: 60px;
      color: #fff;
      font-weight: bold;
      line-height: 80px;
      position: relative;
      letter-spacing: 2px;
      &::before {
        position: absolute;
        content: "";
        width: 120px;
        height: 4px;
        background: #fff;
        bottom: -3px;
        left: 0;
      }
    }
  }
}

/* 面包屑 */
.breadcrumb-wrap {
  box-shadow: 0 5px 20px #f9f9f9;
}
.container {
  max-width: 1600px;
  width: 90%;
  margin: 0 auto;
  padding: 0 20px;
  h2 {
    text-align: center;
    margin: 60px 0 40px;
    font-size: 30px;
    color: #333;
    font-weight: bold;
  }
}
.contact-card {
  background: #fff;
  border-radius: 8px;
  padding: 30px 30px;
  margin-bottom: 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  font-size: 18px;
}
.contact-info {
  flex: 1;
  color: #666;
  line-height: 48px;
  h4{
    font-size: 20px;
    font-weight: bold;
  }
  p {
    display: flex;
    align-items: center;
    img{
      width: 30px; height: 30px; 
      margin-right: 5px;
    }
    &.address {
      align-items: flex-start;
      .icon {
        position: relative;
        top: 12px;
      }
      span {
      }
    }
  }
}
.contact-info span {
  color: #333;
  margin-right: 8px;
  font-size: 20px;
}
.contact-info .red-text {
  color: #e53935;
  font-weight: bold;
}
.contact-info .icon {
  display: block;
  text-align: center;
}
.contact-img {
  width: 300px;
  height: auto;
}
.message-card {
  background: #fff;
  border-radius: 8px;
  padding: 50px 30px 30px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  margin-top: 120px;
  margin-bottom: 100px;
}
.message-card h3 {
  text-align: center;
  margin-bottom: 40px;
  font-size: 20px;
  color: #333;
}
.message-form .form-group {
  margin-bottom: 20px;
}
.message-form label {
  display: block;
  margin-bottom: 8px;
  color: #666;
}
.message-form input,
.message-form textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  color: #333;
}
.message-form textarea {
  height: 100px;
  resize: none;
}
.submit-btn {
  display: block;
  width: 120px;
  height: 40px;
  line-height: 40px;
  text-align: center;
  background-color: #e53935;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 16px;
  cursor: pointer;
  margin: 0 auto;
}
.submit-btn:hover {
  background-color: #c62828;
}
/* 响应式适配 */
@media (max-width: 768px) {
  .contact-card {
    flex-direction: column;
    text-align: center;
  }
  .contact-img {
    margin-top: 20px;
  }
}
</style>
