From 12848453da6141bcedf32c4e6e266046d79d2dd2 Mon Sep 17 00:00:00 2001 From: huangjinming Date: Mon, 9 Jan 2023 10:11:49 +0800 Subject: [PATCH] fix --- src/chain/blockchain.ts | 3 +- src/components/market/Piecedialog.vue | 6 +++- src/components/market/TheSellDialog.vue | 45 +++++++++++++++++++++---- src/components/market/nft/HeroNft.vue | 13 ++++++- src/components/market/nft/PieceNft.vue | 4 +-- 5 files changed, 60 insertions(+), 11 deletions(-) diff --git a/src/chain/blockchain.ts b/src/chain/blockchain.ts index d104c77..995ed02 100644 --- a/src/chain/blockchain.ts +++ b/src/chain/blockchain.ts @@ -454,8 +454,9 @@ export class Blockchain { .send({ gas: 1000000 }) } - public async beginNftSell(nftToken: string, currency: string, tokenId: string, amount: number, price: number,marketAddress:string ) { + 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 + '')) diff --git a/src/components/market/Piecedialog.vue b/src/components/market/Piecedialog.vue index f258901..b488409 100644 --- a/src/components/market/Piecedialog.vue +++ b/src/components/market/Piecedialog.vue @@ -73,13 +73,17 @@
-
+ +
+
+
Sell
diff --git a/src/components/market/TheSellDialog.vue b/src/components/market/TheSellDialog.vue index 451f0a8..be41537 100644 --- a/src/components/market/TheSellDialog.vue +++ b/src/components/market/TheSellDialog.vue @@ -17,7 +17,7 @@
- +
PEBDING ORDER
-
CONFIRM
+
CONFIRM
@@ -78,6 +78,7 @@ height="51px" alt="" /> + @@ -86,6 +87,7 @@ import WeaponSellTop from "./WeaponSellTop.vue"; import PieceSellTop from "./PieceSellTop.vue"; import HeroSellTop from "./HeroSellTop.vue"; import ChipSellTop from "./ChipSellTop.vue"; +import MessageBox from "./MessageBox.vue"; import { AppModule } from "@/store/modules/app"; import { sellMyNft } from "@/api/Market"; import { CONTRACT_ADDRESS } from "@/configs/config_chain"; @@ -98,6 +100,7 @@ export default { HeroSellTop, ChipSellTop, PieceSellTop, + MessageBox, }, data() { return { @@ -105,8 +108,9 @@ export default { price: "", nft_Token: "", chainManager: new ChainManager(), + loadingInstance: "", cunout: 1, - orderId:9, + orderId: 9, dialogVisible: false, isWeapon: false, options: [], @@ -130,7 +134,8 @@ export default { this.$emit("handPutHide"); }, async handMessage() { - if (this.data.selling ? this.data.selling > 0 : this.price.selling > 0) { + + if (this.data.selling ? this.data.selling > 0 : this.piece.selling > 0) { try { const nftres = await this.chainManager.bc.beginUpdatePrice( this.orderId, @@ -166,7 +171,10 @@ export default { amount: this.piece ? this.cunout : 1, price: this.price, marketAddress: CONTRACT_ADDRESS[AppModule.chainId].marketDddress, + nfttype: + this.type == "hero" || this.type == "weapon" ? false : true, }; + this.showLoading(); console.log(shellData, "shellData"); const nftres = await this.chainManager.bc.beginNftSell( this.nft_Token, @@ -174,10 +182,22 @@ export default { this.piece ? this.piece.detail.token_id : this.data.detail.token_id, this.piece ? this.cunout : 1, this.price, - CONTRACT_ADDRESS[AppModule.chainId].marketDddress + CONTRACT_ADDRESS[AppModule.chainId].marketDddress, + this.type == "hero" || this.type == "weapon" ? false : true ); + if (nftres.status == true) { + this.hideLoading(); + this.$nextTick(() => { + this.$refs.message.open(1); + }); + console.log("handMessage"); + } console.log(nftres, "beginSell"); } catch (err) { + this.hideLoading(); + this.$nextTick(() => { + this.$refs.message.open(0); + }); console.log("query order status error", err); } } @@ -193,11 +213,24 @@ export default { this.cunout--; } }, + handClick() { + // console.log(this.data.selling, "-==-=-=-=p1"); + console.log(this.piece, "-==-=-=-=p2"); + }, handPlus() { - if (this.cunout < this.piece.balance) { + if (this.cunout <= this.piece.balance) { this.cunout++; } }, + showLoading() { + this.loadingInstance = this.$loading({ + background: "rgba(0, 0, 0, 0.8)", + }); + }, + + hideLoading() { + this.loadingInstance?.close(); + }, }, }; diff --git a/src/components/market/nft/HeroNft.vue b/src/components/market/nft/HeroNft.vue index b30b293..36fd51a 100644 --- a/src/components/market/nft/HeroNft.vue +++ b/src/components/market/nft/HeroNft.vue @@ -112,6 +112,7 @@ :currencyTypeList="currencyTypeList" @handPutShow="handPutShow" @handPutHide="handPutHide" + @handMessage="handMessage" > +