|
|
require('activity/store-home.page.css');
|
|
|
|
|
|
import $ from 'yoho-jquery';
|
|
|
import Page from 'yoho-page';
|
|
|
import historyRender from 'activity/store-home/history.hbs';
|
|
|
|
|
|
class History extends Page {
|
|
|
constructor() {
|
|
|
super();
|
|
|
this.page = 1;
|
|
|
this.loading = false;
|
|
|
this.selector = {
|
|
|
$hisUl: $('.his-ul')
|
|
|
};
|
|
|
this.view = {
|
|
|
historyRender
|
|
|
};
|
|
|
this.init();
|
|
|
}
|
|
|
|
|
|
init() {
|
|
|
$(window).scroll(() => {
|
|
|
window.requestAnimationFrame(this.scrollHandler.bind(this));
|
|
|
});
|
|
|
}
|
|
|
|
|
|
scrollHandler() {
|
|
|
if (($(window).scrollTop() + $(window).height() >= $(document).height() * 0.8)) {
|
|
|
this.doMore();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
doMore() {
|
|
|
if (!this.end && !this.loading) {
|
|
|
this.page++;
|
|
|
this.moreList(this.page);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
moreList() {
|
|
|
this.loading = true;
|
|
|
this.ajax({
|
|
|
url: '/activity/store-home/moreHistory',
|
|
|
data: {
|
|
|
page: this.page,
|
|
|
shopType: window.queryString.shopType
|
|
|
},
|
|
|
}).then(result => {
|
|
|
if (result && result.list.length > 0) {
|
|
|
this.selector.$hisUl.append(this.view.historyRender(result));
|
|
|
this.loading = false;
|
|
|
} else {
|
|
|
this.end = true;
|
|
|
}
|
|
|
}).catch(error => {
|
|
|
console.error(error);
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$(() => {
|
|
|
new History();
|
|
|
}); |
...
|
...
|
|