修改社媒任务显示

This commit is contained in:
yuyongdong 2024-04-22 20:37:04 +08:00
parent c34d8d6da9
commit 4d74b0dac2
3 changed files with 73 additions and 10 deletions

52
src/utils/debounce.js Normal file
View File

@ -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)
}
}
}

View File

@ -91,7 +91,7 @@
<div class="box-btm-con-boost">
<div class="boost">
<p>Invite others to boost your chest for better rewards.</p>
<div class="copy-btn" @click="copyLink(boxData)">
<div class="copy-btn" @click="antiShake(boxData)">
<div class="icon">
<img src="@/assets/box/Invite_icon.png" alt="">
</div>
@ -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() {

View File

@ -74,7 +74,7 @@
<!-- <p></p> -->
<p>Invite Your Friends <span @click="ruleDialogVisible = true"><img src="@/assets/home/Icon_.png" alt=""></span></p>
</div>
<div class="copy-btn" @click="copyLinkCode"><img src="./../../assets/common/Icon_Explore.png" alt="">Copy Invite Link</div>
<div class="copy-btn" @click="antiShake"><img src="./../../assets/common/Icon_Explore.png" alt="">Copy Invite Link</div>
<div class="copy-see" @click="isLogin">
View Invites
</div>
@ -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() {