提交 9d3f24c1 authored 作者: zhanglian's avatar zhanglian

转账成功提示

上级 20c9cf0d
...@@ -18,8 +18,6 @@ import 'swiper/swiper-bundle.css' ...@@ -18,8 +18,6 @@ import 'swiper/swiper-bundle.css'
Vue.config.productionTip = false Vue.config.productionTip = false
Vue.use(animated) Vue.use(animated)
Vue.use(AsyncComputed) Vue.use(AsyncComputed)
......
import Vue from 'vue' import Vue from 'vue'
import { Dialog } from 'vant'; import { Dialog, Loading,Notify } from 'vant';
// 全局注册 // 全局注册
Vue.use(Dialog); Vue.use(Dialog);
\ No newline at end of file Vue.use(Loading);
Vue.use(Notify);
\ No newline at end of file
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
</li> </li>
</ul> </ul>
</EDialog> </EDialog>
<van-loading class="loading-bg" type="spinner" color="#303030" size="24px" v-show="pageLoading"/>
</div> </div>
</template> </template>
...@@ -77,6 +78,7 @@ export default { ...@@ -77,6 +78,7 @@ export default {
data() { data() {
return { return {
dialogVisible: false, dialogVisible: false,
pageLoading: false,
tokenList: [], tokenList: [],
tokenListOrigin: [{ tokenListOrigin: [{
name: 'TKM', name: 'TKM',
...@@ -234,13 +236,11 @@ export default { ...@@ -234,13 +236,11 @@ export default {
chainName: 'tkm', chainName: 'tkm',
coinData: {}, coinData: {},
} }
let bsc = { let bsc = {
name: 'BSC', name: 'BSC',
chainName: 'bsc', chainName: 'bsc',
coinData: {}, coinData: {},
} }
if (this.tokenListBSC.map(item => item.chainId).includes(this.chainId)) { if (this.tokenListBSC.map(item => item.chainId).includes(this.chainId)) {
this.holdItem = bsc; this.holdItem = bsc;
this.exchangeItem = tkm; this.exchangeItem = tkm;
...@@ -248,10 +248,9 @@ export default { ...@@ -248,10 +248,9 @@ export default {
this.holdItem = tkm; this.holdItem = tkm;
this.exchangeItem = bsc; this.exchangeItem = bsc;
} }
this.changeItem = 'holdItem'; this.changeItem = 'holdItem';
let token = this.tokenListOrigin.find(item => item.chainId == this.chainId && item.chainName == this.holdItem.chainName); let token = this.tokenListOrigin.find(item => item.chainId == this.chainId && item.chainName == this.holdItem.chainName);
if(!token){ if (!token) {
token = this.getTokensByChainName(this.holdItem.chainName)[0] token = this.getTokensByChainName(this.holdItem.chainName)[0]
} }
this.changeSelect(0, token) this.changeSelect(0, token)
...@@ -259,12 +258,12 @@ export default { ...@@ -259,12 +258,12 @@ export default {
formateChainName(chainId) { formateChainName(chainId) {
let tkmChainIds = this.tokenListTKM.map(item => item.chainId); let tkmChainIds = this.tokenListTKM.map(item => item.chainId);
let bscChainIds = this.tokenListBSC.map(item => item.chainId); let bscChainIds = this.tokenListBSC.map(item => item.chainId);
if (tkmChainIds.includes(chainId - 0)) { if (tkmChainIds.includes(chainId - 0)) {
return `Thinkium ${chainId}#链` return `Thinkium ${chainId}#链`
} else if(bscChainIds.includes(chainId - 0)) { } else if (bscChainIds.includes(chainId - 0)) {
return `BSC` return `BSC`
}else{ } else {
return chainId return chainId
} }
}, },
...@@ -323,7 +322,7 @@ export default { ...@@ -323,7 +322,7 @@ export default {
this.dialogVisible = true this.dialogVisible = true
this.changeItem = type; this.changeItem = type;
}, },
transfer() { async transfer() {
const { inputValue, holdItem, exchangeItem } = this; const { inputValue, holdItem, exchangeItem } = this;
const value = (inputValue + '').trim() - 0; const value = (inputValue + '').trim() - 0;
if (!value) { if (!value) {
...@@ -335,21 +334,29 @@ export default { ...@@ -335,21 +334,29 @@ export default {
}); });
return; return;
} }
if (holdItem.coinData.type == 'main') { this.pageLoading = true;
this.depositNative({ try {
chain: exchangeItem.coinData.chainId + '', if (holdItem.coinData.type == 'main') {
value: this.$toBig(value) await this.depositNative({
}); chain: exchangeItem.coinData.chainId + '',
} else { value: this.$toBig(value)
this.depositToken({ });
chain: exchangeItem.coinData.chainId + '', } else {
value: this.$toBig(value), await this.depositToken({
tokenAddress: holdItem.coinData.contractAddress, chain: exchangeItem.coinData.chainId + '',
}); value: this.$toBig(value),
} tokenAddress: holdItem.coinData.contractAddress,
});
}
this.$notify({ type: 'success', message: '转账成功' });
} catch (err) {
this.$notify({ type: 'warning', message: '转账失败' });
}
this.pageLoading = false;
}, },
depositNative({ address = window.defaultAccount, chain, value }) { async depositNative({ address = window.defaultAccount, chain, value }) {
let params = [ let params = [
address, address,
chain, chain,
...@@ -357,7 +364,7 @@ export default { ...@@ -357,7 +364,7 @@ export default {
let overrides = { let overrides = {
value, value,
} }
bridge.methods.depositNative(...params).send(overrides) await bridge.methods.depositNative(...params).send(overrides)
}, },
async depositToken({ value, tokenAddress, address = window.defaultAccount, chain }) { async depositToken({ value, tokenAddress, address = window.defaultAccount, chain }) {
let token = ''; let token = '';
...@@ -372,7 +379,7 @@ export default { ...@@ -372,7 +379,7 @@ export default {
address, address,
chain chain
] ]
bridge.methods.depositToken(...params).send(); await bridge.methods.depositToken(...params).send();
}, },
async approve({ value, contractAddress, owner = window.defaultAccount, spender }) { async approve({ value, contractAddress, owner = window.defaultAccount, spender }) {
console.log({ value, contractAddress, owner, spender }); console.log({ value, contractAddress, owner, spender });
...@@ -572,5 +579,14 @@ export default { ...@@ -572,5 +579,14 @@ export default {
background-color: rgba($color: #FCBF19, $alpha: 0.1); background-color: rgba($color: #FCBF19, $alpha: 0.1);
} }
} }
.loading-bg{
position: fixed;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
background: rgba(0,0,0,0.3);
}
} }
</style> </style>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论