277 lines
7.8 KiB
Vue

<template>
<a-modal :class="'buyDia'" v-model:open="props.buyDialogVisible" :closable="false" :footer="null" style="width: 1141px;" :maskClosable="false" @ok="handleOk">
<!-- <template #footer>
<a-button key="back" @click="handleCancel">Return</a-button>
<a-button key="submit" type="primary" :loading="loading" @click="handleOk">Submit</a-button>
</template> -->
<div class="top-close" @click="handleCancel">
<img src="@/assets/img/marketplace/Close counter.png" alt="">
</div>
<div class="content">
<div class="content-title">Transaction confirmation ( {{ props.buyDataArr.length }} )</div>
<div class="content-table">
<div>NFT</div>
<div>Token ID</div>
<div>Price</div>
</div>
<div class="content-nfts" v-for="(item, index) in props.buyDataArr" :key="index">
<li>
<div class="nft">
<div class="nft-img">
<img :src="item.nft.image" alt="">
</div>
<div class="nft-name">{{ item.nft.name }}</div>
</div>
<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 class="price-img"><img src="@/assets/img/marketplace/ETHicon.png" alt=""></div>
</div>
</li>
</div>
</div>
<div class="btm">
<div class="btm-left">
<li>Total&nbsp;:&nbsp;</li>
<li>
<div>
<!-- <span>{{ priceCalculated(buyDataArr[0].event.data.buy[0].amount) }}</span> -->
<span>0.08</span>
<img src="@/assets/img/marketplace/ETHicon.png" alt="">
</div>
<!-- <div class="money">$ 400</div> -->
</li>
</div>
<div class="btm-right" @click="buyConfirm">Confirm</div>
</div>
</a-modal>
</template>
<script setup>
import { ref, toRaw, defineEmits } from "vue";
import {priceCalculated} from "@/configs/priceCalculate.js"
import {PassportWallet} from "@/wallet/passPort.js"
// const passProd = ref(new PassportWallet())
const props = defineProps({
buyDialogVisible: {
type: Boolean,
required: true,
},
buyDataArr: {
type: Array,
required: true,
},
});
console.log(toRaw(props.buyDataArr))
const emit = defineEmits(['handleClose'])
const handleOk = (e) => {
emit('handleClose')
};
const buyConfirm = async () => {
const pass = new PassportWallet()
let ids = []
ids.push(toRaw(props.buyDataArr)[0].nft.token_id)
// console.log(ids)
// return
let res = await pass.beginBuy(toRaw(props.buyDataArr)[0].nft.token_id)
console.log('购买', res)
}
//计算对象数组中某个属性合计
const totalPrice = () => {
// toRaw(props.buyDataArr).reduce((arr, amount)) => {
// return arr +
// }
// return priceCalculated(price)
// countTotal(arr, amount) {
// let $total = 0
// $total = arr.reduce((total, currentValue, currentIndex, arr) => {
// return currentValue[keyName] ? total + currentValue[keyName] * currentValue[keyNameTwo] : total
// }, 0)
// return $total
// }
}
const handleCancel = (e) => {
emit('handleClose')
}
</script>
<style lang="scss" scoped>
// .ant-modal-wrap{
// :deep(.ant-modal-wrap) {
// width: 200px;
// background: #B966FF;
// }
.ant-modal {
// width: 1140px !important;
// color: #fff;
.ant-modal-content {
padding: 0px;
background: #1a1821;
border: 1px solid #B966FF;
box-shadow: 0px 15px 28px 3px rgba(22,22,22,0.13);
border-radius: 100px;
.top-close {
position: absolute;
top: -53px;
right: -53px;
width: 106px;
height: 106px;
cursor: pointer;
img {
width: 100%;
height: 100%;
}
}
.ant-modal-body {
padding: 30px 50px;
padding-bottom: 10px;
.content {
.content-title {
font-family: 'Anton';
font-weight: 400;
font-size: 48px;
margin-left: 50px;
}
.content-table {
width: 1017px;
height: 48px;
line-height: 48px;
margin: 0 auto;
background: #2d2738;
border-radius: 20px;
display: flex;
justify-content: space-between;
align-items: center;
color: #A8A5AC;
font-size: 14px;
div {
width: 240px;
text-align: center;
&:nth-child(1) {
width: 540px;
text-align: left;
padding-left: 100px;
box-sizing: border-box;
}
&:nth-child(3) {
text-align: right;
padding-right: 100px;
box-sizing: border-box;
}
}
}
.content-nfts {
width: 1017px;
margin: 0 auto;
li {
display: flex;
justify-content: space-between;
align-items: center;
margin: 20px 0;
>div {
width: 240px;
font-family: 'Poppins';
font-weight: 500;
font-size: 30px;
text-align: center;
}
.nft {
display: flex;
align-items: center;
width: 540px;
.nft-img {
width: 110px;
height: 164px;
border: 1px solid #fff;
margin-left: 50px;
}
.nft-name {
font-weight: bold;
margin-left: 20px;
}
}
.id {
}
.price {
display: flex;
justify-content: center;
align-items: center;
.price-img {
width: 28px;
height: 28px;
margin-left: 10px;
img {
width: 100%;
height: 100%;
}
}
}
}
}
}
.btm {
display: flex;
justify-content: space-between;
align-items: center;
margin-left: 60px;
padding-top: 20px;
border-top: 2px solid #3A3B57;
box-sizing: border-box;
.btm-left {
display: flex;
margin-left: 20px;
li {
font-family: 'Anton';
font-weight: 400;
font-size: 42px;
color: #BB7FFF;
div {
display: flex;
align-items: center;
img {
width: 39px;
height: 39px;
margin-left: 20px;
}
}
.money {
font-family: 'Poppins';
font-weight: 400;
font-size: 24px;
}
}
}
.btm-right {
width: 240px;
height: 40px;
display: flex;
align-items: center;
justify-content: center;
line-height: 40px;
margin-right: 20px;
background: #fec25d;
color: #2D2738;
font-family: 'Poppins';
font-weight: 500;
font-size: 14px;
text-align: center;
border-radius: 20px;
box-shadow: 0 0 5px 0px #fec25d;
cursor: pointer;
}
}
}
}
}
// }
</style>