From 114b41144e29f898a94d1ae1eb28fe7154148c74 Mon Sep 17 00:00:00 2001 From: Gsh <15170702455@163.com> Date: Sat, 1 Nov 2025 18:39:02 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=A2=9E=E5=8A=A0=E9=82=80=E8=AF=B7?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/CardFlipActivity.vue | 164 ++++++++++++++++-- .../components/Header/components/Avatar.vue | 70 +++++++- Yi.Ai.Vue3/types/components.d.ts | 2 +- 3 files changed, 219 insertions(+), 17 deletions(-) diff --git a/Yi.Ai.Vue3/src/components/userPersonalCenter/components/CardFlipActivity.vue b/Yi.Ai.Vue3/src/components/userPersonalCenter/components/CardFlipActivity.vue index f061fe42..80e83546 100644 --- a/Yi.Ai.Vue3/src/components/userPersonalCenter/components/CardFlipActivity.vue +++ b/Yi.Ai.Vue3/src/components/userPersonalCenter/components/CardFlipActivity.vue @@ -10,9 +10,15 @@ */ import type { CardFlipRecord, CardFlipStatusOutput, FlipCardOutput } from '@/api/cardFlip/types'; import { ElMessage, ElMessageBox } from 'element-plus'; -import { onMounted, ref } from 'vue'; +import { onMounted, ref, watch } from 'vue'; import { flipCard, generateMyInviteCode, getWeeklyTaskStatus, useInviteCode } from '@/api/cardFlip'; +// ============ Props ============ +/** 接收外部传入的邀请码(通过 URL 参数传递) */ +const props = defineProps<{ + externalInviteCode?: string; +}>(); + // ============ 状态管理 ============ /** 任务数据:包含翻牌记录、次数统计、邀请码等信息 */ const taskData = ref(null); @@ -83,6 +89,29 @@ onMounted(async () => { await playShuffleAnimation(); }); +// ============ 监听外部邀请码 ============ +/** + * 监听外部传入的邀请码 + * 如果有邀请码,自动打开对话框并预填 + */ +watch( + () => props.externalInviteCode, + (newCode) => { + if (newCode && newCode.trim()) { + // 延迟500ms,确保页面已经渲染完成 + setTimeout(() => { + inputInviteCode.value = newCode.trim().toUpperCase(); + inviteCodeDialog.value = true; + ElMessage.info({ + message: '🎁 检测到邀请码,已为您自动填充,请点击确认使用', + duration: 3000, + }); + }, 500); + } + }, + { immediate: true } +); + // ============ 新增:初始洗牌动画 ============ /** * 初始洗牌动画 @@ -738,6 +767,52 @@ function copyInviteCode() { }); } +/** + * 生成分享链接 + * 生成包含邀请码的完整 URL + */ +function generateShareLink(): string { + const inviteCode = taskData.value?.myInviteCode; + if (!inviteCode) return ''; + + const baseUrl = window.location.origin; + const path = window.location.pathname; + return `${baseUrl}${path}?inviteCode=${inviteCode}`; +} + +/** + * 生成分享文案 + * 类似小红书风格的分享内容 + */ +function generateShareContent(): string { + const shareLink = generateShareLink(); + return `🎁 邀请你来翻牌抽奖,赢取Token大奖! + +使用我的邀请码可解锁3次额外翻牌机会,必定中奖,最大奖励翻倍!💰 + +👉 点击链接立即参与: +${shareLink} + +🍀 快来试试手气吧!`; +} + +/** + * 复制分享链接和文案 + */ +function copyShareContent() { + if (!taskData.value?.myInviteCode) { + ElMessage.warning('暂无邀请码'); + return; + } + + const shareContent = generateShareContent(); + navigator.clipboard.writeText(shareContent).then(() => { + ElMessage.success('🎉 分享内容已复制到剪贴板!快去分享给好友吧~'); + }).catch(() => { + ElMessage.error('复制失败,请手动复制'); + }); +} + // ============ 工具函数 ============ /** * 格式化 Token 显示(单位:万) @@ -1063,16 +1138,31 @@ function getCardClass(record: CardFlipRecord): string[] {
{{ taskData.myInviteCode }}
- - 复制邀请码 - +
+ + 复制邀请码 + + + 复制分享链接 + +

💌 分享给好友,好友使用后可解锁最后3次翻牌机会

+
+ + +
@@ -1999,16 +2089,68 @@ function getCardClass(record: CardFlipRecord): string[] { } } - .el-button { - width: 100%; + .button-group { + display: flex; + gap: 8px; margin-bottom: 12px; + + .el-button { + flex: 1; + } } .invite-tip { font-size: 13px; color: #909399; line-height: 1.5; - margin: 0; + margin: 0 0 16px 0; + } + + .share-preview { + background: #f5f7fa; + border: 1px solid #e4e7ed; + border-radius: 8px; + padding: 12px; + text-align: left; + + .share-preview-title { + font-size: 14px; + font-weight: bold; + color: #303133; + margin-bottom: 8px; + text-align: center; + } + + .share-preview-content { + font-size: 13px; + color: #606266; + line-height: 1.6; + white-space: pre-line; + background: #fff; + padding: 10px; + border-radius: 4px; + max-height: 200px; + overflow-y: auto; + + /* 自定义滚动条 */ + &::-webkit-scrollbar { + width: 4px; + } + + &::-webkit-scrollbar-track { + background: rgba(0, 0, 0, 0.05); + border-radius: 2px; + } + + &::-webkit-scrollbar-thumb { + background: rgba(0, 0, 0, 0.2); + border-radius: 2px; + + &:hover { + background: rgba(0, 0, 0, 0.3); + } + } + } } } diff --git a/Yi.Ai.Vue3/src/layouts/components/Header/components/Avatar.vue b/Yi.Ai.Vue3/src/layouts/components/Header/components/Avatar.vue index 3c07896e..af4e9605 100644 --- a/Yi.Ai.Vue3/src/layouts/components/Header/components/Avatar.vue +++ b/Yi.Ai.Vue3/src/layouts/components/Header/components/Avatar.vue @@ -1,8 +1,9 @@