zoukankan      html  css  js  c++  java
  • 小程序加载更多,上拉刷新

    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="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="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="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>

     

     
  • 相关阅读:
    DP大作战—状态压缩dp
    DP大作战—组合背包
    DP大作战——多重背包
    单链表的使用——计算多项式加法
    单链表逆置
    钢条切割问题
    哈夫曼树及解码
    双“11”的抉择
    矩阵链相乘助教版代码
    abs()函数的返回值问题
  • 原文地址:https://www.cnblogs.com/xzhce/p/14070159.html
Copyright © 2011-2022 走看看