diff --git a/frontend/pages/commission/components/commission-menu.vue b/frontend/pages/commission/components/commission-menu.vue index ede18a2..3132346 100644 --- a/frontend/pages/commission/components/commission-menu.vue +++ b/frontend/pages/commission/components/commission-menu.vue @@ -77,16 +77,6 @@ path: '/pages/commission/apply', isAgentFrom: true, }, - { - img: '/assets/addons/shopro/uniapp/commission/commission_icon2.png', - title: '我的邀请码', - path: '/pages/user/invite-code', - }, - { - img: '/assets/addons/shopro/uniapp/commission/commission_icon7.png', - title: '邀请海报', - path: 'action:showShareModal', - }, { img: '/assets/addons/shopro/uniapp/commission/commission_icon8.png', title: '分享记录', diff --git a/frontend/sheep/components/s-user-card/s-user-card.vue b/frontend/sheep/components/s-user-card/s-user-card.vue index 2fb633e..64f3b16 100644 --- a/frontend/sheep/components/s-user-card/s-user-card.vue +++ b/frontend/sheep/components/s-user-card/s-user-card.vue @@ -21,10 +21,12 @@ - - + + + 邀请码: + {{ state.inviteCode }} + + @@ -57,7 +59,7 @@ * * */ - import { computed, reactive } from 'vue'; + import { computed, reactive, watch, onMounted } from 'vue'; import sheep from '@/sheep'; import { showShareModal, showAuthModal } from '@/sheep/hooks/useModal'; @@ -66,6 +68,57 @@ // 是否登录 const isLogin = computed(() => sheep.$store('user').isLogin); + + // 状态管理 + const state = reactive({ + inviteCode: '', + }); + + // 获取邀请码 + const getInviteCode = async () => { + if (!isLogin.value) return; + + try { + const { data, code } = await sheep.$api.invite.myCode(); + if (code === 1 && data) { + state.inviteCode = data.invite_code || data; + } + } catch (error) { + console.error('获取邀请码失败:', error); + } + }; + + // 监听登录状态变化 + watch(isLogin, (newVal) => { + if (newVal) { + getInviteCode(); + } else { + state.inviteCode = ''; + } + }); + + // 组件挂载时获取邀请码 + onMounted(() => { + if (isLogin.value) { + getInviteCode(); + } + }); + + // 复制邀请码 + const copyInviteCode = () => { + if (!state.inviteCode) return; + + uni.setClipboardData({ + data: state.inviteCode, + success: () => { + sheep.$helper.toast('邀请码已复制'); + }, + fail: () => { + sheep.$helper.toast('复制失败,请重试'); + } + }); + }; + // 接收参数 const props = defineProps({ background: { @@ -133,6 +186,33 @@ } } + .invite-code-box { + cursor: pointer; + padding: 8rpx 16rpx; + background: #fff5f0; + border-radius: 24rpx; + border: 1rpx solid #ffe0cc; + + .invite-code-label { + font-size: 24rpx; + color: #999999; + margin-right: 8rpx; + } + + .invite-code-value { + font-size: 26rpx; + font-weight: 600; + color: #ff6100; + margin-right: 10rpx; + } + + .copy-icon { + font-size: 26rpx; + color: #ff6100; + opacity: 0.8; + } + } + .bind-mobile-box { width: 100%; height: 84rpx;