feat: rebuild miniapp reference home

This commit is contained in:
Codex
2026-09-14 06:45:36 +08:00
parent df47543501
commit 36b15d9ca8
6 changed files with 189 additions and 253 deletions
+36 -8
View File
@@ -2,7 +2,7 @@
* 首页 - V1.1 新版(U18)
* 结构:品牌区 → 用户状态条 → Banner → 8入口 → 推荐 → 服务建议 → 活动 → 服务站 → 安全提醒
*/
const { authStore, appStore } = require('../../stores')
const { authStore, appStore, matchStore } = require('../../stores')
const api = require('../../utils/api')
const ENTRY_VISUALS = {
@@ -129,7 +129,12 @@ Page({
statusChecks: checks,
banners: banners || [],
quickEntries: quickEntries?.length
? quickEntries.map((entry) => ({ ...entry, ...ENTRY_VISUALS[entry.code] }))
? QUICK_ENTRIES.map((defaultEntry) => {
const serverEntry = quickEntries.find((entry) => entry.code === defaultEntry.code)
return serverEntry
? { ...defaultEntry, ...serverEntry, ...ENTRY_VISUALS[defaultEntry.code] }
: { ...defaultEntry, enabled: false, disabledReason: '服务暂未开放' }
})
: QUICK_ENTRIES,
recommendations: recommendations || [],
recState: (recommendations && recommendations.length > 0) ? 'loaded' : 'empty',
@@ -198,18 +203,41 @@ Page({
if (userId) wx.navigateTo({ url: `/pages/profile-detail/profile-detail?id=${userId}` })
},
onLike(e) {
async onLike(e) {
const userId = e.detail?.userId
if (!userId) return
if (!userId || this.data.actionLoadingUserId) return
this.setData({ actionLoadingUserId: userId })
setTimeout(() => this.setData({ actionLoadingUserId: '' }), 500)
try {
const result = await matchStore.like(userId)
this.setData({ recommendations: this.data.recommendations.filter((item) => item.userId !== userId) })
if (result?.mutualMatch) {
appStore.toastSuccess('双向喜欢!可以开始聊天了')
if (result.matchedConversationId) {
wx.navigateTo({ url: `/pages/chat/chat?id=${result.matchedConversationId}` })
}
} else {
appStore.toastSuccess('已表达喜欢')
}
} catch (err) {
appStore.toastError(err instanceof Error ? err.message : '操作失败')
} finally {
this.setData({ actionLoadingUserId: '' })
}
},
onPass(e) {
async onPass(e) {
const userId = e.detail?.userId
if (!userId) return
if (!userId || this.data.actionLoadingUserId) return
this.setData({ actionLoadingUserId: userId })
setTimeout(() => this.setData({ actionLoadingUserId: '' }), 500)
try {
await matchStore.pass(userId)
this.setData({ recommendations: this.data.recommendations.filter((item) => item.userId !== userId) })
appStore.toastSuccess('已略过')
} catch (err) {
appStore.toastError(err instanceof Error ? err.message : '操作失败')
} finally {
this.setData({ actionLoadingUserId: '' })
}
},
onEmptyAction(e) {