index.vue 8.51 KB
<template>
  <div class="hager-solution-index">
    <hager-box :style="{backgroundColor: '#F5F6FB', height: top_img_height }">
      <div class="hager-solution-top">
        <el-row v-if="!is_xs" :gutter="20" style="display: flex;">
          <el-col :span="8">
            <div class="banner-text-wrapper">
              <div class="text">
                <span class="title">解决方案</span>&nbsp;<span class="sub">Solution</span>
              </div>
              <div class="text-sub">
                海格电气用丰富的行业知识和应用经验,<br/>为多个行业提供智能低压配电解决方案和智能楼宇解决方案。
              </div>
            </div>
          </el-col>
          <el-col :span="16">
            <img :style="{ height: top_img_height, width: '100%' }" src="https://cdn.ipadbiz.cn/hager/banner/01.png">
          </el-col>
        </el-row>
        <img v-else :style="{ height: top_img_height, width: '100%' }" src="https://cdn.ipadbiz.cn/hager/banner/01.png">
      </div>
    </hager-box>
    <hager-box class="box-n">
      <hager-h1 title="行业解决方案" sub="Industry Solutions" style="margin: 2rem 0 1rem;"></hager-h1>
      <div>海格电气为建筑,能源,工业,基础设施等行业提供安全、稳定、可靠、智能的低压配电解决方案及KNX智能楼宇解决方案。</div>
      <div v-if="!is_xs" class="hager-industry-solutions">
        <el-row :gutter="15" v-for="(item, index) in splitListIntoChunks(solution_list)" :key="index">
          <el-col :span="6" v-for="(x, idx) in item" :key="idx">
            <div @click="goToSolution(item)" class="card">
              <img :src="x.src" class="card-image">
              <div class="card-content">
                <div class="card-title">
                  <span>{{ x.title }}</span>
                  <i class="el-icon-right"></i>
                </div>
                <p class="card-sub">{{ x.sub }}</p>
              </div>
            </div>
          </el-col>
        </el-row>
      </div>
      <div v-else style="margin: 1rem 0;">
        <swiper ref="mySolutionSwiper" class="swiper" :options="swiperOption" @slideChange="onSlideChange">
          <swiper-slide v-for="(item, index) in solution_list" :key="index">
            <div @click="goToSolution(item)" class="card" style="margin-bottom: 1rem;">
              <img :src="item.src" alt="学校图片" class="card-image">
              <div class="card-content">
                <div class="card-title">
                  <span>{{ item.title }}</span>
                  <i class="el-icon-right"></i>
                </div>
                <p class="card-sub">{{ item.sub }}</p>
              </div>
            </div>
          </swiper-slide>
        </swiper>
        <div class="xs-control">
          <div>
            <i :class="['el-icon-arrow-left', activeIndex === 0 ? 'disabled' : '']" @click="prevSolutionBtn()"></i>
            <i :class="['el-icon-arrow-right', reach_end ? 'disabled' : '']" @click="nextSolutionBtn()"></i>
          </div>
        </div>
      </div>
      <div class="more-box" style="margin-top: 2rem;">
        <hager-more></hager-more>
      </div>
    </hager-box>
    <hager-service></hager-service>
  </div>
</template>

<script>
import mixin from 'common/mixin';
import hagerBox from '@/components/common/hagerBox';
import hagerH1 from '@/components/common/hagerH1.vue';
import hagerMore from '@/components/hagerMore.vue';
import hagerService from '@/components/common/hagerService.vue';

