<script setup lang="ts">
let pageTitle: any = ref("公司简介-深圳市合科泰电子有限公司");
useHead(() => ({
  title: pageTitle.value,
}));
import banner from "@/assets/img/about-us/banner.png";
import { useAll } from "~/api/pubAll/service";
const { getContent, devHistory } = useAll();
let pageData: any = ref([]);
let pageData2: any = ref([]);

/**
 * 从发展历程数据中提取可排序年份。
 * @param item 发展历程单项数据。
 * @returns 返回用于升序排序的年份数字。
 * @throws 该函数不主动抛出异常。
 */
function getTimelineYear(year: any) {
  return Number(year || 0);
}

/**
 * 对发展历程数据按年份做升序排序。
 * @returns 返回升序后的发展历程数组。
 * @throws 该函数不主动抛出异常。
 */
const sortedTimelineData = computed(() => {
  // 这里复制一份数组再排序，避免直接修改接口原始响应，降低对其他逻辑的影响。
  return [...pageData2.value].sort(
    (a: any, b: any) => getTimelineYear(a?.year) - getTimelineYear(b?.year)
  );
});

const { data: ssrGetContent } = await useAsyncData<any>("getContentsss", () =>
  getContent({
    language: 1,
    code: 5,
  })
);
setData(ssrGetContent.value);

/**
 * 设置公司简介数据。
 * @param res 接口返回结果。
 * @returns 无返回值。
 * @throws 该函数不主动抛出异常。
 */
function setData(res: any) {
  if (res.httpCode == 200) {
    pageData.value = res?.data;
  }
}

const { data: ssrDevHistory } = await useAsyncData<any>("devHistoryssss", () =>
  devHistory()
);
setData2(ssrDevHistory.value);

/**
 * 设置发展历程数据。
 * @param res 接口返回结果。
 * @returns 无返回值。
 * @throws 该函数不主动抛出异常。
 */
