feat(guest): 支持游客态浏览示例衣物与搭配

游客可点开示例衣物详情与搭配抽屉,不再在浏览路径上要求登录。
This commit is contained in:
2026-09-17 11:41:42 +08:00
parent 45222317af
commit f0503c7ad7
30 changed files with 648 additions and 127 deletions
+20 -7
View File
@@ -7,7 +7,7 @@ import { clothesStatusFlag } from '../../utils/clothes-status'
import { resolvePendingClothes } from '../../utils/pending-clothes'
import { setTabBarSelected } from '../../utils/tabbar'
import { navScroll } from '../../utils/nav'
import { GUEST_WARDROBE, GuestClothes, goLogin } from '../../utils/guest'
import { GUEST_WARDROBE, goLogin } from '../../utils/guest'
import { logger } from '../../utils/logger'
// 日志模块名
@@ -24,9 +24,9 @@ const CATEGORIES = [
]
// 游客态分类筛选:与分类条 value 对齐,「全部」返回完整示例
function filterGuestClothes(index: number): GuestClothes[] {
function filterGuestClothes(index: number): ClothesItem[] {
const cat = CATEGORIES[index] ? CATEGORIES[index].value : ''
return cat ? GUEST_WARDROBE.filter((it) => it.category === cat) : GUEST_WARDROBE
return cat ? GUEST_WARDROBE.filter((it) => it.category_main === cat) : GUEST_WARDROBE
}
Page({
@@ -73,14 +73,22 @@ Page({
// 未登录:游客态浏览,零请求,不再强制跳登录(微信审核合规要求:
// 用户可先浏览体验功能服务,登录与否由用户自行选择)
if (!auth.isLoggedIn()) {
if (!this.data.guest) this.setData({ guest: true, list: [], loading: false })
if (!this.data.guest) {
// 重新回到游客态(如登录态失效后选择先逛逛):按当前分类还原示例数据
this.setData({
guest: true,
guestList: filterGuestClothes(this.data.activeCategory),
list: [],
loading: false,
})
}
return
}
// 登录成功回到首页:清空示例数据,切回真实衣橱
if (this.data.guest) {
logger.info(LOG, '检测到登录态,从游客态切换为真实衣橱')
;(this as any).firstShown = true
this.setData({ guest: false, guestList: [], list: [], total: 0, uploadRemain: 0, loading: true })
this.setData({ guest: false, list: [], total: 0, uploadRemain: 0, loading: true })
this.resolvePending()
this.refresh()
return
@@ -237,11 +245,16 @@ Page({
},
onClothesTap(e: WechatMiniprogram.CustomEvent) {
const item = e.detail.item as ClothesItem
// 游客态:打开本地示例衣物详情(只读、零请求),浏览路径上不要求登录
if (this.data.guest) {
this.onGuestLogin()
logger.debug(LOG, '游客态点击示例衣物, uuid=', item && item.clothes_uuid)
wx.navigateTo({
url: `/pages/clothes-detail/clothes-detail?demo=${item.clothes_uuid}`,
fail: (err) => logger.warn(LOG, 'navigateTo 示例衣物详情失败, err=', err && err.errMsg),
})
return
}
const item = e.detail.item as ClothesItem
logger.debug(LOG, '点击衣物, uuid=', item && item.clothes_uuid)
wx.navigateTo({
url: `/pages/clothes-detail/clothes-detail?uuid=${item.clothes_uuid}`,