This commit is contained in:
huangjinming 2023-01-18 19:08:40 +08:00
parent 61b20d4243
commit c0e9963c76
4 changed files with 44 additions and 17 deletions

View File

@ -117,6 +117,7 @@
<script> <script>
import { AppModule } from "@/store/modules/app"; import { AppModule } from "@/store/modules/app";
import { UserModule } from "@/store/modules/user";
import { CONTRACT_ADDRESS } from "@/configs/config_chain"; import { CONTRACT_ADDRESS } from "@/configs/config_chain";
import ChainManager from "@/chain/ChainManager"; import ChainManager from "@/chain/ChainManager";
import { formatPrice } from "@/utils/chain.util"; import { formatPrice } from "@/utils/chain.util";
@ -132,8 +133,16 @@ export default {
loadingInstance: null, loadingInstance: null,
}; };
}, },
computed: {
logined() {
return !!UserModule.token && !!AppModule.step;
},
},
methods: { methods: {
async haldBuy() { async haldBuy() {
if (!this.logined) {
await this.chainManager.login();
}
try { try {
this.showLoading(); this.showLoading();
const nftres = await this.chainManager.bc.beginApproveBuy( const nftres = await this.chainManager.bc.beginApproveBuy(

View File

@ -59,6 +59,7 @@
<script> <script>
import HeroBuyTop from "./HeroBuyTop.vue"; import HeroBuyTop from "./HeroBuyTop.vue";
import { AppModule } from "@/store/modules/app"; import { AppModule } from "@/store/modules/app";
import { UserModule } from "@/store/modules/user";
import { CONTRACT_ADDRESS } from "@/configs/config_chain"; import { CONTRACT_ADDRESS } from "@/configs/config_chain";
import ChainManager from "@/chain/ChainManager"; import ChainManager from "@/chain/ChainManager";
import { formatPrice } from "@/utils/chain.util"; import { formatPrice } from "@/utils/chain.util";
@ -76,9 +77,17 @@ export default {
dialogVisible: false, dialogVisible: false,
}; };
}, },
computed: {
logined() {
return !!UserModule.token && !!AppModule.step;
},
},
methods: { methods: {
async haldBuy() { async haldBuy() {
console.log(this.logined, "logined");
if (!this.logined) {
await this.chainManager.login();
}
try { try {
this.showLoading(); this.showLoading();
const nftres = await this.chainManager.bc.beginApproveBuy( const nftres = await this.chainManager.bc.beginApproveBuy(
@ -99,7 +108,6 @@ export default {
} }
}, },
async handBeginBuy() { async handBeginBuy() {
try { try {
this.showLoading(); this.showLoading();
const nftres = await this.chainManager.bc.beginBuy( const nftres = await this.chainManager.bc.beginBuy(
@ -113,9 +121,9 @@ export default {
this.$emit("handMessageHide"); this.$emit("handMessageHide");
this.closeTip(); this.closeTip();
this.$emit("on-close"); this.$emit("on-close");
setTimeout(()=>{ setTimeout(() => {
this.$emit("getMarketNftList"); this.$emit("getMarketNftList");
},1000) }, 1000);
}, 1000); }, 1000);
} }
} catch (err) { } catch (err) {
@ -138,7 +146,6 @@ export default {
}, },
closeTip() { closeTip() {
this.$emit("handBuyHide"); this.$emit("handBuyHide");
}, },
}, },
}; };

View File

@ -114,7 +114,7 @@ export default {
cunout: 1, cunout: 1,
orderId: 9, orderId: 9,
dialogVisible: false, dialogVisible: false,
visible:this.isPiecePut, visible: this.isPiecePut,
isWeapon: false, isWeapon: false,
isApprove: false, isApprove: false,
options: [], options: [],
@ -182,16 +182,16 @@ export default {
if (nftres.status == true) { if (nftres.status == true) {
this.hideLoading(); this.hideLoading();
this.$emit("handMessage", 1); this.$emit("handMessage", 1);
setTimeout(() => {
this.$emit("handMessageHide");
this.closeTip();
this.type == "piece"
? this.$emit("closeTip", false)
: this.$emit("on-close");
setTimeout(() => { setTimeout(() => {
this.$emit("getMarketNftList"); this.$emit("handMessageHide");
this.closeTip();
this.type == "piece"
? this.$emit("closeTip", false)
: this.$emit("on-close");
setTimeout(() => {
this.$emit("getMarketNftList");
}, 1000);
}, 1000); }, 1000);
}, 1000);
} }
} catch (err) { } catch (err) {
this.hideLoading(); this.hideLoading();
@ -199,6 +199,10 @@ export default {
console.log("query order status error", err); console.log("query order status error", err);
} }
} else { } else {
if (!this.currencyTypeList || this.currencyTypeList.length === 0) {
this.$emit("handMessage", 0);
return;
}
switch (this.type) { switch (this.type) {
case "hero": case "hero":
this.nft_Token = CONTRACT_ADDRESS[AppModule.chainId].hero; this.nft_Token = CONTRACT_ADDRESS[AppModule.chainId].hero;
@ -213,7 +217,7 @@ export default {
this.nft_Token = CONTRACT_ADDRESS[AppModule.chainId].piece; this.nft_Token = CONTRACT_ADDRESS[AppModule.chainId].piece;
break; break;
} }
try { try {
this.showLoading(); this.showLoading();
const nftres = await this.chainManager.bc.beginApproveSell( const nftres = await this.chainManager.bc.beginApproveSell(
@ -233,7 +237,6 @@ export default {
this.hideLoading(); this.hideLoading();
this.isApprove = false; this.isApprove = false;
this.$emit("handMessage", 0); this.$emit("handMessage", 0);
} }
} }
} }
@ -261,7 +264,6 @@ export default {
break; break;
} }
try { try {
this.showLoading(); this.showLoading();
const nftres = await this.chainManager.bc.beginNftSell( const nftres = await this.chainManager.bc.beginNftSell(
this.nft_Token, this.nft_Token,

View File

@ -91,6 +91,7 @@
<script> <script>
import { AppModule } from "@/store/modules/app"; import { AppModule } from "@/store/modules/app";
import { UserModule } from "@/store/modules/user";
import { CONTRACT_ADDRESS } from "@/configs/config_chain"; import { CONTRACT_ADDRESS } from "@/configs/config_chain";
import { formatPrice } from "@/utils/chain.util"; import { formatPrice } from "@/utils/chain.util";
import ChainManager from "@/chain/ChainManager"; import ChainManager from "@/chain/ChainManager";
@ -107,8 +108,16 @@ export default {
dialogVisible: false, dialogVisible: false,
}; };
}, },
computed: {
logined() {
return !!UserModule.token && !!AppModule.step;
},
},
methods: { methods: {
async haldBuy() { async haldBuy() {
if (!this.logined) {
await this.chainManager.login();
}
try { try {
this.showLoading(); this.showLoading();
const nftres = await this.chainManager.bc.beginApproveBuy( const nftres = await this.chainManager.bc.beginApproveBuy(