feat(order): 优化订单列表展示逻辑

- 为 PaymentCountdown 组件添加背景渐变样式- 添加订单支付过期判断和过滤逻辑
- 优化订单列表项的样式和结构
-修复 invite.ts 中的若干问题
This commit is contained in:
2025-08-19 16:17:00 +08:00
parent 2ddf0e9605
commit 40e282cf8f
3 changed files with 68 additions and 46 deletions

View File

@@ -17,9 +17,12 @@ export function parseInviteParams(options: any): InviteParams | null {
try {
// 从 scene 参数中解析邀请信息
if (options.scene) {
// 确保 scene 是字符串类型
const sceneStr = typeof options.scene === 'string' ? options.scene : String(options.scene)
const params: InviteParams = {}
const pairs = options.scene.split('&')
const pairs = sceneStr.split('&')
pairs.forEach((pair: string) => {
const [key, value] = pair.split('=')
if (key && value) {
@@ -36,10 +39,10 @@ export function parseInviteParams(options: any): InviteParams | null {
}
}
})
return params.inviter ? params : null
}
// 从 query 参数中解析邀请信息(兼容旧版本)
if (options.referrer) {
return {
@@ -47,7 +50,7 @@ export function parseInviteParams(options: any): InviteParams | null {
source: 'link'
}
}
return null
} catch (error) {
console.error('解析邀请参数失败:', error)
@@ -80,7 +83,7 @@ export function getStoredInviteParams(): InviteParams | null {
// 检查是否过期24小时
const now = Date.now()
const expireTime = 24 * 60 * 60 * 1000 // 24小时
if (now - stored.timestamp < expireTime) {
return {
inviter: stored.inviter,
@@ -139,7 +142,7 @@ export async function handleInviteRelation(userId: number): Promise<boolean> {
// 清除本地存储的邀请参数
clearInviteParams()
console.log(`邀请关系建立成功: ${inviterId} -> ${userId}`)
return true
} catch (error) {
@@ -167,7 +170,7 @@ export function getSourceDisplayName(source: string): string {
'poster': '海报分享',
'unknown': '未知来源'
}
return sourceMap[source] || source
}
@@ -177,11 +180,11 @@ export function getSourceDisplayName(source: string): string {
export function validateInviteCode(scene: string): boolean {
try {
if (!scene) return false
// 检查是否包含必要的参数
const hasInviter = scene.includes('inviter=')
const hasSource = scene.includes('source=')
return hasInviter && hasSource
} catch (error) {
return false
@@ -208,19 +211,19 @@ export function trackInviteSource(source: string, inviterId?: number) {
timestamp: Date.now(),
userAgent: Taro.getSystemInfoSync()
}
// 可以发送到统计服务
console.log('邀请来源统计:', trackData)
// 暂存到本地,后续可批量上报
const existingTracks = Taro.getStorageSync('invite_tracks') || []
existingTracks.push(trackData)
// 只保留最近100条记录
if (existingTracks.length > 100) {
existingTracks.splice(0, existingTracks.length - 100)
}
Taro.setStorageSync('invite_tracks', existingTracks)
} catch (error) {
console.error('统计邀请来源失败:', error)