已完成

This commit is contained in:
yuyongdong 2024-07-08 10:26:19 +08:00
parent 2ca64a7396
commit 3b36b36eb0
7 changed files with 123 additions and 76 deletions

View File

@ -86,7 +86,7 @@ const buyConfirm = async () => {
hideModal({errcode: 0, res}); hideModal({errcode: 0, res});
} }
} catch (err) { } catch (err) {
console.log("buy fail", err); console.log("buy fail", err.message);
hideModal({errcode: 1, err}); hideModal({errcode: 1, err});
} }
}; };
@ -209,25 +209,33 @@ onMounted(() => {
height: 164px; height: 164px;
// border: 1px solid #fff; // border: 1px solid #fff;
margin-left: 50px; margin-left: 50px;
.card-img-common { :deep(.card-img-common) {
width: 100%;
height: 100%;
li {
width: 100%;
height: 100%;
font-size: 12px;
.img-top { .img-top {
width: 100px; width: 40px;
height: 30px; height: 15px;
top: 20px; top: 5px;
left: 20px; left: 5px;
} }
.img-btm { .img-btm {
bottom: 30px; bottom: 8px;
left: 30px; left: 10px;
>div { >div {
width: 120px; width: 30px;
height: 40px; height: 15px;
} }
div:nth-child(2) { div:nth-child(2) {
margin-left: 8px; margin-left: 8px;
} }
} }
} }
}
} }
.nft-name { .nft-name {
font-weight: bold; font-weight: bold;

View File

@ -17,6 +17,7 @@
<div class="content-nfts"> <div class="content-nfts">
<div class="content-nfts-top"> <div class="content-nfts-top">
<div class="content-nfts-top-left"> <div class="content-nfts-top-left">
<!-- <img :src="props.sellDataArr.image" alt /> -->
<ImgCard :nftData="props.sellDataArr" /> <ImgCard :nftData="props.sellDataArr" />
</div> </div>
<div class="content-nfts-top-right"> <div class="content-nfts-top-right">
@ -24,13 +25,20 @@
<div class="content-nfts-top-right-price"> <div class="content-nfts-top-right-price">
<li> <li>
<div class="price-top-input"> <div class="price-top-input">
<!-- <a-input v-model:value="priceValue" placeholder="Enter Listing Price" :parser="value =>value.replace(/^\D*(\d*(?:\.\d{0,5})?).*$/g,'$1')" @pressEnter="sellConfirm">
</a-input>-->
<input <input
type="text" type="text"
maxlength="7" maxlength="7"
v-model="priceValue" v-model="priceValue"
placeholder="Enter Listing Price" placeholder="Enter Listing Price"
@input="handleInput" onkeyup="value=value.replace(/[^0-9.]/g,'').replace(/\.{5,}/g,'.').replace(/^(\-)*(\d+)\.(\d\d\d\d\d).*$/,'$1$2.$3')"
onafterpaste="value=value.replace(/[^0-9.]/g,'').replace(/\.{5,}/g,'.').replace(/^(\-)*(\d+)\.(\d\d\d\d\d).*$/,'$1$2.$3')"
/> />
<!--
@input="handleInput"
onkeyup="value=value.replace(/[^0-9.]/g,'').replace(/\.{5,}/g,'.').replace(/^(\-)*(\d+)\.(\d\d\d\d\d).*$/,'$1$2.$3')"
onafterpaste="value=value.replace(/[^0-9.]/g,'').replace(/\.{5,}/g,'.').replace(/^(\-)*(\d+)\.(\d\d\d\d\d).*$/,'$1$2.$3')" -->
</div> </div>
<div class="net-price"> <div class="net-price">
<span>ETH</span> <span>ETH</span>
@ -191,8 +199,6 @@ const sellConfirm = async () => {
currencyAmount: ethers.utils.parseEther(priceValue.value).toString(), currencyAmount: ethers.utils.parseEther(priceValue.value).toString(),
orderExpiry: orderData, orderExpiry: orderData,
}; };
console.log(data)
// return
try { try {
const bc = new BlockChain(); const bc = new BlockChain();
let res = await bc.market.beginSellERC721(data); let res = await bc.market.beginSellERC721(data);
@ -204,11 +210,13 @@ const sellConfirm = async () => {
}, 2000); }, 2000);
} }
} catch (e) { } catch (e) {
console.log(e) if(e.message.indexOf('rejected') > -1) {
message.error('User rejected the request')
} else {
message.error("Your product failed to be listed"); message.error("Your product failed to be listed");
} }
}
} else { } else {
// alert("Price cannot be empty");
message.error("Price cannot be empty"); message.error("Price cannot be empty");
} }
}; };

