Authored by bevishuang

优化我的收藏加载更多

<template>
<LayoutApp :show-back="true" :title="title">
<Scroll :scroll-events="['scroll-end','scroll']"
@scroll-end="fetchList"
@scroll-end="fetchList(isMore)"
v-if="favoriteProductList.list.length"
>
<ProductList :list="favoriteProductList.list"></ProductList>
... ... @@ -43,10 +43,10 @@ export default {
this.fetchFavoriteList();
},
methods: {
...mapActions(['fetchFavoriteList','isMore']),
...mapActions(['fetchFavoriteList']),
async fetchList() {
if(isMore){
async fetchList(isMore) {
if(this.isMore){
await this.fetchFavoriteList();
}
... ... @@ -63,7 +63,7 @@ export default {
},
computed: {
...mapState(['favoriteProductList']),
...mapState(['favoriteProductList','isMore']),
},
};
</script>
... ...
... ... @@ -70,11 +70,11 @@ export default {
}
},
fetchList(){
console.log('fetchList:'+this.isMore)
// console.log('fetchList:'+this.isMore)
if (!this.isMore) {
return;
}
console.log('fetchList:'+this.noMore)
// console.log('fetchList:'+this.noMore)
this.fetchNoticeList().then(res => {
this.$nextTick(() => {
this.$refs.scroll.forceUpdate(true);
... ...
... ... @@ -13,22 +13,27 @@ export default function() {
favoriteProductList: {
list:[]
},
isMore: true,
isMore: false,
},
mutations: {
addList(state, { data }) {
console.log(data)
if(data && data.product_list){
// data.product_list.
let { page, product_list = [], pageTotal } = data;
let isShowEmpty = page === 1 && product_list === 0;
let { page, product_list = [], page_total } = data;
// let isShowEmpty = page === 1 && product_list === 0;
// console.log("isShowEmpty:"+isShowEmpty)
// state.isShowEmpty = isShowEmpty
if(pageTotal > page){
if(page_total > page){
console.log('======'+page_total+"///"+page)
state.isMore = true;
state.pageTotal = page_total;
state.page = page + 1;
console.log(state)
}else {
state.isMore = false;
}
state.pageTotal = pageTotal;
state.page = page + 1;
let list = state.favoriteProductList.list.concat(product_list);
Vue.set(state.favoriteProductList, "list", list);
... ...
... ... @@ -79,6 +79,7 @@ module.exports = {
ufo: true,
api: 'ufo.users.noticeList',
params: {},
auth: true,
},
'/api/ufo/home/favoriteProduct': {
ufo: true,
... ...