function setData2(res: any) {
  if (res.httpCode == 200) {
    pageData2.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(http://doc.hotking.com/hkt/adpos/pic/%E5%85%B3%E4%BA%8E%E6%88%91%E4%BB%AC%281%29.png)'">
      </section>
      <!-- 面包屑 -->
      <div class="breadcrumb-wrap section">
        <div class="breadcrumb">
          您现在的位置：<NuxtLink to="/">首页</NuxtLink>&nbsp;> 关于我们
        </div>
      </div>

      <div class="container">
        <!-- 公司简介 -->
        <section class="section company-intro" id="company-intro">
          <h2 class="section-title">公司简介</h2>
          <div class="intro-content">
            <div class="intro-text">
              <h3 class="intro-subtitle">{{pageData[0][1].title}}</h3>
              <div class="intro-paragraph">
                <pre>{{pageData[0][1].content}}</pre>
              </div>

            </div>
            <div class="intro-img">
              <img :src="pageData[0][1].list[0].image" alt="合科泰公司大楼" class="img-responsive">
            </div>
          </div>
        </section>

        <!-- 企业文化 -->
        <section class="section culture" id="company-culture">
          <h2 class="section-title">企业文化</h2>
          <div class="culture-list">
            <div class="culture-item">
              <div class="culture-icon icon-1"></div>
              <h3 class="culture-title">合芯凝聚</h3>
              <p class="culture-desc">打造电子元器件国产替代品牌</p>
            </div>
            <div class="culture-item">
              <div class="culture-icon icon-2"></div>
              <h3 class="culture-title">科技兴国</h3>
              <p class="culture-desc">以技术回应客户期待<br>以温度拓展服务边界</p>
            </div>
            <div class="culture-item">
              <div class="culture-icon icon-3"></div>
              <h3 class="culture-title">泰志传承</h3>
              <p class="culture-desc">将每一份品质锻造成为穿越时光的承诺</p>
            </div>
            <div class="culture-item">
              <div class="culture-icon icon-4"></div>
              <h3 class="culture-title">匠心制造</h3>
              <p class="culture-desc">客户至上 合作共赢<br>专业务实 高效创新</p>
            </div>
          </div>
          <div class="culture-list">
            <div class="culture-item">
              <div class="culture-icon icon-5"></div>
              <h3 class="culture-title">智领未来</h3>
              <p class="culture-desc">持续为全球客户提供稳定可靠的半导体供应</p>
            </div>
            <div class="culture-item">
              <div class="culture-icon icon-6"></div>
              <h3 class="culture-title">芯驱精进</h3>
              <p class="culture-desc">坚持高标准研发投入，以精益求精的工匠精神铸就卓越性能与高可靠性</p>
            </div>
            <div class="culture-item">
              <div class="culture-icon icon-7"></div>
              <h3 class="culture-title">质铸基石</h3>
              <p class="culture-desc">车规级标准，通过严苛的可靠性验证.</p>
            </div>
            <div class="culture-item">
              <div class="culture-icon icon-8"></div>
              <h3 class="culture-title">赋能共赢</h3>
              <p class="culture-desc">提供灵活定制的一站式应用解决方案，与客户携手并进</p>
            </div>
          </div>
        </section>

        <!-- 发展历程 -->
        <section class="section timeline" id="company-history">
          <h2 class="section-title">发展历程</h2>
          <div class="timeline-container">
            <!-- 时间轴主线 -->
            <div class="timeline-line"></div>

            <!-- 左侧事件 -->
            <div class="timeline-group timeline-left">
              <div v-for="(item, index) in sortedTimelineData" :key="item.id || index" class="timeline-item">
                <div v-if="index % 2 === 0" class="timeline-dot"></div>
                <div class="timeline-content">
                  <div class="timeline-year">{{ getTimelineYear(item.year) }}</div>
                  <p class="timeline-text" v-html="item.text"></p>
                </div>
                <div v-if="index % 2 === 1" class="timeline-dot"></div>
              </div>
            </div>
          </div>
        </section>

        <!-- 荣誉证书 -->
        <section class="section honors" id="company-award">
          <h2 class="section-title">荣誉证书</h2>
          <div class="honors-list">
            <div class="honor-item">
              <img src="@/assets/img/about-us/r_1.png" alt="深圳市专精特新企业" class="honor-img">
              <p class="honor-name">深圳市专精特新企业</p>
            </div>
            <div class="honor-item">
              <img src="@/assets/img/about-us/r_2.png" alt="深圳市创新型企业" class="honor-img">
              <p class="honor-name">深圳市创新型企业</p>
            </div>
            <div class="honor-item">
              <img src="@/assets/img/about-us/r_3.png" alt="国家级高新技术企业" class="honor-img">
              <p class="honor-name">国家级高新技术企业</p>
            </div>
            <div class="honor-item">
              <img src="@/assets/img/about-us/r_4.png" alt="科技创新先锋奖" class="honor-img">
              <p class="honor-name">科技创新先锋奖</p>
            </div>
            <div class="honor-item">
              <img src="@/assets/img/about-us/r_5.png" alt="深圳市电子商务金点奖" class="honor-img">
              <p class="honor-name">深圳市电子商务金点奖</p>
            </div>
            <div class="honor-item">
              <img src="@/assets/img/about-us/r_6.png" alt="金奖类最具市场力产品奖" class="honor-img">
              <p class="honor-name">金奖类最具市场力产品奖</p>
            </div>
            <div class="honor-item">
              <img src="@/assets/img/about-us/r_7.png" alt="创新突破蓝点奖" class="honor-img">
              <p class="honor-name">创新突破蓝点奖</p>
            </div>
            <div class="honor-item">
              <img src="@/assets/img/about-us/r_8.png" alt="工程技术研究中心认定" class="honor-img">
              <p class="honor-name">工程技术研究中心认定</p>
            </div>
          </div>
        </section>
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.main-width {
  margin: 0 auto;
  max-width: 1600px;
  padding: 0px;
}
.banner-wrap {
  height: 350px;
  width: 100%;
  position: relative;
  background: url(@/assets/img/about-us/banner.png) no-repeat center center;
  background-size: auto 350px;
  .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;
      }
    }
  }
}

/* 全局基础样式 */
.container {
  max-width: 1600px;
  width: 90%;
  margin: 0 auto;
  padding: 0 20px;
  color: #333;
  .section {
    scroll-margin-top: 140px;
  }
}

/* 面包屑 */
.breadcrumb-wrap {
  box-shadow: 0 5px 20px #f9f9f9;
}
.breadcrumb {
  font-size: 14px;
  color: #666;
  height: 80px;
  display: flex;
  align-items: center;
  width: 90%;
  max-width: 1600px;
  margin: 0 auto;
  padding-left: 15px;
  font-size: 15px;
}

/* 通用区块样式 */
.section {
  margin-bottom: 120px;
  position: relative;
}

.section-title {
  font-size: 34px;
  font-weight: bold;
  text-align: center;
  margin-bottom: 60px;
  color: #333;
  position: relative;
}

.section-title::after {
  content: "";
  display: block;
  width: 80px;
  height: 3px;
  background-color: #e53935;
  margin: 10px auto 0;
}

/* 图片响应式 */
.img-responsive {
  max-width: 100%;
  height: auto;
  display: block;
}

/* 公司简介 */
.intro-content {
  display: flex;
  flex-direction: column;
  margin-top: 80px;
}

.intro-subtitle {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 15px;
  line-height: 40px;
  color: #222;
}

.intro-paragraph {
  margin-bottom: 15px;
  font-size: 16px;
  color: #666;
}

