<template>
  <div>
    <commonBanner mainTitle="中兴智能交通" subTitle="构建绿色交通 享受安全便利出行"></commonBanner>
    <div class="tab-wrapper">
      <ul class="tab-main widthCommon">
        <li
          v-for="(item, index) in tabData"
          :key="item"
          @click="changeTab(index,item)"
          :class="{tabActive:currentIndex==index}"
        >{{item}}
        </li>
      </ul>
    </div>
    <div class="bread">
      <div class=" widthCommon">
        您所在位置: <span class="pointer" @click="$router.push({name:'home'})">首页</span> -> 产品中心 -> {{name}}
      </div>
    </div>


    <div class="widthCommon anchor" style="height: 200px;">1</div>
    <div class="widthCommon anchor" style="height: 400px;">2</div>
    <div class="bgCommon">
      <div class="widthCommon anchor" style="height: 400px;">3</div>
    </div>
    <div class="widthCommon anchor" style="height: 300px;">4</div>
    <div class="widthCommon anchor" style="height: 300px;">5</div>

  </div>
</template>

<script>
import commonBanner from '@/components/commonBanner'

export default {
  name: 'index',
  components: {
    commonBanner
  },
  data() {
    return {
      tabData: [
        '公司简介', '发展历程', '企业文化', '资质认证', '荣誉证书'
      ],
      currentIndex: 0,
      tabView: 'selectTab0',
      name: '',
      scroll: ''
    }
  },
  mounted() {
    this.name = this.tabData[0]
  },
  methods: {
    dataScroll: function () {
      this.scroll =  document.documentElement.scrollTop || document.body.scrollTop
    },
    changeTab: function (index, item) {
      console.log(index)
      this.currentIndex = index
      this.tabView = 'selectTab' + index
      this.name = item

      // 对应锚点
      let jump = document.getElementsByClassName('anchor')
      let total = jump[index].offsetTop
      document.documentElement.scrollTop = total //firefox
      document.body.scrollTop = total //chrome
      window.pageYOffset = total

    },

  }

}
</script>

<style scoped lang="scss">


</style>
