feat: ui improvements, show only active products, limit max page for infinity scroll
This commit is contained in:
6
module/oc_telegram_shop/upload/oc_telegram_shop/src/Services/ProductsService.php
Normal file → Executable file
6
module/oc_telegram_shop/upload/oc_telegram_shop/src/Services/ProductsService.php
Normal file → Executable file
@@ -51,10 +51,12 @@ class ProductsService
|
|||||||
$forMainPage = $params['forMainPage'];
|
$forMainPage = $params['forMainPage'];
|
||||||
$featuredProducts = $params['featuredProducts'];
|
$featuredProducts = $params['featuredProducts'];
|
||||||
$mainpageProducts = $params['mainpageProducts'];
|
$mainpageProducts = $params['mainpageProducts'];
|
||||||
|
$status = $params['status'] ?? 1;
|
||||||
$languageId = 1;
|
$languageId = 1;
|
||||||
$categoryName = '';
|
$categoryName = '';
|
||||||
$imageWidth = 300;
|
$imageWidth = 300;
|
||||||
$imageHeight = 300;
|
$imageHeight = 300;
|
||||||
|
$maxPages = $params['maxPages'] ?? 10;
|
||||||
|
|
||||||
if ($categoryId) {
|
if ($categoryId) {
|
||||||
$categoryName = $this->queryBuilder->newQuery()
|
$categoryName = $this->queryBuilder->newQuery()
|
||||||
@@ -82,6 +84,8 @@ class ProductsService
|
|||||||
->where('product_description.language_id', '=', $languageId);
|
->where('product_description.language_id', '=', $languageId);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
->where('products.status', '=', $status)
|
||||||
|
->whereRaw('products.date_available < NOW()')
|
||||||
->when($categoryId !== 0, function (Builder $query) use ($categoryId) {
|
->when($categoryId !== 0, function (Builder $query) use ($categoryId) {
|
||||||
$query->join(
|
$query->join(
|
||||||
db_table('product_to_category') . ' AS product_to_category',
|
db_table('product_to_category') . ' AS product_to_category',
|
||||||
@@ -102,7 +106,7 @@ class ProductsService
|
|||||||
});
|
});
|
||||||
|
|
||||||
$total = $productsQuery->count();
|
$total = $productsQuery->count();
|
||||||
$lastPage = PaginationHelper::calculateLastPage($total, $perPage);
|
$lastPage = min(PaginationHelper::calculateLastPage($total, $perPage), $maxPages);
|
||||||
$hasMore = $page + 1 <= $lastPage;
|
$hasMore = $page + 1 <= $lastPage;
|
||||||
|
|
||||||
$products = $productsQuery
|
$products = $productsQuery
|
||||||
|
|||||||
@@ -7,8 +7,12 @@
|
|||||||
Каталог
|
Каталог
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
|
|
||||||
<RouterLink v-for="category in categoriesStore.topCategories" class="btn btn-md" :to="{name: 'product.categories.show', params: {category_id: category.id}}">
|
<RouterLink
|
||||||
{{ category.name }}
|
v-for="category in categoriesStore.topCategories"
|
||||||
|
class="btn btn-md max-w-[12rem]"
|
||||||
|
:to="{name: 'product.categories.show', params: {category_id: category.id}}"
|
||||||
|
>
|
||||||
|
<span class="overflow-hidden text-ellipsis whitespace-nowrap">{{ category.name }}</span>
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h3 class="ml-5 text-lg">{{ category.name }}</h3>
|
<h3 class="ml-5 text-lg line-clamp-2">{{ category.name }}</h3>
|
||||||
</a>
|
</a>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -3,11 +3,11 @@
|
|||||||
<h2 class="text-3xl mb-5">Категории</h2>
|
<h2 class="text-3xl mb-5">Категории</h2>
|
||||||
|
|
||||||
<button v-if="parentId" class="py-2 px-4 flex items-center mb-3 cursor-pointer" @click="goBack">
|
<button v-if="parentId" class="py-2 px-4 flex items-center mb-3 cursor-pointer" @click="goBack">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6 min-w-6">
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" d="M10.5 19.5 3 12m0 0 7.5-7.5M3 12h18" />
|
<path stroke-linecap="round" stroke-linejoin="round" d="M10.5 19.5 3 12m0 0 7.5-7.5M3 12h18" />
|
||||||
</svg>
|
</svg>
|
||||||
|
|
||||||
<span class="ml-2">Назад к "{{ parentCategory.name }}"</span>
|
<span class="ml-2 line-clamp-2">Назад к "{{ parentCategory.name }}"</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<div ref="goodsRef" class="safe-top">
|
<div ref="goodsRef" class="safe-top">
|
||||||
|
<SearchInput/>
|
||||||
<ProductsList/>
|
<ProductsList/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import ProductsList from "@/components/ProductsList.vue";
|
import ProductsList from "@/components/ProductsList.vue";
|
||||||
|
import SearchInput from "@/components/SearchInput.vue";
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user