fixed add to cart bugs

This commit is contained in:
mohadese-nm
2024-10-02 09:38:51 +03:30
parent dad18b1a34
commit 1c2169b807
16 changed files with 840 additions and 443 deletions
+38 -35
View File
@@ -1,53 +1,56 @@
<template>
<NuxtLayout :name="device" :config="config">
<main class="cart">
<CartTabs />
<section>
<div>
<ul v-if="cart.items.length > 0">
<li v-for="(item, i) in cart.items" :key="i">
<CartItem :data="item.product" />
</li>
</ul>
<CartTotalAside />
</div>
</section>
<CartTotalFixed v-if="device == 'mobile'" />
<CartBuyersBought />
</main>
</NuxtLayout>
<NuxtLayout :name="device" :config="config">
<main class="cart">
<CartTabs />
<section>
<div>
<ul v-if="cart.items.length > 0">
<li v-for="(item, i) in cart.items" :key="i">
<CartItem :data="item.product" />
</li>
</ul>
<CartTotalAside />
</div>
</section>
<CartTotalFixed v-if="device == 'mobile'" />
<CartBuyersBought />
</main>
</NuxtLayout>
</template>
<script setup>
const config = reactive({ mobile: { header: false } })
const { device } = inject('service')
const config = reactive({ mobile: { header: false } });
const { device } = inject("service");
const cart = useCartStore()
cart.get()
const cart = useCartStore();
if (import.meta.client && localStorage.getItem("cart")) {
cart.items = JSON.parse(localStorage.getItem("cart") || "{}");
} else cart.get();
provide('data', computed(() => cart.items))
provide(
"data",
computed(() => cart.items)
);
</script>
<style lang="scss">
.cart {
@apply w-full flex flex-col gap-[2.6rem] pb-32 lg:gap-6 lg:pt-10;
@apply w-full flex flex-col gap-[2.6rem] pb-32 lg:gap-6 lg:pt-10;
&>section:not([class]) {
@apply w-full min-h-96 flex lg:mb-[6.4rem];
& > section:not([class]) {
@apply w-full min-h-96 flex lg:mb-[6.4rem];
&>div {
@apply container flex flex-col items-center lg:items-start lg:flex-row gap-6;
& > div {
@apply container flex flex-col items-center lg:items-start lg:flex-row gap-6;
&>ul {
@apply max-w-[67.6rem] flex flex-col border-b lg:rounded-[0.6rem] lg:border border-[#E5E5E5] grow;
& > ul {
@apply max-w-[67.6rem] flex flex-col border-b lg:rounded-[0.6rem] lg:border border-[#E5E5E5] grow;
&>li {
@apply p-6 lg:p-10 border-b last:border-b-0 border-[#E5E5E5];
}
}
& > li {
@apply p-6 lg:p-10 border-b last:border-b-0 border-[#E5E5E5];
}
}
}
}
}
</style>
+27 -15
View File
@@ -1,22 +1,34 @@
<template>
<div class="flex flex-col w-72 h-max mx-auto mt-60 gap-6 lg:gap-10">
<InputText
class="w-full rounded-[0.6rem] border shadow-none border-[#CCCCCC] text-zinc-800 font-iran-sans"
v-model="pass"
placeholder="پسورد"
></InputText>
<Button class="text-center" @click="confirm">تائید</Button>
</div>
<NuxtLayout :name="device" :config="config">
<main class="home">
<HomeTopSlider />
<HomeMainCategories />
<HomeBanners />
<HomeAmazingOffers />
<HomeReviews />
<HomeEstProducts />
<HomePopularCategories />
<HomeLatestPosts />
<HomeProducers :title="$t('producers')" />
</main>
</NuxtLayout>
</template>
<script setup>
const router = useRouter();
const pass = ref("");
const confirm = () => {
if (pass.value === "s@A123456") {
router.push("/home")
}
}
import init from "../initialize/home";
provide("init", init);
const { device } = inject("service");
const config = reactive({
mobile: { header: { search: true, menu: true } },
});
const { status, data, error } = await useFetch("/api/pages/landing");
if (status.value == "success") {
useSeoMeta(data.value.meta || {});
provide("data", data.value);
} else throw createError(error.value);
</script>
<style lang="scss">