diff --git a/component/head-top/head-top.js b/component/head-top/head-top.js index 048a9bc..4b6b498 100644 --- a/component/head-top/head-top.js +++ b/component/head-top/head-top.js @@ -5,17 +5,35 @@ const { defineComponent, ref, onMounted, nextTick } = Vue; // 定义组件(直接使用模板) export const headTop = defineComponent({ name: "headTop", - props: { - itemdata: { - type: Object, - default: () => {}, - }, - }, + props: {}, setup(props) { onMounted(() => {}); - let signInAlreadyState = ref(false); + let state = ref(0); // 是否已经签到 + + let userInfoWinTimerCount = 0; + const userInfoWinTimer = setInterval(() => { + if (todaysignedState) { + state.value = todaysigned; + clearInterval(userInfoWinTimer); + } + userInfoWinTimerCount++; + if (userInfoWinTimerCount >= 3000) clearInterval(userInfoWinTimer); + }, 50); + + const signIn = () => { + ajax("/v2/api/forum/sign").then((res) => { + if (res.code != 200) { + creationAlertBox("error", res.message); + return; + } + + let data = res.data; + state.value = 1; + creationAlertBox("success", res.message || "签到成功"); + }); + }; let input = ref(""); let defaultSearchText = ref("屯特"); @@ -23,8 +41,9 @@ export const headTop = defineComponent({ const searchText = input.value || defaultSearchText.value; redirectToExternalWebsite("/search/" + searchText); }; - return { input, defaultSearchText, goSearch, signInAlreadyState }; + + return { state, signIn, input, defaultSearchText, goSearch }; }, - template: `
`, + template: ``, }); diff --git a/component/head-top/head-top.txt b/component/head-top/head-top.txt index 0cb4d61..8a29215 100644 --- a/component/head-top/head-top.txt +++ b/component/head-top/head-top.txt @@ -8,11 +8,7 @@
{{ item }}
{{ item.location || '' }}
{{ item }}
{{ item.location || '' }}
-
-
-