diff --git a/src/components/assets/assetsContent.vue b/src/components/assets/assetsContent.vue index a852185..9630384 100644 --- a/src/components/assets/assetsContent.vue +++ b/src/components/assets/assetsContent.vue @@ -6,8 +6,8 @@
- - + + @@ -37,10 +37,10 @@ const marketplaceList = useMarketplaceStore() const navList = ref([ { - name: "Founder's Tag" + name: "NFTs" }, { - name: "NFTs" + name: "Founder's Tag" }, { name: "Centralized Assets" diff --git a/src/components/assets/assetsHeader.vue b/src/components/assets/assetsHeader.vue index f24552c..4ed568d 100644 --- a/src/components/assets/assetsHeader.vue +++ b/src/components/assets/assetsHeader.vue @@ -9,11 +9,12 @@
{{ localWalletStore.showAddress ? localWalletStore.showAddress : 'User Address' }}
- Total contribution:  999999999 +

Total Contribution Credits:  {{ contributionPointTotal }}

- Contribution are expected daily:   +150000/d - +

Daily Expected:   +{{ contributionPoint }}/d

+ +
@@ -49,7 +50,7 @@ Collection
- +
CEC Incentives Record
@@ -175,8 +176,84 @@
- -
1212121
+ +
Staking Rules
+
+ +
+

1. Staking Rules

+
+

*Contributions only count if staked for a minimum of 24 hours.

+

*If unstaked before 24 hours, no Credits will be awarded.

+

*Contribution Credits are calculated daily at 00:00 UTC.

+
+

2. Staking Rewards

+
+
  • +

    hero

    +
    + Tier + Daily contribution points +
    +
    +
    + Tier 1 + 10 +
    +
    + Tier 2 + 20 +
    +
    + Tier 3 + 40 +
    +
    + Tier 4 + 80 +
    +
    + Tier 5 + 160 +
    +
    +
  • +
  • +

    Founder’s Tag

    +
    + Tier + Daily contribution points +
    +
    +
    + Tier 1 + 20 +
    +
    + Tier 2 + 40 +
    +
    + Tier 3 + 100 +
    +
    +   + +
    +
    +   + +
    +
    +
  • +
    +

    3. Bonus Calculation

    +
    +

    Each Founder's Tag: +10%

    +

    Each Genesis Hero: +5%

    +

    Maximum bonus cap: +100%

    +
    @@ -187,10 +264,12 @@ import { ref, watch, computed, onMounted } from "vue" import ConfirmDialog from "@/components/Dialogs/confirmDialog.vue"; import {createModal} from "@/utils/model.util"; -import { apiCecInfo } from "@/utils/marketplace" +import { apiCecInfo, apiExpected, apiUserData } from "@/utils/marketplace" import { priceCalculated } from "@/configs/priceCalculate" +import { useMarketplaceStore } from "@/store/marketplace" import {walletStore} from "@/store/wallet"; +const marketplaceStore = useMarketplaceStore() const localWalletStore = walletStore() const bgCor = ref(['#5bbbff', '#ffc35b', '#bb7fff', '#ff6600']) @@ -250,14 +329,47 @@ const getCecInfo = async () => { if(address) { const {data, errcode} = await apiCecInfo(address) // console.log(errcode,data) - if(errcode == 0) { - cecInfo.value = data - } + if(errcode == 0) { + cecInfo.value = data + } } else { return } } +const contributionPoint = ref(0) +const getExpected = async () => { + let address = localWalletStore.address + if(address) { + const {contribution_point, errcode} = await apiExpected(address) + if(errcode == 0) { + contributionPoint.value = contribution_point + } + } else { + return + } +} + +const contributionPointTotal = ref(0) +const getUserData = async () => { + let address = localWalletStore.address + if(address) { + const {errcode, contribution_point, gold} = await apiUserData(address) + if(errcode == 0) { + contributionPointTotal.value = contribution_point + marketplaceStore.userGold = gold + } + } else { + return + } +} + +const dataInfo = async () => { + await getCecInfo() + await getExpected() + await getUserData() +} + watch(localWalletStore,() => { // console.log('localWalletStore.token',localWalletStore.address,localWalletStore.token) if(!localWalletStore.address) { @@ -284,12 +396,12 @@ watch(localWalletStore,() => { ] } } else { - getCecInfo() + dataInfo() } }) onMounted(() => { - getCecInfo() + dataInfo() }) @@ -343,13 +455,19 @@ onMounted(() => { font-family: 'Poppins'; font-weight: 500; font-size: 14px; - color: #FFFFFF; img { + width: 27px; + height: 23px; + margin-left: 10px; + } + .icon { width: 30px; height: 30px; - margin-left: 10px; cursor: pointer; } + span { + color: #00DEFF; + } } } } @@ -705,7 +823,114 @@ onMounted(() => { } } :deep(.rulesModal) { - background: #1a1821; + width: 1152px !important; + height: 805px; + background: #1A1821; + box-shadow: 0px 15px 28px 3px rgba(22,22,22,0.13); + border-radius: 100px; + border: 1px solid #B966FF; + .ant-modal-content { + width: 944px; + margin: 0 auto; + color: #FFF; + background: #1A1821; + border-radius: 100px; + box-shadow: 0 0 0 0; + .ant-modal-body { + overflow: hidden; + .log-title { + width: 944px; + margin: 0 auto; + font-family: 'Anton'; + font-weight: 400; + font-size: 48px; + color: #FFFFFF; + margin-top: 23px; + border-bottom: 2px solid #3D4057; + } + .closable { + position: absolute; + right: -120px; + top: -30px; + z-index: 99; + cursor: pointer; + img { + width: 120px; + height: 120px; + } + } + h3 { + font-family: 'Poppins'; + font-weight: bold; + font-size: 29px; + color: #FFFFFF; + margin-top: 20px; + } + .staking-content { + display: flex; + justify-content: space-between; + li { + width: 427px; + border-radius: 50px; + h4 { + font-family: 'Poppins'; + font-weight: bold; + font-size: 30px; + color: #AB74EA; + text-align: center; + } + .hero-title { + height: 50px; + line-height: 50px; + background: #604680; + border-radius: 30px 30px 0 0; + font-family: 'Poppins'; + font-weight: bold; + font-size: 18px; + color: #F6F6F6; + span { + display: inline-block; + text-align: center; + &:nth-child(1) { + width: 127px; + border-right: 2px solid #1a1821; + } + &:nth-child(2) { + width: 300px; + } + } + } + .hero-body { + div { + height: 46px; + line-height: 46px; + text-align: center; + background: #2d2738; + font-family: 'Poppins'; + font-weight: 600; + font-size: 20px; + color: #F3F0FF; + border-top: 2px solid #1a1821; + span { + display: inline-block; + text-align: center; + &:nth-child(1) { + width: 127px; + border-right: 2px solid #1a1821; + } + &:nth-child(2) { + width: 300px; + } + } + &:last-child { + border-radius: 0 0 30px 30px; + } + } + } + } + } + } + } } } \ No newline at end of file diff --git a/src/components/assets/cenCard.vue b/src/components/assets/cenCard.vue index e4c4b6d..c193cf9 100644 --- a/src/components/assets/cenCard.vue +++ b/src/components/assets/cenCard.vue @@ -6,7 +6,7 @@
    - HERO + Legacy Heroes
    @@ -102,29 +102,6 @@ const sellNft = async (val) => { sellDialogVisible.value = true } -// 取消出售 -// const cancelNft = async (val) => { -// let orderIds = await getNftData(val) -// try { -// const bc = new BlockChain() -// let res = await bc.market.cancelOrder([orderIds.event.data.id]) -// if(res.result) { -// let timer = setTimeout(() => { -// message.success('Your item has been unlisted.') -// emit('renewMyNft') -// clearTimeout(timer); -// }, 2000); -// } -// } catch (e) { -// if(e.message.indexOf('rejected') > -1) { -// message.error('User rejected the request') -// } else { -// message.error('Your item has failed to be unlisted.') -// } -// } -// } - - const loadingDialogVisible = ref(false) // 下链使用 const lockToGame = async(type) => { @@ -150,17 +127,24 @@ const lockToGame = async(type) => { } // mint一个英雄 const mintHero = async () => { - try { - const res = await new BlockChain().locker.mintNft([toRaw(props.nftData).uniid]) - message.success('Mint success.') - emit('renewMyNft') - } catch (e) { - if(e.message.indexOf('rejected') > -1) { - message.error('User rejected the request') - } else if (e.message.indexOf('select wallet') > -1) { - message.error('user cancel select wallet') - } else { - message.error('Mint Failed.') + if(marketplaceStore.userGold < 0) { + const confirmResult = await createModal(ConfirmDialog, { + title: '', + message: 'Mint Failed - Negative in-game gold balance. Please adjust your balance to continue.' + }).show() + } else { + try { + const res = await new BlockChain().locker.mintNft([toRaw(props.nftData).uniid]) + message.success('Mint success.') + emit('renewMyNft') + } catch (e) { + if(e.message.indexOf('rejected') > -1) { + message.error('User rejected the request') + } else if (e.message.indexOf('select wallet') > -1) { + message.error('user cancel select wallet') + } else { + message.error('Mint Failed.') + } } } } diff --git a/src/components/assets/centralization.vue b/src/components/assets/centralization.vue index cfa3a5b..a4b9929 100644 --- a/src/components/assets/centralization.vue +++ b/src/components/assets/centralization.vue @@ -104,9 +104,8 @@ const getMyAssets = async () => { if(bc.passportLogined) { try { let nftListBox - const ptoken = await bc.passportToken() - let res = await apiHeroList(data, ptoken) - // console.log(res,'----------------------') + // const ptoken = await bc.passportToken() + let res = await apiHeroList(data) // return nftList.value = [...nftList.value, ...res.rows] // nftListBox = nftList.value.reduce((acc, obj) => { diff --git a/src/components/assets/collectibles.vue b/src/components/assets/collectibles.vue index 02d0954..e294128 100644 --- a/src/components/assets/collectibles.vue +++ b/src/components/assets/collectibles.vue @@ -37,10 +37,10 @@ import NftId from "@/configs/item.json" import { apiAssetsState } from "@/utils/marketplace" import {useMarketplaceStore} from "@/store/marketplace"; import {walletStore} from "@/store/wallet"; +import { BlockChain } from "@/components/chain/BlockChain" const marketplaceStore = useMarketplaceStore() const localWalletStore = walletStore() const nftList = ref([]) -// console.log('localWalletStore', localWalletStore.token) const overviewValue = ref() const statusValue = ref('0') @@ -83,6 +83,9 @@ const getMyAssets = async () => { cursor: next_cursor.value, search_name: overviewValue.value } + const bc = new BlockChain() + // const pstoken = await bc.token() + // const ptoken = await bc.passportToken() if(myADdress) { try { let nftListBox diff --git a/src/components/assets/founder.vue b/src/components/assets/founder.vue index 68c5c3f..8444db0 100644 --- a/src/components/assets/founder.vue +++ b/src/components/assets/founder.vue @@ -35,7 +35,7 @@ + + diff --git a/src/components/layout/NavBar.vue b/src/components/layout/NavBar.vue index e5891eb..ea3a95b 100644 --- a/src/components/layout/NavBar.vue +++ b/src/components/layout/NavBar.vue @@ -277,6 +277,7 @@ const immuTableLogout = async () => { // immutableStore.accessToken = '' // immutableStore.accounts = '' // await new PassportWallet().logout() + location.reload() } catch (e) { console.log(e) } diff --git a/src/configs/priceCalculate.js b/src/configs/priceCalculate.js index f66e4ff..1850146 100644 --- a/src/configs/priceCalculate.js +++ b/src/configs/priceCalculate.js @@ -51,4 +51,36 @@ export const totalPrice = (price) => { export const showTime = (time) => { let str = time.split('.') return str[0] +} + +// 处理贡献值 +export const contribution = (quality) => { + let str + if(quality == 1) { + str = 10 + } else if(quality == 2) { + str = 20 + } else if(quality == 3) { + str = 30 + } else if(quality == 4) { + str = 40 + } else if(quality == 5) { + str = 160 + } + return str +} + +// 质押时间 +export const timeStaking = (time) => { + let timeArr = [] + let now = new Date().getTime() + let str = (now/1000) - time + let d = Math.floor(str / 60 / 60 / 24); + d = d < 10 ? "0" + d : d; + let h = Math.floor((str / 60 / 60) % 24); + h = h < 10 ? "0" + h : h; + let m = Math.floor((str / 60) % 60); + m = m < 10 ? "0" + m : m; + timeArr = [d, h, m] + return timeArr } \ No newline at end of file diff --git a/src/store/marketplace.js b/src/store/marketplace.js index fa10f1a..52f9714 100644 --- a/src/store/marketplace.js +++ b/src/store/marketplace.js @@ -41,6 +41,7 @@ export const useMarketplaceStore = defineStore('marketplace', () => { } }) const detailData = ref() + const userGold = ref(0) const updateOverviewStatus = (_connected) => { overview.value = _connected; @@ -101,8 +102,8 @@ export const useMarketplaceStore = defineStore('marketplace', () => { getCartList, getCartListState, addCartListState, delCartListState, - currencyPrice,priceDatas, - detailData, + currencyPrice, priceDatas, + detailData, userGold } }, { diff --git a/src/utils/marketplace.js b/src/utils/marketplace.js index 1dfeb20..ed0382c 100644 --- a/src/utils/marketplace.js +++ b/src/utils/marketplace.js @@ -134,4 +134,16 @@ export const apiUnlockOrMint = async (data, token) => { export const apiMintNft = async (data, token) => { const url = `${API_BASE}/api/ingame/asset/hero/mint` return httpPost(url, data, token) -} \ No newline at end of file +} + +// 取每日预期所得 +export const apiExpected = async (account_address) => { + const url = `${API_BASE}/api/activity/stacking/expected_daily/${account_address}` + return httpGet(url, {}) +} + +// 用户信息 +export const apiUserData = async (account_address) => { + const url = `${API_BASE}/api/user/${account_address}` + return httpGet(url, {}) +} diff --git a/src/views/DetailView.vue b/src/views/DetailView.vue index 5ac10e7..91c57de 100644 --- a/src/views/DetailView.vue +++ b/src/views/DetailView.vue @@ -10,7 +10,8 @@
    -

    {{ detailData.nft.name }}

    +

    Founder's Tag

    +

    {{ detailData.nft.name }}

    Owner:
    {{ detailData.nft.owner_address ? detailData.nft.owner_address : myAddress }}
    @@ -32,14 +33,24 @@
    - - Time remaining : 6d:10h:22m +
    + + Time remaining :   + {{ timeStaking(detailData.nft.last_lock_time)[0] }}:d + {{ timeStaking(detailData.nft.last_lock_time)[1] }}:h + {{ timeStaking(detailData.nft.last_lock_time)[2] }}:m + +
    +
    + +{{ contribution(detailData.nft.detail.quality) }}/d + +
    Unstake
    -
    +
    Mint
    +
    Buy Now
    @@ -64,11 +76,12 @@ 2、下架 3、使用 --> -
    -
    List
    +
    +
    List
    Cancel listing
    -
    Convert
    -
    Redeem
    +
    Stake
    +
    Stake
    +
    @@ -102,7 +115,7 @@
    -
    +

    Property

  • @@ -145,7 +158,7 @@
  • -
    +

    Property

    @@ -191,6 +204,7 @@ import { useMarketplaceStore } from "@/store/marketplace" import LazyLoadImg from "@/components/lazyloadimg" import {formatPrice} from "@/components/chain/utils" import {createModal} from "@/utils/model.util"; +import { contribution, timeStaking } from "@/configs/priceCalculate" const router = useRouter(); const route = useRoute(); const localWalletStore = walletStore() @@ -297,19 +311,19 @@ const clearCart = async () => { // 下链使用 const lockToGame = async(type) => { - if(type == 'redeem') { + if(type == 'founder') { const confirmResult = await createModal(ConfirmDialog, { title: '', - message: `Redeem ${detailData.value.nft.detail.gold_coins} Gold to your game account. Do you wish to proceed?` + message: `Are you sure you want to stake?` }).show() if (confirmResult.errcode == 0) { loadingDialogVisible.value = true - lockToGameConfirm() + unlockMainConfirm() } } else if(type == 'convert') { const confirmResult = await createModal(ConfirmDialog, { title: '', - message: 'After converting, you will be able to use the hero in the game. At the end of Season 1, the hero will automatically be returned to your wallet or Immutable Passport. Do you want to proceed?' + message: 'Are you sure you want to stake?' }).show() if (confirmResult.errcode == 0) { loadingDialogVisible.value = true @@ -332,26 +346,51 @@ const lockToGameConfirm = async () => { loadingDialogVisible.value = false } } - -// 赎回 -const backStaking = async () => { +const unlockMainConfirm = async () => { try { const bc = new BlockChain() - let res = await bc.locker.unlockOrMintGameNft(detailData.value.nft.contract_address,[detailData.value.nft.token_id]) - if(res) { - let timer = setTimeout(() => { - message.success('Unstake success.') - router.go(-1) - clearTimeout(timer); - }, 2000); - } + let res = await bc.locker.lockMain(detailData.value.nft.contract_address, [detailData.value.nft.token_id]) + message.success('lockToGame success') + // router.go(-1) + emit('renewMyNft') + loadingDialogVisible.value = false + // router.push('/assets') } catch (e) { if(e.message.indexOf('rejected') > -1) { message.error('User rejected the request') - } else if (e.message.indexOf('select wallet') > -1) { - message.error('user cancel select wallet') } else { - message.error('Unstake fail') + message.error('lockToGame fail.') + } + loadingDialogVisible.value = false + } +} + +// 赎回 +const backStaking = async () => { + if(marketplaceList.userGold < 0) { + const confirmResult = await createModal(ConfirmDialog, { + title: '', + message: 'Unstake Failed - Negative in-game gold balance. Please adjust your balance to continue.' + }).show() + } else { + try { + const bc = new BlockChain() + let res = await bc.locker.unlockOrMintGameNft(detailData.value.nft.contract_address,[detailData.value.nft.token_id]) + if(res) { + let timer = setTimeout(() => { + message.success('Unstake success.') + router.go(-1) + clearTimeout(timer); + }, 2000); + } + } catch (e) { + if(e.message.indexOf('rejected') > -1) { + message.error('User rejected the request') + } else if (e.message.indexOf('select wallet') > -1) { + message.error('user cancel select wallet') + } else { + message.error('Unstake fail') + } } } } @@ -442,17 +481,24 @@ const sellHandleClose = (val) => { // mint上链 const mintHero = async () => { - try { - const res = await new BlockChain().locker.mintNft([detailData.value.nft.uniid]) - message.success('Mint success.') - router.go(-1) - } catch (e) { - if(e.message.indexOf('rejected') > -1) { - message.error('User rejected the request') - } else if (e.message.indexOf('select wallet') > -1) { - message.error('user cancel select wallet') - } else { - message.error('Mint Failed.') + if(marketplaceList.userGold < 0) { + const confirmResult = await createModal(ConfirmDialog, { + title: '', + message: 'Mint Failed - Negative in-game gold balance. Please adjust your balance to continue.' + }).show() + } else { + try { + const res = await new BlockChain().locker.mintNft([detailData.value.nft.uniid]) + message.success('Mint success.') + router.go(-1) + } catch (e) { + if(e.message.indexOf('rejected') > -1) { + message.error('User rejected the request') + } else if (e.message.indexOf('select wallet') > -1) { + message.error('user cancel select wallet') + } else { + message.error('Mint Failed.') + } } } } @@ -613,23 +659,48 @@ onMounted(() => { } } .back-time { - width: 340px; + // width: 340px; height: 40px; line-height: 40px; - background: #272130; border-radius: 20px; font-family: 'Poppins'; font-weight: 300; font-size: 18px; - color: #9A50FF; display: flex; align-items: center; - img { - width: 20px; - height: 25px; - margin-right: 6px; - margin-left: 24px; + div { + display: flex; + align-items: center; + background: #272130; + padding: 0 24px; + border-radius: 20px; + img { + width: 20px; + height: 25px; + margin-right: 6px; + // margin-left: 24px; + } + span { + display: inline-block; + height: 40px; + line-height: 40px; + color: #9A50FF; + } + &:nth-child(2) { + margin-left: 20px; + span { + font-family: 'Poppins'; + font-weight: 600; + font-size: 20px; + color: #F3F0FF; + } + img { + width: 25px; + margin-left: 10px; + } + } } + } .top-right-btns { div {