<template>
  <div class="shop-index">
    <van-search placeholder="请输入商品关键词" />
    <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
      <!-- <van-swipe-item v-for="(image, index) in images" :key="index">
        <img v-lazy="image" />
      </van-swipe-item> -->
      <van-swipe-item v-for="(image) in swiperImgList" :key="image.id"> <img :src="image.url" alt=""></van-swipe-item>
    </van-swipe>
    <div class="show">
      <product-list />
    </div>
  </div>
</template>


<script type="text/javascript">
import Vue from "vue";
// import axios from "axios";
import ProductList from "../../components/ProductList";
import {
  NavBar,
  Search,
  Swipe,
  SwipeItem,
  Lazyload,
  Card,
  PullRefresh,
  List,
} from "vant";

Vue.use(NavBar);
Vue.use(Search);
Vue.use(Swipe);
Vue.use(SwipeItem);
Vue.use(Lazyload);
Vue.use(Card);
Vue.use(PullRefresh);
Vue.use(List);

// Vue.prototype.$http = axios;

export default {
  head() {
    return {
      title: "积分商城",
    };
  },
  data() {
    return {
      images: [],
      list: [],
      loading: false, //加载状态
      finished: false, //是否完成加载
      refreshing: false, //是否正在上拉刷新
      swiperImgList:[]
    };
  },
  components: {
    ProductList,
  },
  beforeCreate() {},
  created() {
    this.initSwiperImg();
  },
  mounted() {
  },
  methods: {
    onLoad() {
      var that = this;
      that.$axios
        .get("/getIntegralWaresInfoList", {
          params: {
            stationId: "1",
          },
        })
        .then((res) => {
          if (res.data.retCode == 0) {
            that.list = res.data.data; //追加数据
            // 加载状态结束
            that.loading = false;
            that.finished = true;
          }
        });
    },
    onRefresh() {
      // 清空列表数据
      that.finished = true;
      // 重新加载数据
      // 将 loading 设置为 true，表示处于加载状态
      that.loading = true;
      that.onLoad();
    },
    initSwiperImg() {
      this.$axios
        .$get("/getIntegralShopPicInfoList", {
          params: {
            stationId: this.stationId,
          },
        })
        .then((res) => {  
          if(res.retCode === 0){
            this.swiperImgList = res.data
          }
        });
    },
  },
};
</script>

<style scope>
.shop-index * {
  box-sizing: border-box;
}
.shop-index .my-swipe .van-swipe-item {
  color: #fff;
  width:3.2rem;
  text-align: center;
  border-radius: 4vw;
  box-sizing: border-box;
}
.shop-index .my-swipe .van-swipe-item img{
  width:100%;
  height:100%;  
  border-radius: 4vw;
}
.shop-index {
  width: 92vw;
  margin: 0 auto;
}
.shop-index .list {
  width: 92vw;
}
.shop-index .list .list-item {
  display: flex;
  margin-top: 30px;
  width: 92vw;
  height: 28.5vw;
}
.shop-index .list .list-item .list-item-left {
  width: 28.5vw;
  height: 28.5vw;
  border: 0.26vw solid #eeeeee;
  flex-shrink: 0;
}
.shop-index .list .list-item .list-item-left img {
  display: inline-block;
  width: 100%;
  height: 100%;
  border-radius: 3vw;
}
.shop-index .list .list-item .list-item-right {
  margin-left: 3vw;
  width: 60.5vw;
  color: red;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  font-size: 4.266vw;
  font-weight: 400;
  color: #111111;
  line-height: 6vw;
  height: 28.5vw;
}
.shop-index .list .list-item .list-item-right .item-right-top {
  width: 60.5vw;
  height: 12vm;
  flex-shrink: 0;
  word-break: break-all;
  height: 20vw;
}

.shop-index .list .list-item .list-item-right .item-right-top {
  width: 60.5vw;
  height: 12vm;
  flex-shrink: 0;
}
</style>
