This commit is contained in:
huangjinming 2023-01-10 16:28:39 +08:00
parent 3f2e5cf92e
commit a8ef7edb88
7 changed files with 128 additions and 40 deletions

View File

@ -453,19 +453,32 @@ export class Blockchain {
.transfer(account, amountBN) .transfer(account, amountBN)
.send({ gas: 1000000 }) .send({ gas: 1000000 })
} }
public async beginNftSell(nftToken: string, currency: string, tokenId: string, amount: number, price: number,marketAddress:string ,nftType:boolean) { public async beginNftSell(nftToken: string, currency: string, tokenId: string, amount: number, price: number,marketAddress:string ,nftType:boolean) {
const nftInstance = await this.getContractInstance(nftToken, ERC721ABI) const nftInstance = await this.getContractInstance(nftToken, ERC721ABI)
nftType == true? await nftInstance.methods.setApprovalForAll(marketAddress, true).send({ gas: 1000000}): nftType == true? await nftInstance.methods.setApprovalForAll(marketAddress, true).send({ gas: 1000000}):
await nftInstance.methods.approve(marketAddress, tokenId).send({ gas: 1000000}) await nftInstance.methods.approve(marketAddress, tokenId).send({ gas: 1000000})
console.log('11')
const priceBN = this.web3.utils.toBN(this.web3.utils.toWei(price + '')) const priceBN = this.web3.utils.toBN(this.web3.utils.toWei(price + ''))
const marketInstance: any = await this.getContractInstance(marketAddress, MARKET_ABI) const marketInstance: any = await this.getContractInstance(marketAddress, MARKET_ABI)
return marketInstance.methods return marketInstance.methods
.sell(nftToken, currency, tokenId,priceBN, amount) .sell(nftToken, currency, tokenId,priceBN, amount)
.send({ gas: 1000000 }) .send({ gas: 1000000 })
} }
public async beginApproveSell( tokenId: string,marketAddress:string,nftToken:string,nftType:boolean){
const nftInstance = await this.getContractInstance(nftToken, ERC721ABI)
nftType == true? await nftInstance.methods.setApprovalForAll(marketAddress, true).send({ gas: 1000000}):
await nftInstance.methods.approve(marketAddress, tokenId).send({ gas: 1000000})
}
// public async beginNftSell(nftToken: string, currency: string, tokenId: string, amount: number, price: number,marketAddress:string ) {
// const priceBN = this.web3.utils.toBN(this.web3.utils.toWei(price + ''))
// const marketInstance: any = await this.getContractInstance(marketAddress, MARKET_ABI)
// return marketInstance.methods
// .sell(nftToken, currency, tokenId,priceBN, amount)
// .send({ gas: 1000000 })
// }
public async beginApproveBuy( currency: string,marketAddress:string,price:string){
const coinInstance: any = await this.getContractInstance(currency)
const res = await coinInstance.methods.increaseAllowance(marketAddress, price).send({ gas: 1000000 })
}
public async beginBuy(orderId:string,price:number,currency:string,marketAddress:string){ public async beginBuy(orderId:string,price:number,currency:string,marketAddress:string){
const coinInstance: any = await this.getContractInstance(currency) const coinInstance: any = await this.getContractInstance(currency)
const res = await coinInstance.methods.increaseAllowance(marketAddress, price).send({ gas: 1000000 }) const res = await coinInstance.methods.increaseAllowance(marketAddress, price).send({ gas: 1000000 })

View File

@ -1,20 +1,24 @@
<template> <template>
<el-dialog :show-close="false" :visible.sync="dialogVisible"> <el-dialog :show-close="false" :visible.sync="dialogVisible">
<div class="container" v-show="msgType == 0"> <div class="container" v-if="msgType == 0">
<div class="title">Transfaction Failed</div> <div class="title">Transfaction Failed</div>
<div class="wangning-img"> <div class="wangning-img">
<img src="../../assets/market/dialog/wangning.png" alt="" /> <img src="../../assets/market/dialog/wangning.png" alt="" />
</div> </div>
<div class="view">View in Poiygonscan</div> <div class="view">View in Poiygonscan</div>
<div class="confirm-btn">Confirm</div> <div class="confirm-btn" @click="handClick">
Confirm
</div> </div>
<div class="success-container" v-show="msgType == 1"> </div>
<div class="success-container" v-else-if="msgType == 1">
<div class="title">Transfaction Complete</div> <div class="title">Transfaction Complete</div>
<div class="wangning-img"> <div class="wangning-img">
<img src="../../assets/market/dialog/success.png" alt="" /> <img src="../../assets/market/dialog/success.png" alt="" />
</div> </div>
<div class="view">View in Poiygonscan</div> <div class="view">View in Poiygonscan</div>
<div class="confirm-btn">Confirm</div> <div class="confirm-btn" @click="handClick">
Confirm
</div>
</div> </div>
<Close @closeMyself="close" /> <Close @closeMyself="close" />
</el-dialog> </el-dialog>
@ -25,7 +29,7 @@ import Close from "./Close.vue";
export default { export default {
components: { Close }, components: { Close },
props: [ "data", "isType"], props: ["data", "isType"],
data() { data() {
return { return {
dialogVisible: false, dialogVisible: false,
@ -41,6 +45,10 @@ export default {
this.dialogVisible = true; this.dialogVisible = true;
this.msgType = type; this.msgType = type;
}, },
handClick() {
this.dialogVisible = false;
console.log("handClick", "999");
},
}, },
}; };
</script> </script>
@ -99,6 +107,7 @@ export default {
} }
.confirm-btn { .confirm-btn {
text-align: center; text-align: center;
cursor: pointer;
width: 438px; width: 438px;
height: 74px; height: 74px;
line-height: 74px; line-height: 74px;

View File

@ -68,7 +68,7 @@
</div> </div>
<div class="pending"> <div class="pending">
<div class="pending-order" @click="handMessage">PEBDING ORDER</div> <div class="pending-order" @click="handMessage">PEBDING ORDER</div>
<div class="confirm" @click="handClick">CONFIRM</div> <div class="confirm" @click="handConfirm">CONFIRM</div>
</div> </div>
</div> </div>
</div> </div>
@ -79,7 +79,7 @@
height="51px" height="51px"
alt="" alt=""
/></span> /></span>
<MessageBox ref="message"></MessageBox> <!-- <MessageBox ref="message"></MessageBox> -->
</el-dialog> </el-dialog>
</template> </template>
@ -159,21 +159,56 @@ export default {
this.$emit("handPutHide"); this.$emit("handPutHide");
}, },
async handMessage() { async handMessage() {
this.$refs.deptForm.validate(async(valid) => { this.$emit('handMessage',0)
console.log("handMessage",1);
// switch (this.type) {
// case "hero":
// this.nft_Token = CONTRACT_ADDRESS[AppModule.chainId].hero;
// break;
// case "weapon":
// this.nft_Token = CONTRACT_ADDRESS[AppModule.chainId].weapon;
// break;
// case "chip":
// this.nft_Token = CONTRACT_ADDRESS[AppModule.chainId].chip;
// break;
// case "piece":
// this.nft_Token = CONTRACT_ADDRESS[AppModule.chainId].piece;
// break;
// }
// try {
// const nftres = await this.chainManager.bc.beginApproveSell(
// this.piece ? this.piece.detail.token_id : this.data.detail.token_id,
// CONTRACT_ADDRESS[AppModule.chainId].marketDddress,
// this.nft_Token,
// this.type == "hero" || this.type == "weapon" ? false : true
// );
// console.log(nftres, "beginSell");
// } catch (err) {
// console.log("query order status error", err);
// }
console.log("handMessage2222");
},
async handConfirm() {
this.$refs.deptForm.validate(async (valid) => {
if (valid) { if (valid) {
console.log(this.piece.o_link, "o_link"); console.log(this.piece.o_link, "o_link");
if ( if (
this.type == "piece" ? this.piece.o_link > 0 : this.data.o_link > 0 this.type == "piece" ? this.piece.o_link > 0 : this.data.o_link > 0
) { ) {
try { try {
const nftres = await this.chainManager.bc.beginUpdatePrice( const nftres = await this.chainManager.bc.beginUpdatePrice(
this.type == "piece" ? this.piece.o_link : this.data.o_link, this.type == "piece" ? this.piece.o_link : this.data.o_link,
this.shell.price, this.shell.price,
CONTRACT_ADDRESS[AppModule.chainId].marketDddress CONTRACT_ADDRESS[AppModule.chainId].marketDddress
); );
console.log(nftres, "beginSell"); console.log(nftres, "beginSell");
if (nftres.status == true) {
this.hideLoading();
this.$emit('handMessage',1)
}
} catch (err) { } catch (err) {
this.hideLoading();
this.$emit('handMessage',0)
console.log("query order status error", err); console.log("query order status error", err);
} }
} else { } else {
@ -206,7 +241,7 @@ export default {
this.type == "hero" || this.type == "weapon" ? false : true, this.type == "hero" || this.type == "weapon" ? false : true,
}; };
this.showLoading(); this.showLoading();
console.log(shellData, "shellData",'999999990000000000000000'); console.log(shellData, "shellData", "999999990000000000000000");
const nftres = await this.chainManager.bc.beginNftSell( const nftres = await this.chainManager.bc.beginNftSell(
this.nft_Token, this.nft_Token,
this.value, this.value,
@ -220,17 +255,12 @@ export default {
); );
if (nftres.status == true) { if (nftres.status == true) {
this.hideLoading(); this.hideLoading();
this.$nextTick(() => { this.$emit('handMessage',1)
this.$refs.message.open(1);
});
console.log("handMessage");
} }
console.log(nftres, "beginSell"); console.log(nftres, "beginSell");
} catch (err) { } catch (err) {
this.hideLoading(); this.hideLoading();
this.$nextTick(() => { this.$emit('handMessage',0)
this.$refs.message.open(0);
});
console.log("query order status error", err); console.log("query order status error", err);
} }
} }
@ -248,10 +278,6 @@ export default {
this.cunout--; this.cunout--;
} }
}, },
handClick() {
// console.log(this.data.selling, "-==-=-=-=p1");
console.log(this.piece, "-==-=-=-=p2");
},
handPlus() { handPlus() {
if (this.cunout <= this.piece.balance) { if (this.cunout <= this.piece.balance) {
this.cunout++; this.cunout++;

View File

@ -1,6 +1,10 @@
<template> <template>
<div> <div>
<div class="no-sale" v-if="chip.o_link > 0 && isType == 'mynft'" @click="chipDialog(chip)"> <div
class="no-sale"
v-if="chip.o_link > 0 && isType == 'mynft'"
@click="chipDialog(chip)"
>
<img width="205px" src="../../../assets/market/hero/no-sale.png" alt="" /> <img width="205px" src="../../../assets/market/hero/no-sale.png" alt="" />
</div> </div>
<div @click="chipDialog(chip)"> <div @click="chipDialog(chip)">
@ -25,7 +29,10 @@
<div class="tree-guard">{{ chip.detail.chip_name }}</div> <div class="tree-guard">{{ chip.detail.chip_name }}</div>
</div> </div>
<div class="lease-listing" v-if="isType == 'mynft'"> <div class="lease-listing" v-if="isType == 'mynft'">
<div class="rent"></div> <div class="rent" v-if="chip.o_link">
{{ formatPriceShow(chip.s_price ? chip.s_price : " ", 18) }}
</div>
<div class="rent" v-else></div>
<div class="sell">Sell</div> <div class="sell">Sell</div>
</div> </div>
<div class="price-content" v-else> <div class="price-content" v-else>
@ -38,7 +45,9 @@
/> />
</div> </div>
<div class="price">{{formatPriceShow( chip.s_price ? chip.s_price : " ",18 )}}</div> <div class="price">
{{ formatPriceShow(chip.s_price ? chip.s_price : " ", 18) }}
</div>
</div> </div>
<div class="buy"> <div class="buy">
<img width="78px" src="../../../assets/market/chip/buy.png" alt="" /> <img width="78px" src="../../../assets/market/chip/buy.png" alt="" />
@ -63,6 +72,7 @@
:type="type" :type="type"
:isBuy="isBuy" :isBuy="isBuy"
:data="chip" :data="chip"
@handMessage="handMessage"
@handBuyShow="handBuyShow" @handBuyShow="handBuyShow"
@handBuyHide="handBuyHide" @handBuyHide="handBuyHide"
></ChipBuyDialog> ></ChipBuyDialog>
@ -72,14 +82,17 @@
v-if="currencyTypeList" v-if="currencyTypeList"
:currencyTypeList="currencyTypeList" :currencyTypeList="currencyTypeList"
:isPiecePut="isPiecePut" :isPiecePut="isPiecePut"
@handMessage="handMessage"
@handPutShow="handPutShow" @handPutShow="handPutShow"
@handPutHide="handPutHide" @handPutHide="handPutHide"
/> />
<MessageBox ref="message"></MessageBox>
</div> </div>
</template> </template>
<script> <script>
import ChipDialog from "../ChipDialog"; import ChipDialog from "../ChipDialog";
import MessageBox from "../MessageBox.vue";
import { formatPrice } from "@/utils/chain.util"; import { formatPrice } from "@/utils/chain.util";
import ChipBuyDialog from "../ChipBuyDialog.vue"; import ChipBuyDialog from "../ChipBuyDialog.vue";
import TheSellDialog from "../TheSellDialog.vue"; import TheSellDialog from "../TheSellDialog.vue";
@ -87,6 +100,7 @@ export default {
props: ["chip", "isType", "currencyTypeList"], props: ["chip", "isType", "currencyTypeList"],
components: { components: {
ChipDialog, ChipDialog,
MessageBox,
TheSellDialog, TheSellDialog,
ChipBuyDialog, ChipBuyDialog,
}, },
@ -105,6 +119,11 @@ export default {
formatPriceShow(price, decimals, fixed = 2) { formatPriceShow(price, decimals, fixed = 2) {
return formatPrice(price, decimals, fixed); return formatPrice(price, decimals, fixed);
}, },
handMessage(typeNumber) {
this.$nextTick(() => {
this.$refs.message.open(typeNumber);
});
},
chipDialog() { chipDialog() {
this.dialogVisible = true; this.dialogVisible = true;
}, },

View File

@ -68,7 +68,9 @@
</div> </div>
<div class="lease-listing" v-if="isType == 'mynft'"> <div class="lease-listing" v-if="isType == 'mynft'">
<div class="rent"></div> <div class="rent" v-if="data.o_link" > {{ formatPriceShow(data.s_price ? data.s_price : " ", 18) }}</div>
<div class="rent" v-else>
</div>
<div class="sell">Sell</div> <div class="sell">Sell</div>
</div> </div>
<div class="sale" v-else> <div class="sale" v-else>
@ -239,13 +241,13 @@ export default class HeroNft extends Vue {
formatPriceShow(price: number | string, decimals?: number, fixed = 2) { formatPriceShow(price: number | string, decimals?: number, fixed = 2) {
return formatPrice(price, decimals, fixed); return formatPrice(price, decimals, fixed);
} }
handMessage() { handMessage(number:any) {
console.log("msg"); console.log("msg");
let msg :any= this.$refs.message
// this.$nextTick(() => { this.$nextTick(() => {
// this.$refs.message.open(1); msg.open(number);
// console.log('msg2023'); console.log('msg2023');
// }); });
} }
} }
</script> </script>

View File

@ -29,7 +29,8 @@
" "
alt="" alt=""
/> />
<span class="amount">{{ piece.amount ?piece.amount: piece.balance <span class="amount">{{
piece.amount ? piece.amount : piece.balance
}}</span> }}</span>
</div> </div>
<div class="level-content"> <div class="level-content">
@ -38,7 +39,11 @@
</div> </div>
</div> </div>
<div class="lease-listing" v-if="isType == 'mynft'"> <div class="lease-listing" v-if="isType == 'mynft'">
<div class="rent"></div> <div class="rent" v-if="piece.o_link">
{{ formatPriceShow(piece.s_price ? piece.s_price : " ", 18) }}
</div>
<div class="rent" v-else>
</div>
<div class="sell">Sell</div> <div class="sell">Sell</div>
</div> </div>
<div class="price-content" v-else> <div class="price-content" v-else>
@ -92,6 +97,7 @@
:type="type" :type="type"
ref="buydialog" ref="buydialog"
:isBuy="isBuy" :isBuy="isBuy"
@handMessage="handMessage"
@handBuyShow="handBuyShow" @handBuyShow="handBuyShow"
@handBuyHide="handBuyHide" @handBuyHide="handBuyHide"
></ChipBuyDialog> ></ChipBuyDialog>
@ -155,9 +161,9 @@ export default {
handBuyHide(handBuyHide) { handBuyHide(handBuyHide) {
this.isBuy = handBuyHide; this.isBuy = handBuyHide;
}, },
handMessage() { handMessage(typeNumber) {
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.message.open(1); this.$refs.message.open(typeNumber);
}); });
}, },
}, },

View File

@ -38,7 +38,10 @@
</div> </div>
</div> </div>
<div class="lease-listing" v-if="isType == 'mynft'"> <div class="lease-listing" v-if="isType == 'mynft'">
<div class="rent"></div> <div class="rent" v-if="weapon.o_link">
{{ formatPriceShow(weapon.s_price ? weapon.s_price : " ", 18) }}
</div>
<div class="rent" v-else></div>
<div class="sell">Sell</div> <div class="sell">Sell</div>
</div> </div>
<div class="price-content" v-else> <div class="price-content" v-else>
@ -87,6 +90,7 @@
v-if="currencyTypeList" v-if="currencyTypeList"
:currencyTypeList="currencyTypeList" :currencyTypeList="currencyTypeList"
:isPiecePut="isPiecePut" :isPiecePut="isPiecePut"
@handMessage="handMessage"
@handPutShow="handPutShow" @handPutShow="handPutShow"
@handPutHide="handPutHide" @handPutHide="handPutHide"
></TheSellDialog> ></TheSellDialog>
@ -96,12 +100,15 @@
:data="weapon" :data="weapon"
@handBuyShow="handBuyShow" @handBuyShow="handBuyShow"
@handBuyHide="handBuyHide" @handBuyHide="handBuyHide"
@handMessage="handMessage"
></TheBuyDialog> ></TheBuyDialog>
<MessageBox ref="message"></MessageBox>
</div> </div>
</template> </template>
<script> <script>
import DunDialog from "../DunDialog"; import DunDialog from "../DunDialog";
import MessageBox from '../MessageBox.vue'
import TheSellDialog from "../TheSellDialog.vue"; import TheSellDialog from "../TheSellDialog.vue";
import TheBuyDialog from "../WeaponBuyDialog.vue"; import TheBuyDialog from "../WeaponBuyDialog.vue";
import { formatPrice } from "@/utils/chain.util"; import { formatPrice } from "@/utils/chain.util";
@ -109,6 +116,7 @@ export default {
props: ["weapon", "isType", "currencyTypeList"], props: ["weapon", "isType", "currencyTypeList"],
components: { components: {
DunDialog, DunDialog,
MessageBox,
TheSellDialog, TheSellDialog,
TheBuyDialog, TheBuyDialog,
}, },
@ -191,6 +199,11 @@ export default {
handBuyShow() { handBuyShow() {
this.isBuy = true; this.isBuy = true;
}, },
handMessage(typeNumber) {
this.$nextTick(() => {
this.$refs.message.open(typeNumber);
});
},
handBuyHide() { handBuyHide() {
this.isBuy = false; this.isBuy = false;
}, },