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)
.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 })

View File

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

View File

@ -68,7 +68,7 @@
</div>
<div class="pending">
<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>
@ -79,7 +79,7 @@
height="51px"
alt=""
/></span>
<MessageBox ref="message"></MessageBox>
<!-- <MessageBox ref="message"></MessageBox> -->
</el-dialog>
</template>
@ -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++;

View File

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

View File

@ -68,7 +68,9 @@
</div>
<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>
<div class="sale" v-else>
@ -239,13 +241,13 @@ export default class HeroNft extends Vue {
formatPriceShow(price: number | string, decimals?: number, fixed = 2) {
return formatPrice(price, decimals, fixed);
}
handMessage() {
handMessage(number:any) {
console.log("msg");
// this.$nextTick(() => {
// this.$refs.message.open(1);
// console.log('msg2023');
// });
let msg :any= this.$refs.message
this.$nextTick(() => {
msg.open(number);
console.log('msg2023');
});
}
}
</script>

View File

@ -29,8 +29,9 @@
"
alt=""
/>
<span class="amount">{{ piece.amount ?piece.amount: piece.balance
}}</span>
<span class="amount">{{
piece.amount ? piece.amount : piece.balance
}}</span>
</div>
<div class="level-content">
<div class="tree-guard">
@ -38,7 +39,11 @@
</div>
</div>
<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>
<div class="price-content" v-else>
@ -92,6 +97,7 @@
:type="type"
ref="buydialog"
:isBuy="isBuy"
@handMessage="handMessage"
@handBuyShow="handBuyShow"
@handBuyHide="handBuyHide"
></ChipBuyDialog>
@ -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);
});
},
},

View File

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