Authored by bevishuang

优化我的收藏加载更多

1 <template> 1 <template>
2 <LayoutApp :show-back="true" :title="title"> 2 <LayoutApp :show-back="true" :title="title">
3 <Scroll :scroll-events="['scroll-end','scroll']" 3 <Scroll :scroll-events="['scroll-end','scroll']"
4 - @scroll-end="fetchList" 4 + @scroll-end="fetchList(isMore)"
5 v-if="favoriteProductList.list.length" 5 v-if="favoriteProductList.list.length"
6 > 6 >
7 <ProductList :list="favoriteProductList.list"></ProductList> 7 <ProductList :list="favoriteProductList.list"></ProductList>
@@ -43,10 +43,10 @@ export default { @@ -43,10 +43,10 @@ export default {
43 this.fetchFavoriteList(); 43 this.fetchFavoriteList();
44 }, 44 },
45 methods: { 45 methods: {
46 - ...mapActions(['fetchFavoriteList','isMore']), 46 + ...mapActions(['fetchFavoriteList']),
47 47
48 - async fetchList() {  
49 - if(isMore){ 48 + async fetchList(isMore) {
  49 + if(this.isMore){
50 await this.fetchFavoriteList(); 50 await this.fetchFavoriteList();
51 } 51 }
52 52
@@ -63,7 +63,7 @@ export default { @@ -63,7 +63,7 @@ export default {
63 }, 63 },
64 64
65 computed: { 65 computed: {
66 - ...mapState(['favoriteProductList']), 66 + ...mapState(['favoriteProductList','isMore']),
67 }, 67 },
68 }; 68 };
69 </script> 69 </script>
@@ -70,11 +70,11 @@ export default { @@ -70,11 +70,11 @@ export default {
70 } 70 }
71 }, 71 },
72 fetchList(){ 72 fetchList(){
73 - console.log('fetchList:'+this.isMore) 73 + // console.log('fetchList:'+this.isMore)
74 if (!this.isMore) { 74 if (!this.isMore) {
75 return; 75 return;
76 } 76 }
77 - console.log('fetchList:'+this.noMore) 77 + // console.log('fetchList:'+this.noMore)
78 this.fetchNoticeList().then(res => { 78 this.fetchNoticeList().then(res => {
79 this.$nextTick(() => { 79 this.$nextTick(() => {
80 this.$refs.scroll.forceUpdate(true); 80 this.$refs.scroll.forceUpdate(true);
@@ -13,22 +13,27 @@ export default function() { @@ -13,22 +13,27 @@ export default function() {
13 favoriteProductList: { 13 favoriteProductList: {
14 list:[] 14 list:[]
15 }, 15 },
16 - isMore: true, 16 + isMore: false,
17 }, 17 },
18 mutations: { 18 mutations: {
19 addList(state, { data }) { 19 addList(state, { data }) {
20 console.log(data) 20 console.log(data)
21 if(data && data.product_list){ 21 if(data && data.product_list){
22 // data.product_list. 22 // data.product_list.
23 - let { page, product_list = [], pageTotal } = data;  
24 - let isShowEmpty = page === 1 && product_list === 0; 23 + let { page, product_list = [], page_total } = data;
  24 + // let isShowEmpty = page === 1 && product_list === 0;
25 // console.log("isShowEmpty:"+isShowEmpty) 25 // console.log("isShowEmpty:"+isShowEmpty)
26 // state.isShowEmpty = isShowEmpty 26 // state.isShowEmpty = isShowEmpty
27 - if(pageTotal > page){ 27 + if(page_total > page){
  28 + console.log('======'+page_total+"///"+page)
28 state.isMore = true; 29 state.isMore = true;
  30 + state.pageTotal = page_total;
  31 + state.page = page + 1;
  32 + console.log(state)
  33 + }else {
  34 + state.isMore = false;
29 } 35 }
30 - state.pageTotal = pageTotal;  
31 - state.page = page + 1; 36 +
32 37
33 let list = state.favoriteProductList.list.concat(product_list); 38 let list = state.favoriteProductList.list.concat(product_list);
34 Vue.set(state.favoriteProductList, "list", list); 39 Vue.set(state.favoriteProductList, "list", list);
@@ -79,6 +79,7 @@ module.exports = { @@ -79,6 +79,7 @@ module.exports = {
79 ufo: true, 79 ufo: true,
80 api: 'ufo.users.noticeList', 80 api: 'ufo.users.noticeList',
81 params: {}, 81 params: {},
  82 + auth: true,
82 }, 83 },
83 '/api/ufo/home/favoriteProduct': { 84 '/api/ufo/home/favoriteProduct': {
84 ufo: true, 85 ufo: true,