<template>
  <div>
    <van-swipe class="my-swipe" :autoplay="10000" :show-indicators="false">
      <van-swipe-item v-for="(item, index) in bannerList" :key="index"
        ><img @click="goGoods(item)" :src="item.cover_url" alt=""
      /></van-swipe-item>
    </van-swipe>
  </div>
</template>
<script>
import { getBanner } from "../../api";
export default {
  data() {
    return {
      bannerList: [], //轮播图列表
    };
  },
  mounted() {
    this.getBanner();
  },
  methods: {
    // 获取首页轮播
    getBanner() {
      getBanner().then((res) => {
        if (res.status == 200) {
          this.bannerList = res.data.data.list;
        }
      });
    },
    // 进入商品详情
    goGoods(e) {
      this.$router.push({
        path: "/home",
        query: {
          goods_id: e.goods_id,
        },
      });
    },
  },
};
</script>

<style scoped lang='less'>
.my-swipe {
  height: 1920px;
  img {
    width: 100%;
    height: 100%;
  }
}
</style>
