-
{{ priceCalculated(item.event.data.buy[0].amount) }}
+
{{ priceCalculated(item.amount) }}
@@ -121,8 +121,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 0751d5f..072b57d 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 }}
@@ -53,6 +53,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: {
@@ -132,9 +133,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 }}
( $ {{ 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,'----')
}