View File

@ -63,6 +63,7 @@ const statusChild = (val) => {
// //
const renewMyNft = async() => { const renewMyNft = async() => {
let timer = setTimeout(() => { let timer = setTimeout(() => {
nftList.value = []
getMyAssets() getMyAssets()
// location.reload() // location.reload()
clearTimeout(timer); clearTimeout(timer);
@ -118,8 +119,9 @@ const handleScroll = () => {
} }
watch(localWalletStore,() => { watch(localWalletStore,() => {
console.log('localWalletStore.token',localWalletStore.address,localWalletStore.token)
if(!localWalletStore.token) { if(!localWalletStore.token) {
getMyAssets() nftList.value = []
} else { } else {
getMyAssets() getMyAssets()
} }

View File

@ -8,6 +8,7 @@
<div class="card-name"> <div class="card-name">
<div> <div>
<span v-if="nftData.type == 1">GENESIS HERO</span> <span v-if="nftData.type == 1">GENESIS HERO</span>
<span v-if="nftData.type == 11">GOLD CARD</span>
</div> </div>
<div class="no-sell" v-show="nftData.on_sale == 1" @click="cancelNft(nftData)"> <div class="no-sell" v-show="nftData.on_sale == 1" @click="cancelNft(nftData)">
<img src="@/assets/img/marketplace/On_SeLL.png" alt=""> <img src="@/assets/img/marketplace/On_SeLL.png" alt="">
@ -119,9 +120,13 @@ const cancelNft = async (val) => {
}, 2000); }, 2000);
} }
} catch (e) { } catch (e) {
if(e.message.indexOf('rejected') > -1) {
message.error('User rejected the request')
} else {
message.error('Your item has failed to be unlisted.') message.error('Your item has failed to be unlisted.')
} }
} }
}
// 使 // 使
const lockToGame = async(type) => { const lockToGame = async(type) => {
@ -147,15 +152,18 @@ const lockToGameConfirm = async () => {
try { try {
const bc = new BlockChain() const bc = new BlockChain()
let res = await bc.locker.lock(toRaw(props.nftData).contract_address, [toRaw(props.nftData).token_id]) let res = await bc.locker.lock(toRaw(props.nftData).contract_address, [toRaw(props.nftData).token_id])
// console.log('lockToGame success', res)
message.success('lockToGame success') message.success('lockToGame success')
// router.go(-1) // router.go(-1)
emit('renewMyNft') emit('renewMyNft')
// router.push('/assets') // router.push('/assets')
} catch (e) { } catch (e) {
if(e.message.indexOf('rejected') > -1) {
message.error('User rejected the request')
} else {
message.error('lockToGame fail.') message.error('lockToGame fail.')
} }
} }
}
// //

View File

@ -7,6 +7,7 @@
<div class="card-name"> <div class="card-name">
<div> <div>
<span v-if="nftData.nft.type == 1">GENESIS HERO</span> <span v-if="nftData.nft.type == 1">GENESIS HERO</span>
<span v-if="nftData.nft.type == 11">GOLD CARD</span>
</div> </div>
<div>{{nftData.nft.name}}</div> <div>{{nftData.nft.name}}</div>
</div> </div>
@ -72,21 +73,23 @@ const buyNft = async (val) => {
buyDataArr.value = [] buyDataArr.value = []
buyDataArr.value.push(props.nftData) buyDataArr.value.push(props.nftData)
console.log("buy",buyDataArr.value) console.log("buy",buyDataArr.value)
// return
const buyResult = await createModal(BuyDialog, { const buyResult = await createModal(BuyDialog, {
buyDataArr: buyDataArr.value, buyDataArr: buyDataArr.value,
}).show() }).show()
console.log(buyResult)
if(buyResult.errcode == 0) { if(buyResult.errcode == 0) {
if(buyResult.res == 'Insufficient Balance') { if(buyResult.res == 'Insufficient Balance') {
message.error('Insufficient Balance.') message.error('Insufficient Balance.')
} else { } else {
message.success('Success! Buy.') message.success('Success! Buy.')
} }
} else {
if(buyResult.err.message.indexOf('rejected') > -1) {
message.error('User rejected the request')
} else { } else {
message.error('Buy fail.') message.error('Buy fail.')
} }
} }
}
// //
const cancelNft = async (val) => { const cancelNft = async (val) => {
@ -99,10 +102,13 @@ const cancelNft = async (val) => {
emit('renewNft') emit('renewNft')
} }
} catch (e) { } catch (e) {
console.log(e) if(e.message.indexOf('rejected') > -1) {
message.error('User rejected the request')
} else {
message.error('Your item has failed to be unlisted.') message.error('Your item has failed to be unlisted.')
} }
} }
}
// //
const toDetail = () => { const toDetail = () => {

View File

@ -13,7 +13,7 @@
<li v-else> <li v-else>
<div class="gold-img"> <div class="gold-img">
<img v-if="props.nftData.item_id == 10017" src="@/assets/img/marketplace/Coin_icon_1000.png" alt=""> <img v-if="props.nftData.item_id == 10017" src="@/assets/img/marketplace/Coin_icon_1000.png" alt="">
<img v-if="props.nftData.item_id == 10000" src="@/assets/img/marketplace/Coin_icon_10000.png" alt=""> <img v-else-if="props.nftData.item_id == 10018" src="@/assets/img/marketplace/Coin_icon_10000.png" alt="">
</div> </div>
</li> </li>
</div> </div>
@ -43,11 +43,6 @@ const props = defineProps({
} }
li { li {
position: relative; position: relative;
}
.gold-img {
border: 2px solid #fff;
background: rgb(60, 50, 26);
}
.img-top { .img-top {
position: absolute; position: absolute;
display: flex; display: flex;
@ -82,4 +77,9 @@ const props = defineProps({
} }
} }
} }
.gold-img {
border: 2px solid #fff;
background: rgb(60, 50, 26);
}
}
</style> </style>

