feat(invite): 添加邀请关系防重复处理功能

- 增加邀请关系存在性检查,避免重复处理
- 实现过期邀请关系记录清理功能
- 在建立邀请关系时保存记录,防止 future duplicates
This commit is contained in:
2025-08-26 19:01:47 +08:00
parent 24c6e6c0fd
commit c3dbc5b611
2 changed files with 68 additions and 0 deletions

View File

@@ -89,6 +89,18 @@ const Header = (props: any) => {
const handleGetPhoneNumber = ({detail}: {detail: {code?: string, encryptedData?: string, iv?: string}}) => {
const {code, encryptedData, iv} = detail
// 防重复登录检查
const loginKey = 'login_in_progress'
const loginInProgress = Taro.getStorageSync(loginKey)
if (loginInProgress && Date.now() - loginInProgress < 5000) { // 5秒内防重
console.log('登录正在进行中,跳过重复请求')
return
}
// 标记登录开始
Taro.setStorageSync(loginKey, Date.now())
// 获取存储的邀请参数
const inviteParams = getStoredInviteParams()
const refereeId = inviteParams?.inviter ? parseInt(inviteParams.inviter) : 0
@@ -116,6 +128,9 @@ const Header = (props: any) => {
TenantId
},
success: async function (res) {
// 清除登录防重标记
Taro.removeStorageSync('login_in_progress')
if (res.data.code == 1) {
Taro.showToast({
title: res.data.message,
@@ -149,6 +164,10 @@ const Header = (props: any) => {
Taro.reLaunch({
url: '/pages/index/index'
})
},
fail: function() {
// 清除登录防重标记
Taro.removeStorageSync('login_in_progress')
}
})
} else {