From a71e14d2e6a8f797d4e1de2ca862c5039f392e6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=98=E9=A3=8E?= Date: Thu, 12 Feb 2026 17:34:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8C=B9=E9=85=8D=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=EF=BC=8C=E6=96=B0=E5=A2=9E=E5=A5=BD=E5=8F=8B=E4=BC=98?= =?UTF-8?q?=E6=83=A0=E5=B1=95=E7=A4=BA=E9=80=BB=E8=BE=91=EF=BC=8C=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E9=80=9A=E8=BF=87=E6=8E=A8=E8=8D=90=E7=A0=81=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=8A=98=E6=89=A3=E3=80=82=E8=B0=83=E6=95=B4=E4=BB=B7?= =?UTF-8?q?=E6=A0=BC=E8=AE=A1=E7=AE=97=E6=96=B9=E5=BC=8F=EF=BC=8C=E7=A1=AE?= =?UTF-8?q?=E4=BF=9D=E7=94=A8=E6=88=B7=E5=9C=A8=E8=B4=AD=E4=B9=B0=E6=97=B6?= =?UTF-8?q?=E8=83=BD=E7=9C=8B=E5=88=B0=E5=AE=9E=E9=99=85=E4=BC=98=E6=83=A0?= =?UTF-8?q?=E3=80=82=E6=9B=B4=E6=96=B0=E9=A1=B5=E9=9D=A2=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E4=BB=A5=E6=8F=90=E5=8D=87=E7=94=A8=E6=88=B7=E4=BD=93=E9=AA=8C?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- miniprogram/pages/match/match.js | 105 ++++++++++++++++-------- miniprogram/pages/match/match.wxml | 15 +++- miniprogram/pages/match/match.wxss | 22 +++++ miniprogram/pages/settings/settings.js | 2 +- miniprogram/project.private.config.json | 11 ++- soul-api/soul-api | Bin 19128305 -> 19128305 bytes 6 files changed, 113 insertions(+), 42 deletions(-) diff --git a/miniprogram/pages/match/match.js b/miniprogram/pages/match/match.js index 7e87ffde..194cc3d8 100644 --- a/miniprogram/pages/match/match.js +++ b/miniprogram/pages/match/match.js @@ -80,12 +80,36 @@ Page({ // 匹配价格(可配置) matchPrice: 1, - extraMatches: 0 + extraMatches: 0, + // 好友优惠展示(与 read 页一致) + userDiscount: 5, + hasReferralDiscount: false, + showDiscountHint: false, + displayMatchPrice: 1 }, - onLoad() { + onLoad(options = {}) { + // ref:支持 query.ref 或 scene 中的 ref=xxx(分享进入时) + let ref = options.ref + if (!ref && options.scene) { + const sceneStr = (typeof options.scene === 'string' ? decodeURIComponent(options.scene) : '').trim() + const parts = sceneStr.split(/[&_]/) + for (const part of parts) { + const eq = part.indexOf('=') + if (eq > 0) { + const k = part.slice(0, eq) + const v = part.slice(eq + 1) + if (k === 'ref' && v) { ref = v; break } + } + } + } + if (ref) { + wx.setStorageSync('referral_code', ref) + app.handleReferralCode({ query: { ref } }) + } this.setData({ - statusBarHeight: app.globalData.statusBarHeight || 44 + statusBarHeight: app.globalData.statusBarHeight || 44, + _ref: ref }) this.loadMatchConfig() this.loadStoredContact() @@ -105,31 +129,39 @@ Page({ this.refreshMatchCountAndStatus() }, - // 加载匹配配置 + // 加载匹配配置(含 userDiscount 用于好友优惠展示) async loadMatchConfig() { try { - const res = await app.request('/api/miniprogram/match/config', { - method: 'GET' + const userId = app.globalData.userInfo?.id + const [matchRes, configRes] = await Promise.all([ + app.request('/api/miniprogram/match/config', { method: 'GET' }), + app.request('/api/miniprogram/config', { method: 'GET' }) + ]) + + const matchPrice = matchRes?.success && matchRes?.data ? (matchRes.data.matchPrice || 1) : 1 + const userDiscount = configRes?.userDiscount ?? 5 + const hasReferral = !!(wx.getStorageSync('referral_code') || this.data._ref) + const hasReferralDiscount = hasReferral && userDiscount > 0 + const displayMatchPrice = hasReferralDiscount + ? Math.round(matchPrice * (1 - userDiscount / 100) * 100) / 100 + : matchPrice + + if (matchRes?.success && matchRes?.data) { + MATCH_TYPES = matchRes.data.matchTypes || MATCH_TYPES + FREE_MATCH_LIMIT = matchRes.data.freeMatchLimit || FREE_MATCH_LIMIT + } + + this.setData({ + matchTypes: MATCH_TYPES, + totalMatchesAllowed: FREE_MATCH_LIMIT, + matchPrice, + userDiscount, + hasReferralDiscount, + showDiscountHint: userDiscount > 0, + displayMatchPrice }) - if (res.success && res.data) { - // 更新全局配置 - MATCH_TYPES = res.data.matchTypes || MATCH_TYPES - FREE_MATCH_LIMIT = res.data.freeMatchLimit || FREE_MATCH_LIMIT - const matchPrice = res.data.matchPrice || 1 - - this.setData({ - matchTypes: MATCH_TYPES, - totalMatchesAllowed: FREE_MATCH_LIMIT, - matchPrice: matchPrice - }) - - console.log('[Match] 加载匹配配置成功:', { - types: MATCH_TYPES.length, - freeLimit: FREE_MATCH_LIMIT, - price: matchPrice - }) - } + console.log('[Match] 加载匹配配置成功:', { matchPrice, userDiscount, hasReferralDiscount, displayMatchPrice }) } catch (e) { console.log('[Match] 加载匹配配置失败,使用默认配置:', e) } @@ -155,6 +187,15 @@ Page({ if (res.success && res.data) { app.globalData.matchCount = res.data.matchCount ?? 0 app.globalData.matchQuota = res.data.matchQuota || null + // 根据 hasReferrer 更新优惠展示(与 read 页一致) + const hasReferral = !!(wx.getStorageSync('referral_code') || this.data._ref || res.data.hasReferrer) + const matchPrice = this.data.matchPrice ?? 1 + const userDiscount = this.data.userDiscount ?? 5 + const hasReferralDiscount = hasReferral && userDiscount > 0 + const displayMatchPrice = hasReferralDiscount + ? Math.round(matchPrice * (1 - userDiscount / 100) * 100) / 100 + : matchPrice + this.setData({ hasReferralDiscount, displayMatchPrice }) } } catch (e) { console.log('[Match] 拉取 matchQuota 失败:', e) @@ -254,8 +295,8 @@ Page({ return } - // 创业合伙类型 - 真正的匹配功能(仅当登录且服务端确认次数用尽时,弹出购买) - if (this.data.showQuotaExhausted) { + // 创业合伙类型 - 超过匹配次数时直接弹出付费弹窗 + if (this.data.showQuotaExhausted || this.data.needPayToMatch) { this.setData({ showUnlockModal: true }) return } @@ -355,17 +396,9 @@ Page({ setTimeout(() => { clearInterval(timer) - // 次数用尽(后端校验) + // 次数用尽(后端校验)- 直接弹出付费弹窗 if (quotaExceeded) { - this.setData({ isMatching: false }) - wx.showModal({ - title: '今日匹配次数已用完', - content: '请购买更多次数继续匹配', - confirmText: '去购买', - success: (r) => { - if (r.confirm) this.setData({ showUnlockModal: true }) - } - }) + this.setData({ isMatching: false, showUnlockModal: true }) this.refreshMatchCountAndStatus() return } diff --git a/miniprogram/pages/match/match.wxml b/miniprogram/pages/match/match.wxml index 2efda433..fd174f77 100644 --- a/miniprogram/pages/match/match.wxml +++ b/miniprogram/pages/match/match.wxml @@ -39,7 +39,7 @@ 购买次数 - ¥1 = 1次匹配 + ¥{{displayMatchPrice || matchPrice || 1}} = 1次匹配 👥 @@ -344,7 +344,16 @@ 单价 - ¥{{matchPrice || 1}} / 次 + + ¥{{matchPrice || 1}} + ¥{{displayMatchPrice || matchPrice || 1}} / 次 + 省{{userDiscount}}% + + + ¥{{matchPrice || 1}} / 次 + 好友链接立省{{userDiscount}}% + + ¥{{matchPrice || 1}} / 次 已购买 @@ -353,7 +362,7 @@ - 立即购买 ¥{{matchPrice || 1}} + 立即购买 ¥{{hasReferralDiscount ? (displayMatchPrice || matchPrice || 1) : (matchPrice || 1)}} 明天再来 diff --git a/miniprogram/pages/match/match.wxss b/miniprogram/pages/match/match.wxss index 3719ae27..b662a249 100644 --- a/miniprogram/pages/match/match.wxss +++ b/miniprogram/pages/match/match.wxss @@ -1110,6 +1110,28 @@ color: #ffffff; } +.info-value-row { + display: flex; + align-items: center; + gap: 12rpx; +} + +.info-original { + font-size: 24rpx; + color: rgba(255, 255, 255, 0.5); + text-decoration: line-through; +} + +.info-discount { + font-size: 22rpx; + color: #00CED1; +} + +.info-discount-hint { + font-size: 22rpx; + color: rgba(255, 255, 255, 0.5); +} + .unlock-buttons { display: flex; flex-direction: column; diff --git a/miniprogram/pages/settings/settings.js b/miniprogram/pages/settings/settings.js index c46ab852..230a7582 100644 --- a/miniprogram/pages/settings/settings.js +++ b/miniprogram/pages/settings/settings.js @@ -45,7 +45,7 @@ Page({ if (isLoggedIn && userInfo) { // 从本地存储或用户信息中获取绑定数据 const phoneNumber = wx.getStorageSync('user_phone') || userInfo.phone || '' - const wechatId = wx.getStorageSync('user_wechat') || userInfo.wechat || '' + const wechatId = wx.getStorageSync('user_wechat') || userInfo.wechatId || userInfo.wechat || '' const alipayAccount = wx.getStorageSync('user_alipay') || userInfo.alipay || '' const address = wx.getStorageSync('user_address') || userInfo.address || '' // 默认开启自动提现 diff --git a/miniprogram/project.private.config.json b/miniprogram/project.private.config.json index 6ec30cf3..072fabb7 100644 --- a/miniprogram/project.private.config.json +++ b/miniprogram/project.private.config.json @@ -24,12 +24,19 @@ "miniprogram": { "list": [ { - "name": "pages/referral/referral", - "pathName": "pages/referral/referral", + "name": "pages/addresses/addresses", + "pathName": "pages/addresses/addresses", "query": "", "scene": null, "launchMode": "default" }, + { + "name": "pages/referral/referral", + "pathName": "pages/referral/referral", + "query": "", + "launchMode": "default", + "scene": null + }, { "name": "pages/read/read", "pathName": "pages/read/read", diff --git a/soul-api/soul-api b/soul-api/soul-api index 1a1011c7913f7096c58cd7b4b6d5696462d8c1e9..e72095d36ada9b0226421a5961f770f1dce552f9 100644 GIT binary patch delta 1448 zcmbWz=R*tt9Eb5sk%W?D#UY!x>qb|$PzZ5yHg$C;azf5dX0k$&z4zYXkiGZbd++Sc z^ZOUP_&o2vZ@xL%X>K{#G~T0%%5LnLIM_bKW>@zM@1~1xp)p3(?9riJ*Z^Zlg38p( z7^$|z$3*nErf>G}32G8boQR zcK@CDI?m5MA;bTRS9$}raWM2qgC=72D zfe(tJ7>c6=O2QYV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