feat: 全面优化小程序界面和功能

 新增功能:
- 配置后台匹配规则选择功能,支持多种匹配类型自定义
- 推广中心使用真实数据,实现H5/小程序绑定关系
- 配置MySQL数据库连接,建立完整数据表结构

🎨 界面优化:
- 优化登录状态显示,未登录只显示基础功能
- 修复推广中心等页面宽度问题,统一界面布局
- 优化设置页面绑定弹窗样式,简洁大气
- 修复目录页图标和文字对齐问题

🔧 技术改进:
- 匹配功能支持后台配置,动态加载匹配类型
- 推广数据支持API获取,本地存储作为备份
- 数据库表结构完整,支持用户、订单、推广关系
- 小程序登录仅保留微信登录方式

📱 小程序优化:
- 匹配次数调整为每日3次免费
- 支持¥1购买额外匹配次数
- 分享到朋友圈功能优化
- 界面宽度统一,卡片布局一致
This commit is contained in:
卡若
2026-01-23 16:31:54 +08:00
parent e869974341
commit 1e1e6a1093
18 changed files with 1017 additions and 613 deletions

View File

@@ -42,35 +42,56 @@ Page({
},
// 初始化数据
initData() {
async initData() {
const { isLoggedIn, userInfo } = app.globalData
if (isLoggedIn && userInfo) {
// 生成邀请码
const referralCode = userInfo.referralCode || 'REFM' + (userInfo.id || Date.now().toString(36)).toUpperCase().slice(-6)
const referralCode = userInfo.referralCode || 'SOUL' + (userInfo.id || Date.now().toString(36)).toUpperCase().slice(-6)
// 模拟绑定用户数据
const activeBindings = [
{ id: '1', nickname: '小明', bindingDate: '2025/12/25', daysRemaining: 5, status: 'active' },
{ id: '2', nickname: '小红', bindingDate: '2026/1/9', daysRemaining: 20, status: 'active' },
{ id: '3', nickname: '阿强', bindingDate: '2025/12/22', daysRemaining: 2, status: 'active' }
]
// 尝试从API获取真实数据
let realData = null
try {
const res = await app.request('/api/referral/data', {
method: 'GET',
data: { userId: userInfo.id }
})
if (res.success) {
realData = res.data
}
} catch (e) {
console.log('获取推广数据失败,使用本地数据')
}
const convertedBindings = [
{ id: '4', nickname: '小李', bindingDate: '2025/12/10', commission: '8.91', orderAmount: '9.90', status: 'converted' }
]
// 使用真实数据或本地存储的数据
const storedBindings = wx.getStorageSync('referral_bindings') || []
const storedEarnings = wx.getStorageSync('referral_earnings') || { total: 0, pending: 0 }
const expiredBindings = [
{ id: '5', nickname: '小王', bindingDate: '2025/11/15', status: 'expired' }
]
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 = []
}
const expiringCount = activeBindings.filter(b => b.daysRemaining <= 7).length
this.setData({
isLoggedIn: true,
userInfo,
earnings: (userInfo.earnings || 0).toFixed(2),
pendingEarnings: (userInfo.pendingEarnings || 0).toFixed(2),
referralCount: userInfo.referralCount || 0,
earnings: realData?.earnings || storedEarnings.total || 0,
pendingEarnings: realData?.pendingEarnings || storedEarnings.pending || 0,
referralCount: realData?.referralCount || activeBindings.length + convertedBindings.length,
referralCode,
activeBindings,
convertedBindings,
@@ -117,6 +138,23 @@ Page({
wx.showToast({ title: '海报功能开发中', icon: 'none' })
},
// 分享到朋友圈
shareToMoments() {
const shareText = `🔥 发现一本超棒的创业实战书《一场Soul的创业实验》\n\n💡 62个真实商业案例从私域运营到资源整合干货满满\n\n🎁 通过我的链接购买立享5%优惠,我是 ${this.data.userInfo?.nickname || '卡若'} 推荐!\n\n👉 ${this.data.referralCode} 是我的专属邀请码\n\n#创业实验 #私域运营 #商业案例`
wx.setClipboardData({
data: shareText,
success: () => {
wx.showModal({
title: '文案已复制',
content: '请打开微信朋友圈,粘贴分享文案即可',
showCancel: false,
confirmText: '知道了'
})
}
})
},
// 提现
handleWithdraw() {
const earnings = parseFloat(this.data.earnings)

View File

@@ -172,14 +172,14 @@
<text class="share-arrow">→</text>
</view>
<button class="share-item share-btn" open-type="share">
<view class="share-item" bindtap="shareToMoments">
<view class="share-icon wechat">💬</view>
<view class="share-info">
<text class="share-title">分享到朋友圈</text>
<text class="share-desc">复制文案发朋友圈</text>
</view>
<text class="share-arrow">→</text>
</button>
</view>
<view class="share-item" bindtap="copyLink">
<view class="share-icon link">🔗</view>