- 从 liveStore 中获取 auctionData,用于展示当前拍卖信息 - 在模板中添加拍卖数据的动态显示,包括当前价、下口价等信息 - 实现拍卖状态的实时更新和对应 UI 的变化 - 优化竞拍列表的展示逻辑,根据不同的拍卖状态显示相应内容 - 在弹窗中添加当前拍卖作品的标识和状态
43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
import { createGlobalState } from '@vueuse/core'
|
|
import {ref} from "vue";
|
|
import {goodStore} from "@/stores/goods/index.js";
|
|
import {authStore} from "@/stores/auth/index.js";
|
|
|
|
export const liveStore = createGlobalState(() => {
|
|
const {auctionDetail,getAuctionDetail} = goodStore();
|
|
const { token } = authStore()
|
|
const quoteStatus = ref(false)
|
|
const show = ref(false)
|
|
const show1=ref(true)
|
|
const playerId=ref('J_prismPlayer')
|
|
const auctionData=ref({})
|
|
const getSocketData=async ()=>{
|
|
if (!auctionDetail.value.uuid){
|
|
await getAuctionDetail()
|
|
}
|
|
const { ws, messages, onMessage } = useWebSocket()
|
|
|
|
// 连接
|
|
ws.connect('/api/v1/m/auction/live',{auctionUuid: auctionDetail.value.uuid,token:token.value})
|
|
|
|
/*// 发送消息
|
|
ws.send({ type: 'chat', content: 'Hello!' })*/
|
|
// 监听消息
|
|
onMessage((data) => {
|
|
auctionData.value = data.data
|
|
console.log('auctionData.value',auctionData.value)
|
|
})
|
|
}
|
|
const changeStatus = () => {
|
|
quoteStatus.value = !quoteStatus.value
|
|
}
|
|
return{
|
|
auctionData,
|
|
getSocketData,
|
|
show1,
|
|
playerId,
|
|
show,
|
|
quoteStatus,
|
|
changeStatus
|
|
}
|
|
}) |