104 lines
3.1 KiB
JavaScript
104 lines
3.1 KiB
JavaScript
var infiniteScroll = {
|
|
/*template: `
|
|
<section class="cha_time">
|
|
<button class="btn btn-blue time_c" @click="loadMore(false)">查询</button>
|
|
|
|
<table class="table">
|
|
<tbody>
|
|
<tr v-for="(item,i) in list">
|
|
<td class="text-center">
|
|
<img :src="item.avatar" class="header">
|
|
</td>
|
|
<td>
|
|
<p>{{item.playerid}}</p>
|
|
<p>{{item.name}}</p>
|
|
<p>{{item.time.substr(5,11)}}</p>
|
|
</td>
|
|
<td class="num">{{item.amount}}</td>
|
|
</tr>
|
|
</tbody>
|
|
<tfoot v-show="loadStateMsg"><tr class="text-center"><td colspan="3">{{loadStateMsg}}</td></tr></tfoot>
|
|
</table>
|
|
</section>
|
|
`,*/
|
|
template: '<section class="cha_time"><button class="btn btn-blue time_c" @click="loadMore(false)">查询</button><table class="table"><tbody><tr v-for="(item,i) in list"><td class="text-center"><img :src="item.avatar" class="header"></td><td><p>{{item.playerid}}</p><p>{{item.name}}</p><p>{{item.time.substr(5,11)}}</p></td><td class="num">{{item.amount}}</td></tr></tbody><tfoot v-show="loadStateMsg"><tr class="text-center"><td colspan="3">{{loadStateMsg}}</td></tr></tfoot></table></section>',
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
} |