feat(share): 更新分享标题显示用户昵称
- 修改分享功能使用用户昵称替代用户ID作为标题前缀 - 添加微信昵称存储逻辑到本地缓存 - 实现用户昵称、真实姓名或用户名的优先级取值 - 添加注释说明微信显示名称的存储用途
This commit is contained in:
@@ -20,9 +20,12 @@ function Home() {
|
||||
useShareAppMessage(() => {
|
||||
// 获取当前用户ID,用于生成邀请链接
|
||||
const userId = Taro.getStorageSync('UserId');
|
||||
const user = Taro.getStorageSync('User') || {};
|
||||
const nickname =
|
||||
(user && (user.nickname || user.realName || user.username)) || '';
|
||||
|
||||
return {
|
||||
title: userId + '超值推荐',
|
||||
title: (nickname || '') + '超值推荐',
|
||||
path: userId ? `/pages/index/index?inviter=${userId}&source=share&t=${Date.now()}` : `/pages/index/index`,
|
||||
success: function () {
|
||||
console.log('首页分享成功');
|
||||
@@ -164,6 +167,7 @@ function Home() {
|
||||
Taro.getUserInfo({
|
||||
success: (res) => {
|
||||
const avatar = res.userInfo.avatarUrl;
|
||||
// Keep WeChat display name in storage so share title can use it.
|
||||
console.log(avatar, 'avatarUrl')
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user