增加当前物品是否在购物车的判断

This commit is contained in:
CounterFire2023 2024-06-29 14:17:45 +08:00
parent 6868d11062
commit f2aea33b9c

View File

@ -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')