|
|
@@ -22,6 +22,7 @@ import { useUserStore } from '@/store/user'
|
|
|
import { formatNumber } from '@/utils'
|
|
|
import { toPage } from '@/utils/page'
|
|
|
import { handleWhatsApp } from '@/utils/social'
|
|
|
+import { toast } from '@/utils/toast'
|
|
|
|
|
|
defineOptions({
|
|
|
name: 'Mine', // 我的
|
|
|
@@ -45,6 +46,18 @@ const isLoggedIn = computed(() => !!userStore.token)
|
|
|
// 获取用户信息
|
|
|
const userInfo = computed(() => userStore.userInfo)
|
|
|
|
|
|
+function copyReferrerCode() {
|
|
|
+ const code = userInfo.value?.invitedCode
|
|
|
+ if (!code)
|
|
|
+ return
|
|
|
+ uni.setClipboardData({
|
|
|
+ data: code,
|
|
|
+ success: () => {
|
|
|
+ toast.success(t('mine.pages.share.copySuccess'))
|
|
|
+ },
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
const groupList = computed(() => {
|
|
|
// 依赖 locale,确保切换语言后这里会重新计算
|
|
|
const _locale = i18n.global.locale
|
|
|
@@ -152,8 +165,30 @@ onShow(() => {
|
|
|
:src="isLoggedIn ? userInfo?.headPic : '/static/images/default-avatar.png'"
|
|
|
/>
|
|
|
<!-- 已登录 -->
|
|
|
- <view v-if="isLoggedIn" class="ml-24rpx text-32rpx font-bold">
|
|
|
- {{ userInfo?.name || userInfo?.username || 'User' }}
|
|
|
+ <view v-if="isLoggedIn" class="ml-24rpx flex flex-col">
|
|
|
+ <view class="flex items-center">
|
|
|
+ <view class="text-32rpx font-bold">
|
|
|
+ {{ userInfo?.name || userInfo?.username || 'User' }}
|
|
|
+ </view>
|
|
|
+ <view
|
|
|
+ v-if="userInfo?.level !== undefined && userInfo?.level !== null"
|
|
|
+ class="ml-12rpx rounded-full bg-#DFBA86 px-16rpx py-2rpx text-24rpx text-white font-bold"
|
|
|
+ >
|
|
|
+ V{{ userInfo?.level }}
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view class="mt-12rpx flex items-center text-24rpx">
|
|
|
+ <text>{{ $t('mine.header.referrerCode') }}:</text>
|
|
|
+ <text class="ml-12rpx font-bold">
|
|
|
+ {{ userInfo?.invitedCode || '-' }}
|
|
|
+ </text>
|
|
|
+ <text class="mx-12rpx">
|
|
|
+ |
|
|
|
+ </text>
|
|
|
+ <text class="font-bold" @click.stop="copyReferrerCode">
|
|
|
+ {{ $t('mine.header.copy') }}
|
|
|
+ </text>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
<!-- 未登录 -->
|
|
|
<view v-else class="ml-24rpx flex items-center">
|