vue mint-ui 上拉加载,下拉刷新

1.html部分

<div class="detail" ref="wrapper">
  <mt-loadmore :top-method="loadTop" :bottom-method="loadBottom" @bottom-status-change="handleBottomChange"
               ref="loadmore" :bottom-all-loaded="allLoaded" :auto-fill="false">
    <ul>
      <li v-for="(item,index) in projectList" @click="go(item,index)">
        <div class="wrap">

          <div class="img">
            <img :src="item.pictures" alt="" :onerror="defaultImg">
            <div v-if="item.topStatus===1" class="zhiding"></div>
          </div>
          <div class="msg">
            <div class="look"><span></span>{{item.favorite_count}}</div>
            <h4>{{item.project_name}}</h4>
            <p>{{item.address}}</p>
            <p>建筑面积:{{item.acreage}}㎡</p>
            <div class="price">销售均价:<span>{{item.price}}元/天/㎡</span></div>
            <div class="tags" v-if="item.tag"><span v-if="index1 < 3" v-for="(item1,index1) in item.tag">{{item1}}</span></div>
          </div>
        </div>
      </li>
    </ul>
    <div class="noInner" v-if="more">暂无更多内容喽!</div>
  </mt-loadmore>
</div>

2.css部分

.detail{
  width: 7.5rem;
  //overflow: scroll;
  background: #fff;
  ul{
    width: 7.5rem;
    overflow: hidden;
    li{
      -webkit-tap-highlight-color: rgba(0,0,0,0);
      display: flex;
      margin: .3rem;
      border-bottom: 0.01rem solid #eaeaea;
      &.cur{
        h4{
          color: #aaa!important;
        }
      }
      .select{
        width:0.45rem;
        height: 1.62rem;
        margin-right: .2rem;
        position: relative;
        .check{
          position: absolute;
          left: 50%;
          top: 50%;
          margin-left: -.2rem;
          margin-top: -.2rem;
          width: .45rem;
          height: .45rem;
          background: url("../../../static/images/common/select.png") no-repeat #fff;
          background-size: .4rem .4rem;
          &.cur{
            background-image: url("../../../static/images/common/select-bg.png");
          }
        }
        input{
          position: absolute;
          left: 50%;
          top: 50%;
          margin-left: -.2rem;
          margin-top: -.2rem;
          width: .4rem;
          height: .4rem;
          opacity: 0;
        }
      }
      .wrap{
        display: flex;
        height: 2.1rem;
        padding-bottom: .3rem;
        position: relative;

        .img{
          width: 2.78rem;
          margin-right:.3rem;
          position: relative;
          img{
            width: 2.78rem;
            height: 2.1rem;
          }
          .zhiding{
            position: absolute;
            left: 0;
            top: 0;
            width: 0.74rem;
            height: 0.34rem;
            background-image: url("../../../static/images/common/zhiding.png");
            -webkit-background-size: .74rem .34rem;
            background-size: .74rem .34rem;
          }
        }
        .msg{
          width: 4.74rem;
          position: relative;
          .look{
            position: absolute;
            width: 1rem;
            right: .5rem;
            top: .45rem;
            font-size: .28rem;
            color:#aaa;
            span{
              display: inline-block;
              width: .28rem;
              height: .18rem;
              margin-right: .1rem;
              background: url("../../../static/images/common/look.png");
              -webkit-background-size: 100% 100%;
              background-size: 100% 100%;
            }
          }
          .price{
            font-size: .28rem;
            margin-bottom: .1rem;
            span{
              margin-left: .05rem;
              font-size: .28rem;
              font-weight: normal;
              color: #e8584f;
            }
          }
          h4{
            width: 3.8rem;
            height: .32rem;
            overflow: hidden;
            text-overflow:ellipsis;
            white-space: nowrap;
            font-size: .32rem;
            color: #333;
            font-weight:bold;
            margin-bottom: 0.15rem;
          }
          p{
            font-size: .28rem;
            height: .24rem;
            color: #aaa;
            margin-bottom: 0.2rem;
          }
          .tags{
            span{
              display: inline-block;
              padding: 0rem .08rem;
              line-height: .36rem;
              text-align: center;
              background: #E5F1FF;
              color: #64aaff;
              font-size: .23rem;
              margin-right: .12rem;
            }
          }
        }

      }
    }
  }
  .noInner{
    text-align: center;
    font-size: .26rem;
    color: #898989;
  }
}

3.js部分

loadTop(){//下拉刷新
  $(".shoplist ul li").removeClass("cur");
  var that = this;
  var data = {
    cityId: sessionStorage.cityId || 110100, //所属城市【必传】
    pageSize: this.pageSize, //每页数据量【必传】
    pageNum: this.pageNum, //页码从1开始【必传】
    projectType: 1, //项目类型,1是销售,2是招商【必传】
    projectDistrictId: this.regionSelect, //区域筛选
    houseType: this.typeSelect, //建筑类型筛选
    beginPrice: this.beginpriceSelect, //价格段筛选
    endPrice: this.endpriceSelect, //价格段筛选
    acreageRangeValue: this.areaSelect, //面积段筛选
    projectName: this.search //项目名称筛选
  }
  setTimeout(function () {
    that.$http({
      url: that.changeData() + '/project/list',
      method: "post",
      params: data
    }).then(function(res){
      console.log(res)
      that.projectList = res.data.projectList;
      that.$refs.loadmore.onTopLoaded();
    }.bind(this)).catch(function(err){
      console.log("商店列表页面错误:",err)
    })
  },1000)
},
loadBottom() {//上拉加载
  var that = this;
  this.pageNum1++;
  that.allLoaded = false;
  var data = {
    cityId: sessionStorage.cityId || 110100, //所属城市【必传】
    pageSize: this.pageSize, //每页数据量【必传】
    pageNum: this.pageNum1, //页码从1开始【必传】
    projectType: 1, //项目类型,1是销售,2是招商【必传】
    projectDistrictId: this.regionSelect, //区域筛选
    houseType: this.typeSelect, //建筑类型筛选
    beginPrice: this.beginpriceSelect, //价格段筛选
    endPrice: this.endpriceSelect, //价格段筛选
    acreageRangeValue: this.areaSelect, //面积段筛选
    projectName: this.search //项目名称筛选
  }
  setTimeout(function () {
    that.$http({
      url: that.changeData() + '/project/list',
      method: "post",
      params: data
    }).then(function(res){
      console.log(res)
      that.projectList = that.projectList.concat(res.data.projectList)
      if(res.data.projectList <= 0){
        that.allLoaded = true;
      }
      that.$refs.loadmore.onBottomLoaded();
    }.bind(this)).catch(function(err){
      console.log("商店列表页面错误:",err)
    })
  },1000)
},
handleBottomChange(){
  var that = this;
  if(this.allLoaded == true){
    this.more = true;
    setTimeout(function () {
      that.more = false;
    },2000)
  }
},
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值