fix:bug

This commit is contained in:
2026-09-13 23:32:35 +08:00
parent 323f520d7b
commit 1a11816839
14 changed files with 701 additions and 46 deletions
@@ -33,17 +33,27 @@ Page({
logger.debug(LOG, '穿搭详情加载成功, 单品数=', outfit.items && outfit.items.length)
this.setData({ outfit })
const clothes = await Promise.all(
outfit.items.map(async (it) => {
try {
return await request<ClothesItem>({ url: `/clothes/${it.clothes_uuid}`, showError: false })
} catch (e: any) {
logger.warn(LOG, '单品详情拉取失败, uuid=', it.clothes_uuid, 'code=', e && e.code)
return { clothes_uuid: it.clothes_uuid } as ClothesItem
}
})
// 封面与衣物缩略图直接使用穿搭明细里的抠图(processed_image),
// 避免非属主逐件请求 /clothes/:uuid 被拒(50005)导致图片与名称全部丢失。
const baseClothes = (outfit.items || []).map(
(it) => ({ clothes_uuid: it.clothes_uuid, processed_image: it.processed_image }) as ClothesItem,
)
this.setData({ clothes })
this.setData({ clothes: baseClothes })
// 属主可进一步拉取衣物详情补充名称;非属主无权限,跳过。
if (this.data.isOwner) {
const clothes = await Promise.all(
(outfit.items || []).map(async (it) => {
try {
return await request<ClothesItem>({ url: `/clothes/${it.clothes_uuid}`, showError: false })
} catch (e: any) {
logger.warn(LOG, '单品详情拉取失败, uuid=', it.clothes_uuid, 'code=', e && e.code)
return { clothes_uuid: it.clothes_uuid, processed_image: it.processed_image } as ClothesItem
}
})
)
this.setData({ clothes })
}
const like = await request<{ is_liked: boolean; like_count: number }>({
url: `/like/${this.data.uuid}`,
@@ -162,16 +172,40 @@ Page({
onItemTap(e: WechatMiniprogram.TouchEvent) {
const uuid = e.currentTarget.dataset.uuid as string
// 非属主无权读取衣物详情(50005),点击仅提示;属主正常跳转。
if (!this.data.isOwner) {
logger.debug(LOG, '非属主点击衣物,仅可查看穿搭, uuid=', uuid)
wx.showToast({ title: '仅可查看穿搭', icon: 'none' })
return
}
wx.navigateTo({
url: `/pages/clothes-detail/clothes-detail?uuid=${uuid}`,
fail: (err) => logger.warn(LOG, 'navigateTo 单品详情失败, err=', err && err.errMsg),
})
},
onShareAppMessage() {
return {
title: this.data.outfit.outfit_name || '我的穿搭',
path: `/pages/outfit-detail/outfit-detail?uuid=${this.data.uuid}&owner=0`,
}
// 分享前先创建穿搭分享记录拿到 share_uuid,链接指向分享详情页;
// 失败(如穿搭未公开)则回退到普通穿搭详情链接,保证分享动作仍可用。
onShareAppMessage(): any {
const name = this.data.outfit.outfit_name || '我的穿搭'
return request<{ share_uuid: string }>({
url: '/outfit-share',
method: 'POST',
data: { outfit_uuid: this.data.uuid },
})
.then((res) => {
logger.info(LOG, '穿搭分享创建成功, share_uuid=', res.share_uuid)
return {
title: name,
path: `/pages/outfit-share-detail/outfit-share-detail?uuid=${res.share_uuid}`,
}
})
.catch((e: any) => {
logger.warn(LOG, '穿搭分享创建失败,回退普通分享链接, code=', e && e.code)
return {
title: name,
path: `/pages/outfit-detail/outfit-detail?uuid=${this.data.uuid}&owner=0`,
}
})
},
})