下拉加载代码

<template>
    <section class="list" id="src">
      <div class="title"><h3>专属SRC</h3><span>厂商发布悬赏,感谢白帽子参与安全保障计划</span></div>
      <div class="card">
        <card v-for="(list,index) in cardList" :key="index" :boxStyle="boxStyle" :paddingStyle="{padding:'0px'}">

          <img v-if="list.logo && list.logo != null && list.logo != ''" :src="list.logo|base64" class="img" @click="routerPush('srcDetails',{companyId:list.companyId})">
          <img v-else src="../../../../static/images/defaultCompany.png" class="img" @click="routerPush('srcDetails',{companyId:list.companyId})">
          <h3 :title="list.companyName">{{list.companyName}}</h3>
          <span>{{list.description}}</span>
          <el-button :disabled="list.warning" :class="['button',{'isDisabled':list.warning}]" @click="routerPush('submit',{companyId:list.companyId,activityId:list.activityId,companyName:list.companyName,flag:'专属SRC'})">提交漏洞</el-button>
        </card>
      </div>
      <div class="manualLoading" v-if="busy"><i v-if="massage === '正在加载'" class="el-icon-loading"></i>{{massage}}</div>
    </section>
</template>
<style lang="scss" scoped>
    .manualLoading {
      text-align: center;
      height: 30px;
      line-height: 30px;
      font-family: PingFangSC-Regular;
      font-size: 16px;
      color: #9C9C9C;
      margin-bottom: 30px;
      i {
          margin-right: 8px;
        }
    }

 
</style>
<script>

export default {

  data() {
    return {
      
      pageData: {
        currentPage: 1,
        pageSize: 12
      },
      total: 0,
      busy: false,
      descName: "createTime",
      flag: '',
      massage: "正在加载",
      cardList: [],
  },
  components: {
    Card,
    paFooter
  },
  created() {
    this.flag = this.des
     this.getListData(this.queryData())
    const _this = this;
    window.onscroll = function() {
      if (
        document.getElementById("src") &&
        _this.scroll() + document.body.offsetHeight >
          document.getElementById("src").offsetHeight &&
        !_this.busy
      ) {
        _this.getListData(_this.queryData());
      }
    };
  },

  methods: {

    queryData() {
      const descName = this.descName;
      const query = {
        page: this.pageData.currentPage,
        rows: this.pageData.pageSize,
        descName: this.descName
      };
      return query;
    },

    getListData(query) {
       console.log(query)
      if (this.busy && query.page !== 1) return;
      this.busy = true;
      this.massage = "正在加载";
      this.api
        .get("activity/srcActivityList", {
          ...query
        })
        .then(res => {
          if (res.data.data.rows.length > 0) {
            // console.log(query.page)
            if(query.page === 1) {
              this.cardList = res.data.data.rows;
            } else {
              const item = res.data.data.rows;
              this.cardList = [...this.cardList, ...item];
            }
            // console.log(this.cardList)
            this.total = res.data.data.total;
            // console.log(this.total)
            this.busy = false;
            this.pageData.currentPage += 1;
            this.footerShow = true;
            if ( this.pageData.currentPage > Math.ceil(this.total / this.pageData.pageSize)) {
              this.busy = true;
              this.massage = "没有更多了";
            }
          } else {
            this.busy = true;
          }
        });
    },
    // 页面被卷去的高度的兼容性封装
    scroll() {
      return (
        window.pageYOffset ||
        document.documentElement.scrollTop ||
        document.body.scrollTop ||
        0
      );
    }
  }
};
</script>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值