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] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BD=93=E5=89=8D=E7=89=A9?= =?UTF-8?q?=E5=93=81=E6=98=AF=E5=90=A6=E5=9C=A8=E8=B4=AD=E7=89=A9=E8=BD=A6?= =?UTF-8?q?=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')