Merge branch 'new-CounterFire' of http://git.kingsome.cn/huangjinming/CounterFireGames into new-CounterFire
This commit is contained in:
commit
53490821b3
@ -19,7 +19,7 @@
|
|||||||
<div class="cart-item-right-price">
|
<div class="cart-item-right-price">
|
||||||
<div>{{ priceCalculated(item.event.data.buy[0].amount) }}</div>
|
<div>{{ priceCalculated(item.event.data.buy[0].amount) }}</div>
|
||||||
<div class="cart-item-right-price-img">
|
<div class="cart-item-right-price-img">
|
||||||
<img src="@/assets/img/marketplace/ETHicon.png" alt="">
|
<img :src="item.icon" alt="">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="cart-item-right-clear" @click="deleteNft(item)">
|
<div class="cart-item-right-clear" @click="deleteNft(item)">
|
||||||
@ -33,14 +33,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="cart-total-price">
|
<div class="cart-total-price">
|
||||||
<div class="top">
|
<template v-for="(item, index) in priceList" :key="index">
|
||||||
<div class="left">Total Price</div>
|
<div :class="{'top': index == 0, 'bottom': index > 0}">
|
||||||
<div class="right">{{ completePrice(cartList) }} <img src="@/assets/img/marketplace/ETHicon.png" alt=""></div>
|
<div class="left" v-if="index == 0">Total Price</div>
|
||||||
|
<div class="left" v-if="index > 0"></div>
|
||||||
|
<div class="right">{{ priceCalculated(item.amount) }} <img :src="item.icon" alt=""></div>
|
||||||
</div>
|
</div>
|
||||||
|
</template>
|
||||||
<div class="bottom">
|
<div class="bottom">
|
||||||
<div class="left"></div>
|
<div class="left"></div>
|
||||||
<div class="right">
|
<div class="right">
|
||||||
<div>≈ {{ 200 }}$</div>
|
<div v-if="priceList.length > 0">≈ {{ usdTotal }}$</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -58,11 +61,13 @@ import { useRouter } from "vue-router";
|
|||||||
import { useMarketplaceStore } from "@/store/marketplace"
|
import { useMarketplaceStore } from "@/store/marketplace"
|
||||||
import {priceCalculated, completePrice} from "@/configs/priceCalculate.js"
|
import {priceCalculated, completePrice} from "@/configs/priceCalculate.js"
|
||||||
import {createModal} from "@/utils/model.util";
|
import {createModal} from "@/utils/model.util";
|
||||||
|
import {formatPrice} from "@/components/chain/utils"
|
||||||
const marketplaceList = useMarketplaceStore()
|
const marketplaceList = useMarketplaceStore()
|
||||||
import {
|
import {
|
||||||
apiDelCartList,
|
apiDelCartList,
|
||||||
apiClearCartList,
|
apiClearCartList,
|
||||||
} from "@/utils/marketplace"
|
} from "@/utils/marketplace"
|
||||||
|
import { computed } from "vue";
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const emit = defineEmits(['clickStatusChild'])
|
const emit = defineEmits(['clickStatusChild'])
|
||||||
|
|
||||||
@ -77,6 +82,33 @@ const toMarketplace = () => {
|
|||||||
router.push('/marketplace');
|
router.push('/marketplace');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const priceList = computed(() => {
|
||||||
|
let map = new Map()
|
||||||
|
for (let item of cartList.value) {
|
||||||
|
if (!map.has(item.currencyName)) {
|
||||||
|
map.set(item.currencyName, {
|
||||||
|
icon: item.icon,
|
||||||
|
amount: 0n,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
let data = map.get(item.currencyName)
|
||||||
|
data.amount += item.amount
|
||||||
|
map.set(item.currencyName, data)
|
||||||
|
}
|
||||||
|
let result = []
|
||||||
|
for (let [key, value] of map) {
|
||||||
|
result.push(value)
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
});
|
||||||
|
|
||||||
|
const usdTotal = computed(() => {
|
||||||
|
let total = 0
|
||||||
|
for (let item of cartList.value) {
|
||||||
|
total += Number(item.usd)
|
||||||
|
}
|
||||||
|
return total.toFixed(2)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -86,6 +118,19 @@ const getCartList = async () => {
|
|||||||
// if(token) {
|
// if(token) {
|
||||||
try {
|
try {
|
||||||
let res = await marketplaceList.getCartListState()
|
let res = await marketplaceList.getCartListState()
|
||||||
|
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])
|
||||||
|
sub.icon = _data.icon
|
||||||
|
sub.usd = _data.usd
|
||||||
|
sub.currencyName = _data.currencyName
|
||||||
|
sub.amount = _data.amount
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
console.log(res)
|
console.log(res)
|
||||||
cartList.value = res.data
|
cartList.value = res.data
|
||||||
marketplaceList.getCartList = res
|
marketplaceList.getCartList = res
|
||||||
|
@ -100,9 +100,15 @@ export class BlockChain {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get token() {
|
async token() {
|
||||||
const suffix = (this.store.walletType == 2 || this.store.walletType == 1) ? '.cf' : ''
|
const suffix = (this.store.walletType == 2 || this.store.walletType == 1) ? '.cf' : ''
|
||||||
return this.store.token+suffix
|
let token = this.store.token;
|
||||||
|
if (!suffix) {
|
||||||
|
const res = await this.wallet.getAccessToken();
|
||||||
|
token = res.token
|
||||||
|
}
|
||||||
|
|
||||||
|
return token+suffix
|
||||||
}
|
}
|
||||||
|
|
||||||
async logout() {
|
async logout() {
|
||||||
|
@ -233,14 +233,19 @@ export class ImtblMarket {
|
|||||||
|
|
||||||
async updateCurrencyPrice() {
|
async updateCurrencyPrice() {
|
||||||
const ids = ['immutable-x', 'ethereum', 'usd-coin']
|
const ids = ['immutable-x', 'ethereum', 'usd-coin']
|
||||||
let priceList = await queryTokenPriceCg(ids);
|
try {
|
||||||
priceList = priceList.map((item) => {
|
let priceList = await queryTokenPriceCg(ids);
|
||||||
return {
|
priceList = priceList.map((item) => {
|
||||||
id: item.id,
|
return {
|
||||||
price: item.current_price
|
id: item.id,
|
||||||
}
|
price: item.current_price
|
||||||
})
|
}
|
||||||
this.marketStore.currencyPrice = priceList;
|
})
|
||||||
return priceList;
|
this.marketStore.currencyPrice = priceList;
|
||||||
|
return priceList;
|
||||||
|
} catch (err) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -208,8 +208,8 @@ export const formatPrice = (data) => {
|
|||||||
const marketplaceList = useMarketplaceStore()
|
const marketplaceList = useMarketplaceStore()
|
||||||
const type = data.item_type
|
const type = data.item_type
|
||||||
let address;
|
let address;
|
||||||
let icon, price, usd
|
let icon, price, usd, currencyName;
|
||||||
const tokenAmount = priceCalculated(data.amount, 3)
|
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') {
|
||||||
address = 'NATIVE'
|
address = 'NATIVE'
|
||||||
@ -224,6 +224,7 @@ export const formatPrice = (data) => {
|
|||||||
}
|
}
|
||||||
if (address) {
|
if (address) {
|
||||||
const currencyData = currencyMap[address]
|
const currencyData = currencyMap[address]
|
||||||
|
currencyName = currencyData.name
|
||||||
if (currencyData) {
|
if (currencyData) {
|
||||||
const currencyPrice = marketplaceList.priceDatas
|
const currencyPrice = marketplaceList.priceDatas
|
||||||
icon = currencyData.icon
|
icon = currencyData.icon
|
||||||
@ -231,5 +232,5 @@ export const formatPrice = (data) => {
|
|||||||
usd = (amount * price.price).toFixed(2)
|
usd = (amount * price.price).toFixed(2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {icon, price, usd, tokenAmount}
|
return {icon, price, usd, tokenAmount, currencyName, amount: BigInt(data.amount)}
|
||||||
}
|
}
|
@ -64,13 +64,13 @@ export class PassportWallet {
|
|||||||
const passportProvider = this.passportInstance.connectEvm();
|
const passportProvider = this.passportInstance.connectEvm();
|
||||||
const accounts = await passportProvider.request({ method: "eth_requestAccounts" });
|
const accounts = await passportProvider.request({ method: "eth_requestAccounts" });
|
||||||
const provider = new providers.Web3Provider(passportProvider);
|
const provider = new providers.Web3Provider(passportProvider);
|
||||||
const token = await this.passportInstance.getAccessToken()
|
const token = await this.passportInstance.getIdToken()
|
||||||
return { provider, accounts, token };
|
return { provider, accounts, token };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async getAccessToken() {
|
async getAccessToken() {
|
||||||
const token = await this.passportInstance.getAccessToken();
|
const token = await this.passportInstance.getIdToken();
|
||||||
return { token }
|
return { token }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ const net_id = import.meta.env.VUE_APP_NET_ID
|
|||||||
const toJson = res => res.json();
|
const toJson = res => res.json();
|
||||||
|
|
||||||
const httpPost = async (url, data) => {
|
const httpPost = async (url, data) => {
|
||||||
const token = new BlockChain().token;
|
const token = await new BlockChain().token();
|
||||||
let headers = {"Content-Type": "application/json"};
|
let headers = {"Content-Type": "application/json"};
|
||||||
// let token = token;
|
// let token = token;
|
||||||
if (token) {
|
if (token) {
|
||||||
@ -23,7 +23,7 @@ const httpPost = async (url, data) => {
|
|||||||
|
|
||||||
|
|
||||||
const httpGet = async (url, data) => {
|
const httpGet = async (url, data) => {
|
||||||
const token = new BlockChain().token;
|
const token = await new BlockChain().token();
|
||||||
let headers = {"Content-Type": "application/json"};
|
let headers = {"Content-Type": "application/json"};
|
||||||
if (token) {
|
if (token) {
|
||||||
headers['Authorization'] = `Bearer ${token}`;
|
headers['Authorization'] = `Bearer ${token}`;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user