From 6868d11062eee872c88113f8ce47dd73818ec195 Mon Sep 17 00:00:00 2001 From: CounterFire2023 <136581895+CounterFire2023@users.noreply.github.com> Date: Sat, 29 Jun 2024 14:08:39 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=B4=AD=E7=89=A9?= =?UTF-8?q?=E8=BD=A6=E6=97=B6,=20=E5=88=A4=E6=96=AD=E5=87=BA=E5=94=AE?= =?UTF-8?q?=E7=9A=84=E8=B4=A7=E5=B8=81=E6=98=AF=E5=90=A6=E5=92=8C=E8=B4=AD?= =?UTF-8?q?=E7=89=A9=E8=BD=A6=E9=87=8C=E7=9A=84=E7=9B=B8=E5=90=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/common/card.vue | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/components/common/card.vue b/src/components/common/card.vue index 65caf74..fabc9d9 100644 --- a/src/components/common/card.vue +++ b/src/components/common/card.vue @@ -41,8 +41,6 @@ import ImgCard from "@/components/common/imgCard.vue" import {priceCalculated} from "@/configs/priceCalculate.js" import {walletStore} from "@/store/wallet"; import { BlockChain } from "@/components/chain/BlockChain" -import LazyLoadImg from "@/components/lazyloadimg" -import placeholderImg from '@/assets/img/marketplace/GenesisHeroes_NFT.png' import { useMarketplaceStore } from "@/store/marketplace" @@ -113,7 +111,22 @@ const addCart = async (val) => { } ] } + try { + + let res = await marketplaceList.getCartListState() + if (res.data && res.data.length) { + const currency = res.data[0].event?.data?.buy[0].contract_address || '' + const type = res.data[0].event?.data?.buy[0].item_type || '' + const currentCurrency = val.event?.data?.buy[0].contract_address || '' + const currentType = val.event?.data?.buy[0].item_type || '' + if (currency != currentCurrency || type != currentType) { + // TODO: 提示用户添加相同类型的商品 + alert('Please add the same type of item to the shopping cart') + return + } + } + const { errcode, errmsg } = await marketplaceList.addCartListState(data) console.log(errcode, errmsg) if(errcode == 0) { From f2aea33b9c2701c17e718ac0c332f3a1b4ce44a8 Mon Sep 17 00:00:00 2001 From: CounterFire2023 <136581895+CounterFire2023@users.noreply.github.com> Date: Sat, 29 Jun 2024 14:17:45 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E7=89=A9=E5=93=81=E6=98=AF=E5=90=A6=E5=9C=A8=E8=B4=AD=E7=89=A9?= =?UTF-8?q?=E8=BD=A6=E7=9A=84=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/common/card.vue | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/components/common/card.vue b/src/components/common/card.vue index fabc9d9..e78701c 100644 --- a/src/components/common/card.vue +++ b/src/components/common/card.vue @@ -116,10 +116,19 @@ const addCart = async (val) => { let res = await marketplaceList.getCartListState() if (res.data && res.data.length) { + let exists = res.data.find(item => { + return item.nft.token_id == val.nft.token_id && item.nft.contract_address == val.nft.contract_address + }) + if (exists) { + alert('already in the shopping cart') + return + } + const currency = res.data[0].event?.data?.buy[0].contract_address || '' const type = res.data[0].event?.data?.buy[0].item_type || '' const currentCurrency = val.event?.data?.buy[0].contract_address || '' const currentType = val.event?.data?.buy[0].item_type || '' + if (currency != currentCurrency || type != currentType) { // TODO: 提示用户添加相同类型的商品 alert('Please add the same type of item to the shopping cart')