Introduce.vue 5.8 KB
<!--
 * @Description:
 * @Author: huyue
 * @Date: 2023-07-04 13:55:35
 * @LastEditors: yangming yangming@didihu.com.cn
 * @LastEditTime: 2024-01-29 16:09:43
-->
<template>
  <div class="introduce-container">
    <div class="introduce-box">
      <div class="introduce-box-title linear-gradient-text">
        {{ Introduce.title }}
      </div>
      <div class="introduce-box-content">
        {{ Introduce.content }}
      </div>
    </div>
    <div class="books-box">
      <div class="books-box-title">
        {{ Introduce.qualificationsTitle }}
      </div>
      <div class="books-line">
        <img src="@/assets/images/viewEntireLifecycleOfCar/line.png" />
      </div>
      <div class="qualifications-list">
        <div class="qualifications-item" v-for="(item, index) in Introduce.qualificationsList" :key="'qu' + index">
          <div class="qualifications-title">{{ item.title }}</div>
          <div class="qualifications-num linear-gradient-text">
            {{ item.num }}
            <span :class="{ f28: item.unit == '+' ? true : false }">{{ item.unit }}</span>
          </div>
        </div>
      </div>
      <el-carousel class="swiper-box" ref="slideCarousel" :interval="4000" autoplay>
        <el-carousel-item v-for="(item, index) in Introduce.booksList" :key="'sw' + index">
          <div class="swiper-body">
            <div class="books-item" v-for="(i, idx) in 8" :key="'book' + idx">
              <img :src="require(`@/assets/images/viewEntireLifecycleOfCar/b${index + 1}_${idx + 1}.png`)" />
            </div>
          </div>
        </el-carousel-item>
      </el-carousel>
    </div>
  </div>
</template>

<script>
import detail from '@/utils/data'
export default {
  name: 'Introduce',
  data() {
    return {
      Introduce: detail.Introduce
    }
  },
  mounted() {
    // 调用方法
    this.slideBanner()
  },
  methods: {
    // 滑动切换
    slideBanner() {
      // 选中的轮播图
      var box = document.querySelector('.swiper-box')
      var startPoint = 0
      var stopPoint = 0
      // 重置坐标
      var resetPoint = function () {
        startPoint = 0
        stopPoint = 0
      }
      // 手指按下
      box.addEventListener('touchstart', function (e) {
        // 手指点击位置的X坐标
        startPoint = e.changedTouches[0].pageX
      })
      // 手指滑动
      box.addEventListener('touchmove', function (e) {
        // 手指滑动后终点位置X的坐标
        stopPoint = e.changedTouches[0].pageX
      })
      // 当手指抬起的时候,判断图片滚动离左右的距离
      const that = this
      box.addEventListener('touchend', function (e) {
        console.log('1:' + startPoint)
        console.log('2:' + stopPoint)
        if (stopPoint == 0 || startPoint - stopPoint == 0) {
          resetPoint()
          return
        }
        if (startPoint - stopPoint > 0) {
          resetPoint()
          that.$refs.slideCarousel.next()
          return
        }
        if (startPoint - stopPoint < 0) {
          resetPoint()
          that.$refs.slideCarousel.prev()
          return
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.introduce-box {
  width: 800px;
  height: 404px;
  background: url('../assets/images/viewEntireLifecycleOfCar/border_1.png');
  background-size: 100% 100%;
  padding: 12px 52px;
  box-sizing: border-box;

  &-title {
    font-weight: 1000;
    font-size: 28px;
    color: #ffffff;
    letter-spacing: 1px;
    line-height: 40px;
    text-align: center;
  }

  .books-line img {
    width: 436px;
    height: 6px;
  }

  &-content {
    margin-top: 32px;
    font-size: 24px;
    color: #dedede;
    letter-spacing: 0;
    line-height: 40px;
  }
}

.books-box {
  margin-top: 24px;
  width: 800px;
  height: 467px;
  background: url('../assets/images/viewEntireLifecycleOfCar/border_2.png');
  background-size: 100% 100%;
  padding: 28px;
  box-sizing: border-box;

  &-title {
    font-size: 22px;
    color: #44ffff;
    letter-spacing: 0;
    line-height: 32px;
    font-weight: 700;
  }

  .qualifications-list {
    display: flex;
    gap: 40px;
    margin-top: 20px;

    .qualifications-item {
      width: 220px;
      height: 66px;
      background: url('../assets/images/viewEntireLifecycleOfCar/q-border.png');
      background-size: 100% 100%;
      padding: 15px 29px;
      box-sizing: border-box;
      display: flex;
      align-items: center;
      justify-content: center;

      .qualifications-title {
        font-size: 16px;
        color: #ffffff;
      }

      .qualifications-num {
        font-size: 28px;
        color: #6578ff;
        line-height: 36px;
        font-weight: 700;
        margin-left: 15px;

        span {
          font-weight: 500;
          font-size: 16px;
          color: #0ffadf;
          margin-left: 5px;

          &.f28 {
            font-size: 28px;
          }
        }
      }
    }
  }

  .swiper-box {
    padding-top: 28px;
    height: 265px;

    /deep/ {
      .el-carousel__container {
        height: 100%;
      }

      .el-carousel__arrow {
        display: none;
      }

      .el-carousel__button {
        width: 24px;
        height: 4px;
        opacity: 0.35;
        transform: scaleY(-1) rotate(-180deg);
        background-image: linear-gradient(90deg, #00c8ff 0%, #0069f2 100%);
      }

      .is-active {
        .el-carousel__button {
          opacity: 1;
        }
      }
    }

    .swiper-body {
      display: flex;
      gap: 18px 34px;
      flex-wrap: wrap;

      .books-item {
        width: 158px;
        height: 106px;
        background: url('../assets/images/viewEntireLifecycleOfCar/books-border.png');
        background-size: 100% 100%;
        position: relative;
        padding: 12px 8px;
        box-sizing: border-box;

        img {
          width: 140px;
          height: 84px;
          opacity: 0.9;
        }
      }
    }
  }
}
</style>