feat(circle): 集成HaveADrink SDK实现酒友圈功能
- 集成HaveADrink SDK版本从1.0.4升级至1.0.8 - 实现酒友圈API接口,替换原有的mock数据 - 添加地理位置权限配置(requiredPrivateInfos) - 重构API调用方式,统一使用client实例调用真实接口 - 更新WebSocket协议与SDK保持一致,支持聊天、输入状态、已读回执等功能 - 实现游标分页获取动态信息流 - 添加文件上传API支持图片上传 - 优化API错误处理,支持业务级错误提示 - 调整酒局状态显示,新增upcoming待开始状态 - 优化自我感觉标签映射逻辑,支持更多状态类型 - 更新websocket连接认证方式,使用Authorization header传递token - 添加服务端连接确认和被踢下线事件处理
This commit is contained in:
@@ -67,6 +67,7 @@
|
||||
<script>
|
||||
import EmptyState from '../../components/EmptyState.vue'
|
||||
import { GetConversations } from '../../common/api'
|
||||
import wsManager from '../../common/websocket'
|
||||
import themeMixin from '../../common/theme-mixin'
|
||||
|
||||
export default {
|
||||
@@ -83,6 +84,13 @@ export default {
|
||||
},
|
||||
onShow() {
|
||||
this.loadConversations()
|
||||
this.bindWsEvents()
|
||||
},
|
||||
onHide() {
|
||||
this.unbindWsEvents()
|
||||
},
|
||||
onUnload() {
|
||||
this.unbindWsEvents()
|
||||
},
|
||||
methods: {
|
||||
async loadConversations() {
|
||||
@@ -110,6 +118,31 @@ export default {
|
||||
},
|
||||
goCircle() {
|
||||
uni.switchTab({ url: '/pages/circle/circle' })
|
||||
},
|
||||
|
||||
// === WebSocket 实时更新 ===
|
||||
bindWsEvents() {
|
||||
wsManager.on('message', this.onWsMessage)
|
||||
},
|
||||
unbindWsEvents() {
|
||||
wsManager.off('message', this.onWsMessage)
|
||||
},
|
||||
/** 收到新消息时更新会话列表 */
|
||||
onWsMessage(data) {
|
||||
const convId = data.conversationId
|
||||
const idx = this.conversations.findIndex(c => String(c.id) === String(convId))
|
||||
if (idx >= 0) {
|
||||
const conv = this.conversations[idx]
|
||||
conv.lastMessage = data.content || '[新消息]'
|
||||
conv.lastTime = '刚刚'
|
||||
conv.unread = (conv.unread || 0) + 1
|
||||
// 移动到顶部
|
||||
this.conversations.splice(idx, 1)
|
||||
this.conversations.unshift(conv)
|
||||
} else {
|
||||
// 新会话,重新加载列表
|
||||
this.loadConversations()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user