Browse Source

更新’

git commit -m 更新’
master
j1ack 2 years ago
parent
commit
85ff153114
  1. 14
      component/GeneralButton/index.vue
  2. 113
      pages/index/index.vue
  3. 1
      utils/language/en_US.js
  4. 1
      utils/language/zh_TW.js
  5. 28
      utils/web3x/web3x.js

14
component/GeneralButton/index.vue

@ -1,6 +1,6 @@
<template>
<view>
<view class="btn" :style="{'--bgColor':bgColor,'width':btnWidth}" @click="$u.throttle(emitClick, 900)">
<view class="btn" :class="btnDisabled?'gray':'blue'" :style="{'width':btnWidth}" @click="$u.throttle(emitClick, 900)">
<text>{{ btnTitle }}</text>
</view>
</view>
@ -10,6 +10,12 @@
export default {
name:"Btn",
props: {
btnDisabled: {
type: Boolean,
default () {
return false
}
},
btnTitle: {
type: String,
default () {
@ -63,4 +69,10 @@
line-height: 32rpx;
}
}
.blue{
background: #006BFF;
}
.gray{
background: #909399 !important;
}
</style>

113
pages/index/index.vue

@ -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 {

1
utils/language/en_US.js

@ -1,6 +1,7 @@
// zh_TW.js
export default {
tabBar: {
te:'Successfully submitted, waiting for block confirmation.',
Home: 'Dear Ipswap Foundation Member:',
contract: 'Mapping smart contracts',
address: 'My inviter address',

1
utils/language/zh_TW.js

@ -1,6 +1,7 @@
// zh_TW.js
export default {
tabBar: {
te:'提交成功,等待區塊確認。',
Home: '尊敬的ippswap基金會會員:',
contract: '映射智能合約',
address: '我的邀請人地址',

28
utils/web3x/web3x.js

@ -219,7 +219,7 @@ class IPPT extends ERC20 {
* creatCode(address superior, address plivate) public returns (bool)
* @return {PromiEvent<Eth.Contract>}
*/
creatCode (superior, plivate) {
$creatCode (superior, plivate) {
return this.send(this.contract.methods.creatCode(superior, plivate), {from: this.selectedAddress});
}
}
@ -342,6 +342,32 @@ class Web3X {
async switchToBscTestnet () {
return await this.switchChain('0x61');
}
/**
* 添加 BSC 正式网
*/
async addBscMainnet () {
return await this.addChain({
chainId: '0x38',
chainName: 'Binance Smart Chain Mainnet',
nativeCurrency: {
name: 'BNB',
symbol: 'bnb',
decimals: 18,
},
rpcUrls: ['https://bsc-dataseed.binance.org/'],
blockExplorerUrls: ['https://bscscan.com'],
});
}
/**
* 切换到 BSC 正式网, 需先调用 web3x.addBscMainnet()
*/
async switchToBscMainnet () {
return await this.switchChain('0x38');
}
/**
* 添加 BSC 测试网

Loading…
Cancel
Save