add address field and merge with front

This commit is contained in:
Parsa Nazer
2025-02-02 18:27:55 +03:30
9 changed files with 137 additions and 124 deletions
+4 -4
View File
@@ -23,12 +23,12 @@ const emit = defineEmits(["select"]);
:class="
isSelected
? 'border-cyan-500 ring-2 ring-offset-2 ring-cyan-500'
: 'border-gray-300'
: 'border-slate-200'
"
class="flex flex-col items-center transition-all cursor-pointer w-full gap-4 p-4 border rounded-xl bg-gray-50"
class="flex flex-col items-center transition-all cursor-pointer w-full gap-4 p-4 border rounded-xl bg-slate-50"
>
<span
class="flex items-center justify-start w-full lg:text-[1.125rem] font-semibold text-gray-900"
class="flex items-center justify-start w-full lg:text-[1.125rem] font-semibold text-slate-900"
>
آدرس
</span>
@@ -37,7 +37,7 @@ const emit = defineEmits(["select"]);
class="flex flex-col items-center justify-between w-full gap-4 lg:flex-row"
>
<span
class="w-full text-start text-sm lg:text-[1rem] lg:w-9/12 text-gray-700"
class="w-full text-start text-sm lg:text-[1rem] lg:w-9/12 text-slate-700"
>
{{
!!address
+6 -16
View File
@@ -62,25 +62,15 @@ const addNew = () => {
"
>
<DialogTrigger>
<button
class="flex items-center gap-1 rtl:flex-row-reverse font-iran-yekan-x cursor-pointer"
<Button
:end-icon="!!address ? 'bi:pen' : 'bi:plus'"
size="md"
class="rounded-full"
>
<span class="font-bold text-cyan-500 text-sm lg:text-[1rem]">
<span class="font-bold">
{{ !!address ? "ویرایش آدرس" : "افزودن آدرس" }}
</span>
<Icon
v-if="!!address"
name="bi:pen"
class="**:fill-cyan-500"
size="16"
/>
<Icon
v-else
name="bi:plus"
class="**:stroke-cyan-500"
size="20"
/>
</button>
</Button>
</DialogTrigger>
<DialogPortal>
<DialogOverlay
+17 -13
View File
@@ -10,11 +10,11 @@ const handleDeleteFromCart = () => {};
<template>
<div
class="flex flex-col items-center w-full gap-4 p-4 border lg:flex-row border-gray-300 rounded-xl bg-gray-50"
class="flex flex-col items-center w-full gap-4 p-4 border lg:flex-row border-slate-200 rounded-xl bg-slate-50"
>
<div class="flex items-center justify-start w-full gap-2.5 lg:gap-4">
<div
class="size-[88px] aspect-square shrink-0 rounded-100 border border-gray-300 overflow-hidden"
class="size-[10rem] aspect-square shrink-0 rounded-xl border border-slate-200 overflow-hidden"
>
<img
src="/img/product-1.jpg"
@@ -23,8 +23,12 @@ const handleDeleteFromCart = () => {};
/>
</div>
<div class="flex flex-col w-full gap-4">
<span class="font-semibold lg:text-[1.125rem] text-gray-900">
<div class="flex flex-col w-full gap-5">
<span class="font-semibold typo-sub-h-md text-slate-600">
موبایل
</span>
<span class="font-semibold typo-sub-h-xl text-black">
فشارسنج بازویی امرن Omron M3
</span>
@@ -32,9 +36,9 @@ const handleDeleteFromCart = () => {};
<div class="flex items-center">
<button
@click="counter++"
class="border size-10 flex-center rounded-100 border-gray-400"
class="border size-10 flex-center rounded-100 border-slate-300"
>
<Icon name="bi:plus" class="**:stroke-gray-800" />
<Icon name="bi:plus" class="**:stroke-slate-800" />
</button>
<div class="size-10 flex-center">{{ counter }}</div>
@@ -43,7 +47,7 @@ const handleDeleteFromCart = () => {};
@click="
counter > 1 ? counter-- : handleDeleteFromCart
"
class="border size-10 flex-center rounded-100 border-gray-400"
class="border size-10 flex-center rounded-100 border-slate-300"
>
<Icon
v-if="counter == 1"
@@ -53,12 +57,12 @@ const handleDeleteFromCart = () => {};
<Icon
v-else
name="bi:dash"
class="**:stroke-gray-800"
class="**:stroke-slate-800"
/>
</button>
</div>
<span class="text-[1.25rem] text-gray-900 font-semibold">
<span class="typo-p-lg text-black font-semibold">
۲,۸۹۱,۰۰۰&nbsp;تومان
</span>
</div>
@@ -68,14 +72,14 @@ const handleDeleteFromCart = () => {};
<div class="flex items-center justify-between w-full lg:hidden">
<div class="flex items-center">
<button
class="border size-10 flex-center rounded-100 border-gray-400"
class="border size-10 flex-center rounded-100 border-slate-400"
>
<svg
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
class="stroke-gray-800"
class="stroke-slate-800"
xmlns="http://www.w3.org/2000/svg"
>
<path
@@ -96,7 +100,7 @@ const handleDeleteFromCart = () => {};
<div class="size-10 text-[1.125rem] flex-center">1</div>
<button
class="border size-10 flex-center rounded-100 border-gray-400"
class="border size-10 flex-center rounded-100 border-slate-400"
>
<svg
width="16"
@@ -128,7 +132,7 @@ const handleDeleteFromCart = () => {};
</button>
</div>
<span class="text-[1.125rem] text-gray-900 font-semibold">
<span class="text-[1.125rem] text-slate-900 font-semibold">
۲,۸۹۱,۰۰۰&nbsp;تومان
</span>
</div>
+2 -2
View File
@@ -73,13 +73,13 @@ const nav_links = ref<NavLink[]>([
class="**:stroke-black"
/>
</NuxtLink>
<button class="flex-center">
<NuxtLink to="/cart" class="flex-center">
<Icon
name="ci:cart"
size="24px"
class="**:stroke-black"
/>
</button>
</NuxtLink>
</div>
<nav
@@ -17,10 +17,16 @@ defineProps<Props>();
// state
const { data : homeData } = useHomeData();
const { data: homeData, suspense } = useHomeData();
const swiper_instance = ref<SwiperClass | null>(null);
// queries
await useAsyncData(async () => {
await suspense();
});
// methods
const onSwiper = (swiper: SwiperClass) => {
@@ -79,7 +85,10 @@ const onSwiper = (swiper: SwiperClass) => {
</div>
<div class="w-full">
<Swiper :slides-per-view="3" :space-between="24" @swiper="onSwiper">
<SwiperSlide v-for="product in homeData!.products" :key="product.id">
<SwiperSlide
v-for="product in homeData!.products"
:key="product.id"
>
<ProductCard
:id="product.id"
brand="برند محصول"
+73 -58
View File
@@ -28,7 +28,7 @@ const nextPage = computed(() => route.meta.nextPage);
>
<NuxtLink
v-if="prevPage"
:to="{ name: prevPage.name }"
:to="{ name: prevPage?.name }"
class="flex items-center gap-2 text-sm lg:text-[1rem]"
>
<Icon
@@ -36,7 +36,7 @@ const nextPage = computed(() => route.meta.nextPage);
class="**:stroke-cyan-400"
/>
<span class="font-bold text-cyan-400">
{{ prevPage.label }}
{{ prevPage?.label }}
</span>
</NuxtLink>
</div>
@@ -57,68 +57,83 @@ const nextPage = computed(() => route.meta.nextPage);
</div>
<div
class="space-y-[1.25rem] bg-gray-50 p-4 sticky top-44 w-full lg:w-3/12 transition-all border border-gray-300 rounded-xl"
class="flex flex-col bg-slate-50 sticky top-44 w-full lg:w-3/12 transition-all border border-slate-200 rounded-xl"
>
<div
class="flex items-center justify-between w-full text-gray-800"
class="w-full flex items-center justify-between p-5 border-b border-slate-200"
>
<span class="max-w-1/2 text-sm lg:text-[1rem]">
جمع سبد خرید:
</span>
<span class="max-w-1/2 text-sm lg:text-[1rem]">
۳,۲۹۱,۰۰۰ تومان
</span>
</div>
<div
class="flex items-center justify-between w-full text-status-error-primary"
>
<span class="max-w-1/2 text-sm lg:text-[1rem]">
تخفیف:
</span>
<span class="max-w-1/2 text-sm lg:text-[1rem]">
۹۰۰,۰۰۰ تومان
</span>
</div>
<div
class="flex items-center justify-between w-full text-gray-900"
>
<span class="max-w-1/2 text-sm lg:text-[1rem]">
جمع کل:
</span>
<span class="max-w-1/2 text-sm lg:text-[1rem]">
۲,۳۹۱,۰۰۰ تومان
</span>
</div>
<label
v-if="route.name == 'cart-checkout'"
class="flex items-center w-full group gap-2 p-3 my-5 text-sm transition-all border text-gray-600 focus-within:ring-2 focus-within:ring-offset-2 focus-within:ring-cyan-500 bg-gray-50 border-gray-200 rounded-100"
>
<input
type="text"
placeholder="کد تخفیف"
class="w-full border-none focus:border-none focus:outline-none placeholder:text-gray-600 h-[22px]"
<span class="typo-sub-h-xl text-black"
>فاکتور خرید</span
>
<Icon
name="ci:cart"
class="**:stroke-black"
size="24"
/>
<button
class="ring ring-offset-[-4px] active:ring-offset-2 transition-all duration-75 font-bold text-cyan-500 rounded-50"
>
ثبت
</button>
</label>
</div>
<NuxtLink :to="{ name: nextPage.name }">
<Button
start-icon="bi:arrow-right"
class="w-full rounded-full"
<div class="flex flex-col p-5 gap-[1rem]">
<div
class="flex items-center justify-between w-full text-slate-800"
>
{{ nextPage.label }}
</Button>
</NuxtLink>
<span class="max-w-1/2 text-sm lg:text-[1rem]">
جمع سبد خرید:
</span>
<span class="max-w-1/2 text-sm lg:text-[1rem]">
۳,۲۹۱,۰۰۰ تومان
</span>
</div>
<div
class="flex items-center justify-between w-full text-status-error-primary"
>
<span class="max-w-1/2 text-sm lg:text-[1rem]">
تخفیف:
</span>
<span class="max-w-1/2 text-sm lg:text-[1rem]">
۹۰۰,۰۰۰ تومان
</span>
</div>
<div
class="flex items-center justify-between w-full text-slate-900"
>
<span class="max-w-1/2 text-sm lg:text-[1rem]">
جمع کل:
</span>
<span class="max-w-1/2 text-sm lg:text-[1rem]">
۲,۳۹۱,۰۰۰ تومان
</span>
</div>
<label
v-if="route.name == 'cart-checkout'"
class="flex items-center w-full group gap-2 p-3 text-sm transition-all border text-slate-600 focus-within:ring-2 focus-within:ring-offset-2 focus-within:ring-cyan-500 bg-slate-50 border-slate-200 rounded-100"
>
<input
type="text"
placeholder="کد تخفیف"
class="w-full border-none focus:border-none focus:outline-none placeholder:text-slate-600 h-[22px]"
/>
<button
class="ring ring-offset-[-4px] active:ring-offset-2 transition-all duration-75 font-bold text-cyan-500 rounded-50"
>
ثبت
</button>
</label>
<NuxtLink :to="{ name: nextPage?.name }">
<Button
start-icon="bi:arrow-right"
class="w-full rounded-full mt-2"
>
{{ nextPage?.label }}
</Button>
</NuxtLink>
</div>
</div>
</div>
</div>
+3 -6
View File
@@ -69,7 +69,7 @@ const selectedGateway = ref<PaymentGateway>(paymentGateways.value[0]);
:key="index"
:class="
selectedGateway.id == gateway.id
? 'ring-2 ring-offset-2 ring-cyan-500 border-cyan-500'
? 'ring-2 ring-offset-2 ring-black border-black'
: 'border-slate-200'
"
class="w-full p-5 border rounded-xl flex flex-col gap-4 transition-all cursor-pointer"
@@ -99,13 +99,10 @@ const selectedGateway = ref<PaymentGateway>(paymentGateways.value[0]);
<div class="h-7 flex-center col-span-full lg:hidden">
<button class="gap-2 flex-center">
<span class="text-sm font-bold text-cyan-500">
<span class="text-sm font-bold text-black">
مشاهده بیشتر
</span>
<Icon
name="bi:chevron-down"
class="**:stroke-cyan-500"
/>
<Icon name="bi:chevron-down" class="**:stroke-black" />
</button>
</div>
</div>
+20 -23
View File
@@ -60,96 +60,96 @@ const handleSelectAddress = (address: Address) => {
</div>
<div
class="flex flex-col items-center w-full gap-4 p-4 border border-gray-300 rounded-xl bg-gray-50"
class="flex flex-col items-center w-full gap-4 p-4 border border-slate-200 rounded-xl bg-slate-50"
>
<span
class="flex items-center justify-start w-full lg:text-[1.125rem] font-semibold text-gray-900"
class="flex items-center justify-start w-full lg:text-[1.125rem] font-semibold text-slate-900"
>
زمان و شیوه ارسال
شیوه ارسال
</span>
<label
@click="deliveryData.deliveryMethod.pishtaz = true"
:class="
deliveryData.deliveryMethod.pishtaz
? 'ring-cyan-500 ring-offset-2 ring-2'
? 'ring-black ring-offset-2 ring-2'
: ''
"
class="flex flex-col select-none w-full gap-2 p-3 transition-all border cursor-pointer delivery-option focus-within:ring-2 ring-cyan-500 ring-offset-2 focus-within:border-cyan-500 rounded-100 border-gray-300 bg-gray-50"
class="flex flex-col select-none w-full gap-2 p-3 transition-all border cursor-pointer delivery-option focus-within:ring-2 ring-black ring-offset-2 focus-within:border-black rounded-100 border-slate-200 bg-slate-50"
>
<div class="flex items-center justify-between w-full">
<div class="flex items-center gap-2.5">
<SwitchRoot
v-model="deliveryData.deliveryMethod.pishtaz"
:defaultValue="false"
class="w-[3rem] h-[1.8rem] shrink-0 flex data-[state=unchecked]:bg-slate-200 data-[state=checked]:bg-cyan-500 border border-slate-300 data-[state=checked]:border-cyan-800/20 rounded-full relative transition-all focus-within:outline-none"
class="w-[3rem] h-[1.8rem] shrink-0 flex data-[state=unchecked]:bg-slate-200 data-[state=checked]:bg-black border border-slate-200 data-[state=checked]:border-black/20 rounded-full relative transition-all focus-within:outline-none"
>
<SwitchThumb
class="size-6 my-auto bg-white text-sm ms-1 flex items-center justify-center shadow-xl rounded-full transition-transform translate-x-0.5 will-change-transform data-[state=checked]:-translate-x-[68%]"
/>
</SwitchRoot>
<span
class="w-full text-gray-800 text-sm lg:text-[1rem]"
class="w-full text-slate-800 text-sm lg:text-[1rem]"
>پست پیشتاز</span
>
</div>
<span class="text-gray-800 text-sm lg:text-[1rem]">
<span class="text-slate-800 text-sm lg:text-[1rem]">
۱۵۰٬۰۰۰ تومان
</span>
</div>
</label>
<label
class="flex items-center opacity-50 select-none pointer-events-none justify-between w-full p-3 transition-all border cursor-pointer delivery-option focus-within:ring-2 ring-cyan-500 ring-offset-2 focus-within:border-cyan-500 rounded-100 border-gray-300 bg-gray-50"
class="flex items-center opacity-50 select-none pointer-events-none justify-between w-full p-3 transition-all border cursor-pointer delivery-option focus-within:ring-2 ring-black ring-offset-2 focus-within:border-black rounded-100 border-slate-200 bg-slate-50"
>
<div class="flex items-center gap-2.5">
<SwitchRoot
v-model="deliveryData.deliveryMethod.tipax"
class="w-[3rem] h-[1.8rem] shrink-0 flex data-[state=unchecked]:bg-slate-200 data-[state=checked]:bg-cyan-500 border border-slate-300 data-[state=checked]:border-cyan-800/20 rounded-full relative transition-all focus-within:outline-none"
class="w-[3rem] h-[1.8rem] shrink-0 flex data-[state=unchecked]:bg-slate-200 data-[state=checked]:bg-black border border-slate-200 data-[state=checked]:border-black/20 rounded-full relative transition-all focus-within:outline-none"
>
<SwitchThumb
class="size-6 my-auto bg-white text-sm ms-1 flex items-center justify-center shadow-xl rounded-full transition-transform translate-x-0.5 will-change-transform data-[state=checked]:-translate-x-[68%]"
/>
</SwitchRoot>
<span class="w-full text-gray-800 text-sm lg:text-[1rem]"
<span class="w-full text-slate-800 text-sm lg:text-[1rem]"
>تیپاکس</span
>
</div>
<span class="text-gray-800 text-sm lg:text-[1rem]">
<span class="text-slate-800 text-sm lg:text-[1rem]">
۱۵۰٬۰۰۰ تومان
</span>
</label>
<label
class="flex items-center opacity-50 select-none pointer-events-none justify-between w-full p-3 transition-all border cursor-pointer delivery-option focus-within:ring-2 ring-cyan-500 ring-offset-2 focus-within:border-cyan-500 rounded-100 border-gray-300 bg-gray-50"
class="flex items-center opacity-50 select-none pointer-events-none justify-between w-full p-3 transition-all border cursor-pointer delivery-option focus-within:ring-2 ring-black ring-offset-2 focus-within:border-black rounded-100 border-slate-200 bg-slate-50"
>
<div class="flex items-center gap-2.5">
<SwitchRoot
v-model="deliveryData.deliveryMethod.peyk"
class="w-[3rem] h-[1.8rem] shrink-0 flex data-[state=unchecked]:bg-slate-200 data-[state=checked]:bg-cyan-500 border border-slate-300 data-[state=checked]:border-cyan-800/20 rounded-full relative transition-all focus-within:outline-none"
class="w-[3rem] h-[1.8rem] shrink-0 flex data-[state=unchecked]:bg-slate-200 data-[state=checked]:bg-black border border-slate-200 data-[state=checked]:border-black/20 rounded-full relative transition-all focus-within:outline-none"
>
<SwitchThumb
class="size-6 my-auto bg-white text-sm ms-1 flex items-center justify-center shadow-xl rounded-full transition-transform translate-x-0.5 will-change-transform data-[state=checked]:-translate-x-[68%]"
/>
</SwitchRoot>
<span class="w-full text-gray-800 text-sm lg:text-[1rem]"
<span class="w-full text-slate-800 text-sm lg:text-[1rem]"
>ارسال با پیک (فقط ارسال درون شهری شیراز)</span
>
</div>
<span class="text-gray-800 text-sm lg:text-[1rem]">
<span class="text-slate-800 text-sm lg:text-[1rem]">
۱۵۰٬۰۰۰ تومان
</span>
</label>
</div>
<div
class="flex flex-col items-center w-full gap-4 p-4 border lg:gap-6 border-gray-300 rounded-xl bg-gray-50"
class="flex flex-col items-center w-full gap-4 p-4 border lg:gap-6 border-slate-200 rounded-xl bg-slate-50"
>
<span
class="flex items-center justify-start w-full lg:text-[1.125rem] font-semibold text-gray-900"
class="flex items-center justify-start w-full lg:text-[1.125rem] font-semibold text-slate-900"
>
خلاصه سفارش
</span>
@@ -161,13 +161,10 @@ const handleSelectAddress = (address: Address) => {
<div class="h-7 flex-center col-span-full lg:hidden">
<button class="gap-2 flex-center">
<span class="text-sm font-bold text-cyan-500">
<span class="text-sm font-bold text-black">
مشاهده بیشتر
</span>
<Icon
name="bi:chevron-down"
class="**:stroke-cyan-500"
/>
<Icon name="bi:chevron-down" class="**:stroke-black" />
</button>
</div>
</div>
+1
View File
@@ -2,6 +2,7 @@
definePageMeta({
layout: "cart",
pageTitle: "سبد خرید",
prevPage: { name: "index", label: "بازگشت به خانه" },
nextPage: { name: "cart-delivery", label: "انتخاب آدرس" },
});
</script>