export default {
  components: { hagerBox, hagerH1, hagerMore, hagerService },
  mixins: [mixin.init],
  data () {
    return {
      solution_list: [{
        src: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg',
        title: '1住宅解决方案',
        sub: 'Residential Solution Case'
      }, {
        src: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg',
        title: '2住宅解决方案',
        sub: 'Residential Solution Case'
      }, {
        src: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg',
        title: '3住宅解决方案',
        sub: 'Residential Solution Case'
      }, {
        src: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg',
        title: '4住宅解决方案',
        sub: 'Residential Solution Case'
      }, {
        src: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg',
        title: '1住宅解决方案',
        sub: 'Residential Solution Case'
      }, {
        src: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg',
        title: '2住宅解决方案',
        sub: 'Residential Solution Case'
      }, {
        src: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg',
        title: '3住宅解决方案',
        sub: 'Residential Solution Case'
      }, {
        src: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg',
        title: '4住宅解决方案',
        sub: 'Residential Solution Case'
      }],
      swiperOption: {
        slidesPerView: 2,
        spaceBetween: 50,
        preventClicks : true,
        slideToClickedSlide: false,
        touchRatio: 0,
        breakpoints: {
          1024: {
            slidesPerView: 4,
            spaceBetween: 40
          },
          768: {
            slidesPerView: 3,
            spaceBetween: 30
          },
          640: {
            slidesPerView: 2,
            spaceBetween: 20
          },
          320: {
            slidesPerView: 2,
            spaceBetween: 10
          },
          160: {
            slidesPerView: 1,
            spaceBetween: 0
          }
        }
      },
      activeIndex: 0,
      reach_end: false,
    }
  },
  mounted () {

  },
  methods: {
    splitListIntoChunks (list) {
      const chunkSize = 4; // 每组4个项目
      const result = [];

      // 按每4个为一组进行分割
      for (let i = 0; i < list.length; i += chunkSize) {
        const chunk = list.slice(i, i + chunkSize);
        result.push(chunk);
      }

      return result;
    },
    goToSolution (v) {
      this.$router.push({
        path: '/solution/detail',
        query: {
          id: v.id
        }
      });
    },
    prevSolutionBtn () {
      this.$refs.mySolutionSwiper.$swiper.slidePrev();
    },
    nextSolutionBtn () {
      this.$refs.mySolutionSwiper.$swiper.slideNext();
    },
    onSlideChange (swiper) {
      this.activeIndex = swiper.activeIndex;
      const isEnd = swiper.isEnd;

      if (isEnd) {
        this.reach_end = true;
      } else {
        this.reach_end = false;
      }
    },
  }
}
</script>

<style lang="less" scoped>
.hager-solution-index {
  .hager-solution-top {

    width: 100%;
    .banner-text-wrapper {
      height: 100%;
      display: flex;
      // align-items: center;
      justify-content: center;
      flex-direction: column;
    }
    img {
      width: 100%;
      max-width: 100%; /* 防止宽度超出容器 */
      object-fit: fill; /* 保持图片内容的完整性,可以根据需求调整为 cover 或 contain */
    }
  }
  .hager-industry-solutions {
    margin: 2rem 0;
    .case-item {
      position: relative;
      height: 12rem;
      padding: 1.5rem;
      text-align: center;
      color: #FFF;
      border-radius: 8px;
      background-size: cover;
      background-position: top center;
      transition: transform 0.3s ease-in-out;
      &:hover {
        transform: scale(1.05);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
        cursor: pointer;
      }
    }
  }
  .card {
    // width: 300px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    background-color: #F3F3F3;
    margin: 0;
    transition: transform 0.3s ease-in-out;
    margin-bottom: 1rem;
    &:hover {
      transform: scale(1.05);
      box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
      cursor: pointer;
    }
    .card-image {
      width: 100%;
      height: 12rem;
      object-fit: cover;
    }

    .card-content {
      padding: 15px;
      .card-title {
        display: flex;
        align-items: center;
        justify-content: space-between;
        font-size: 1rem;
        color: @secondary-color;
        margin-bottom: 10px;
        font-weight: bold;
      }
      .card-sub {
        font-size: 0.85rem;
        line-height: 1.6;
        margin-bottom: 15px;
      }
    }
  }

  .xs-control {
    display: flex;
    justify-content: flex-end;
    margin-top: 1rem;
    margin-bottom: 1rem;
    i {
      font-size: 1.35rem;
      color: #EE6D10;
      &:hover {
        cursor: pointer;
      }
      &.disabled {
        color: #ccc;
      }
    }
  }
}
</style>