Skip to content

Commit

Permalink
Merge pull request #96 from thuongtruong1009/product/feature
Browse files Browse the repository at this point in the history
feat: get products of shop by id
  • Loading branch information
thuongtruong1009 authored Jun 7, 2022
2 parents ee973f5 + f730ac9 commit 679a108
Show file tree
Hide file tree
Showing 28 changed files with 1,265 additions and 490 deletions.
6 changes: 5 additions & 1 deletion src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ declare module 'vue' {
CBDemo1: typeof import('./components/buyer/CBDemo1.vue')['default']
CBDemo2: typeof import('./components/buyer/CBDemo2.vue')['default']
CBDemo3: typeof import('./components/buyer/CBDemo3.vue')['default']
CBFeature: typeof import('./components/buyer/CBFeature.vue')['default']
CBFlashSales: typeof import('./components/buyer/CBFlashSales.vue')['default']
CBFooter: typeof import('./components/buyer/CBFooter.vue')['default']
CBHead: typeof import('./components/buyer/CBHead.vue')['default']
Expand All @@ -41,6 +42,7 @@ declare module 'vue' {
CCartItem: typeof import('./components/buyer/CCartItem.vue')['default']
CError: typeof import('./components/CError.vue')['default']
CExtension: typeof import('./components/CExtension.vue')['default']
CGetCategoryChildren: typeof import('./components/CGetCategoryChildren.vue')['default']
CLoading: typeof import('./components/CLoading.vue')['default']
CMap: typeof import('./components/CMap.vue')['default']
Counter: typeof import('./components/Counter.vue')['default']
Expand Down Expand Up @@ -71,6 +73,7 @@ declare module 'vue' {
IBCreate: typeof import('./components/icons/account/IBCreate.vue')['default']
IBDashboard: typeof import('./components/icons/account/IBDashboard.vue')['default']
IBDelete: typeof import('./components/icons/account/IBDelete.vue')['default']
IBDescription: typeof import('./components/icons/product/IBDescription.vue')['default']
IBDownload: typeof import('./components/icons/account/IBDownload.vue')['default']
IBEmail: typeof import('./components/icons/auth/IBEmail.vue')['default']
IBEye: typeof import('./components/icons/account/IBEye.vue')['default']
Expand Down Expand Up @@ -140,6 +143,7 @@ declare module 'vue' {
IRupee: typeof import('./components/icons/header/IRupee.vue')['default']
ISave: typeof import('./components/icons/ISave.vue')['default']
ISChat: typeof import('./components/icons/seller/ISChat.vue')['default']
ISDescription: typeof import('./components/icons/seller/ISDescription.vue')['default']
ISearch: typeof import('./components/icons/ISearch.vue')['default']
ISEdit: typeof import('./components/icons/seller/ISEdit.vue')['default']
ISell: typeof import('./components/icons/ISell.vue')['default']
Expand Down Expand Up @@ -177,8 +181,8 @@ declare module 'vue' {
PSRegister: typeof import('./components/partterns/seller/PSRegister.vue')['default']
README: typeof import('./components/README.md')['default']
RMenu: typeof import('./components/header/RMenu.vue')['default']
RProductCard: typeof import('./components/rendering/RProductCard.vue')['default']
RProductCardGrid: typeof import('./components/rendering/RProductCardGrid.vue')['default']
RProductSearch: typeof import('./components/rendering/RProductSearch.vue')['default']
SHead: typeof import('./components/seller/SHead.vue')['default']
SLMenu: typeof import('./components/seller/SLMenu.vue')['default']
}
Expand Down
72 changes: 72 additions & 0 deletions src/components/CGetCategoryChildren.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<script setup>
import { useRouter } from 'vue-router'
import { useProduct } from '~/stores/product'
const router = useRouter()
const product = useProduct()
const props = defineProps({
level0: Object,
})
const searchCategory = async(category) => {
await router.push(`/search/${encodeURIComponent(category)}`)
await location.reload()
}
</script>

<template>
<div class="grid grid-cols-4 rounded-xl gap-2">
<div class="py-2 max-h-max overflow-y-scroll rounded-xl shadow-md" :class="{'bg-white dark:(bg-blue-gray-800 shadow-gray-600)': props.level0}">
<div v-for="(category, i) in props.level0" :key="i" class="flex justify-between items-center dark:hover:bg-blue-gray-700 hover:(bg-[#FAFAFA] text-red-500 font-medium) px-3 py-1 cursor-pointer" @mouseover="product.level.level1 = category.children" @click="searchCategory(category.name)">
<p>{{ category.name }}</p>
<ICaretRight v-if="category.number_of_children" />
</div>
</div>

<Transition duration="500" name="nested">
<div v-if="product.level.level1" :class="{'py-2 bg-white rounded-xl shadow-md dark:(bg-blue-gray-800 shadow-gray-600)': product.level.level1}">
<div v-for="(category, i) in product.level.level1" :key="i" class="flex justify-between items-center dark:hover:bg-blue-gray-700 hover:(bg-[#FAFAFA] text-red-500 font-medium) px-3 py-1 cursor-pointer" @mouseover="product.level.level2 = category.children" @click="searchCategory(category.name)">
<p>{{ category.name }}</p>
<ICaretRight v-if="category.number_of_children" />
</div>
</div>
</Transition>

<Transition duration="500" name="nested">
<div v-if="product.level.level2" class="py-2 bg-white rounded-xl shadow-md dark:(bg-blue-gray-800 shadow-gray-600)">
<div v-for="(category, i) in product.level.level2" :key="i" class="flex justify-between items-center dark:hover:bg-blue-gray-700 hover:(bg-[#FAFAFA] text-red-500 font-medium) px-3 py-1 cursor-pointer" @mouseover="product.level.level3 = category.children">
<a>{{ category.name }}</a>
<ICaretRight v-if="category.number_of_children" />
</div>
</div>
</Transition>

<Transition duration="500" name="nested">
<div v-if="product.level.level3" :class="{'py-2 bg-white rounded-xl shadow-md dark:(bg-blue-gray-800 shadow-gray-600)': product.level.level3}">
<div v-for="(category, i) in product.level.level3" :key="i" class="flex justify-between items-center dark:hover:bg-blue-gray-700 hover:(bg-[#FAFAFA] text-red-500 font-medium) px-3 py-1 cursor-pointer">
<p>{{ category.name }}</p>
<ICaretRight v-if="category.number_of_children" />
</div>
</div>
</Transition>
</div>
</template>

<style scoped>
::-webkit-scrollbar-thumb {
background: #ddd;
}
::-webkit-scrollbar {
width: 2px;
}
.nested-enter-active {
transition: all 0.2s ease-in-out;
}
.nested-enter-from{
transform: translateY(30px);
opacity: 0;
}
</style>
7 changes: 6 additions & 1 deletion src/components/CPagination.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ defineEmits(['on-prev', 'on-next'])

<template>
<div class="flex justify-center items-center">
<a href="#" class="inline-flex items-center py-2 px-4 mr-3 text-sm font-medium text-gray-500 bg-white rounded-lg border border-gray-300 hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white" :class="{'pointer-events-none opacity-65': props.index <= 1}" @click="$emit('on-prev')">
<a href="#" class="inline-flex items-center py-2 px-4 text-sm font-medium text-gray-500 bg-white rounded-lg border border-gray-300 hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white" :class="{'pointer-events-none opacity-65': props.index <= 1}" @click="$emit('on-prev')">
<svg class="mr-2 w-5 h-5" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M7.707 14.707a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 1.414L5.414 9H17a1 1 0 110 2H5.414l2.293 2.293a1 1 0 010 1.414z" clip-rule="evenodd" /></svg>
{{ t('pagination.previous') }}
</a>
<div class="bg-orange-400 flex items-center justify-center h-8 w-8 text-white rounded-full font-medium shadow-lg mx-3">
<p>
{{ props.index }}
</p>
</div>
<a href="#" class="inline-flex items-center py-2 px-4 text-sm font-medium text-gray-500 bg-white rounded-lg border border-gray-300 hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white" @click="$emit('on-next')">
{{ t('pagination.next') }}
<svg class="ml-2 w-5 h-5" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M12.293 5.293a1 1 0 011.414 0l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-2.293-2.293a1 1 0 010-1.414z" clip-rule="evenodd" /></svg>
Expand Down
37 changes: 21 additions & 16 deletions src/components/CProductCardFlow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,30 +77,35 @@ const onClosePopup = () => {
<span class="bg-green-600 text-white font-bold capitalize text-xs rounded p-0.75">-10%</span>
<span class="bg-orange-400 text-white font-bold capitalize text-xs rounded p-0.75">{{ t('search.new') }}</span>
</div>
<div class="card-img max-w-full max-h-7/12" @click="onVisitProduct(props.card.id, props.card.shop_id)">
<img class="first-img rounded-xl w-full" :src="`${getResources(props.card.images[0])}_tn`" alt="product_img">
<div class="split third rounded-lg shadow-md card-img max-w-80 min-w-80 max-h-80 p-1" @click="onVisitProduct(props.card.id, props.card.shop_id)">
<div class="cover">
<img class="first-img rounded-xl w-full" :src="`${getResources(props.card.images[0])}_tn`" alt="product_img">
</div>
<!-- <img class="first-img rounded-xl w-full" :src="`${getResources(props.card.images[0])}_tn`" alt="product_img"> -->
</div>
<!-- <div class="split third rounded-lg shadow-md" @click="onVisitProduct(props.card.id, props.card.shop_id)">
<div class="cover">
<img class="first-img rounded-t-lg w-full max-h-80" :src="`${getResources(props.card.images[0])}_tn`" alt="product_img">
</div>
</div> -->
</div>
<div class="product-description text-left p-2">
<div class="product-description text-left p-2 w-full">
<div class="px-2">
<p class="card-title cursor-pointer duration-200 ease-linear hover:text-[#FF6600]" @click="onVisitProduct(props.card.id, props.card.shop_id)">
{{ props.card.name }}
</p>
<div class="star-rating flex justify-start py-2">
<img v-for="i in 5" :key="i" src="https://img.icons8.com/fluency/48/ffffff/star.png" class="max-w-4 max-h-4">
</div>
<div class="flex items-center justify-start">
<h6 class="card-price font-bold tracking-tighter mr-2 black text[#9B9B9B] text-decoration line-through">
$999
</h6>
<h6 class="font-bold tracking-tighter text-red-500">
{{ productPrice }}
</h6>
<div class="flex justify-between">
<div class="flex items-center justify-start">
<h6 class="card-price font-bold tracking-tighter mr-2 black text[#9B9B9B] text-decoration line-through">
$999
</h6>
<h6 class="font-bold tracking-tighter text-red-500">
{{ productPrice }}
</h6>
</div>
<div class="star-rating flex justify-start py-2">
<img v-for="i in 5" :key="i" src="https://img.icons8.com/fluency/48/ffffff/star.png" class="max-w-4 max-h-4">
</div>
</div>
</div>

Expand All @@ -115,13 +120,13 @@ const onClosePopup = () => {
</div>

<div class="py-5 flex justify-start">
<h3 class="uppercase py-2.5 px-10 rounded-md bg-black text-white font-medium text-sm cursor-pointer hover:bg-[#F33535] duration-200" @click="onOpenPopup">
<h3 class="uppercase py-2.5 px-10 rounded-md bg-black text-white font-medium text-sm cursor-pointer hover:bg-[#F33535] dark:bg-[#F33535] duration-200" @click="onOpenPopup">
{{ t('search.add-to-cart') }}
</h3>
</div>

<div v-if="isPopup === true" class="popup-modal z-3 fixed w-screen h-screen top-0 left-0 flex justify-center items-center ease-linear">
<div class="bg-white w-284 z-20 rounded-lg" @click="onClosePopup">
<div class="bg-white dark:bg-gray-800 w-284 z-20 rounded-lg" @click="onClosePopup">
<div class="text-white flex justify-center items-center bg-black rounded-t-lg gap-2 relative py-2">
<ICheck />
<h5 class="text-lg" style="font-family: 'Gilroy-Medium'">
Expand Down Expand Up @@ -182,7 +187,7 @@ const onClosePopup = () => {
}
.split.third img {
width: 100%;
height: auto;
height: 100%;
-webkit-transition: -webkit-transform 0.8s ease;
transition: -webkit-transform 0.8s ease;
transition: transform 0.8s ease;
Expand Down
19 changes: 15 additions & 4 deletions src/components/CProductCardGrid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const product = useProduct()
const props = defineProps({
card: Object,
mode: String,
})
const productPrice = ref()
Expand Down Expand Up @@ -59,17 +60,27 @@ const onVisitProduct = (prod_id, shop_id) => {
</script>

<template>
<div class="card-type flex justify-between absolute w-full p-2">
<img v-if="props.mode === 'feature'" src="/img/today/extra.png" alt="extra" class="absolute top-0 left-0 w-full z-1">
<img v-if="props.mode === 'feature'" src="/img/today/discount.svg" alt="discount" class="absolute -top-2 -right-6 w-21 z-1">
<div v-if="props.mode === 'feature'" class="absolute top-1 -right-4 w-20 text-xs z-1">
<p class="text-red-500">
30%
</p>
<p class="text-white" style="font-size:0.55em;">
{{ t('ctoday.decrease') }}
</p>
</div>
<div v-if="props.mode === 'discount'" class="card-type flex justify-between absolute w-full p-2 z-1">
<span class="bg-green-600 text-white font-bold capitalize text-xs rounded p-0.75">-10%</span>
<span class="bg-orange-400 text-white font-bold capitalize text-xs rounded p-0.75">{{ t('search.new') }}</span>
</div>
<div class="split third rounded-lg shadow-md" @click="onVisitProduct(props.card.id, props.card.shop_id)">
<div class="split third rounded-lg shadow-md z-0" @click="onVisitProduct(props.card.id, props.card.shop_id)">
<div class="cover">
<img class="first-img rounded-t-lg w-full max-h-80" :src="`${getResources(props.card.images[0])}_tn`" alt="product_img">
</div>
</div>
<div class="product-description text-left p-2">
<p class="card-title cursor-pointer duration-200 ease-linear hover:text-[#FF6600] text-sm" @click="onVisitProduct(props.card.id, props.card.shop_id)">
<p class="card-title cursor-pointer duration-200 ease-linear hover:text-[#FF6600] dark:text-gray-300 text-sm" @click="onVisitProduct(props.card.id, props.card.shop_id)">
{{ sliceText(props.card.name) }}...
</p>
<div class="flex items-center justify-between my-2">
Expand All @@ -84,7 +95,7 @@ const onVisitProduct = (prod_id, shop_id) => {
<div class="star-rating flex justify-start">
<img v-for="i in 5" :key="i" src="https://img.icons8.com/fluency/48/ffffff/star.png" class="max-w-4 max-h-4">
</div>
<h6 class="text-xs">
<h6 class="text-xs dark:text-gray-300">
Solded {{ props.card.sold }}
</h6>
</div>
Expand Down
53 changes: 53 additions & 0 deletions src/components/buyer/CBFeature.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<script setup>
import { useLoading } from '~/stores/loading'
import ProductRequest from '~/services/product-request'
const loading = useLoading()
const { t } = useI18n()
const payload = reactive({
limit: 10,
page: 1,
})
const productList = ref([])
watch(async() => {
loading.isLoading = true
const { data: featureData } = await ProductRequest.getProductsFeature({ params: { ...payload } })
productList.value = featureData.data
loading.isLoading = false
})
</script>

<template>
<div class="hint-today-container max-w-349 my-10">
<div class="flex justify-start rounded-lg border-1 border-[#e9e9e9] bg-light-100 dark:(bg-blue-gray-800 border-transparent)">
<h2 class="text-red-500 border-b-4 border-b-solid border-b-red-500 text-lg rounded-l-lg text-left inline-block py-2 px-10 uppercase font-medium">
{{ t('ctoday.hint') }}
</h2>
</div>
<div class="flex flex-wrap gap-3 py-3">
<div v-if="loading.isLoading" class="grid-products-list flex justify-center flex-wrap gap-5 py-10">
<RProductCardGrid v-for="index in 12" :key="index" />
</div>
<div v-else v-cloak class="grid-products-list flex justify-center flex-wrap gap-5 py-10">
<div v-for="(prod, index) in productList" :key="index" class="card duration-200 ease-linear relative rounded-lg w-60 shadow-md dark:bg-gray-700 hover:shadow-gray-400/50 pb-0">
<CProductCardGrid :card="prod" mode="feature" />
</div>
</div>
</div>
<div class="flex justify-center">
<p class="bg-white dark:(bg-blue-gray-800 hover:bg-blue-gray-700 text-gray-300 border-transparent) border-1 border-solid border-gray-200 py-2 px-10 rounded-md cursor-pointer hover:(bg-[#F5F5F5] border-gray-300)" :class="{'hidden':payload.limit === 25}" @click="payload.limit += 5">
{{ t('ctoday.see-more') }}
</p>
</div>
</div>
</template>

<style scoped>
.hint-today-container > div:nth-child(2) > div{
font-size: 14px;
line-height: 16.8px;
padding: 10px;
}
</style>
2 changes: 1 addition & 1 deletion src/components/buyer/CBFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { t } = useI18n()
<template>
<div class="footer flex dark:text-$dark-text">
<div class="left md:(w-1/3 p-16 bg-gray-100) text-left dark:bg-black <md:(w-1/2 p-7 bg-light-200)">
<IBrand class="py-4" />
<IBrand class="py-4" style="filter: drop-shadow(3px 5px 2px rgb(0 0 0 / 0.2));" />
<p class="py-4">
{{ t('footer.commit') }}
</p>
Expand Down
1 change: 1 addition & 0 deletions src/components/head/CBBrand.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
svg {
fill: white;
width: 9rem;
filter: drop-shadow(3px 5px 2px rgb(0 0 0 / 0.2));
}
</style>
11 changes: 6 additions & 5 deletions src/components/head/CBList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import AccountRequest from '~/services/account-request'
import { useCart } from '~/stores/cart'
import { toast } from '~/stores/toast'
import { useUser } from '~/stores/user'
import { getResources } from '~/utils/resources'
import { floorNumber } from '~/utils/floorNumber'
import { removeItemByIndex } from '~/utils/arrayHandle'
Expand Down Expand Up @@ -75,10 +76,10 @@ const handleOrder = async() => {
<div class="container flex justify-center items-center lg:w-xs text-white dark:text-black">
<div>
<router-link to="/buyer/favourite">
<IHeart class="hover:text-[#adff2f] dark:text-[#adff2f]" />
<IHeart class="hover:text-[#adff2f] dark:text-[#adff2f]" style="filter: drop-shadow(3px 5px 2px rgb(0 0 0 / 0.2));" />
</router-link>
</div>
<div class="flex items-end hover:text-[#adff2f] dark:text-[#adff2f] relative" @click="openNav">
<div class="flex items-end hover:text-[#adff2f] dark:text-[#adff2f] relative" style="filter: drop-shadow(3px 5px 2px rgb(0 0 0 / 0.2));" @click="openNav">
<span class="total-notifications absolute -top-2 left-5 bg-green-500 w-5 h-5 text-white rounded-full flex justify-center items-center pr-0.5 text-xs font-medium">{{ cart.result.length }}</span>
<IBCart />
<h1 class="font-semibold ml-3">
Expand All @@ -87,8 +88,8 @@ const handleOrder = async() => {
</div>
<div>
<router-link to="/buyer/account/dashboard">
<img v-if="avatarID" :src="`https://tp-o.tk/resources/images/${avatarID}`" alt="avatar_img" class="rounded-full w-12 h-12 border-2 border-blue-500" style="object-fit: cover;">
<img v-else class="w-12 h-12 rounded-full" src="/img/avatar_sample.png" alt="avatar_sample">
<img v-if="avatarID" :src="getResources(avatarID)" alt="avatar_img" class="rounded-full w-12 min-w-12 max-w-12 h-12 min-h-12 max-h-12 border-2 border-blue-500" style="object-fit: cover;filter: drop-shadow(3px 5px 2px rgb(0 0 0 / 0.2));">
<img v-else class="w-12 min-w-12 max-w-12 h-12 min-h-12 max-h-12 rounded-full shadow-lg shadow-gray-500/50" src="/img/avatar_sample.png" alt="avatar_sample">
</router-link>
</div>
<div v-if="isBlurBgModal" class="blur-bg w-screen h-screen absolute top-0 -left-10 bg-black bg-opacity-30 z-1" @click="closeNav" />
Expand All @@ -107,7 +108,7 @@ const handleOrder = async() => {
src="/img/product/1.png" alt="cart_product_img" class="max-w-25 max-h-25 border-light-600 border-solid border-1 rounded-md mr-3"
> -->
<img
:src="`https://tp-o.tk/resources/images/${item.product.images[0]}`" alt="cart_product_img" class="max-w-25 max-h-25 border-light-600 border-solid border-1 rounded-md mr-3"
:src="getResources(item.product.images[0])" alt="cart_product_img" class="max-w-25 max-h-25 border-light-600 border-solid border-1 rounded-md mr-3"
>
</a>
<div>
Expand Down
Loading

1 comment on commit 679a108

@vercel
Copy link

@vercel vercel bot commented on 679a108 Jun 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.