var infiniteScroll = { /*template: `

{{item.playerid}}

{{item.name}}

{{item.time.substr(5,11)}}

{{item.amount}}
{{loadStateMsg}}
`,*/ template: '

{{item.playerid}}

{{item.name}}

{{item.time.substr(5,11)}}

{{item.amount}}
{{loadStateMsg}}
', data: function () { return { loadState: 1, // 0-禁止加载 1-可以加载,加载暂停 2-加载中 3-加载异常 loadStateMsg: '', pageIndex: 0, // 页码 wxInfo: {}, list: [] } }, props: { func: String, startTime: String, endTime: String, params: Object, wxInfo: Object, userInfo: Object }, created: function () { var that = this; var $doc = $(document); var $win = $(window); window.addEventListener('scroll', function () { var docHeight = $doc.height(); var winHeight = $win.height(); var scrHeight = $doc.scrollTop(); //console.log(docHeight, winHeight, scrHeight); if (( docHeight > winHeight ) && scrHeight >= (docHeight - winHeight)) { that.loadMore(true); } }) }, methods: { loadMore: function (flag) { if (!flag || this.loadState === 1) { this.loadState = 2; this.loadStateMsg = '加载中...'; if (!flag) this.list = []; setTimeout(function () { if (flag) this.pageIndex++; else this.pageIndex = 1; this.loadState = 2; var that = this; $.api( that.func, { agentid: that.params.agentid, channelid: that.params.channelid, openid: that.wxInfo.openid, begintime: that.startTime, endtime: that.endTime, page_index: that.pageIndex }, function (res) { var listLength = res.detail.length; if (listLength > 0) { that.list = that.list.concat(res.detail); that.loadState = 1; } if (listLength < parseInt(res.page_size)) { that.loadState = 3; that.loadStateMsg = '暂无记录'; } } ); }, 2000); } } } }