diff --git a/pages/agent/ability-list/index.js b/pages/agent/ability-list/index.js index 0881cea..e89f1de 100644 --- a/pages/agent/ability-list/index.js +++ b/pages/agent/ability-list/index.js @@ -1,17 +1,58 @@ // pages/message/detail/index.js import Scene from '../../index/scene' +import { getActivityList } from "../../../api/ztb" +const app = getApp() Scene({ /** * 页面的初始数据 */ data: { - + height: app.globalData.fragmentHeight, + kg: app.globalData.kg, + loading: true, + requesting: false, + finished: false, + orderList: [], + form: { + pageNum: 1 + } }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + this.setData({ height: app.globalData.fragmentHeight }) + this.fetchPapersList() + }, + onRefreshList: function () { + if (this.data.requesting) { + return + } + this.setData({ orderList: [], ['form.pageNum']: 1, loading: true, finished: false }) + this.fetchPapersList() + }, + // 获取特价列表 + fetchPapersList: function () { + if (this.data.requesting || this.data.finished) { + return + } + this.data.requesting = true + getActivityList(this.data.form).then(result => { + if (result.data.records.length) { + var respList = result.data.records + let nowList = `orderList[${this.data.orderList.length}]` + var num = result.data.current + var finished = result.data.current >= result.data.pages + this.setData({ [nowList]: respList, ['form.pageNum']: (num + 1), finished, requesting: false, loading: false }) + } else { + this.setData({ requesting: false, finished: true, loading: false }) + } + }).catch(err => { + this.setData({ requesting: false, finished: true, loading: false }) + }).finally(() => { + this.refresh = this.refresh || this.selectComponent('#refresh') + this.refresh.setRefresh(false) + }) } }) \ No newline at end of file diff --git a/pages/agent/ability-list/index.json b/pages/agent/ability-list/index.json index 19bbcd2..40d9565 100644 --- a/pages/agent/ability-list/index.json +++ b/pages/agent/ability-list/index.json @@ -1,5 +1,9 @@ { "usingComponents": { + "refresh-view": "/components/refresh-view/index", + "van-divider": "/components/divider/index", + "van-loading": "/components/loading/index", + "ability-item": "/pages/agent/ability-item/index", "notification": "/pages/message/notification/index" } } \ No newline at end of file diff --git a/pages/agent/ability-list/index.wxml b/pages/agent/ability-list/index.wxml index 79f99dd..2daf532 100644 --- a/pages/agent/ability-list/index.wxml +++ b/pages/agent/ability-list/index.wxml @@ -3,4 +3,25 @@ 消息情况 + + + + + + + {{loading? '正在加载' : '暂无数据'}} + + + + + + + + + + + {{finished?'到底啦~':'加载中...'}} + + +