登陆成功后,增加当前帐号返回

This commit is contained in:
cebgcontract 2022-10-20 14:46:49 +08:00
parent 7a8f0972b4
commit d6eb43e36c
2 changed files with 35 additions and 34 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,42 +1,43 @@
var jcchain = require('./jcchain.js') var jcchain = require("./jcchain.js");
var chain = new jcchain.JCChain() var chain = new jcchain.JCChain();
var toggleLoginBtn = function () { var toggleLoginBtn = function () {
if (chain.logined) { if (chain.logined) {
$('#header_loginbtn').hide() $("#header_loginbtn").hide();
$('#header_logoutbtn').show() $("#header_logoutbtn").show();
} else { } else {
$('#header_loginbtn').show() $("#header_loginbtn").show();
$('#header_logoutbtn').hide() $("#header_logoutbtn").hide();
} }
} };
toggleLoginBtn() toggleLoginBtn();
var logSuccess = function () { var logSuccess = function () {
console.log('login success') console.log("login success");
toggleLoginBtn() console.log(chain);
} toggleLoginBtn();
$('#header_loginbtn').click(function () { };
chain.login().then(logSuccess.bind(this)) $("#header_loginbtn").click(function () {
}) chain.login().then(logSuccess.bind(this));
});
$('#header_logoutbtn').click(function () { $("#header_logoutbtn").click(function () {
chain.logout().then(() => { chain.logout().then(() => {
toggleLoginBtn() toggleLoginBtn();
}) });
}) });
jcchain.EventBus.$on(jcchain.SHOW_CHAIN_MODAL, function () { jcchain.EventBus.$on(jcchain.SHOW_CHAIN_MODAL, function () {
console.log('show chain modal') console.log("show chain modal");
$('#wallet_modal').show() $("#wallet_modal").show();
}) });
$('#metamask_card').click(function () { $("#metamask_card").click(function () {
chain.selectWalletAndLogin(1).then(logSuccess.bind(this)) chain.selectWalletAndLogin(1).then(logSuccess.bind(this));
$('#wallet_modal').hide() $("#wallet_modal").hide();
}) });
$('#wc_card').click(function () { $("#wc_card").click(function () {
chain.selectWalletAndLogin(2).then(logSuccess.bind(this)) chain.selectWalletAndLogin(2).then(logSuccess.bind(this));
$('#wallet_modal').hide() $("#wallet_modal").hide();
}) });
$('.comingSoon').click(function(){ $(".comingSoon").click(function () {
$.message({type:'default',content:'Coming Soon.'}); $.message({ type: "default", content: "Coming Soon." });
}) });