Merge branch 'new-CounterFire' of http://git.kingsome.cn/huangjinming/CounterFireGames into new-CounterFire
This commit is contained in:
commit
5e9ca195e9
@ -19,6 +19,7 @@ import OverView from "@/components/common/searchView/Overview.vue";
|
||||
import Card from "@/components/common/hangingCard.vue";
|
||||
import { apiHangingState } from "@/utils/marketplace"
|
||||
import {walletStore} from "@/store/wallet";
|
||||
import { formatPrice } from "@/components/chain/utils"
|
||||
const localWalletStore = walletStore()
|
||||
|
||||
const nftList = ref([])
|
||||
@ -54,6 +55,15 @@ const getHistoryList = async () => {
|
||||
}
|
||||
if(myAddress) {
|
||||
let res = await apiHangingState(data)
|
||||
for (let sub of res.rows) {
|
||||
if (sub.event?.data) {
|
||||
const _data = formatPrice(sub.event.data)
|
||||
sub.event.icon = _data.icon
|
||||
sub.event.usd = _data.usd
|
||||
sub.event.currencyName = _data.currencyName
|
||||
sub.event.amount = _data.amount
|
||||
}
|
||||
}
|
||||
nftList.value = res.rows
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import StatusRadio from "@/components/common/searchView/statusRadio.vue";
|
||||
import Card from "@/components/common/tradingCard.vue";
|
||||
import { apiHistoryState, nftDetail } from "@/utils/marketplace"
|
||||
import {walletStore} from "@/store/wallet";
|
||||
import { parseTradeEvent } from "@/components/chain/utils"
|
||||
const localWalletStore = walletStore()
|
||||
const myAddress = ref(localWalletStore.address)
|
||||
const nftList = ref([])
|
||||
@ -46,6 +47,15 @@ const getHistoryList = async () => {
|
||||
}
|
||||
if(myAddress.value) {
|
||||
let res = await apiHistoryState(myAddress.value,data)
|
||||
for (let sub of res.rows) {
|
||||
if (sub.event?.data) {
|
||||
const _data = parseTradeEvent(sub.event)
|
||||
sub.event.icon = _data.icon
|
||||
sub.event.usd = _data.usd
|
||||
sub.event.currencyName = _data.currencyName
|
||||
sub.event.amount = _data.amount
|
||||
}
|
||||
}
|
||||
nftList.value = res.rows
|
||||
}
|
||||
}
|
||||
|
@ -242,3 +242,38 @@ export const formatPrice = (nftData) => {
|
||||
}
|
||||
return {icon, price, usd, tokenAmount, currencyName, amount: amountBn}
|
||||
}
|
||||
|
||||
export const parseTradeEvent = (event) => {
|
||||
const marketplaceList = useMarketplaceStore()
|
||||
const payments = event.data?.details?.payment
|
||||
const feeList = payments?.fees || []
|
||||
let amountBn = 0n;
|
||||
for (const fee of feeList) {
|
||||
amountBn += BigInt(fee.amount)
|
||||
}
|
||||
let address;
|
||||
let icon, price, usd, currencyName;
|
||||
if (payments?.token?.contract_address) {
|
||||
address = payments?.token?.contract_address
|
||||
if (address) {
|
||||
address = address.toLowerCase()
|
||||
}
|
||||
} else {
|
||||
address = 'NATIVE'
|
||||
}
|
||||
if (!address) {
|
||||
return {icon, price}
|
||||
}
|
||||
if (address) {
|
||||
const currencyData = currencyMap[address]
|
||||
currencyName = currencyData.name
|
||||
if (currencyData) {
|
||||
const currencyPrice = marketplaceList.priceDatas
|
||||
icon = currencyData.icon
|
||||
price = currencyPrice.find(o => o.id == currencyData.id_query)
|
||||
let amount = parseFloat(ethers.utils.formatUnits(amountBn, 18))
|
||||
usd = (amount * price.price).toFixed(2)
|
||||
}
|
||||
}
|
||||
return {icon, price, usd, currencyName, amount: amountBn}
|
||||
}
|
@ -16,8 +16,10 @@
|
||||
<div class="price">
|
||||
{{ priceCalculated(event.data.buy[0].amount) }}
|
||||
<div class="price-icon">
|
||||
<img src="@/assets/img/marketplace/ETHicon.png" alt="">
|
||||
<!-- <img src="@/assets/img/marketplace/ETHicon.png" alt=""> -->
|
||||
<img :src="event.icon" alt="">
|
||||
</div>
|
||||
<!-- {{ priceCalculated(event.data.buy[0].amount) }} -->
|
||||
</div>
|
||||
</template>
|
||||
</a-table-column>
|
||||
@ -53,6 +55,7 @@ import ImgCard from "@/components/common/imgCard.vue"
|
||||
import { priceCalculated, showTime } from "@/configs/priceCalculate"
|
||||
import { BlockChain } from "@/components/chain/BlockChain"
|
||||
|
||||
|
||||
const props = defineProps({
|
||||
nftData: {
|
||||
type: Array,
|
||||
@ -60,6 +63,7 @@ const props = defineProps({
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
const eventNft = async (e) => {
|
||||
console.log(e.data.id)
|
||||
// return
|
||||
@ -68,7 +72,6 @@ const eventNft = async (e) => {
|
||||
console.log("---",res)
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
@ -21,16 +21,16 @@
|
||||
<a-table-column title="Price" data-index="event" :width="400">
|
||||
<template #default="{ text: event }">
|
||||
<div class="price">
|
||||
<div class="nft-price">{{ event.data.details.asset[0].amount }}</div>
|
||||
<p>$ 400</p>
|
||||
<div class="nft-price">{{ priceCalculated(event.amount) }}</div>
|
||||
<p>$ {{ event.usd }}</p>
|
||||
</div>
|
||||
</template>
|
||||
</a-table-column>
|
||||
<a-table-column title="" data-index="event">
|
||||
<template #default="{ text: event }">
|
||||
<div class="price-icon">
|
||||
<span>{{event}}</span>
|
||||
<img src="@/assets/img/marketplace/ETHicon.png" alt="">
|
||||
<!-- <span>{{event}}</span> -->
|
||||
<img :src="event.icon" alt="">
|
||||
</div>
|
||||
</template>
|
||||
</a-table-column>
|
||||
@ -51,7 +51,7 @@
|
||||
<a-table-column title="" data-index="event">
|
||||
<template #default="{ text: event }">
|
||||
<div class="from-to-icon">
|
||||
<span>{{event}}</span>
|
||||
<!-- <span>{{event}}</span> -->
|
||||
<img src="@/assets/img/marketplace/Arrows.png" alt="">
|
||||
</div>
|
||||
</template>
|
||||
@ -70,11 +70,11 @@
|
||||
</div>
|
||||
</template>
|
||||
</a-table-column>
|
||||
<a-table-column title="Contract" data-index="nft" :width="400">
|
||||
<template #default="{ text: nft }">
|
||||
<a-table-column title="Contract" data-index="event" :width="400">
|
||||
<template #default="{ text: event }">
|
||||
<div class="contract">
|
||||
<div class="nft-contract">
|
||||
<a :href="nft.meta_url" target="_back">
|
||||
<a :href="chainExpolor(event.data.blockchain_metadata.transaction_hash)" target="_back">
|
||||
<span>Etherscan</span>
|
||||
<img src="@/assets/img/marketplace/Links web icon.png" alt="">
|
||||
</a>
|
||||
@ -89,7 +89,8 @@
|
||||
<script setup>
|
||||
import { ref } from "vue"
|
||||
import ImgCard from "@/components/common/imgCard.vue"
|
||||
import { sliceAddress, showTime } from "@/configs/priceCalculate"
|
||||
import { sliceAddress, showTime, priceCalculated } from "@/configs/priceCalculate"
|
||||
import { currentChainCfg } from '@/components/chain/utils'
|
||||
|
||||
const props = defineProps({
|
||||
nftData: {
|
||||
@ -98,6 +99,12 @@ const props = defineProps({
|
||||
},
|
||||
});
|
||||
|
||||
const chainExpolor = (urlPart) => {
|
||||
const base = currentChainCfg.explorerurl
|
||||
return `${base}/tx/${urlPart}`
|
||||
}
|
||||
|
||||
|
||||
|
||||
console.log(props.nftData)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user