import httpRequestApi from '../../../utils/APIClient'; import { formatDate } from '../../../utils/util'; Page({ data: { messageList: [], totalNo: 1, totalSize: 0, index: 1, statusbarobj: { isshowbtn: false, //是否显示按钮 title: "小学语文朗读配音", //标题 }, }, onLoad: function (options) { wx.setNavigationBarTitle({ title: '消息列表' }) this.getMessage(); }, getMessage: function () { console.log(this.data.totalNo) console.log(this.data.index) if (this.data.totalNo < this.data.index) { return; } httpRequestApi.getMessageList(this.data.index, 10).success((res) => { res.data.data.list.forEach(item => { item.gmtCreated = formatDate(item.gmtCreated, 1) this.data.messageList.push(item); }) this.setData({ messageList: this.data.messageList, totalNo: res.data.data.totalNo, index: this.data.index + 1 }) httpRequestApi.refreshMessageStatus().success((res) => { console.log(res) }) }); }, onReachBottom: function () { this.getMessage(); } })