@lancom/shared 0.0.350 → 0.0.351
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<nav>
|
|
4
|
+
<ul class="pagination">
|
|
5
|
+
<li
|
|
6
|
+
v-for="page in totalPages"
|
|
7
|
+
:key="page"
|
|
8
|
+
:class="{ active: page === currentPage }">
|
|
9
|
+
<a :href="`${baseUrl}${page > 1 ? `${dividerPage}page=${page}` : ''}`">
|
|
10
|
+
{{ page }}
|
|
11
|
+
</a>
|
|
12
|
+
</li>
|
|
13
|
+
</ul>
|
|
14
|
+
</nav>
|
|
15
|
+
</div>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<script>
|
|
19
|
+
export default {
|
|
20
|
+
data() {
|
|
21
|
+
const baseUrl = this.$route.fullPath
|
|
22
|
+
.replace(/page=[0-9]+/, '')
|
|
23
|
+
.replace(/\?$/, '')
|
|
24
|
+
.replace(/\&$/, '');
|
|
25
|
+
return {
|
|
26
|
+
baseUrl,
|
|
27
|
+
dividerPage: baseUrl.includes('?') ? '&' : '?',
|
|
28
|
+
currentPage: parseInt(this.$route.query.page) || 1
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
props: {
|
|
32
|
+
itemsCount: {
|
|
33
|
+
type: Number,
|
|
34
|
+
required: true
|
|
35
|
+
},
|
|
36
|
+
itemsPerPage: {
|
|
37
|
+
type: Number,
|
|
38
|
+
default: 50
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
computed: {
|
|
42
|
+
totalPages() {
|
|
43
|
+
return Math.min(20, Math.ceil(this.itemsCount / this.itemsPerPage));
|
|
44
|
+
},
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<style lang="scss" scoped>
|
|
50
|
+
@import "@/assets/scss/variables";
|
|
51
|
+
.pagination {
|
|
52
|
+
list-style: none;
|
|
53
|
+
display: flex;
|
|
54
|
+
gap: 6px;
|
|
55
|
+
padding: 0;
|
|
56
|
+
justify-content: center;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.pagination li {
|
|
60
|
+
cursor: pointer;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.pagination li.active {
|
|
64
|
+
background-color: $medium_gray;
|
|
65
|
+
color: white;
|
|
66
|
+
font-weight: bold;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.pagination li a {
|
|
70
|
+
text-decoration: none;
|
|
71
|
+
color: inherit;
|
|
72
|
+
display: block;
|
|
73
|
+
border: 1px solid #ddd;
|
|
74
|
+
padding: 8px 12px;
|
|
75
|
+
border-radius: 3px;
|
|
76
|
+
}
|
|
77
|
+
</style>
|
|
@@ -16,16 +16,14 @@
|
|
|
16
16
|
</div>
|
|
17
17
|
</div>
|
|
18
18
|
<pagination
|
|
19
|
-
v-if="
|
|
20
|
-
|
|
21
|
-
:
|
|
22
|
-
:per-page="perPage"
|
|
23
|
-
:options="{ chunk: 3 }" />
|
|
19
|
+
v-if="count > perPage"
|
|
20
|
+
:itemsCount="count"
|
|
21
|
+
:itemsPerPage="perPage" />
|
|
24
22
|
</div>
|
|
25
23
|
</template>
|
|
26
24
|
|
|
27
25
|
<script>
|
|
28
|
-
import Pagination from '
|
|
26
|
+
import Pagination from '@lancom/shared/components/common/pagination';
|
|
29
27
|
import NewsListItem from '../news_list_item/news-list-item';
|
|
30
28
|
|
|
31
29
|
export default {
|
|
@@ -48,23 +46,6 @@ export default {
|
|
|
48
46
|
page: {
|
|
49
47
|
type: Number
|
|
50
48
|
}
|
|
51
|
-
},
|
|
52
|
-
computed: {
|
|
53
|
-
currentPage: {
|
|
54
|
-
get() {
|
|
55
|
-
return this.page;
|
|
56
|
-
},
|
|
57
|
-
set(page) {
|
|
58
|
-
const params = [];
|
|
59
|
-
if (page > 1) {
|
|
60
|
-
params.push(`page=${page}`);
|
|
61
|
-
}
|
|
62
|
-
const link = `${this.$route.path}${params.length ? `?${params.join('&')}` : ''}`;
|
|
63
|
-
window.location = link;
|
|
64
|
-
// this.$router.push(link);
|
|
65
|
-
// window.scrollTo(0, 0);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
49
|
}
|
|
69
50
|
};
|
|
70
51
|
</script>
|
|
@@ -10,17 +10,16 @@
|
|
|
10
10
|
:placeholder="placeholder" />
|
|
11
11
|
</slot>
|
|
12
12
|
<pagination
|
|
13
|
-
v-
|
|
14
|
-
:
|
|
15
|
-
:
|
|
16
|
-
:options="{ chunk: 3 }" />
|
|
13
|
+
v-if="count > perPage"
|
|
14
|
+
:itemsCount="count"
|
|
15
|
+
:itemsPerPage="perPage" />
|
|
17
16
|
</div>
|
|
18
17
|
</div>
|
|
19
18
|
</template>
|
|
20
19
|
|
|
21
20
|
<script>
|
|
22
21
|
import { mapGetters } from 'vuex';
|
|
23
|
-
import Pagination from '
|
|
22
|
+
import Pagination from '@lancom/shared/components/common/pagination';
|
|
24
23
|
import { generateProductsLink } from '@lancom/shared/assets/js/utils/product';
|
|
25
24
|
import ProductList from '../product_list/product-list';
|
|
26
25
|
|
package/layouts/products.vue
CHANGED
|
@@ -99,7 +99,8 @@
|
|
|
99
99
|
...mapGetters(['notificationBar', 'shop', 'country', 'currency']),
|
|
100
100
|
...mapGetters('products', ['category', 'categories', 'brands', 'types', 'tags', 'loadError', 'count', 'products', 'minPrice', 'maxPrice']),
|
|
101
101
|
pageItemCanonical() {
|
|
102
|
-
|
|
102
|
+
const page = +this.$route.query.page;
|
|
103
|
+
return `${this.breadcrumbs[this.breadcrumbs.length - 1]?.to}${page > 1 ? `?page=${page}` : ''}`;
|
|
103
104
|
},
|
|
104
105
|
currentBrand() {
|
|
105
106
|
return this.findByRouteParam(this.brands, 'brand');
|
|
@@ -314,7 +315,8 @@
|
|
|
314
315
|
...this.$route.query,
|
|
315
316
|
country: this.country?._id,
|
|
316
317
|
currency: this.currency?._id,
|
|
317
|
-
placeholder
|
|
318
|
+
placeholder,
|
|
319
|
+
limit: 80
|
|
318
320
|
};
|
|
319
321
|
try {
|
|
320
322
|
await this.fetchProducts({ params, shop: this.shop._id });
|