feat(guest): 支持游客态浏览示例衣物与搭配
游客可点开示例衣物详情与搭配抽屉,不再在浏览路径上要求登录。
This commit is contained in:
@@ -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}`,
|
||||
|
||||
@@ -60,15 +60,14 @@
|
||||
bind:action="onUpload"
|
||||
/>
|
||||
|
||||
<!-- 游客态:本地示例衣物网格(可切换分类即时筛选) -->
|
||||
<!-- 游客态:本地示例衣物网格(可切换分类筛选,点卡片可看示例详情,不要求登录) -->
|
||||
<view wx:elif="{{guest}}" class="wd-grid">
|
||||
<view class="wd-tile" wx:for="{{guestList}}" wx:key="key" bindtap="onGuestLogin">
|
||||
<view class="gd-img">
|
||||
<view class="icon {{item.icon}} gd-ph"></view>
|
||||
<view class="guest-flag">示例</view>
|
||||
</view>
|
||||
<view class="tile-name">{{item.name}}</view>
|
||||
<view class="tile-sub">{{item.category}} · {{item.color}}色</view>
|
||||
<view class="wd-tile" wx:for="{{guestList}}" wx:key="clothes_uuid">
|
||||
<clothes-card
|
||||
item="{{item}}"
|
||||
statusText="示例"
|
||||
bind:select="onClothesTap"
|
||||
/>
|
||||
</view>
|
||||
<view wx:if="{{!guestList.length}}" class="gd-none">该分类暂无示例内容</view>
|
||||
</view>
|
||||
|
||||
@@ -53,26 +53,7 @@
|
||||
transform: scale(.975);
|
||||
}
|
||||
|
||||
/* ===== 游客态:示例衣物瓦片(线稿占位 + 示例角标) ===== */
|
||||
.gd-img {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
aspect-ratio: 1 / 1;
|
||||
background: var(--paper-2);
|
||||
border-radius: var(--r-img);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.gd-img .gd-ph {
|
||||
width: 56%;
|
||||
height: 56%;
|
||||
color: var(--art);
|
||||
}
|
||||
|
||||
/* 分类下无示例时的整行占位 */
|
||||
/* ===== 游客态:示例衣物网格(复用 clothes-card,仅保留无示例时的占位) ===== */
|
||||
.gd-none {
|
||||
grid-column: 1 / -1;
|
||||
padding: 72rpx 0;
|
||||
|
||||
Reference in New Issue
Block a user