Files
xinlong-shop-taro/.workbuddy/memory/2026-07-13.md
赵忠林 e39eebbf1c feat(share): 补做首页分享功能,支持仅分享到好友
- useShare 增加 enableTimeline 配置,默认启用朋友圈分享
- 首页配置 enableShareAppMessage 并调用 useShare,enableTimeline 设为 false
- 解决 tabBar 页微信不支持朋友圈分享的问题,避免无效注册
- 分享路径添加裂变参数,增强邀请下级功能
- 保持类型检查零错误,改动兼容现有历史 TS2688 错误
2026-07-13 08:22:13 +08:00

17 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 2026-07-13 工作日志
## 小程序分享 / 朋友圈能力全量接入
- 新增 `src/hooks/useShare.ts`:统一注册 `useShareAppMessage` + `useShareTimeline`,自动追加 `inviter=${user.id}` 裂变参数;导出 `isTimelineSinglePage()`scene===1154
- 新增 `src/components/SharePoster/index.tsx`Canvas 2D 生成「封面+标题+价格+小程序码」海报,返回临时图路径作 imageUrl。
- 新增 `src/api/share.ts``generateShareCode(page, inviterId)`,复用 `generateMiniProgramCode`scene=uid_${id}page 透传)。
- 扩展 `src/api/shop/shopInvite/index.ts``generateMiniProgramCode`URL 透传 `page` 参数(后端需读取转发)。
- 接入 10 个页面:商品/积分/拼团/秒杀/活动/赛事详情(带 canvas 海报);邀请下级/分销推广/升级VIP/分享赚佣金(仅 enableShare + useShare
- 类型检查:本次改动零错误,仅余 1 个历史既有错误TS2688 @tarojs/taro 类型解析,非本次引入)。
- 待办/注意:朋友圈分享必须真机测试;后端需支持按 page 生成指定落地页小程序码;单页模式降级(避免强制登录跳转)可调用 `isTimelineSinglePage()`
## 首页接入分享(补做)
- `src/hooks/useShare.ts` 增加 `enableTimeline?: boolean` 选项(默认 truetabBar 页传 false 避免注册无效的朋友圈回调React hook 规则下用内部 `if` 判断返回空对象,始终调用 hook
- `src/pages/index/index.tsx`config 加 `enableShareAppMessage: true`,组件内调用 `useShare({ title, path:'/pages/index/index', enableTimeline:false })`
- 说明:首页为 tabBar 页,微信不允许分享到朋友圈,故仅启用「分享给好友」,路径带 inviter 裂变参数。
- 类型检查:零错误(历史既有 1 个 TS2688 仍在)。