Files
template-nuxt4/app/api/app/invite/index.ts
2026-04-29 01:33:33 +08:00

91 lines
1.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import request from '@/utils/request'
/**
* 生成二维码邀请
*/
export function generateInviteQrCode(data: {
appId: number
role: string
}) {
return request.post<{
code: number
message: string
data: {
token: string
inviteUrl: string // 邀请链接
miniprogramQrCode?: string // 小程序码Base64图片优先展示
expireTime?: string
}
}>('/api/app/developer/invite/qrcode', data)
}
/**
* 生成链接邀请
*/
export function generateInviteLink(data: {
appId: number
role: string
}) {
return request.post<{
code: number
message: string
data: {
inviteUrl: string
token: string
expireTime: string
}
}>('/api/app/developer/invite/link', data)
}
/**
* 验证邀请
*/
export function verifyInvite(data: {
token: string
appId?: number
}) {
return request.post<{
code: number
message: string
data: {
valid: boolean
appId: number
appName: string
role: string
inviterName: string
inviterAvatar?: string
expireTime: string
}
}>('/api/app/developer/invite/verify', data)
}
/**
* 接受邀请
*/
export function acceptInvite(data: {
token: string
appId?: number
role?: string
}) {
return request.post<{
code: number
message: string
data: null
}>('/api/app/developer/invite/accept', data)
}
/**
* 查询邀请状态(用于轮询检测是否被使用)
*/
export function getInviteStatus(token: string) {
return request.get<{
code: number
message: string
data: {
status: number // 0: 未使用, 1: 已使用
usedAt?: string // 使用时间
usedBy?: string // 使用者名称
}
}>('/api/app/developer/invite/status', { token })
}