scroll-view 위로 끌 어 올 리 기(tab 여러 페이지 데이터 로 딩 전환)

2240 단어 api
원본 링크:http://www.xiaoshu168.com/wxapplet/121.html
var app = getApp();
const _JulijiaUrl = require('../../utils/baseurl');
const requestUtil = require('../../utils/httpHelper');
var GetList = function (that) {
  var page = that.data.page;
  var p = page[that.data.currentTab];
  var typeid = that.data.typedata[that.data.currentTab].id;
  requestUtil.httpGet(_JulijiaUrl.julijia_newslistpage, { page: p, typeid: typeid }, function (res) {
    var pagelist = that.data.listdatat;
    for (var i = 0; i < res.length; i++) 
    {
      pagelist[that.data.currentTab].data.push(res[i]);
    }  
    p++;
    page[that.data.currentTab] = p;
    that.setData({
      listdatat: pagelist,
      page: page
    });
  });
}  


Page({
  data: {
    /** 
        *      
        */
    winWidth: 0,
    winHeight: 0,
    // tab    
    currentTab: 0,
    typedata:'',
    listdatat:'',
    page:[],
    typeid:'',
  },
  onLoad: function () {
    var that = this;


    /** 
     *        
     */
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          winWidth: res.windowWidth,
          winHeight: res.windowHeight
        });
      }
    });
    
    /**
     *     
     */
    requestUtil.httpGet(_JulijiaUrl.julijia_newslist, {}, function (res) {
      /** 
       *       
       */
      var page = that.data.page;
      for (var p = 0; p < res.typeData.length; p++) {
        page.push(2);
      }
      that.setData({
        typedata: res.typeData,
        listdatat: res.listDta,
        typeid: res.typeData[0].id
      });
    });
    
  },
  /** 
     *     tab 
     */
  bindChange: function (e) {
    var that = this;
    that.setData({ currentTab: e.detail.current,
      typeid: e.target.id
    });
  },
  /** 
   *   tab   
   */
  swichNav: function (e) {


    var that = this;
    if (this.data.currentTab === e.target.dataset.current) {
      return false;
    } else {
      that.setData({
        currentTab: e.target.dataset.current,
      });
    }
    that.setData({
      typeid: e.target.dataset.id
    });
  },
  /** 
   *        
   */
  bindDownLoad:function(e) {
    var that = this;
    GetList(that);
  },
});

좋은 웹페이지 즐겨찾기