diff --git a/src/utils/debounce.js b/src/utils/debounce.js new file mode 100644 index 0000000..0f12e49 --- /dev/null +++ b/src/utils/debounce.js @@ -0,0 +1,52 @@ +// 防抖 +export const debounce = (fn, delay) => { + var time = null + return function() { + let context = this;//记录一下this指向 + let args = arguments; + //清除定时任务 + if (time) clearTimeout(time); + time = setTimeout(function() { + time = null; + fn.apply(context, args) + }, delay) + } +} + +export const throttle=(fn, delay) => { + // 时间戳 + var timeTwo = 0 //new Date(); + // 定时器 + var timeThree = null; + return function() { + let context = this; + let args = arguments; + var now = new Date() + + // !!!!时间戳实现【new Date()虽然获取结果不是时间戳但是计算结果会自动转化为时间戳】 + // if(now-timeTwo>=delay){ + // fn.apply(context,args); + // timeTwo=new Date(); + // } + + // !!!!定时器实现 + // if (!timeThree) { + // timeThree = setTimeout(function () { + // fn.apply(context, args); + // timeThree=null; + // }, delay) + // } + + // 结合 ps:最后一次触发在固定频率内会在延迟后触发 + var wait = delay - (now - timeTwo) + clearTimeout(timeThree) + if (wait <= 0) { + fn.apply(context, args); + timeTwo = new Date(); + } else { + timeThree = setTimeout(function() { + fn.apply(context, args); + }, delay) + } + } +} diff --git a/src/views/home/boxBtm.vue b/src/views/home/boxBtm.vue index 2457bb2..4462714 100644 --- a/src/views/home/boxBtm.vue +++ b/src/views/home/boxBtm.vue @@ -91,7 +91,7 @@

Invite others to boost your chest for better rewards.

-
+
@@ -247,6 +247,7 @@ import { apiBoxOpen } from '@/utils/webapi.js' import PaginationDialog from '@/components/paginationDialog.vue' import Loading from '@/components/loading.vue' import UserImg from "@/components/userImg.vue" +import { debounce, throttle } from "@/utils/debounce.js"; export default { components: { @@ -438,7 +439,7 @@ export default { if(res.data.errcode == 0){ this.myRecordsList = res.data.data }else{ - console.info('[getMyHistoricalLog error]',res) + // console.info('[getMyHistoricalLog error]',res) } }, // 我的助力记录分页 @@ -472,6 +473,10 @@ export default { address_type: address_type, }) }, + + antiShake: throttle(function(data) { + this.copyLink(data) + }, 5000), // 关闭弹窗 recordsHandleClose() { diff --git a/src/views/home/index.vue b/src/views/home/index.vue index fbe4f2e..6a11996 100644 --- a/src/views/home/index.vue +++ b/src/views/home/index.vue @@ -74,7 +74,7 @@

Invite Your Friends

-
Copy Invite Link
+
Copy Invite Link
View Invites
@@ -643,6 +643,7 @@ import Loading from "@/components/loading.vue"; import RuleDialog from "./ruleDialog.vue"; import NftPartner from './nftPartner.vue' import { getToken } from "@/utils/cookies.js"; +import { debounce, throttle } from "@/utils/debounce.js"; import { datafluxRum } from '@cloudcare/browser-rum' // import { getWalletAddress, isWalletConnected, linkWallet } from "@/wallet/index.js"; import { @@ -884,6 +885,10 @@ export default { stateMap.get(this.activeList[i].id) || 0 ); } + this.activeList.map(item => { + return item.status +=1 + }) + console.log(this.activeList) } }, @@ -951,16 +956,14 @@ export default { }, async loginTwitter(id) { // const _address = "0x8c10Ae04BF525734eaC00d5F7c062567461c207F"; - const clientId = "aG1Jdm1YX0NhSU9rYU5sM0xQeVI6MTpjaQ"; + // const clientId = "aG1Jdm1YX0NhSU9rYU5sM0xQeVI6MTpjaQ"; // const codeChallenge = crypto.randomUUID() - const codeChallenge = Date.now(); + // const codeChallenge = Date.now(); const address = this.$store.state.user.address; const redirectUri = "https://oauth-svr.cebggame.com/twitter/redirect_uri"; - const state = btoa(`${address}|${codeChallenge}|${location.href}`); - const url = `https://twitter.com/i/oauth2/authorize?client_id=${clientId}&code_challenge=${codeChallenge}&code_challenge_method=plain&redirect_uri=${encodeURIComponent( - redirectUri - )}&response_type=code&scope=tweet.read+users.read+follows.read+offline.access+like.read&state=${encodeURIComponent( - state + // const state = btoa(`${address}|${codeChallenge}|${location.href}`); + const url = `https://twitter.com/i/oauth2/authorize?state=${encodeURIComponent( + address )}`; let newwin = window.open(url, "twitter connect"); var timer = setInterval(function() { @@ -1280,6 +1283,9 @@ export default { this.walletDialogVisible = true; } }, + antiShake: throttle(function() { + this.copyLinkCode() + }, 5000), // 领取助力奖励 || 判断是否是新用户 async helpConfirm() {