修改一些页面的登录流程

This commit is contained in:
cebgcontract 2022-02-25 11:39:48 +08:00
parent 108c35a199
commit d76c4bc840
8 changed files with 46 additions and 52 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -25,7 +25,7 @@
</div>
<div class="sub-list">
<div class="title">Resources</div>
<a href="">Whitepaper</a>
<a href="https://whitepaper.cebg.games/">Whitepaper</a>
</div>
<div class="sub-list">
<div class="title">About</div>
@ -34,7 +34,7 @@
</div>
<div class="sub-list">
<div class="title">Policies</div>
<a href="javascript:void(0);" @click="comingSoon">Team of use</a>
<a href="/team" @click="comingSoon">Team of use</a>
<a href="javascript:void(0);" @click="comingSoon">Privacy Policy</a>
</div>
<div class="sub-list">

View File

@ -29,6 +29,7 @@ import { EventBus, PRESALE_BEGIN, PRESALE_ERROR, PRESALE_ORDER_GET, PRESALE_SUCC
import { Loading } from 'element-ui'
import { ElLoadingComponent } from 'element-ui/types/loading'
import TimeLoader from '@/components/main/TimeLoader.vue'
import { UserModule } from '@/store/modules/user'
@Component({
name: 'NftSection',
@ -67,7 +68,7 @@ export default class extends Vue {
this.removeEvents()
}
@Watch('accountId')
@Watch('isLogin')
private accountChange() {
if (this.accountId) {
this.getPresaleInfo()
@ -84,6 +85,10 @@ export default class extends Vue {
return AppModule.accountId
}
get isLogin() {
return !!UserModule.token && !!AppModule.step
}
async fetchData() {
await this.queryPresaleList()
await this.getPresaleInfo()

View File

@ -13,7 +13,7 @@
<a class="navItem" href="/">Home</a>
<a class="navItem" href="javascript:void(0);" @click.stop="comingSoon">Official Shop</a>
<a class="navItem dash" href="javascript:void(0);" @click.stop="comingSoon">Marketplace</a>
<label v-if="!walletCollected" class="navItem" @click="collectToWallet">Connect Wallet</label>
<label v-if="!logined" class="navItem" @click="collectToWallet">Connect Wallet</label>
<!-- <button v-if="!walletCollected" class="general-btn connectButton mobile" @click="collectToWallet">-->
<!-- <span>Connect Wallet</span>-->
<!-- </button>-->
@ -22,7 +22,7 @@
<!-- <div>My Profile</div>-->
<!-- <img src="data:image/svg+xml,%3csvg width='10' height='18' viewBox='0 0 10 18' fill='none' xmlns='http://www.w3.org/2000/svg'%3e %3cpath d='M0.0507022 16.0711L1.46491 17.4854L9.9502 9.00007L1.46492 0.514787L0.0507015 1.929L7.12177 9.00007L0.0507022 16.0711Z' fill='%23BCADF2' /%3e %3c/svg%3e">-->
<!-- </label>-->
<label class="navItem" v-if="walletCollected" @click="disconnectWallet">Log Out</label>
<label class="navItem" v-if="logined" @click="disconnectWallet">Log Out</label>
<div class="navChild" :class="{'show': subShow}">
<label class="navItem profile" @click="subShow=!subShow">
<img class="arrowIcon" src="data:image/svg+xml,%3csvg width='10' height='18' viewBox='0 0 10 18' fill='none' xmlns='http://www.w3.org/2000/svg'%3e %3cpath d='M0.0507022 16.0711L1.46491 17.4854L9.9502 9.00007L1.46492 0.514787L0.0507015 1.929L7.12177 9.00007L0.0507022 16.0711Z' fill='%23BCADF2' /%3e %3c/svg%3e">
@ -39,9 +39,10 @@
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'
import { BlockChain } from '@/utils/blockchain'
import { AppModule } from '@/store/modules/app'
import { Message } from 'element-ui'
import { UserModule } from '@/store/modules/user'
import ChainManager from '@/utils/ChainManager'
@Component({
name: 'MobileTop',
@ -52,12 +53,20 @@ import { Message } from 'element-ui'
export default class extends Vue {
menuShow = false
subShow = false
bc = new BlockChain();
chainManager = new ChainManager()
get walletCollected() {
return AppModule.walletConnected
}
async created() {
await this.chainManager.init()
}
get logined() {
return !!UserModule.token && !!AppModule.step
}
toggleMenu() {
this.menuShow = !this.menuShow
if (!this.menuShow) {
@ -67,12 +76,12 @@ export default class extends Vue {
async collectToWallet() {
this.menuShow = false
return this.bc.connect()
return this.chainManager.login()
}
async disconnectWallet() {
this.menuShow = false
return this.bc.disconnect()
return this.chainManager.logout()
}
comingSoon() {

View File

@ -28,6 +28,7 @@ import { Message } from 'element-ui'
import { EventBus, NEED_LOGIN, PRESALE_BEGIN, PRESALE_ERROR, PRESALE_ORDER_GET } from '@/utils/event-bus'
import { UserModule } from '@/store/modules/user'
import { getNonce } from '@/api/User'
import ChainManager from '@/utils/ChainManager'
declare module 'vue/types/vue' {
interface Vue {
@ -42,7 +43,7 @@ declare module 'vue/types/vue' {
props: ['data']
})
export default class extends Vue {
bc = new BlockChain()
chainManger = new ChainManager()
get walletCollected() {
return AppModule.walletConnected
@ -71,14 +72,13 @@ export default class extends Vue {
}
get logined() {
return !!UserModule.token
return !!UserModule.token && !!AppModule.step
}
async buyItem() {
console.log('on click item: ', this.data.id)
if (!this.logined) {
EventBus.$emit(NEED_LOGIN)
return
await this.chainManger.login()
}
if (!this.canBuy) {
Message({
@ -88,31 +88,6 @@ export default class extends Vue {
})
return
}
if (!this.logined) {
try {
await this.bc.connect()
} catch (err) {
Message({
message: err.message,
type: 'error',
duration: 5 * 1000
})
return
}
const preRequest: any = await getNonce({
account: AppModule.accountId,
net_id: AppModule.chainId
})
if (!preRequest.token_state) {
await UserModule.Login({
bcInstance: this.bc,
account: AppModule.accountId,
chainId: AppModule.chainId,
nonce: preRequest.nonce
})
}
}
if (!AppModule.canBuy) {
Message({
message: 'Can`t buy current time',
@ -130,8 +105,8 @@ export default class extends Vue {
EventBus.$emit(PRESALE_BEGIN)
const account = AppModule.accountId
try {
const price = this.bc.parsePrice(this.data.priceDiscount!, this.data.decimals!)
const { nonce, signature } = await this.bc.signPresale({
const price = this.chainManger.bc.parsePrice(this.data.priceDiscount!, this.data.decimals!)
const { nonce, signature } = await this.chainManger.bc.signPresale({
type: this.data.recordId!,
paymentTokenAddress: this.data.coinAddress!,
price,
@ -145,7 +120,7 @@ export default class extends Vue {
nonce,
signature
}
await this.bc.increaseAllowance(this.data.coinAddress!, price)
await this.chainManger.bc.increaseAllowance(this.data.coinAddress!, price)
const res: any = await buyBox(buyData)
const orderId = res.order_id
localStorage.setItem('tmp_presale_order_id', orderId)

View File

@ -33,10 +33,10 @@
<!-- <div class="contact">-->
<!-- <span class="span">Contact Us</span>-->
<!-- </div>-->
<div v-if="!walletCollected" @click="collectToWallet" class="walletBtn active">
<div v-if="!logined" @click="collectToWallet" class="walletBtn active">
<span>Connect Wallet</span>
</div>
<div v-if="walletCollected" @click="disconnectWallet" class="walletBtn">
<div v-if="logined" @click="disconnectWallet" class="walletBtn">
<span>Logout</span>
</div>
<!-- <img-->
@ -51,7 +51,7 @@
</div>
</div>
<top-user-info
v-show="infoPanelShow && walletCollected"
v-show="infoPanelShow && logined"
v-on:close-self="onClose"
></top-user-info>
</div>
@ -60,9 +60,10 @@
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'
import TopUserInfo from '@/components/market/TopUserInfo.vue'
import { BlockChain } from '@/utils/blockchain'
import { AppModule } from '@/store/modules/app'
import { Message } from 'element-ui'
import ChainManager from '@/utils/ChainManager'
import { UserModule } from '@/store/modules/user'
declare module 'vue/types/vue' {
interface Vue {
@ -77,18 +78,22 @@ declare module 'vue/types/vue' {
})
export default class extends Vue {
infoPanelShow = false
bc = new BlockChain();
chainManager = new ChainManager()
get walletCollected() {
return AppModule.walletConnected
async created() {
await this.chainManager.init()
}
get logined() {
return !!UserModule.token && !!AppModule.step
}
async collectToWallet() {
return this.bc.connect()
return this.chainManager.login()
}
async disconnectWallet() {
return this.bc.disconnect()
return this.chainManager.logout()
}
onClose() {

View File

@ -31,7 +31,7 @@
<div>Resources</div>
<img class="btn-plus" src="@/assets/mobile/index/icon-plus.png" alt="plus"/>
</div>
<a href="">Whitepaper</a>
<a href="https://whitepaper.cebg.games/">Whitepaper</a>
</div>
<div class="sub-list" :class="{'close': status[2]}">
<div class="title" @click="toggleSublist(2)">
@ -46,7 +46,7 @@
<div>Policies</div>
<img class="btn-plus" src="@/assets/mobile/index/icon-plus.png" alt="plus"/>
</div>
<a href="javascript:void(0);" @click="comingSoon">Team of use</a>
<a href="/team">Team of use</a>
<a href="javascript:void(0);" @click="comingSoon">Privacy Policy</a>
</div>
<div class="sub-list" :class="{'close': status[4]}">