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:
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<view :class="themeClass" class="page-container publish-page">
|
||||
<!-- 顶部导航 -->
|
||||
<view class="publish-nav" :style="{ paddingTop: navPaddingTop }">
|
||||
<view class="publish-nav" :style="{ paddingTop: navPaddingTop, paddingRight: navPaddingRight }">
|
||||
<view class="publish-nav-inner">
|
||||
<view class="publish-back" @click="goBack">
|
||||
<text class="publish-back-icon">‹</text>
|
||||
@@ -79,16 +79,18 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { PublishFeed } from '../../common/api'
|
||||
import { getRecords } from '../../common/mock-data'
|
||||
import { PublishFeed, UploadImage } from '../../common/api'
|
||||
import client from '../../common/api'
|
||||
import themeMixin from '../../common/theme-mixin'
|
||||
|
||||
export default {
|
||||
mixins: [themeMixin],
|
||||
data() {
|
||||
const menuBtn = uni.getMenuButtonBoundingClientRect()
|
||||
const sysInfo = uni.getSystemInfoSync()
|
||||
return {
|
||||
navPaddingTop: menuBtn.top + 'px',
|
||||
navPaddingRight: (sysInfo.windowWidth - menuBtn.left + 8) + 'px',
|
||||
text: '',
|
||||
images: [],
|
||||
visibility: 'friends',
|
||||
@@ -115,10 +117,11 @@ export default {
|
||||
goBack() {
|
||||
uni.navigateBack()
|
||||
},
|
||||
loadLastRecord() {
|
||||
async loadLastRecord() {
|
||||
try {
|
||||
const records = getRecords()
|
||||
const drank = records.find(r => r.mode === 'drank')
|
||||
const res = await client.GetRecords({ page: 1, pageSize: 5, month: '', mode: '' })
|
||||
const list = res.list || []
|
||||
const drank = list.find(r => String(r.mode) === 'drank' || String(r.mode) === 'Drank')
|
||||
if (drank) this.lastRecord = drank
|
||||
} catch (e) { /* ignore */ }
|
||||
},
|
||||
@@ -140,16 +143,29 @@ export default {
|
||||
if (!this.canSubmit) return
|
||||
this.publishing = true
|
||||
try {
|
||||
// 先上传图片获取远程URL
|
||||
let uploadedUrls = []
|
||||
if (this.images.length) {
|
||||
uni.showLoading({ title: '上传图片中...' })
|
||||
for (const img of this.images) {
|
||||
const upRes = await UploadImage({ filePath: img })
|
||||
if (upRes.data && upRes.data.url) {
|
||||
uploadedUrls.push(upRes.data.url)
|
||||
}
|
||||
}
|
||||
uni.hideLoading()
|
||||
}
|
||||
await PublishFeed({
|
||||
text: this.text,
|
||||
images: this.images,
|
||||
images: uploadedUrls,
|
||||
recordId: this.linkRecord && this.lastRecord ? this.lastRecord.id : null,
|
||||
visibility: this.visibility
|
||||
})
|
||||
uni.showToast({ title: '发布成功 🍻', icon: 'none' })
|
||||
setTimeout(() => uni.navigateBack(), 800)
|
||||
} catch (e) {
|
||||
uni.showToast({ title: '发布失败', icon: 'none' })
|
||||
uni.hideLoading()
|
||||
// 全局拦截器已弹出错误提示
|
||||
}
|
||||
this.publishing = false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user