<template>
  <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
    <van-list
      v-model="loading"
      :finished="true"
      finished-text="没有更多了~"
      @load="onLoad"
    >
      <div class="shoplist">
        <div class="list-item" v-for="item in list" :key="item.src">
          <div class="list-item-left">
            <img :src="item.waresPic" alt="" srcset="" />
          </div>
          <div class="list-item-right">
            <div class="item-right-top">
              <span class="info">
                {{ item.waresName }}
              </span>
              {{ item.waresDetail }}
            </div>
            <div class="item-right-bottom">
              <span class="price"><span class="icon"></span>40</span>
              <span class="sold">已售 233</span>
            </div>
          </div>
        </div>
      </div>
    </van-list>
  </van-pull-refresh>
</template>

<script>
import Vue from "vue";
import { PullRefresh, List } from "vant";

Vue.use(PullRefresh);
Vue.use(List);

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

<style scope>
.shoplist {
  width: 92vw;
}

.shoplist .list-item {
  display: flex;
  margin-top: 30px;
  width: 92vw;
  height: 28.5vw;
}
.shoplist .list-item .list-item-left {
  width: 28.5vw;
  height: 28.5vw;
  border: 0.26vw solid #eeeeee;
  flex-shrink: 0;
}
.shoplist .list-item .list-item-left img {
  display: inline-block;
  width: 100%;
  height: 100%;
  border-radius: 3vw;
}
.shoplist .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;
}
.shoplist .list-item .list-item-right .item-right-top {
  flex-shrink: 0;
  word-break: break-all;
  width: 4.53rem;
  height: 1.45rem;
  font-size: 0.32rem;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #111111;
  line-height: 0.45rem;
}

.shoplist .list-item .list-item-right .item-right-top .info {
  font-weight: 500;
}

.shoplist .list-item .list-item-right .item-right-bottom {
  width: 4.53rem;
  height: 0.9rem;
  position: relative;
}
.shoplist .list-item .list-item-right .item-right-bottom .price {
  font-size: 0.4rem;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 500;
  color: #fe9700;
  line-height: 0.56rem;
  position: absolute;
  left: 0.1rem;
  bottom: 0rem;
}
.shoplist .list-item .list-item-right .item-right-bottom .price .icon {
  display: inline-block;
  width: 0.3rem;
  height: 0.3rem;
  background: url("../static/common/a01_jifen@2x.png") no-repeat;
  background-size: cover;
  margin-right: 0.1rem;
}
.shoplist .list-item .list-item-right .item-right-bottom .sold {
  width: 1.16rem;
  height: 0.4rem;
  font-size: 0.28rem;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #bcbcbc;
  line-height: 0.4rem;
  position: absolute;
  right: 0.1rem;
  bottom: 0.03rem;
}
</style>
