This commit is contained in:
huangjinming 2023-01-05 19:18:53 +08:00
parent 1ba20aa3b9
commit bc9185d0d2
5 changed files with 77 additions and 44 deletions

View File

@ -465,7 +465,7 @@ export class Blockchain {
.send({ gas: 1000000 })
}
public async beginBuy(orderId:string,marketAddress:string,price:string,currency:string){
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 })
const marketInstance: any = await this.getContractInstance(marketAddress, MARKET_ABI)

View File

@ -71,6 +71,8 @@ export default {
try {
const nftres = await this.chainManager.bc.beginBuy(
this.orderId,
this.data.s_price,
this.data.currency,
CONTRACT_ADDRESS[AppModule.chainId].marketDddress
);
console.log(nftres, "beginSell");

View File

@ -276,8 +276,8 @@
<div class="buy-price">
<div class="mynft" v-if="isType === 'mynft'">
<div class="for-rent-btn" v-if="hero.selling > 0">
<div class="adjust" @click="handPutShow"></div>
<div class="remove"></div>
<div class="adjust" @click="handPutShow(hero)"></div>
<div class="remove" @click="handremove"></div>
</div>
<div v-else>
<div class="rent"></div>
@ -329,7 +329,9 @@ import AccountCard from "./AccountCard.vue";
import ProgressCard from "./ProgressCard.vue";
import LuckyValue from "./LuckyValue.vue";
import MosaicChipDialog from "./MosaicChip.vue";
import { AppModule } from "@/store/modules/app";
import { CONTRACT_ADDRESS } from "@/configs/config_chain";
import ChainManager from "@/chain/ChainManager";
export default {
props: ["dialogVisible", "hero", "isType"],
components: {
@ -344,6 +346,8 @@ export default {
return {
isTabs: false,
type: "hero",
orderId: 1,
chainManager: new ChainManager(),
};
},
methods: {
@ -355,6 +359,7 @@ export default {
this.$emit("on-open");
//"on-close"
},
closeTip() {},
showTip() {
this.isTabs = true;
@ -380,14 +385,25 @@ export default {
this.$emit("showTip", true);
this.isTabs = true;
},
handPutShow() {
this.$emit("handPutShow");
handPutShow(data) {
this.$emit("handPutShow",data);
console.log("ppwowerw");
},
handBuyShow() {
this.$emit("handBuyShow");
console.log("handBuyShow");
},
async handremove() {
try {
const nftres = await this.chainManager.bc.beginCancelOrder(
this.orderId,
CONTRACT_ADDRESS[AppModule.chainId].marketDddress
);
console.log(nftres, "beginSell");
} catch (err) {
console.log("query order status error", err);
}
},
},
};
</script>

View File

@ -142,6 +142,18 @@ export default {
this.$emit("handPutHide");
},
async handMessage() {
if (this.data.selling ? this.data.selling > 0 : this.price.selling > 0) {
try {
const nftres = await this.chainManager.bc.beginUpdatePrice(
this.orderId,
this.price,
CONTRACT_ADDRESS[AppModule.chainId].marketDddress
);
console.log(nftres, "beginSell");
} catch (err) {
console.log("query order status error", err);
}
} else {
switch (this.type) {
case "hero":
this.nft_Token = CONTRACT_ADDRESS[AppModule.chainId].hero;
@ -180,6 +192,7 @@ export default {
} catch (err) {
console.log("query order status error", err);
}
}
},
init(data) {
this.dialogVisible = true;

View File

@ -127,7 +127,9 @@ import { Component, Vue, Watch } from "vue-property-decorator";
import Herodialog from "../HeroDialog.vue";
import HeroBuyDialog from "../HeroBuyDialog.vue";
import TheSellDialog from "../TheSellDialog.vue";
import { AppModule } from "@/store/modules/app";
import { CONTRACT_ADDRESS } from "@/configs/config_chain";
import ChainManager from "@/chain/ChainManager";
@Component({
name: "HeroNft",
components: {