feat: 分销规则完善 + 微信支付修复
1. 分销规则: - 链接带ID绑定推荐关系 - 一级分销 + 30天有效期 - 客户抢夺机制(过期可被抢走) - 90%收益归分发者 2. 新增统计数据: - 绑定用户数 - 链接进入人数 - 带来付款人数 3. 微信支付: - 添加点击反馈 - 优化支付流程日志 - 改善错误提示 4. 分销中心UI优化
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
/**
|
||||
* Soul创业派对 - 分销中心页
|
||||
* 1:1还原Web版本
|
||||
*
|
||||
* 可见数据:
|
||||
* - 绑定用户数(当前有效绑定)
|
||||
* - 通过链接进的人数(总访问量)
|
||||
* - 带来的付款人数(已转化购买)
|
||||
* - 收益统计(90%归分发者)
|
||||
*/
|
||||
const app = getApp()
|
||||
|
||||
@@ -10,19 +15,25 @@ Page({
|
||||
isLoggedIn: false,
|
||||
userInfo: null,
|
||||
|
||||
// 收益数据
|
||||
earnings: 0,
|
||||
pendingEarnings: 0,
|
||||
distributorShare: 90,
|
||||
// === 核心可见数据 ===
|
||||
bindingCount: 0, // 绑定用户数(当前有效)
|
||||
visitCount: 0, // 通过链接进的人数
|
||||
paidCount: 0, // 带来的付款人数
|
||||
|
||||
// 统计数据
|
||||
referralCount: 0,
|
||||
expiringCount: 0,
|
||||
// === 收益数据 ===
|
||||
earnings: 0, // 已结算收益
|
||||
pendingEarnings: 0, // 待结算收益
|
||||
withdrawnEarnings: 0, // 已提现金额
|
||||
shareRate: 90, // 分成比例(90%)
|
||||
|
||||
// === 统计数据 ===
|
||||
referralCount: 0, // 总推荐人数
|
||||
expiringCount: 0, // 即将过期人数
|
||||
|
||||
// 邀请码
|
||||
referralCode: '',
|
||||
|
||||
// 绑定用户
|
||||
// 绑定用户列表
|
||||
showBindingList: true,
|
||||
activeTab: 'active',
|
||||
activeBindings: [],
|
||||
@@ -31,6 +42,9 @@ Page({
|
||||
currentBindings: [],
|
||||
totalBindings: 0,
|
||||
|
||||
// 收益明细
|
||||
earningsDetails: [],
|
||||
|
||||
// 海报
|
||||
showPosterModal: false,
|
||||
isGeneratingPoster: false
|
||||
@@ -61,48 +75,58 @@ Page({
|
||||
})
|
||||
if (res.success) {
|
||||
realData = res.data
|
||||
console.log('[Referral] 获取推广数据成功:', realData)
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('获取推广数据失败,使用本地数据')
|
||||
console.log('[Referral] 获取推广数据失败,使用本地数据')
|
||||
}
|
||||
|
||||
// 使用真实数据或本地存储的数据
|
||||
const storedBindings = wx.getStorageSync('referral_bindings') || []
|
||||
const storedEarnings = wx.getStorageSync('referral_earnings') || { total: 0, pending: 0 }
|
||||
// 使用真实数据或默认值
|
||||
let activeBindings = realData?.activeUsers || []
|
||||
let convertedBindings = realData?.convertedUsers || []
|
||||
let expiredBindings = []
|
||||
|
||||
let activeBindings, convertedBindings, expiredBindings
|
||||
|
||||
if (realData) {
|
||||
activeBindings = realData.activeBindings || []
|
||||
convertedBindings = realData.convertedBindings || []
|
||||
expiredBindings = realData.expiredBindings || []
|
||||
} else if (storedBindings.length > 0) {
|
||||
// 使用本地存储的数据
|
||||
activeBindings = storedBindings.filter(b => b.status === 'active')
|
||||
convertedBindings = storedBindings.filter(b => b.status === 'converted')
|
||||
expiredBindings = storedBindings.filter(b => b.status === 'expired')
|
||||
} else {
|
||||
// 默认空数据
|
||||
activeBindings = []
|
||||
convertedBindings = []
|
||||
expiredBindings = []
|
||||
// 兼容旧字段名
|
||||
if (!activeBindings.length && realData?.activeBindings) {
|
||||
activeBindings = realData.activeBindings
|
||||
}
|
||||
if (!convertedBindings.length && realData?.convertedBindings) {
|
||||
convertedBindings = realData.convertedBindings
|
||||
}
|
||||
if (realData?.expiredBindings) {
|
||||
expiredBindings = realData.expiredBindings
|
||||
}
|
||||
|
||||
const expiringCount = activeBindings.filter(b => b.daysRemaining <= 7).length
|
||||
const expiringCount = activeBindings.filter(b => b.daysRemaining <= 7 && b.daysRemaining > 0).length
|
||||
|
||||
this.setData({
|
||||
isLoggedIn: true,
|
||||
userInfo,
|
||||
earnings: realData?.earnings || storedEarnings.total || 0,
|
||||
pendingEarnings: realData?.pendingEarnings || storedEarnings.pending || 0,
|
||||
referralCount: realData?.referralCount || activeBindings.length + convertedBindings.length,
|
||||
|
||||
// 核心可见数据
|
||||
bindingCount: realData?.bindingCount || activeBindings.length,
|
||||
visitCount: realData?.visitCount || 0,
|
||||
paidCount: realData?.paidCount || convertedBindings.length,
|
||||
|
||||
// 收益数据
|
||||
earnings: realData?.earnings || 0,
|
||||
pendingEarnings: realData?.pendingEarnings || 0,
|
||||
withdrawnEarnings: realData?.withdrawnEarnings || 0,
|
||||
shareRate: realData?.shareRate || 90,
|
||||
|
||||
// 统计
|
||||
referralCount: realData?.referralCount || realData?.stats?.totalBindings || activeBindings.length + convertedBindings.length,
|
||||
expiringCount,
|
||||
|
||||
referralCode,
|
||||
activeBindings,
|
||||
convertedBindings,
|
||||
expiredBindings,
|
||||
expiringCount,
|
||||
currentBindings: activeBindings,
|
||||
totalBindings: activeBindings.length + convertedBindings.length + expiredBindings.length
|
||||
totalBindings: activeBindings.length + convertedBindings.length + expiredBindings.length,
|
||||
|
||||
// 收益明细
|
||||
earningsDetails: realData?.earningsDetails || []
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user