'隐藏邀请海报添加展示邀请码'

This commit is contained in:
gonghaoxing 2025-10-29 14:40:21 +08:00
parent 098e3dfafd
commit cc1c869a1a
2 changed files with 85 additions and 15 deletions

View File

@ -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: '分享记录',

View File

@ -21,10 +21,12 @@
</view>
</view>
</view>
<view class="right-box ss-m-r-52">
<!-- <button class="ss-reset-button" @tap="showShareModal">
<text class="sicon-qrcode"></text>
</button> -->
<view class="right-box ss-m-r-36" v-if="isLogin && state.inviteCode">
<view class="invite-code-box ss-flex ss-col-center" @tap="copyInviteCode">
<text class="invite-code-label">邀请码:</text>
<text class="invite-code-value">{{ state.inviteCode }}</text>
<text class="cicon-copy copy-icon"></text>
</view>
</view>
</view>
@ -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;