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="id">{{ item.nft.token_id }}</div>
<div class="price"> <div class="price">
<!-- <div>{{ priceCalculated(buyDataArr[0].event.data.buy[0].amount) }}</div> --> <!-- <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"> <div class="price-img">
<img :src="item.icon" alt /> <img :src="item.icon" alt />
</div> </div>
@ -76,7 +76,7 @@ const props = defineProps({
const totalPrice = computed(() => { const totalPrice = computed(() => {
let total = 0n; let total = 0n;
props.buyDataArr.forEach((item) => { props.buyDataArr.forEach((item) => {
total += BigInt(item.event.data.buy[0].amount); total += item.amount;
}); });
return priceCalculated(total); return priceCalculated(total);
}); });

View File

@ -17,7 +17,7 @@
</div> </div>
<div class="cart-item-right"> <div class="cart-item-right">
<div class="cart-item-right-price"> <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"> <div class="cart-item-right-price-img">
<img :src="item.icon" alt=""> <img :src="item.icon" alt="">
</div> </div>
@ -122,8 +122,8 @@ const getCartList = async () => {
console.log(res) console.log(res)
if (res.data && res.data.length > 0) { if (res.data && res.data.length > 0) {
for (let sub of res.data) { for (let sub of res.data) {
if (sub.event?.data?.buy && sub.event.data.buy.length > 0) { if (sub.event?.data) {
const _data = formatPrice(sub.event.data.buy[0]) const _data = formatPrice(sub.event.data)
sub.icon = _data.icon sub.icon = _data.icon
sub.usd = _data.usd sub.usd = _data.usd
sub.currencyName = _data.currencyName sub.currencyName = _data.currencyName

View File

@ -204,11 +204,19 @@ export const switchEthereumChain = async (provider, targetChainId) => {
return deferred.promise return deferred.promise
} }
export const formatPrice = (data) => { export const formatPrice = (nftData) => {
const data = nftData.buy[0]
const feeList = nftData.fees || []
const marketplaceList = useMarketplaceStore() const marketplaceList = useMarketplaceStore()
const type = data.item_type const type = data.item_type
let address; let address;
let icon, price, usd, currencyName; 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 tokenAmount = priceCalculated(data.amount)
const amount = parseFloat(ethers.utils.formatUnits(data.amount, 18)) const amount = parseFloat(ethers.utils.formatUnits(data.amount, 18))
if (type == 'NATIVE') { if (type == 'NATIVE') {
@ -232,5 +240,5 @@ export const formatPrice = (data) => {
usd = (amount * price.price).toFixed(2) 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 class="card-price">
<div> <div>
<span> <span>
{{ priceCalculated(nftData.event.data.buy[0].amount) }} {{ price }}
</span> </span>
<img :src="icon" alt="图片"> <img :src="icon" alt="图片">
</div> </div>
@ -54,6 +54,7 @@ const emit = defineEmits(['renewNft'])
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
const router = useRouter(); const router = useRouter();
const icon = ref('') const icon = ref('')
const price = ref('-')
const { proxy } = getCurrentInstance(); const { proxy } = getCurrentInstance();
const props = defineProps({ const props = defineProps({
nftData: { nftData: {
@ -136,9 +137,10 @@ const cardLogin = async () => {
onMounted(() => { onMounted(() => {
// console.log(JSON.parse(JSON.stringify(props.nftData)), "-=-=-"); // console.log(JSON.parse(JSON.stringify(props.nftData)), "-=-=-");
if (props.nftData?.event?.data?.buy && props.nftData?.event?.data?.buy.length > 0) { if (props.nftData?.event?.data) {
const data = formatPrice(props.nftData?.event?.data?.buy[0]) const data = formatPrice(props.nftData?.event?.data)
icon.value = data.icon icon.value = data.icon
price.value = priceCalculated(data.amount.toString())
} }
}); });
</script> </script>

View File

@ -25,7 +25,7 @@
</li> </li>
<li> <li>
<div class="price"> <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"> <img :src="icon" alt="ICON">
<span>( $ {{ usd }} )</span> <span>( $ {{ usd }} )</span>
</div> </div>
@ -164,6 +164,7 @@ const myAddress = localWalletStore.address
const nftAbilities = ref() const nftAbilities = ref()
const icon = ref('') const icon = ref('')
const usd = ref('') const usd = ref('')
const price = ref('')
// //
const buyNow = async () => { const buyNow = async () => {
@ -291,10 +292,11 @@ const getDetail = async () => {
nftData.event = data.event nftData.event = data.event
nftAbilities.value = data.nft.detail nftAbilities.value = data.nft.detail
detailData.value = data detailData.value = data
if (data.event?.data?.buy && data.event?.data?.buy.length > 0) { if (data.event?.data) {
const _data = formatPrice(data.event?.data?.buy[0]) const _data = formatPrice(data.event?.data)
icon.value = _data.icon icon.value = _data.icon
usd.value = _data.usd usd.value = _data.usd
price.value = priceCalculated(_data.amount.toString())
} }
console.log(data,'----') console.log(data,'----')
} }