diff --git a/src/router/index.ts b/src/router/index.ts index fdadc42..f6962c8 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -49,6 +49,11 @@ const routes: Array = [ component: () => import("@/views/invite/index.vue"), meta: { requiresAuth: true }, }, + { + path: "/bind_invite", + component: () => import("@/views/invite/bind.vue"), + meta: { requiresAuth: true }, + }, { path: "/settings", component: () => import("@/views/settings/index.vue"), diff --git a/src/views/invite/bind.vue b/src/views/invite/bind.vue new file mode 100644 index 0000000..2b58708 --- /dev/null +++ b/src/views/invite/bind.vue @@ -0,0 +1,502 @@ + + + + + diff --git a/src/views/invite/index.vue b/src/views/invite/index.vue index 3937e3f..02e774b 100644 --- a/src/views/invite/index.vue +++ b/src/views/invite/index.vue @@ -4,22 +4,15 @@ import { checkmarkCircleOutline, copyOutline, downloadOutline, - linkOutline, peopleOutline, - qrCodeOutline, shareOutline, ticketOutline, } from "ionicons/icons"; +import { client, safeClient } from "@/api"; -// 邀请信息 -const inviteInfo = ref({ - inviteCode: "ABCD1234", - inviteLink: "https://example.com/invite?code=ABCD1234", - downloadLink: "https://example.com/download", - qrCodeUrl: "https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=https://example.com/invite?code=ABCD1234", - totalInvites: 28, - todayInvites: 3, -}); +const userStore = useUserStore(); +const { userProfile } = storeToRefs(userStore); +const { data } = safeClient(client.api.referrals.summary.get()); // 复制状态 const copyStatus = ref({ @@ -28,7 +21,11 @@ const copyStatus = ref({ download: false, }); -async function handleCopy(text: string, type: "link" | "code" | "download") { +async function handleCopy(text?: string, type: "link" | "code" | "download" = "link") { + if (!text) { + console.warn("没有可复制的文本"); + return; + } try { await Clipboard.write({ string: text, @@ -94,7 +91,7 @@ function handleDownloadQR() { 累计邀请
- {{ inviteInfo.totalInvites }} + {{ data?.totalCount }}
人 @@ -105,7 +102,7 @@ function handleDownloadQR() { 今日邀请
- {{ inviteInfo.todayInvites }} + {{ data?.totalCount }}
人 @@ -143,14 +140,14 @@ function handleDownloadQR() { 邀请码
- {{ inviteInfo.inviteCode }} + {{ userProfile?.referralCode?.slice(0, 6) }}
-
+ -
+ @@ -237,7 +234,7 @@ function handleDownloadQR() {
邀请二维码