|
|
@ -2,8 +2,9 @@ |
|
|
|
<view class="content"> |
|
|
|
<tab-bar /> |
|
|
|
<view class="container"> |
|
|
|
<view class="tip" :class="showTip?'tipShow':''"> |
|
|
|
提交成功,等待区块确认。 |
|
|
|
<view class="tip flex2" :class="showTip?'tipshow':''"> |
|
|
|
<u-icon name="checkmark-circle-fill" color="#42B983" size="36" style="margin-right: 20rpx;"></u-icon> |
|
|
|
{{ i18n.te }} |
|
|
|
</view> |
|
|
|
<view class="top"> |
|
|
|
<view class="title f44 text-primary"> |
|
|
@ -39,7 +40,8 @@ |
|
|
|
<u-input v-model="form.supAddress" placeholder="" :clearable="false" :disabled="true" /> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<general-button @emitClick="submit" :btnTitle="i18n.confirm"></general-button> |
|
|
|
<general-button @emitClick="submit" :btnTitle="i18n.confirm" |
|
|
|
:btnDisabled="btnDisabled"></general-button> |
|
|
|
|
|
|
|
<view class="item m48"> |
|
|
|
<view class="flex2 label-title"> |
|
|
@ -65,12 +67,22 @@ |
|
|
|
|
|
|
|
const ipptAddress = '0x622d7b79a904e00e5fcab06396ff009e441f0186' |
|
|
|
|
|
|
|
function delay(time) { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
setTimeout(() => { |
|
|
|
resolve() |
|
|
|
}, time) |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
export default { |
|
|
|
components: { |
|
|
|
GeneralButton, |
|
|
|
}, |
|
|
|
data() { |
|
|
|
return { |
|
|
|
isScroll: false, |
|
|
|
btnDisabled: false, |
|
|
|
url: '', |
|
|
|
showTip: false, |
|
|
|
form: { |
|
|
@ -91,7 +103,7 @@ |
|
|
|
onPullDownRefresh() { |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
onPageScroll(e) {}, |
|
|
|
onLoad(val) { |
|
|
|
this.url = location.origin + '?inviteCode='; |
|
|
|
if (val.inviteCode) { |
|
|
@ -104,10 +116,8 @@ |
|
|
|
}, 500) |
|
|
|
}, |
|
|
|
onReachBottom() { |
|
|
|
|
|
|
|
}, |
|
|
|
onReady() { |
|
|
|
|
|
|
|
}, |
|
|
|
methods: { |
|
|
|
// 点击复制按钮 |
|
|
@ -128,13 +138,24 @@ |
|
|
|
} |
|
|
|
web3x.connectViaInPage() |
|
|
|
.then(res => { |
|
|
|
// const chainId = await ethereum.request({ method: 'eth_chainId' }); async |
|
|
|
// console.log(parseInt(chainId)) |
|
|
|
// 用户进来是否询问添加切换网络 |
|
|
|
// await web3x.addBscMainnet() |
|
|
|
// await web3x.switchToBscMainnet() |
|
|
|
// await web3x.connectViaInPage() |
|
|
|
|
|
|
|
this.form.address = web3x.selectedAddress |
|
|
|
// 当前钱包地址 |
|
|
|
// console.log("当前钱包地址", web3x.selectedAddress); |
|
|
|
this.url = location.origin + '?inviteCode=' + web3x.selectedAddress |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
submit() { |
|
|
|
if (this.btnDisabled) { |
|
|
|
return; |
|
|
|
} |
|
|
|
if (!this.form.supAddress) { |
|
|
|
uni.$u.toast(this.$t("tabBar").empty) |
|
|
|
return |
|
|
@ -151,14 +172,24 @@ |
|
|
|
const allowance = await web3x.usdt.$allowance(web3x.selectedAddress, ipptAddress) |
|
|
|
// console.log(allowance, '当前用户授权给ippt的数量') |
|
|
|
// 如果 allowance 大于某个值则不需要重新授权. 示例为 1000000 USDT |
|
|
|
let onece = false; |
|
|
|
if (allowance > Number(1000000) * 10 ** Number(18)) { |
|
|
|
web3x.ippt.$creatCode(this.form.supAddress, web3x.selectedAddress) |
|
|
|
web3x.ippt.$creatCode(this.form.supAddress, web3x.selectedAddress).on( |
|
|
|
"transactionHash", () => { |
|
|
|
this.showTip = true; |
|
|
|
uni.pageScrollTo({ |
|
|
|
scrollTop: 0, |
|
|
|
duration: 200 |
|
|
|
}); |
|
|
|
// 确认按钮置灰 |
|
|
|
this.btnDisabled = true |
|
|
|
uni.hideLoading() |
|
|
|
}) |
|
|
|
.on("confirmation", (confirmation, receipt, |
|
|
|
latestBlockHash) => { |
|
|
|
if (confirmation >= 5) { |
|
|
|
this.showTip = true |
|
|
|
console.log("区块确认") |
|
|
|
uni.hideLoading() |
|
|
|
if (confirmation >= 5 && !onece) { |
|
|
|
onece = true; |
|
|
|
this.showTip = false |
|
|
|
} |
|
|
|
}) |
|
|
|
} else { |
|
|
@ -168,18 +199,28 @@ |
|
|
|
if (allowance == 0) { |
|
|
|
// 然后在进行极限授权 |
|
|
|
web3x.usdt.approveMAX(ipptAddress) |
|
|
|
.on("transactionHash", () => { |
|
|
|
.on("transactionHash", async () => { |
|
|
|
// console.log("调用极限授权") |
|
|
|
// 调用IPPT 合约绑定上级关系 |
|
|
|
// 0xFb4FC7Ddb8c4aa6b944703CE1e89D2B9Aa67a400: 上级地址 |
|
|
|
// web3x.selectedAddress: 当前钱包地址 |
|
|
|
// 弹框 |
|
|
|
this.showTip = true; |
|
|
|
// 置顶 |
|
|
|
uni.pageScrollTo({ |
|
|
|
scrollTop: 0, |
|
|
|
duration: 200 |
|
|
|
}); |
|
|
|
// 确认按钮置灰 |
|
|
|
this.btnDisabled = true |
|
|
|
uni.hideLoading() |
|
|
|
await delay(2000) |
|
|
|
web3x.ippt.$creatCode(this.form.supAddress, web3x.selectedAddress) |
|
|
|
.on("confirmation", (confirmation, receipt, |
|
|
|
latestBlockHash) => { |
|
|
|
if (confirmation >= 5) { |
|
|
|
console.log("区块确认") |
|
|
|
this.showTip = true |
|
|
|
uni.hideLoading() |
|
|
|
if (confirmation >= 5 && !onece) { |
|
|
|
onece = true; |
|
|
|
this.showTip = false |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
@ -192,15 +233,30 @@ |
|
|
|
// console.log("取消授权完成") |
|
|
|
// 然后在进行极限授权 |
|
|
|
web3x.usdt.approveMAX(ipptAddress) |
|
|
|
.on("transactionHash", () => { |
|
|
|
.on("transactionHash", async () => { |
|
|
|
// console.log("调用极限授权") |
|
|
|
// 调用IPPT 合约绑定上级关系 |
|
|
|
// 0xFb4FC7Ddb8c4aa6b944703CE1e89D2B9Aa67a400: 上级地址 |
|
|
|
// web3x.selectedAddress: 当前钱包地址 |
|
|
|
web3x.ippt.$creatCode(this.form.supAddress, web3x |
|
|
|
.selectedAddress) |
|
|
|
this.showTip = true |
|
|
|
this.showTip = true; |
|
|
|
// 置顶 |
|
|
|
uni.pageScrollTo({ |
|
|
|
scrollTop: 0, |
|
|
|
duration: 200 |
|
|
|
}); |
|
|
|
// 确认按钮置灰 |
|
|
|
this.btnDisabled = true |
|
|
|
uni.hideLoading() |
|
|
|
await delay(2000) |
|
|
|
web3x.ippt.$creatCode(this.form.supAddress, web3x |
|
|
|
.selectedAddress) |
|
|
|
.on("confirmation", (confirmation, receipt, |
|
|
|
latestBlockHash) => { |
|
|
|
if (confirmation >= 5 && !onece) { |
|
|
|
onece = true; |
|
|
|
this.showTip = false |
|
|
|
} |
|
|
|
}) |
|
|
|
}).catch(() => { |
|
|
|
uni.hideLoading() |
|
|
|
}) |
|
|
@ -234,17 +290,22 @@ |
|
|
|
transition: .5s all; |
|
|
|
position: fixed; |
|
|
|
width: 100%; |
|
|
|
height: 70rpx; |
|
|
|
height: 100rpx; |
|
|
|
padding: 10rpx 0; |
|
|
|
border-radius: 20rpx; |
|
|
|
width: 75%; |
|
|
|
padding-left: 36rpx; |
|
|
|
left: 50%; |
|
|
|
transform: translateX(-50%); |
|
|
|
top: 120rpx; |
|
|
|
padding: 14rpx 30rpx; |
|
|
|
transform: translate(-50%, -50%); |
|
|
|
top: 55%; |
|
|
|
color: #fff; |
|
|
|
z-index: 9999; |
|
|
|
background: radial-gradient(104.53% 5436.39% at -4.53% 16.35%, #7F97EC 3.77%, #8D6CEA 11.22%, #5944D7 24.63%, #2D2EA8 36.47%, #182390 63.92%, #16228E 100%); |
|
|
|
} |
|
|
|
.tipShow{ |
|
|
|
top: 100rpx; |
|
|
|
|
|
|
|
.tipshow { |
|
|
|
opacity: 1; |
|
|
|
top: 50%; |
|
|
|
} |
|
|
|
|
|
|
|
.m48 { |
|
|
|