list.vue
2.46 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
<template>
<LayoutApp :show-back="true" title="二手" class="list-wrapper">
<LayoutScroll
ref="scrolllist"
@scroll="onScroll"
@scroll-end="scrollEndHandler"
@pulling-up="fetchSkupList(isMore)"
v-if="skupList.list.length"
class="list-scroll-bg"
>
<SecondList ref="second" :list="skupList.list" :yasParams="yasParams"></SecondList>
</LayoutScroll>
<UfoNoItem class="empty" :tip="`暂无数据`" v-else></UfoNoItem>
</LayoutApp>
</template>
<script>
import SecondList from './components/second-list';
import UfoNoItem from '../../components/ufo-no-item';
import { createNamespacedHelpers } from 'vuex';
const { mapState, mapActions } = createNamespacedHelpers('second/skupList');
export default {
name: 'UfoSecondListPage',
components: {
SecondList,
UfoNoItem
},
data() {
return {
isFetch: true,
scrollY: 0,
yasParams: {
P_NAME: 'XY_UFOSecondList',
TYPE_ID: 5,
TAB_ID: '',
TAB_NAME: '',
P_PARAM: [].toString()
}
};
},
computed: {
...mapState(['skupList', 'isMore'])
},
methods: {
...mapActions(['fetchSecondSkupList']),
async fetchSkupList(isMore) {
if (this.isMore) {
await this.fetchSecondSkupList({ isReset: false });
}
},
onScroll({ y }) {
this.scrollY = -y;
},
scrollEndHandler({ y }) {
this.scrollY = -y;
this.$refs.second.yasShowEvent(-y);
},
yasShowPage() {
let { total, list } = this.skupList;
let PRD_LIST = [];
for (let item of list) {
PRD_LIST.push(item.product_id);
}
PRD_LIST = PRD_LIST.toString();
this.$store.dispatch('reportYas', {
params: {
param: { ...this.yasParams, TOTAL: total, PRD_LIST },
appop: 'XY_UFO_PRD_LIST_L'
}
});
},
},
beforeRouteLeave (to, from, next) {
this.isFetch = to.name !== 'SecondProductDetail'
next();
},
activated: function() {
if(this.isFetch) {
this.scrollY = 0;
this.fetchSecondSkupList({ isReset: true });
}
this.$nextTick(()=> {
this.$refs.scrolllist.scrollTo(this.scrollY);
this.$refs.second.yasShowEvent(this.scrollY);
this.yasShowPage();
})
}
};
</script>
<style lang="scss" scoped>
.list-wrapper {
/deep/ .layout-context {
display: flex;
flex-direction: column;
}
.empty {
flex: 1;
}
}
.list-scroll-bg {
background-color: #f5f5f5;
flex: 1;
}
</style>