favorite.vue
2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<template>
<LayoutApp :show-back="true" :title="title" class="favorite-wrapper">
<LayoutScroll
ref="scrolllist"
@pulling-up="fetchList(isMore)"
v-if="favoriteProductList.list.length"
class="fav-scroll-bg"
>
<ProductList :list="favoriteProductList.list"></ProductList>
</LayoutScroll>
<!-- <empty-list v-show="!isShowEmpty" /> -->
<UfoNoItem class="empty" :tip="`暂无数据`" v-else></UfoNoItem>
</LayoutApp>
</template>
<script>
import ProductList from "../../list/components/productList";
import EmptyList from "../../order/order-list/components/empty";
import UfoNoItem from "../../../components/ufo-no-item";
import { Scroll } from "cube-ui";
import { createNamespacedHelpers } from "vuex";
const { mapState, mapActions } = createNamespacedHelpers("home/favorite");
export default {
name: "list",
components: {
ProductList,
Scroll,
EmptyList,
UfoNoItem
},
data() {
return {
scrollToY: -200,
scrollToTime: 700,
scrollToEasing: "bounce",
scrollToEasingOptions: [
{
text: "bounce",
value: "bounce"
},
{
text: "swipe",
value: "swipe"
},
{
text: "swipeBounce",
value: "swipeBounce"
}
],
title: "我的收藏",
scrollOptions: {
bounce: {
top: false
},
pullUpLoad: true
},
fixed: false
};
},
// mounted() {
// this.fetchFavoriteList();
// },
activated() {
let params = {
isReset: true
};
this.fetchFavoriteList({ isReset: true });
// this.scrollToTop();
},
methods: {
...mapActions(["fetchFavoriteList"]),
scrollToTop() {
// let height = this.$refs.scroll.scrollHeight
console.log(this.$refs);
console.log(this.$refs.scrolllist);
this.$refs.scroll.scrollTo(
0,
this.scrollToY,
this.scrollToTime,
ease[this.scrollToEasing]
);
},
async fetchList(isMore) {
if (this.isMore) {
let params = {
isReset: false
};
await this.fetchFavoriteList({ isReset: false });
}
}
// scroll({ y }) {
// const height = this.$refs.banner.$el.offsetHeight + this.$refs.header.offsetHeight;
// if (-y >= height) {
// this.fixed = true;
// } else {
// this.fixed = false;
// }
// }
},
computed: {
...mapState(["favoriteProductList", "isMore"])
}
};
</script>
<style lang="scss" scoped>
.favorite-wrapper {
/deep/ .layout-context {
display: flex;
flex-direction: column;
}
.empty {
flex: 1;
}
}
.fav-scroll-bg {
background-color: #f5f5f5;
flex: 1;
}
</style>