diff --git a/src/chain/blockchain.ts b/src/chain/blockchain.ts index 995ed02..92369dd 100644 --- a/src/chain/blockchain.ts +++ b/src/chain/blockchain.ts @@ -453,19 +453,32 @@ export class Blockchain { .transfer(account, amountBN) .send({ gas: 1000000 }) } - public async beginNftSell(nftToken: string, currency: string, tokenId: string, amount: number, price: number,marketAddress: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}) - console.log('11') 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 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){ const coinInstance: any = await this.getContractInstance(currency) const res = await coinInstance.methods.increaseAllowance(marketAddress, price).send({ gas: 1000000 }) diff --git a/src/components/market/MessageBox.vue b/src/components/market/MessageBox.vue index 9fd15c6..8920392 100644 --- a/src/components/market/MessageBox.vue +++ b/src/components/market/MessageBox.vue @@ -1,20 +1,24 @@ @@ -159,21 +159,56 @@ export default { this.$emit("handPutHide"); }, 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) { console.log(this.piece.o_link, "o_link"); if ( this.type == "piece" ? this.piece.o_link > 0 : this.data.o_link > 0 ) { try { - const nftres = await this.chainManager.bc.beginUpdatePrice( this.type == "piece" ? this.piece.o_link : this.data.o_link, this.shell.price, CONTRACT_ADDRESS[AppModule.chainId].marketDddress ); console.log(nftres, "beginSell"); + if (nftres.status == true) { + this.hideLoading(); + this.$emit('handMessage',1) + } } catch (err) { + this.hideLoading(); + this.$emit('handMessage',0) console.log("query order status error", err); } } else { @@ -206,7 +241,7 @@ export default { this.type == "hero" || this.type == "weapon" ? false : true, }; this.showLoading(); - console.log(shellData, "shellData",'999999990000000000000000'); + console.log(shellData, "shellData", "999999990000000000000000"); const nftres = await this.chainManager.bc.beginNftSell( this.nft_Token, this.value, @@ -220,17 +255,12 @@ export default { ); if (nftres.status == true) { this.hideLoading(); - this.$nextTick(() => { - this.$refs.message.open(1); - }); - console.log("handMessage"); + this.$emit('handMessage',1) } console.log(nftres, "beginSell"); } catch (err) { this.hideLoading(); - this.$nextTick(() => { - this.$refs.message.open(0); - }); + this.$emit('handMessage',0) console.log("query order status error", err); } } @@ -248,10 +278,6 @@ export default { this.cunout--; } }, - handClick() { - // console.log(this.data.selling, "-==-=-=-=p1"); - console.log(this.piece, "-==-=-=-=p2"); - }, handPlus() { if (this.cunout <= this.piece.balance) { this.cunout++; diff --git a/src/components/market/nft/Chip.vue b/src/components/market/nft/Chip.vue index df547a1..0d8045a 100644 --- a/src/components/market/nft/Chip.vue +++ b/src/components/market/nft/Chip.vue @@ -1,6 +1,10 @@ diff --git a/src/components/market/nft/PieceNft.vue b/src/components/market/nft/PieceNft.vue index 7d71dd1..b896242 100644 --- a/src/components/market/nft/PieceNft.vue +++ b/src/components/market/nft/PieceNft.vue @@ -29,8 +29,9 @@ " alt="" /> - {{ piece.amount ?piece.amount: piece.balance - }} + {{ + piece.amount ? piece.amount : piece.balance + }}
@@ -38,7 +39,11 @@
-
+
+ {{ formatPriceShow(piece.s_price ? piece.s_price : " ", 18) }} +
+
+
Sell
@@ -92,6 +97,7 @@ :type="type" ref="buydialog" :isBuy="isBuy" + @handMessage="handMessage" @handBuyShow="handBuyShow" @handBuyHide="handBuyHide" > @@ -155,9 +161,9 @@ export default { handBuyHide(handBuyHide) { this.isBuy = handBuyHide; }, - handMessage() { + handMessage(typeNumber) { this.$nextTick(() => { - this.$refs.message.open(1); + this.$refs.message.open(typeNumber); }); }, }, diff --git a/src/components/market/nft/WeaponList.vue b/src/components/market/nft/WeaponList.vue index fce047a..f8b2164 100644 --- a/src/components/market/nft/WeaponList.vue +++ b/src/components/market/nft/WeaponList.vue @@ -38,7 +38,10 @@
-
+
+ {{ formatPriceShow(weapon.s_price ? weapon.s_price : " ", 18) }} +
+
Sell
@@ -87,6 +90,7 @@ v-if="currencyTypeList" :currencyTypeList="currencyTypeList" :isPiecePut="isPiecePut" + @handMessage="handMessage" @handPutShow="handPutShow" @handPutHide="handPutHide" > @@ -96,12 +100,15 @@ :data="weapon" @handBuyShow="handBuyShow" @handBuyHide="handBuyHide" + @handMessage="handMessage" > +