feat(sdk): 升级HaveADrink SDK并集成邀请系统
- 将HaveADrink依赖从1.0.8升级至1.0.12版本 - 集成邀请码功能,新增common/invite.js处理邀请链路 - 实现发送好友请求返回邀请码的新流程 - 添加删除动态功能,新增DeleteFeed接口 - 集成UniAppWebSocket适配器,重构WebSocket连接管理 - 优化好友请求支持关键词搜索功能 - 在FeedCard组件中添加删除按钮和分享按钮 - 更新SDK类型定义文件以匹配新接口规范
This commit is contained in:
@@ -64,6 +64,11 @@
|
||||
</view>
|
||||
</template>
|
||||
</FriendItem>
|
||||
<!-- 有好友时也保留邀请入口,直接触发带邀请码的转发 -->
|
||||
<button v-if="!keyword" class="invite-btn" open-type="share">
|
||||
<text class="invite-btn-icon">👥</text>
|
||||
<text class="invite-btn-text">邀请更多酒友</text>
|
||||
</button>
|
||||
</view>
|
||||
|
||||
<!-- 空状态 -->
|
||||
@@ -90,6 +95,7 @@
|
||||
import FriendItem from '../../components/FriendItem.vue'
|
||||
import EmptyState from '../../components/EmptyState.vue'
|
||||
import { GetFriends, GetFriendRequests, AcceptFriendRequest, RemoveFriend } from '../../common/api'
|
||||
import { savePendingInvite, handlePendingInvite, getMyInviteCode } from '../../common/invite'
|
||||
import themeMixin from '../../common/theme-mixin'
|
||||
|
||||
export default {
|
||||
@@ -102,13 +108,30 @@ export default {
|
||||
keyword: '',
|
||||
friends: [],
|
||||
requests: [],
|
||||
searchTimer: null
|
||||
searchTimer: null,
|
||||
// 我的邀请码(分享时携带,页面加载时预生成)
|
||||
inviteCode: ''
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
onLoad(options) {
|
||||
this.loadData()
|
||||
// 被分享进入本页时,若携带邀请码参数,继续处理邀请链路
|
||||
if (options && options.inviteCode) {
|
||||
savePendingInvite(options.inviteCode, options.inviterNick)
|
||||
if (uni.getStorageSync('is_logged_in') === 'true') {
|
||||
handlePendingInvite().then(() => this.loadData())
|
||||
}
|
||||
}
|
||||
// 预生成新的邀请码,供右上角分享使用(后端每次邀请都生成新码)
|
||||
this.refreshInviteCode()
|
||||
},
|
||||
methods: {
|
||||
/** 生成新的邀请码(每次分享后调用,保证下次分享用新码) */
|
||||
refreshInviteCode() {
|
||||
getMyInviteCode().then(code => {
|
||||
this.inviteCode = code
|
||||
})
|
||||
},
|
||||
goBack() {
|
||||
uni.navigateBack()
|
||||
},
|
||||
@@ -173,9 +196,21 @@ export default {
|
||||
}
|
||||
},
|
||||
onShareAppMessage() {
|
||||
// 分享链接携带当前邀请码(一次性),好友点开后接受邀请即可成为酒友
|
||||
let user = {}
|
||||
try {
|
||||
user = JSON.parse(uni.getStorageSync('user_info') || '{}')
|
||||
} catch (e) { /* ignore */ }
|
||||
const parts = []
|
||||
if (this.inviteCode) parts.push(`inviteCode=${encodeURIComponent(this.inviteCode)}`)
|
||||
if (user.nickname) parts.push(`inviterNick=${encodeURIComponent(user.nickname)}`)
|
||||
const query = parts.length ? `?${parts.join('&')}` : ''
|
||||
const nick = user.nickname ? `「${user.nickname}」` : ''
|
||||
// 本次分享已用掉当前邀请码,异步生成新码供下次分享
|
||||
this.refreshInviteCode()
|
||||
return {
|
||||
title: '来「碰盏日记」一起记录饮酒生活吧!',
|
||||
path: '/pages/index/index'
|
||||
title: `${nick}邀请你成为酒友,一起记录饮酒生活 🍻`,
|
||||
path: `/pages/index/index${query}`
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -375,4 +410,38 @@ export default {
|
||||
font-size: $fs-xs;
|
||||
color: $coral;
|
||||
}
|
||||
|
||||
/* 邀请更多酒友按钮(重置 button 默认样式) */
|
||||
.invite-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: $sp-sm;
|
||||
width: 100%;
|
||||
margin: $sp-lg 0 0;
|
||||
padding: $sp-lg 0;
|
||||
background: rgba(232,168,56,0.08);
|
||||
border: 1rpx dashed rgba(232,168,56,0.35);
|
||||
border-radius: $radius-lg;
|
||||
line-height: 1;
|
||||
font-size: inherit;
|
||||
|
||||
&:active {
|
||||
background: rgba(232,168,56,0.14);
|
||||
}
|
||||
|
||||
&::after {
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
|
||||
.invite-btn-icon {
|
||||
font-size: $fs-base;
|
||||
}
|
||||
|
||||
.invite-btn-text {
|
||||
font-size: $fs-sm;
|
||||
color: $amber;
|
||||
font-weight: $fw-bold;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user