diff --git a/src/components/Dialogs/buyDialog.vue b/src/components/Dialogs/buyDialog.vue index f60919c..9e58ae5 100644 --- a/src/components/Dialogs/buyDialog.vue +++ b/src/components/Dialogs/buyDialog.vue @@ -34,7 +34,7 @@
{{ item.nft.token_id }}
-
{{ priceCalculated(item.event.data.buy[0].amount) }}
+
{{ priceCalculated(item.amount) }}
@@ -76,7 +76,7 @@ const props = defineProps({ const totalPrice = computed(() => { let total = 0n; props.buyDataArr.forEach((item) => { - total += BigInt(item.event.data.buy[0].amount); + total += item.amount; }); return priceCalculated(total); }); diff --git a/src/components/cart/index.vue b/src/components/cart/index.vue index 2864c37..11e402f 100644 --- a/src/components/cart/index.vue +++ b/src/components/cart/index.vue @@ -17,7 +17,7 @@
-
{{ priceCalculated(item.event.data.buy[0].amount) }}
+
{{ priceCalculated(item.amount) }}
@@ -122,8 +122,8 @@ const getCartList = async () => { console.log(res) if (res.data && res.data.length > 0) { for (let sub of res.data) { - if (sub.event?.data?.buy && sub.event.data.buy.length > 0) { - const _data = formatPrice(sub.event.data.buy[0]) + if (sub.event?.data) { + const _data = formatPrice(sub.event.data) sub.icon = _data.icon sub.usd = _data.usd sub.currencyName = _data.currencyName diff --git a/src/components/chain/utils.js b/src/components/chain/utils.js index d0cfc00..d866089 100644 --- a/src/components/chain/utils.js +++ b/src/components/chain/utils.js @@ -204,11 +204,19 @@ export const switchEthereumChain = async (provider, targetChainId) => { return deferred.promise } -export const formatPrice = (data) => { +export const formatPrice = (nftData) => { + const data = nftData.buy[0] + const feeList = nftData.fees || [] const marketplaceList = useMarketplaceStore() const type = data.item_type let address; let icon, price, usd, currencyName; + let amountBn = BigInt(data.amount) + if (feeList.length > 0) { + feeList.forEach(fee => { + amountBn = amountBn + BigInt(fee.amount) + }) + } const tokenAmount = priceCalculated(data.amount) const amount = parseFloat(ethers.utils.formatUnits(data.amount, 18)) if (type == 'NATIVE') { @@ -232,5 +240,5 @@ export const formatPrice = (data) => { usd = (amount * price.price).toFixed(2) } } - return {icon, price, usd, tokenAmount, currencyName, amount: BigInt(data.amount)} + return {icon, price, usd, tokenAmount, currencyName, amount: amountBn} } \ No newline at end of file diff --git a/src/components/common/card.vue b/src/components/common/card.vue index 7f7761a..65caf74 100644 --- a/src/components/common/card.vue +++ b/src/components/common/card.vue @@ -11,7 +11,7 @@
- {{ priceCalculated(nftData.event.data.buy[0].amount) }} + {{ price }} 图片
@@ -54,6 +54,7 @@ const emit = defineEmits(['renewNft']) import { useRouter } from "vue-router"; const router = useRouter(); const icon = ref('') +const price = ref('-') const { proxy } = getCurrentInstance(); const props = defineProps({ nftData: { @@ -136,9 +137,10 @@ const cardLogin = async () => { onMounted(() => { // console.log(JSON.parse(JSON.stringify(props.nftData)), "-=-=-"); - if (props.nftData?.event?.data?.buy && props.nftData?.event?.data?.buy.length > 0) { - const data = formatPrice(props.nftData?.event?.data?.buy[0]) + if (props.nftData?.event?.data) { + const data = formatPrice(props.nftData?.event?.data) icon.value = data.icon + price.value = priceCalculated(data.amount.toString()) } }); diff --git a/src/views/DetailView.vue b/src/views/DetailView.vue index e5be773..c4a572a 100644 --- a/src/views/DetailView.vue +++ b/src/views/DetailView.vue @@ -25,7 +25,7 @@
  • - {{ priceCalculated(detailData.event.data.buy[0].amount) }}  + {{ price }}  ICON ( $ {{ usd }} )
    @@ -164,6 +164,7 @@ const myAddress = localWalletStore.address const nftAbilities = ref() const icon = ref('') const usd = ref('') +const price = ref('') // 购买 const buyNow = async () => { @@ -291,10 +292,11 @@ const getDetail = async () => { nftData.event = data.event nftAbilities.value = data.nft.detail detailData.value = data - if (data.event?.data?.buy && data.event?.data?.buy.length > 0) { - const _data = formatPrice(data.event?.data?.buy[0]) + if (data.event?.data) { + const _data = formatPrice(data.event?.data) icon.value = _data.icon usd.value = _data.usd + price.value = priceCalculated(_data.amount.toString()) } console.log(data,'----') }