1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- const { Tab } = require('../../assets/libs/zanui/index');
- var app = getApp();
- Page(Object.assign({}, Tab, {
- data: {
- bannerList: [],
- archivesList: [],
- loading: false,
- nodata: false,
- nomore: false,
- tab: {
- list: [],
- selectedId: '0',
- scroll: true,
- height: 44
- },
- },
- //模型的ID,这里使用新闻的模型
- model: 1,
- channel: 0,
- page: 1,
- onLoad: function (option) {
- console.log(option);
- var that = this;
- this.channel = 0;
- this.page = 1;
- this.setData({ ["tab.list"]: app.globalData.newsTabList });
- this.loadArchives();
- },
- onPullDownRefresh: function () {
- this.setData({ nodata: false, nomore: false });
- this.page = 1;
- this.loadArchives(function () {
- wx.stopPullDownRefresh();
- });
- },
- onReachBottom: function () {
- var that = this;
- this.loadArchives(function (data) {
- if (data.archivesList.length == 0) {
- app.info("暂无更多数据");
- }
- });
- },
- loadArchives: function (cb) {
- var that = this;
- if (that.data.nomore == true || that.data.loading == true) {
- return;
- }
- this.setData({ loading: true });
- app.request('/addons/cms/wxapp.archives/index', { model: this.model, channel: this.channel, page: this.page }, function (data, ret) {
- that.setData({
- loading: false,
- nodata: that.page == 1 && data.archivesList.length == 0 ? true : false,
- nomore: that.page > 1 && data.archivesList.length == 0 ? true : false,
- archivesList: that.page > 1 ? that.data.archivesList.concat(data.archivesList) : data.archivesList,
- });
- that.page++;
- typeof cb == 'function' && cb(data);
- }, function (data, ret) {
- app.error(ret.msg);
- });
- },
- handleZanTabChange(e) {
- var componentId = e.componentId;
- var selectedId = e.selectedId;
- this.channel = selectedId;
- this.page = 1;
- this.setData({
- nodata: false,
- nomore: false,
- [`${componentId}.selectedId`]: selectedId
- });
- wx.pageScrollTo({ scrollTop: 0 });
- this.loadArchives();
- }
- }))
|