Administrator
2021-06-19 f6bb88e1f21de51f8d39de6fe5956053fb5a62ca
pages/article/article.vue
@@ -1,9 +1,9 @@
<template>
   <view class="advisory-big">
         <!-- 顶部下拉刷新 -->
         <view v-show="isFlash">
         <!-- <view v-show="isFlash">
            <uni-load-more :status="loadStatus" ></uni-load-more>
         </view>
         </view> -->
         <view  v-for="i in data" class="advisory-model" @click="goDetail(i)">
            <view class="advisory-left">
               <view class="advisory-title-top">
@@ -20,9 +20,9 @@
            
         </view>
         <!-- loading加载提示处 -->
         <view v-show="isLoadMore">
         <!-- <view v-show="isLoadMore">
            <uni-load-more :status="loadStatus" ></uni-load-more>
          </view>
          </view> -->
   </view>
</template>
@@ -34,7 +34,7 @@
            pathUrl:"http://s16s652780.51mypc.cn/api/blade-jfpts",
            page:1,
            pagesize:10,
            loadStatus:'loading',  //加载样式:more-加载前样式,loading-加载中样式,nomore-没有数据样式
            // loadStatus:'loading',  //加载样式:more-加载前样式,loading-加载中样式,nomore-没有数据样式
            isLoadMore:false,  //是否加载中
            isFlash:false,//是否刷新
            data:[]
@@ -45,23 +45,26 @@
      },
      //上拉加载更多
      onReachBottom(){  //上拉触底函数
         console.log("上拉了")
         if(!this.isLoadMore){  //此处判断,上锁,防止重复请求
            this.isLoadMore=true
            // this.isLoadMore=true
            this.page+=1
            this.getArtcilePageList()
            this.getArtcilePageList(2)
         }
      },
      //下拉刷新
      onPullDownRefresh() {
         // console.log("上拉了!....");
         // console.log("下拉了!....");
         if(!this.isFlash){  //此处判断,上锁,防止重复请求
            this.isFlash=true;
            // this.isFlash=true;
            this.page =1;
            this.getArtcilePageList();
            this.getArtcilePageList(1);
            uni.stopPullDownRefresh();
         }
      },
      onLoad() {
          this.getArtcilePageList();
          this.getArtcilePageList(1);
         uni.stopPullDownRefresh();
      },
      methods:{
         //去跳转详情页面
@@ -88,7 +91,7 @@
         },
         
         //获取资讯信息
         getArtcilePageList(){
         getArtcilePageList(tab){
            var that = this;
            uni.request({
               url: that.pathUrl+'/article/article/page',
@@ -100,25 +103,30 @@
               success: (res) => {
                  if(res.data.code==200){
                     if(res.data.data.records){
                        //如果总数小于pageSize,不做其他操作
                        if(res.data.data.total<this.pagesize){
                        if(tab==1){
                           that.data = res.data.data.records;
                        }else{
                           if(res.data.data.records.length<this.pagesize){
                              //如果数量小于分页数量,则为最后一页
                              this.isLoadMore=true;
                              this.loadStatus='nomore';
                           //如果总数小于pageSize,不做其他操作
                           if(res.data.data.total<this.pagesize){
                              that.data = res.data.data.records;
                           }else{
                              this.isLoadMore=false
                              if(res.data.data.records.length<this.pagesize){
                                 //如果数量小于分页数量,则为最后一页
                                 // this.isLoadMore=true;
                                 // this.loadStatus='nomore';
                              }else{
                                 // this.isLoadMore=false
                              }
                              res.data.data.records.forEach((item)=>{
                                 that.data.push(item);
                              })
                           }
                           res.data.data.records.forEach((item)=>{
                              that.data.push(item);
                           })
                        }
                     }else{
                        this.isLoadMore=true;
                        this.loadStatus='nomore';
                        // this.isLoadMore=true;
                        // this.loadStatus='nomore';
                     }
                     uni.stopPullDownRefresh();
                  }
               }
            });