myshoucang.vue 1.9 KB
<template>
  <div class="container">
 <div class="nodata" v-if="tiezilist.length == 0">暂无数据</div>
    <div class="mycollectlist" v-else>
      <van-list
        v-model="loading"
        :finished="finished"
        finished-text="没有更多了"
        @load="onLoad"
      >
        <mytiezi :tiezilist="tiezilist" :showpull="showpull" :fenlei="fenlei" />
      </van-list>
     
    </div>

  </div>
  
</template>

<script>
import mytiezi from "@/components/mytiezi.vue";
export default {
 components: {
    mytiezi
  },
  data(){
    return{
      page:1,
      tiezilist: [],
      showpull: true,
      loading: false,
      finished: false,
    }
  },
  created(){
    this.getmycollect()
  },
  methods:{
    onLoad() {
      // 异步更新数据
      // setTimeout 仅做示例,真实场景中一般为 ajax 请求
      setTimeout(() => {
        let newpage = this.page;
        newpage++;
        this.page = newpage;
        this.getmycollect()
        // 加载状态结束
        this.loading = false;
        // 数据全部加载完成
        if (this.showpull == false) {
          this.finished = true;
        }
      }, 1000);
    },
      // 获取我的收藏
    getmycollect() {
      console.log(347874837)
      let that = this;
      var url = "/api/forum/get_my_collect";
      var params = {
        page: that.page,
        pageNum: 10
      };
      console.log("参数", params);
      that.$axios
        .post(url, params)
        .then(res => {
          console.log(res);
          that.tiezilist = that.tiezilist.concat(res.data);
          if (that.page > 1) {
            if (res.data.length == 0) {
              that.showpull = false;
            }
          }
        })
        .catch(err => {
          console.log(err);
        });
    },
  }
}
</script>

<style>

.nodata {
  color: #999;
  font-size: 0.28rem;
  text-align: center;
  margin-top: 1.5rem;
}

</style>