更新服务器信息为新的 IP 地址,调整相关文档和代码中的默认配置,确保部署和连接的一致性。同时,优化订单管理界面,增强商品信息的格式化逻辑,提升用户体验。

This commit is contained in:
乘风
2026-02-05 21:08:28 +08:00
parent 1a95aee112
commit 3ccf331e12
61 changed files with 11231 additions and 311 deletions

View File

@@ -14,6 +14,7 @@ Page({
statusBarHeight: 44,
isLoggedIn: false,
userInfo: null,
isLoading: false, // 加载状态
// === 核心可见数据 ===
bindingCount: 0, // 绑定用户数(当前有效)
@@ -23,10 +24,14 @@ Page({
expiredCount: 0, // 已过期人数
// === 收益数据 ===
earnings: 0, // 已结算收益
pendingEarnings: 0, // 待结算收益
totalCommission: 0, // 累计佣金总额(所有获得的佣金)
availableEarnings: 0, // 可提现金额(未申请提现的佣金)
pendingWithdrawAmount: 0, // 待审核金额(已申请提现但未审核)
withdrawnEarnings: 0, // 已提现金额
earnings: 0, // 已结算收益(保留兼容)
pendingEarnings: 0, // 待结算收益(保留兼容)
shareRate: 90, // 分成比例90%
minWithdrawAmount: 10, // 最低提现金额(从后端获取)
// === 统计数据 ===
referralCount: 0, // 总推荐人数
@@ -70,6 +75,9 @@ Page({
async initData() {
const { isLoggedIn, userInfo } = app.globalData
if (isLoggedIn && userInfo) {
// 显示加载状态
this.setData({ isLoading: true })
// 生成邀请码
const referralCode = userInfo.referralCode || 'SOUL' + (userInfo.id || Date.now().toString(36)).toUpperCase().slice(-6)
@@ -126,8 +134,11 @@ Page({
status: type,
daysRemaining: user.daysRemaining || 0,
bindingDate: user.bindingDate ? this.formatDate(user.bindingDate) : '--',
expiryDate: user.expiryDate ? this.formatDate(user.expiryDate) : '--',
commission: (user.commission || 0).toFixed(2),
orderAmount: (user.orderAmount || 0).toFixed(2)
orderAmount: (user.orderAmount || 0).toFixed(2),
purchaseCount: user.purchaseCount || 0,
conversionDate: user.conversionDate ? this.formatDate(user.conversionDate) : '--'
}
console.log('[Referral] 格式化用户:', formatted.nickname, formatted.status, formatted.daysRemaining + '天')
return formatted
@@ -150,10 +161,14 @@ Page({
expiredCount,
// 收益数据 - 格式化为两位小数
totalCommission: formatMoney(realData?.totalCommission || 0),
availableEarnings: formatMoney(realData?.availableEarnings || 0),
pendingWithdrawAmount: formatMoney(realData?.pendingWithdrawAmount || 0),
withdrawnEarnings: formatMoney(realData?.withdrawnEarnings || 0),
earnings: formatMoney(realData?.earnings || 0),
pendingEarnings: formatMoney(realData?.pendingEarnings || 0),
withdrawnEarnings: formatMoney(realData?.withdrawnEarnings || 0),
shareRate: realData?.shareRate || 90,
minWithdrawAmount: realData?.minWithdrawAmount || 10,
// 统计
referralCount: realData?.referralCount || realData?.stats?.totalBindings || activeBindings.length + convertedBindings.length,
@@ -167,19 +182,33 @@ Page({
totalBindings: activeBindings.length + convertedBindings.length + expiredBindings.length,
// 收益明细
earningsDetails: (realData?.earningsDetails || []).map(item => ({
id: item.id,
productType: item.productType,
commission: (item.commission || 0).toFixed(2),
payTime: item.payTime ? this.formatDate(item.payTime) : '--',
buyerNickname: item.buyerNickname
}))
earningsDetails: (realData?.earningsDetails || []).map(item => {
// 解析商品描述,获取书名和章节
const productInfo = this.parseProductDescription(item.description, item.productType)
return {
id: item.id,
productType: item.productType,
bookTitle: productInfo.bookTitle,
chapterTitle: productInfo.chapterTitle,
commission: (item.commission || 0).toFixed(2),
payTime: item.payTime ? this.formatDate(item.payTime) : '--',
buyerNickname: item.buyerNickname || '用户',
buyerAvatar: item.buyerAvatar
}
})
})
console.log('[Referral] ✅ 数据设置完成')
console.log('[Referral] - 绑定中:', this.data.bindingCount)
console.log('[Referral] - 即将过期:', this.data.expiringCount)
console.log('[Referral] - 收益:', this.data.earnings)
// 隐藏加载状态
this.setData({ isLoading: false })
} else {
// 未登录时也隐藏loading
this.setData({ isLoading: false })
}
},
@@ -550,23 +579,33 @@ Page({
})
},
// 提现 - 直接到微信零钱(无门槛)
// 提现 - 直接到微信零钱
async handleWithdraw() {
const pendingEarnings = parseFloat(this.data.pendingEarnings) || 0
const availableEarnings = parseFloat(this.data.availableEarnings) || 0
const minWithdrawAmount = this.data.minWithdrawAmount || 10
if (pendingEarnings <= 0) {
if (availableEarnings <= 0) {
wx.showToast({ title: '暂无可提现收益', icon: 'none' })
return
}
// 检查是否达到最低提现金额
if (availableEarnings < minWithdrawAmount) {
wx.showToast({
title: `${minWithdrawAmount}元可提现`,
icon: 'none'
})
return
}
// 确认提现
wx.showModal({
title: '确认提现',
content: `将提现 ¥${pendingEarnings.toFixed(2)} 到您的微信零钱`,
content: `将提现 ¥${availableEarnings.toFixed(2)} 到您的微信零钱`,
confirmText: '立即提现',
success: async (res) => {
if (res.confirm) {
await this.doWithdraw(pendingEarnings)
await this.doWithdraw(availableEarnings)
}
}
})
@@ -668,6 +707,32 @@ Page({
wx.navigateBack()
},
// 解析商品描述,获取书名和章节
parseProductDescription(description, productType) {
if (!description) {
return {
bookTitle: '未知商品',
chapterTitle: ''
}
}
// 匹配格式:《书名》- 章节名
const match = description.match(/《(.+?)》(?:\s*-\s*(.+))?/)
if (match) {
return {
bookTitle: match[1] || '未知书籍',
chapterTitle: match[2] || (productType === 'fullbook' ? '全书购买' : '')
}
}
// 如果匹配失败,直接返回原始描述
return {
bookTitle: description.split('-')[0] || description,
chapterTitle: description.split('-')[1] || ''
}
},
// 格式化日期
formatDate(dateStr) {
if (!dateStr) return '--'