完成充值和cec活动

This commit is contained in:
yuyongdong 2024-08-20 14:44:56 +08:00
parent 7e8c95636f
commit ca83c4f9c0
4 changed files with 73 additions and 46 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -406,7 +406,7 @@
<div v-else class="item-amount item-amount-input"> <div v-else class="item-amount item-amount-input">
<span @click="rechargeDecrease">-</span> <span @click="rechargeDecrease">-</span>
<!-- <span>0</span> --> <!-- <span>0</span> -->
<input type="text" placeholder="0" v-model="brickworkAmount" @input="handleInput" oninput="value=value.replace(/[^\d]/g,'')"> <input type="number" placeholder="0" v-model="brickworkAmount" @input="handleInput" oninput="value=value.replace(/[^\d]/g,'')">
<span @click="rechargeIncrease">+</span> <span @click="rechargeIncrease">+</span>
<h4>Unit</h4> <h4>Unit</h4>
</div> </div>
@ -641,7 +641,6 @@ const getRechargeGoods = async () => {
// selectItem // selectItem
const selectItem = (data, index) => { const selectItem = (data, index) => {
console.log(toRaw(data))
activeIndex.value = index activeIndex.value = index
if(data.goods_id == 1006) { if(data.goods_id == 1006) {
confirmRecharge.value = { confirmRecharge.value = {
@ -660,10 +659,10 @@ const handleInput = (e) => {
if(Number(brickworkAmount.value) > toRaw(confirmRecharge.value).max_buy_times) { if(Number(brickworkAmount.value) > toRaw(confirmRecharge.value).max_buy_times) {
brickworkAmount.value = toRaw(confirmRecharge.value).max_buy_times brickworkAmount.value = toRaw(confirmRecharge.value).max_buy_times
toRaw(confirmRecharge.value).price = toRaw(confirmRecharge.value).max_buy_times toRaw(confirmRecharge.value).price = toRaw(confirmRecharge.value).max_buy_times
toRaw(confirmRecharge.value).diamond = brickworkAmount.value*50 toRaw(confirmRecharge.value).diamond = brickworkAmount.value*100
} else { } else {
toRaw(confirmRecharge.value).price = brickworkAmount.value toRaw(confirmRecharge.value).price = brickworkAmount.value
toRaw(confirmRecharge.value).diamond = brickworkAmount.value*50 toRaw(confirmRecharge.value).diamond = brickworkAmount.value*100
priceAmount.value = brickworkAmount.value priceAmount.value = brickworkAmount.value
} }
@ -672,8 +671,9 @@ const handleInput = (e) => {
const rechargeDecrease = async () => { const rechargeDecrease = async () => {
if(brickworkAmount.value == 1) return false if(brickworkAmount.value == 1) return false
brickworkAmount.value-- brickworkAmount.value--
priceAmount.value-- priceAmount.value = brickworkAmount.value
if(confirmRecharge.value.goods_id == 1001) { // priceAmount.value--
if(confirmRecharge.value.goods_id == 1006) {
toRaw(confirmRecharge.value).price = brickworkAmount.value toRaw(confirmRecharge.value).price = brickworkAmount.value
toRaw(confirmRecharge.value).diamond = brickworkAmount.value*100 toRaw(confirmRecharge.value).diamond = brickworkAmount.value*100
} }
@ -681,7 +681,8 @@ const rechargeDecrease = async () => {
const rechargeIncrease = async () => { const rechargeIncrease = async () => {
if(brickworkAmount.value == toRaw(confirmRecharge.value).max_buy_times) return false if(brickworkAmount.value == toRaw(confirmRecharge.value).max_buy_times) return false
brickworkAmount.value++ brickworkAmount.value++
priceAmount.value++ priceAmount.value = brickworkAmount.value
// priceAmount.value++
if(confirmRecharge.value.goods_id == 1006) { if(confirmRecharge.value.goods_id == 1006) {
toRaw(confirmRecharge.value).price = brickworkAmount.value toRaw(confirmRecharge.value).price = brickworkAmount.value
toRaw(confirmRecharge.value).diamond = brickworkAmount.value*100 toRaw(confirmRecharge.value).diamond = brickworkAmount.value*100
@ -690,7 +691,6 @@ const rechargeIncrease = async () => {
// //
const conformBtn = async () => { const conformBtn = async () => {
// console.log(toRaw(confirmRecharge.value))
// return // return
// if(localWalletStore.walletType == 3) { // if(localWalletStore.walletType == 3) {
let address = localWalletStore.address let address = localWalletStore.address
@ -700,9 +700,10 @@ const conformBtn = async () => {
loadingDialogVisible.value = true loadingDialogVisible.value = true
// getGameLog() // getGameLog()
// return // return
let goods_num = Number(toRaw(confirmRecharge.value).goods_id) == 1006 ? Number(brickworkAmount.value) : 1
try { try {
const bc = new BlockChain() const bc = new BlockChain()
let res = await bc.mall.execBuyItem(Number(toRaw(confirmRecharge.value).goods_id), Number(brickworkAmount.value),toRaw(confirmRecharge.value).currency_list[0].address) let res = await bc.mall.execBuyItem(Number(toRaw(confirmRecharge.value).goods_id), goods_num,toRaw(confirmRecharge.value).currency_list[0].address)
// console.log(res) // console.log(res)
if(res) { if(res) {
brickworkAmount.value = 1 brickworkAmount.value = 1
@ -2193,6 +2194,7 @@ onMounted(() => {
div { div {
width: 36px; width: 36px;
height: 28px; height: 28px;
margin-right: 10px;
img { img {
width: 100%; width: 100%;
height: 100%; height: 100%;
@ -2202,25 +2204,37 @@ onMounted(() => {
.item-amount-input { .item-amount-input {
width: 222px; width: 222px;
height: 42px; height: 42px;
padding: 0 20px;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-evenly; justify-content: space-between;
margin: 0 auto; margin: 0 auto;
background: #1E1B26; background: #1E1B26;
border-radius: 21px; border-radius: 21px;
position: relative; position: relative;
input { input {
color: #fff; color: #fff;
width: 100px; width: 90px;
height: 42px; height: 42px;
border: 0px; border: 0px;
text-align: center; text-align: center;
font-size: 28px;
margin-right: 35px;
}
input[type=number] {
-moz-appearance:textfield;
}
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
-webkit-appearance: none;
margin: 0;
} }
h4 { h4 {
position: absolute; position: absolute;
top: 50%; top: 50%;
right: 50px;
transform: translateY(-50%); transform: translateY(-50%);
right: -43px; // right: -43px;
font-size: 20px; font-size: 20px;
} }
} }

View File

@ -78,7 +78,7 @@ const routes = [
name: "CecActivityView", name: "CecActivityView",
component: CecActivityView, component: CecActivityView,
meta: { meta: {
title: "CecActivityView", title: "Counter Fire-CecActivity",
canonical: "https://.counterfire.games", canonical: "https://.counterfire.games",
}, },
}, },

View File

@ -15,15 +15,16 @@
</div> </div>
</div> </div>
<div class="right"> <div class="right">
<div class="wallet"> <div class="wallet" v-if="localWalletStore.address == null || localWalletStore.address == ''" @click="getLinkWallet">
<span <span>Connect Wallet</span>
v-if="localWalletStore.address == null || localWalletStore.address == ''" <div class="wallet-btn">
@click="getLinkWallet" <img class="hover-show" src="@/assets/img/cec_activity/ConnectMenu1.png" alt />
>Connect Wallet</span> <img class="hover-none" src="@/assets/img/cec_activity/ConnectMenu2.png" alt />
</div>
</div>
<div class="wallet" v-else @click="isLogout = !isLogout">
<div <div
class="wallet-address" class="wallet-address"
@click="isLogout = !isLogout"
v-else
>{{ localWalletStore.showAddress }}</div> >{{ localWalletStore.showAddress }}</div>
<div class="wallet-btn"> <div class="wallet-btn">
<img class="hover-show" src="@/assets/img/cec_activity/ConnectMenu1.png" alt /> <img class="hover-show" src="@/assets/img/cec_activity/ConnectMenu1.png" alt />
@ -37,7 +38,7 @@
<div class="mint-body"> <div class="mint-body">
<div class="mint-body-left"> <div class="mint-body-left">
<div class="mint-body-left-title"> <div class="mint-body-left-title">
<h2>$CEC Bounty Hunt</h2> <h2>Contribution Clash</h2>
<div class="tips"> <div class="tips">
<div class="tips-icon"> <div class="tips-icon">
<img src="@/assets/img/cec_activity/event_help.png" alt /> <img src="@/assets/img/cec_activity/event_help.png" alt />
@ -58,7 +59,7 @@
<div> <div>
<img src="@/assets/img/marketplace/totalContribution.png" alt /> <img src="@/assets/img/marketplace/totalContribution.png" alt />
</div> </div>
<h6>{{ marketplaceStore.contributionPoint }}</h6> <h6>{{ cecInfo.my_contribution }}</h6>
</li> </li>
</div> </div>
<div class="mint-body-left-my-pro"> <div class="mint-body-left-my-pro">
@ -90,7 +91,7 @@
<div class="my-amount"> <div class="my-amount">
<li> <li>
<div>Your Credits</div> <div>Your Credits</div>
<span>{{ marketplaceStore.contributionPoint }}</span> <span>{{ cecInfo.my_contribution }}</span>
</li> </li>
<div class="line"></div> <div class="line"></div>
<li> <li>
@ -99,7 +100,8 @@
</li> </li>
</div> </div>
</div> </div>
<div class="right" :style="{width: `${totalWidth}%`}"></div> <div class="right" v-if="totalWidth != 100" :style="{width: `${totalWidth}%`}"></div>
<div class="total-right" v-else :style="{width: `${totalWidth}%`}"></div>
</div> </div>
<div class="total"> <div class="total">
<li> <li>
@ -165,17 +167,21 @@ const router = useRouter();
const totalCecPool = ref(0) const totalCecPool = ref(0)
const cecInfo = ref({ const cecInfo = ref({
my_contribution: '', my_contribution: '-',
global_contribution: '', global_contribution: '-',
total_cec_pool: '', total_cec_pool: 500000,
my_expected_cec: '' my_expected_cec: '-'
}) })
const myWidth = computed(() => { const myWidth = computed(() => {
let str = (Number(cecInfo.value.my_contribution) / Number(cecInfo.value.global_contribution)) * 100 let str = (Number(cecInfo.value.my_contribution) / Number(cecInfo.value.global_contribution)) * 100
// let str = cecInfo.value.total_cec_pool // let str = cecInfo.value.total_cec_pool
if(str < 10) return 10 if(!localWalletStore.token) {
str = 0
} else {
if(str < 10) return 10
}
return str return str
}) })
@ -186,11 +192,13 @@ const totalWidth = computed(() => {
// //
const getCecActivity = async () => { const getCecActivity = async () => {
if(localWalletStore.token) {
const { errcode, errmsg, contributionPoint, info } = await apiCecActivity(localWalletStore.address) const { errcode, errmsg, contributionPoint, info } = await apiCecActivity(localWalletStore.address)
if(errcode != 0) return if(errcode != 0) return
totalCecPool.value = contributionPoint totalCecPool.value = contributionPoint
cecInfo.value = info cecInfo.value = info
}
} }
// //
@ -228,22 +236,23 @@ const downloadGame = (platform) => {
} }
}; };
// const loginDiscord = () => { const loginDiscord = () => {
// const _address = localWalletStore.address; const _address = localWalletStore.address;
// const codeChallenge = Date.now(); const codeChallenge = Date.now();
// const state = btoa(`${_address}|${codeChallenge}`); const state = btoa(`${_address}|${codeChallenge}`);
// // const url = 'https://discord.com/api/oauth2/authorize?client_id=1116692240224501850&redirect_uri=http%3A%2F%2Flocalhost%3A3010%2Fdiscord%2Fredirect_uri&response_type=code&scope=guilds%20identify%20guilds.members.read' // const url = 'https://discord.com/api/oauth2/authorize?client_id=1116692240224501850&redirect_uri=http%3A%2F%2Flocalhost%3A3010%2Fdiscord%2Fredirect_uri&response_type=code&scope=guilds%20identify%20guilds.members.read'
// const url = `https://discord.com/api/oauth2/authorize?client_id=1117759635269636096&redirect_uri=https%3A%2F%2Foauth-svr.cebggame.com%2Fdiscord%2Fredirect_uri&response_type=code&scope=guilds%20identify%20guilds.members.read&state=${state}`; const url = `https://discord.com/api/oauth2/authorize?client_id=1117759635269636096&redirect_uri=https%3A%2F%2Foauth-svr.cebggame.com%2Fdiscord%2Fredirect_uri&response_type=code&scope=guilds%20identify%20guilds.members.read&state=${state}`;
// // location.href = url // location.href = url
// // // Redirect the user to the Discord OAuth2 authorization page // // Redirect the user to the Discord OAuth2 authorization page
// let params = `scrollbars=yes,resizable=yes,status=no,location=no,toolbar=no,menubar=no,width=600,height=800,left=100,top=100`; let params = `scrollbars=yes,resizable=yes,status=no,location=no,toolbar=no,menubar=no,width=600,height=800,left=100,top=100`;
// let newwin = window.open(url, "discord login", params); let newwin = window.open(url, "discord login", params);
// var timer = setInterval(function() { console.log(newwin)
// if (newwin.closed) { var timer = setInterval(function() {
// clearInterval(timer); if (newwin.closed) {
// } clearInterval(timer);
// }, 10); }
// }; }, 10);
};
// //
const toTwitter = () => { const toTwitter = () => {
@ -714,6 +723,10 @@ onMounted(() => {
background: linear-gradient(180deg, #8929ff, #e362ff); background: linear-gradient(180deg, #8929ff, #e362ff);
border-radius: 0 20px 20px 0; border-radius: 0 20px 20px 0;
} }
.total-right {
background: linear-gradient(180deg, #8929ff, #e362ff);
border-radius: 20px;
}
} }
.total { .total {
position: absolute; position: absolute;