Merge branch 'new-CounterFire' of http://git.kingsome.cn/huangjinming/CounterFireGames into new-CounterFire

This commit is contained in:
yuyongdong 2024-06-29 13:37:44 +08:00
commit bc3df5383b
5 changed files with 25 additions and 13 deletions

View File

@ -34,7 +34,7 @@
<div class="id">{{ item.nft.token_id }}</div>
<div class="price">
<!-- <div>{{ priceCalculated(buyDataArr[0].event.data.buy[0].amount) }}</div> -->
<div>{{ priceCalculated(item.event.data.buy[0].amount) }}</div>
<div>{{ priceCalculated(item.amount) }}</div>
<div class="price-img">
<img :src="item.icon" alt />
</div>
@ -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);
});

View File

@ -17,7 +17,7 @@
</div>
<div class="cart-item-right">
<div class="cart-item-right-price">
<div>{{ priceCalculated(item.event.data.buy[0].amount) }}</div>
<div>{{ priceCalculated(item.amount) }}</div>
<div class="cart-item-right-price-img">
<img :src="item.icon" alt="">
</div>
@ -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

View File

@ -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}
}

View File

@ -11,7 +11,7 @@
<div class="card-price">
<div>
<span>
{{ priceCalculated(nftData.event.data.buy[0].amount) }}
{{ price }}
</span>
<img :src="icon" alt="图片">
</div>
@ -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())
}
});
</script>

View File

@ -25,7 +25,7 @@
</li>
<li>
<div class="price">
<span class="bold">{{ priceCalculated(detailData.event.data.buy[0].amount) }}&nbsp;</span>
<span class="bold">{{ price }}&nbsp;</span>
<img :src="icon" alt="ICON">
<span>( $ {{ usd }} )</span>
</div>
@ -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,'----')
}