.intro-text {
  background-color: #f9f9f9;
  padding: 30px 30px 30px;
  border-radius: 8px;
  pre {
    white-space: pre-wrap; /* 保留格式 + 自动换行（最关键） */
    word-wrap: break-word; /* 长单词强制换行 */
    overflow: visible; /* 不出现滚动条 */
    margin: 0; /* 去掉默认边距 */
    font-family: inherit; /* 让字体和页面一致，不变成等宽体 */
    font-size: 14px;
    line-height: 20px;
    color: #666;
  }
}

.intro-img {
  overflow: hidden;
  margin-top: -60px;
}

/* 企业文化 */
.culture-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  & + .culture-list {
    margin-top: 30px;
  }
}

.culture-item {
  background-color: #f0f0f0;
  padding: 25px 15px;
  border-radius: 8px;
  text-align: center;
}

.culture-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 15px;
  &.icon-1 {
    background: url(@/assets/img/about-us/icon-1.png) no-repeat center center;
    background-size: 80px 80px;
  }
  &.icon-2 {
    background: url(@/assets/img/about-us/icon-2.png) no-repeat center center;
    background-size: 80px 80px;
  }
  &.icon-3 {
    background: url(@/assets/img/about-us/icon-3.png) no-repeat center center;
    background-size: 80px 80px;
  }
  &.icon-4 {
    background: url(@/assets/img/about-us/icon-4.png) no-repeat center center;
    background-size: 80px 80px;
  }
  &.icon-5 {
    background: url(@/assets/img/about-us/icon-5.png) no-repeat center center;
    background-size: 80px 80px;
  }
  &.icon-6 {
    background: url(@/assets/img/about-us/icon-6.png) no-repeat center center;
    background-size: 80px 80px;
  }
  &.icon-7 {
    background: url(@/assets/img/about-us/icon-7.png) no-repeat center center;
    background-size: 80px 80px;
  }
  &.icon-8 {
    background: url(@/assets/img/about-us/icon-8.png) no-repeat center center;
    background-size: 80px 80px;
  }
}

.culture-title {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 10px;
  color: #333;
  line-height: 32px;
}

.culture-desc {
  font-size: 14px;
  color: #666;
}

/* 发展历程 */
.timeline-container {
  position: relative;
  max-width: 100%;
  margin: 0 auto;
}

.timeline-line {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 3px;
  background-color: #e53935;
  transform: translateX(-50%);
  z-index: 1;
}

.timeline-group {
  width: 100%;
  margin-bottom: 30px;
  overflow: hidden;
}

.timeline-item {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
  position: relative;
  &:nth-child(2n) {
    position: relative;
    left: calc(50% + 30px);
    text-align: left;
    .timeline-content {
      text-align: left;
    }
    .timeline-dot {
      left: -30px;
    }
  }
}

.timeline-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: #e53935;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
}

.timeline-content {
  width: calc(50% - 30px);
  background-color: #f9f9f9;
  padding: 15px;
  border-radius: 8px;
  font-size: 14px;
}

.timeline-left .timeline-content {
  margin-right: auto;
  margin-left: 0;
  text-align: right;
}

.timeline-right {
  margin-top: -500px;
  .timeline-content {
    margin-left: auto;
    margin-right: 0;
    text-align: left;
  }
}

.timeline-year {
  font-weight: bold;
  color: #e53935;
  margin-bottom: 5px;
  font-size: 22px;
}

.timeline-text {
  color: #666;
}

/* 荣誉证书 */
.honors-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 50px 30px;
}

.honor-item {
  background-color: #fff;
  border-radius: 8px;
  text-align: center;
}

.honor-img {
  max-width: 100%;
  object-fit: contain;
  margin-bottom: 10px;
}

.honor-name {
  font-size: 18px;
  color: #333;
}
@media (max-width: 1400px) {
  .company-intro {
    .intro-text {
      padding: 20px 20px;
      pre{
        font-size: 13px;
      }
    }
    .intro-subtitle {
      font-size: 20px;
      line-height: 28px;
    }
    .intro-paragraph {
      font-size: 13px;
      &:last-child {
        margin-bottom: 0;
      }
    }
  }
}

/* 响应式适配 - 平板 */
@media (min-width: 768px) {
  /* 公司简介 */
  .intro-content {
    flex-direction: row;
  }
  .intro-text,
  .intro-img {
    width: 50%;
  }

  /* 企业文化 */
  .culture-list {
    grid-template-columns: repeat(2, 1fr);
  }

  /* 荣誉证书 */
  .honors-list {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* 响应式适配 - 桌面端 */
@media (min-width: 992px) {
  /* 企业文化 */
  .culture-list {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* 小屏手机适配 */
@media (max-width: 767px) {
  .timeline-line {
    left: 20px;
    transform: none;
  }
  .timeline-dot {
    left: 20px;
    transform: none;
  }
  .timeline-item {
    flex-direction: column;
    align-items: flex-start;
  }
  .timeline-content {
    width: calc(100% - 40px);
    margin-left: 40px !important;
    margin-right: 0 !important;
    text-align: left !important;
  }
}
</style>