View File

@ -203,12 +203,19 @@ const buyNow = async () => {
const buyResult = await createModal(BuyDialog, { const buyResult = await createModal(BuyDialog, {
buyDataArr: buyDataArr.value, buyDataArr: buyDataArr.value,
}).show() }).show()
if(buyResult.errcode) { console.log(buyResult.errcode)
message.success('buy fail') if(buyResult.errcode == 0) {
return message.success('buy success')
} else if(buyResult.errcode == 1) {
if(buyResult.err.message.indexOf() > -1) {
message.error('User rejected the request')
} else {
message.error('buy fail')
} }
} }
}
// //
const addCart = async () => { const addCart = async () => {
const data = { const data = {
@ -284,9 +291,13 @@ const lockToGameConfirm = async () => {
message.success('lockToGame success') message.success('lockToGame success')
router.go(-1) router.go(-1)
} catch (e) { } catch (e) {
if(e.message.indexOf('rejected') > -1) {
message.error('User rejected the request')
} else {
message.error('lockToGame fail.') message.error('lockToGame fail.')
} }
} }
}
// //
@ -309,23 +320,27 @@ const cancelSell = async() => {
if(res.result) { if(res.result) {
let timer = setTimeout(() => { let timer = setTimeout(() => {
getDetail() getDetail()
message.success('Your item has been unlisted.')
clearTimeout(timer) clearTimeout(timer)
}, 2000); }, 2000);
} }
// console.log('cancelSell success')
} catch (e) { } catch (e) {
try { // try {
let res = await new BlockChain().market.cancelOrdersOnChain([detailData.value.event.data.id]) // let res = await new BlockChain().market.cancelOrdersOnChain([detailData.value.event.data.id])
if(res.result) { // if(res.result) {
let timer = setTimeout(() => { // let timer = setTimeout(() => {
getDetail() // getDetail()
clearTimeout(timer) // clearTimeout(timer)
}, 2000); // }, 2000);
// }
// } catch (e2) {
// // console.log('cancelSell fail', e.message)
// }
if(e.message.indexOf('rejected') > -1) {
message.error('User rejected the request')
} else {
message.error('Your item has failed to be unlisted.')
} }
} catch (e2) {
// console.log('cancelSell fail', e.message)
}
// console.log('cancelSell fail', e.message)
} }
} }