From b742a60c696af1075d377e4a064e0fd65f07593a Mon Sep 17 00:00:00 2001 From: hzj <1304805162@qq.com> Date: Fri, 24 Oct 2025 12:29:29 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E9=82=80=E8=AF=B7=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2):=20=E5=AF=B9=E6=8E=A5=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/invitation.js | 73 +++++ src/views/Invitation/InvitationToRegister.vue | 290 +++++++----------- 2 files changed, 190 insertions(+), 173 deletions(-) create mode 100644 src/api/invitation.js diff --git a/src/api/invitation.js b/src/api/invitation.js new file mode 100644 index 0000000..14c429e --- /dev/null +++ b/src/api/invitation.js @@ -0,0 +1,73 @@ +import { get, post } from '../utils/http.js' + +// 获取我的邀请码 +export const getMyInviteCode = async () => { + try { + const response = await get(`/activity/invite/user/my/invite/code`) + return response + } catch (error) { + console.error('Failed to fetch get my invite code:', error) + console.error('error:' + error.response.errorMsg) + throw error + } +} + +// 绑定邀请码 +export const bindInviteCode = async (data) => { + try { + const response = await post(`/activity/invite/user/bind/invite/code`, data) + return response + } catch (error) { + console.error('Failed to fetch bind invite code:', error) + console.error('error:' + error.response.errorMsg) + throw error + } +} + +// 获取收益统计 +export const getMyInviteIncome = async () => { + try { + const response = await get(`/activity/invite/user/income/statistics`) + return response + } catch (error) { + console.error('Failed to fetch get my invite income:', error) + console.error('error:' + error.response.errorMsg) + throw error + } +} + +// 有效邀请用户列表 +export const getMyInviteUsers = async () => { + try { + const response = await get(`/activity/invite/user/valid/invite/users`) + return response + } catch (error) { + console.error('Failed to fetch get my invite users:', error) + console.error('error:' + error.response.errorMsg) + throw error + } +} + +// 邀请用户奖励池 +export const getInviteAwardPool = async () => { + try { + const response = await get(`/activity/invite/user/award/pool`) + return response + } catch (error) { + console.error('Failed to fetch get my invite award pool:', error) + console.error('error:' + error.response.errorMsg) + throw error + } +} + +// 邀请用户领取奖励 +export const getInviteReceiveAward = async (awardId) => { + try { + const response = await get(`/activity/invite/user/receive/award?id=${awardId}`) + return response + } catch (error) { + console.error('Failed to fetch get receive invite award:', error) + console.error('error:' + error.response.errorMsg) + throw error + } +} diff --git a/src/views/Invitation/InvitationToRegister.vue b/src/views/Invitation/InvitationToRegister.vue index ed2b747..20807d5 100644 --- a/src/views/Invitation/InvitationToRegister.vue +++ b/src/views/Invitation/InvitationToRegister.vue @@ -20,7 +20,7 @@ style="padding: 0 3%; display: flex; flex-direction: column; gap: 12px; padding-bottom: 30px" > -
+
-
18709616238
+
{{ myInviteInfo.inviteCode || '' }}
@@ -123,7 +123,7 @@ " > -
111111
+
{{ myInviteIncome.totalIncome || 0 }}
@@ -140,7 +140,7 @@ " > -
111111
+
{{ myInviteIncome.todayIncome || 0 }}
@@ -165,7 +165,9 @@ background: radial-gradient(323.25% 50.32% at 50% 50%, #d58ef4 0%, #7a5aff 100%); " > -
Number of valid users l invited: 9
+
+ Number of valid users l invited: {{ myInviteIncome.validInviteCount || 0 }} +
@@ -220,9 +222,15 @@ Prowide income + -
-
ID:152319866
+
+
+ ID:{{ user.invitedUserAccount || '-' }} +
-
10Day
+
{{ user.remainingDays || 0 }}Day
-
11111111111
+
+ {{ user.provideIncome || 0 }} +
@@ -274,9 +284,13 @@
- -
- +
+
-
+
- -
-
-
- -
- +
- -
-
-
- - -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
- - -
-
-
- - -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
- - +
@@ -517,7 +392,7 @@
- +
*Only users who registered within 72 hours can fill in the invitation code. Once the @@ -556,13 +431,18 @@ import { } from '@/utils/appConnectionManager.js' import { computed, onMounted, onUnmounted, ref } from 'vue' import GeneralHeader from '@/components/GeneralHeader.vue' -import itemCenter from '@/components/WeeklyStar/itemCenter.vue' -import TopUser from '@/components/WeeklyStar/topUser.vue' import maskLayer from '../../components/MaskLayer.vue' -import { useDebounce, useThrottle } from '@/utils/useDebounce' import { getMemberProfile } from '@/api/wallet' import { showError, showWarning, showInfo, showSuccess } from '@/utils/toast.js' -import { set, useClipboard } from '@vueuse/core' +import { useClipboard } from '@vueuse/core' +import { + getMyInviteCode, // 获取我的邀请码 + bindInviteCode, // 绑定邀请码 + getMyInviteIncome, // 获取收益统计 + getMyInviteUsers, // 有效邀请用户列表 + getInviteAwardPool, // 邀请用户奖励池 + getInviteReceiveAward, // 邀请用户领取奖励 +} from '@/api/invitation.js' // vite动态导入图片 const imageModules = import.meta.glob('@/assets/images/InvitationNewUser/*.{png,jpg,svg}', { @@ -587,13 +467,13 @@ const enterCodeShow = ref(false) //交易弹窗 const tipShow = ref(false) //提示弹窗 const invitationCode = ref('') //邀请码 +const myInviteInfo = ref({}) //我的邀请信息 +const myInviteIncome = ref({}) //邀请用户收益统计 +const myInviteUsers = ref([]) //邀请用户列表 +const inviteAwardPool = ref({}) const showModule = ref('list') //显示模块 -const reward5peopleShow = ref(false) -const reward10peopleShow = ref(false) -const reward15peopleShow = ref(false) - // 展示遮罩层 const maskLayerShow = computed(() => { return helpInfoShow.value || enterCodeShow.value @@ -747,19 +627,83 @@ const connectToApp = async () => { } } +// 更改邀请码 const confirmInvitationCode = () => { if (!invitationCode.value.trim()) { showWarning('Please enter a valid invitation code.') return } - invitationCode.value = '' - showSuccess('Invitation code confirmed!') - enterCodeShow.value = false +} + +// 获取我的邀请码 +const apiGetMyInviteCode = async () => { + const resCode = await getMyInviteCode() + if (resCode.status && resCode.body) { + myInviteInfo.value = resCode.body + } +} + +// 绑定邀请码 +const confirm = async () => { + if (!invitationCode.value.trim()) { + showWarning('Please enter a valid invitation code.') + return + } + let data = { inviteCode: invitationCode.value.trim(), inviteType: 'REGISTER' } + try { + const resBind = await bindInviteCode(data) + if (resBind.status) { + showSuccess('Invitation code bound successfully!') + } else { + showError('Invitation code binding failed.') + } + invitationCode.value = '' + enterCodeShow.value = false + } catch (error) { + showError(error.errorMsg) + } +} + +// 获取收益统计 +const apiGetMyInviteIncome = async () => { + const resIncome = await getMyInviteIncome() + if (resIncome.status && resIncome.body) { + myInviteIncome.value = resIncome.body + } +} + +// 有效邀请用户列表 +const apiGetMyInviteUsers = async () => { + const resUserList = await getMyInviteUsers() + if (resUserList.status && resUserList.body) { + myInviteUsers.value = resUserList.body + } +} + +// 邀请用户奖励池 +const apiGetInviteAwardPool = async () => { + const resAwardPool = await getInviteAwardPool() + if (resAwardPool.status && resAwardPool.body) { + inviteAwardPool.value = resAwardPool.body + } +} + +// 邀请用户领取奖励 +const receiveAward = async (awardId) => { + const resAward = await getInviteReceiveAward(awardId) + if (resAward.status && resAward.body) { + apiGetInviteAwardPool() // 刷新奖励池 + } } onMounted(() => { connectToApp() isInAppEnvironment.value = isInApp() + + apiGetMyInviteCode() // 获取我的邀请码 + apiGetMyInviteIncome() // 获取收益统计 + apiGetMyInviteUsers() // 有效邀请用户列表 + apiGetInviteAwardPool() // 邀请用户奖励池 })