json 

{

"enablePullDownRefresh": true
}
 
 
var app = getApp();
Page({
  data: {
    page: 1, //从第二页开始加载 
    page_size: 10, //每页加载十个 
    release: '',
    isShowLoadmore: false, //正在加载 
    isShowNoDatasTips: false, //没有更多数据
    endloading: false
  },
  onPullDownRefresh() {
    var that = this;
    wx.showLoading({
      title: '下拉刷新',
    });
    wx.request({
      url: 'http://www.guojiayikao.com/weixin/more.php?page='+1, 
      header: {},
      method: 'GET',
      dataType: 'json',
      responseType: 'text',
      success: function (res) {
        if (res.data.status == 1) {
          var datas = res.data.data;
          that.setData({
            datas: datas,
            page:1,
            isShowNoDatasTips:false //底部更多数据
          })
          wx.hideLoading();
        }
      },
      fail: function (res) { },
      complete: function (res) { },
    })
  },
  onLoad: function(options) {
    wx.setNavigationBarTitle({
    title: "文章详情"
    })
    var that = this
    var id = options.id;
     wx.request({
      url: 'http://www.guojiayikao.com/weixin/more.php',
      data: { page: this.data.page},
      header: {},
      method: 'GET',
      dataType: 'json',
      responseType: 'text',
      success: function(res) {
        if (res.data.status == 1) {
          var datas = res.data.data; 
          that.setData({
            datas: datas
          })
        }
      },
      fail: function(res) {},
      complete: function(res) {},
    })
  }, 
  onReachBottom: function() {
    var that = this;
    wx.showLoading({
      title: '玩命加载中',
    });
    // 页数+1
    that.data.page = that.data.page + 1;
    wx.request({
      url: 'http://www.guojiayikao.com/weixin/more.php?page='+that.data.page, 
      header: {},
      method: 'GET',
      dataType: 'json',
      responseType: 'text',
      success: function (res) {
        if (res.data.status == 1) {
          var moreData = that.data.datas;
          console.log(that.data.datas)
          for(var i=0;i<res.data.data.length;i++){
            moreData.push(res.data.data[i])
          }
          if(!res.data.data.length){
            that.setData({
              isShowNoDatasTips:true
            })
          }
          that.setData({
            datas: moreData
          })
          // 隐藏加载框
          wx.hideLoading();
        }
      },
      fail: function (res) { },
      complete: function (res) { },
    })
  }

})

 

 <view class='release_list'>
      <view class="title">文章列表</view>
      <view class='shoppcall comment'>
           <view class='publish' wx:for="{{datas}}" bindtap='tiao'> 
           <navigator url="/pages/listDetail/listDetail?id={{item.contentid}}">
            <view class='publish_list'>
                <view wx:if="{{item.img_count == 0}}" class="no_image" >
                  <view>
                    <text class="circle"></text>
                    <text class='publish_list_item' class="count_">{{item.title}}</text> 
                  </view>
                  <view>
                    <text class='redtree_text'style="width:100%;display:block; ">{{item.inputtime}}</text>
                  </view>
                </view>   
                <view class="list" wx:elif="{{item.img_count == 1}}">
                  <view>
                    <view class="top">{{item.title}}</view>
                    <view class="bottom" style="width:100%;display:block; ">{{item.inputtime}}</view>
                  </view>
                  <view class="image">
                    <image src="{{item.img[0]}}"></image>
                  </view>
                </view>
                 
                <view class="list-img" wx:elif="{{item.img_count == 3}}">
                  <view class="img-block">
                    <image src="{{item.img[0]}}"></image>
                    <text class="abtit">{{item.title}}</text>
                    <text class="abcont"   style="width:100%;display:block;border:1px solid red ">时间:{{item.inputtime}}</text>
                  </view>
                  <view class="img-block">
                    <image src="{{item.img[1]}}"></image>
                    <text class="abtit">{{item.title}}</text>
                    <text class="abcont">时间:{{item.inputtime}}</text>
                  </view>
                  <view class="img-block">
                    <image src="{{item.img[2]}}"></image>
                    <text class="abtit">{{item.title}}</text>
                    <text class="abcont">时间:{{item.inputtime}}</text>
                  </view>
                </view>  
            </view>
            </navigator>
           </view>
      </view>    
      <view  class='Nocomment' wx:if='{{datas.length == 0}}'>
         暂无数据
       </view>
    </view> 
    <view class="loadmore loadmore_line" hidden='{{!isShowNoDatasTips}}'>
      <view class="loadmore_tips">没有更多数据</view>
     </view>

 

 

 
posted on 2020-12-01 19:11  心意如水hucuie22  阅读(184)  评论(1编辑  收藏  举报