融合PK头像头像功能
This commit is contained in:
94
src/views/pk-mini/Forum.vue
Normal file
94
src/views/pk-mini/Forum.vue
Normal file
@@ -0,0 +1,94 @@
|
||||
<template>
|
||||
<!-- 站内信页面 -->
|
||||
<div class="forum">
|
||||
<div class="forum-list">
|
||||
<el-card
|
||||
v-for="(item, index) in noticeList"
|
||||
:key="index"
|
||||
class="notice-card"
|
||||
>
|
||||
<template #header>
|
||||
<div class="card-header">{{ item.title }}</div>
|
||||
</template>
|
||||
<div class="card-body">{{ item.content }}</div>
|
||||
<template #footer>
|
||||
<div class="card-footer">{{ item.time }}</div>
|
||||
</template>
|
||||
</el-card>
|
||||
|
||||
<div v-if="noticeList.length === 0" class="empty-tip">暂无站内信</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { getNoticeList } from '@/api/pk-mini'
|
||||
|
||||
const noticeList = ref([])
|
||||
const page = ref(0)
|
||||
|
||||
async function loadNotices() {
|
||||
try {
|
||||
const res = await getNoticeList({ page: page.value, size: 20 })
|
||||
noticeList.value = res || []
|
||||
} catch (e) {
|
||||
console.error('加载站内信失败', e)
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadNotices()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.forum {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: flex-start;
|
||||
padding: 20px;
|
||||
background: white;
|
||||
border-radius: 16px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.forum-list {
|
||||
width: 90%;
|
||||
max-width: 800px;
|
||||
}
|
||||
|
||||
.notice-card {
|
||||
margin-bottom: 20px;
|
||||
border-radius: 16px;
|
||||
border: 1px solid #4fcacd;
|
||||
background: linear-gradient(180deg, #e4ffff, #ffffff);
|
||||
}
|
||||
|
||||
.card-header {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.card-body {
|
||||
color: #333;
|
||||
font-size: 16px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.card-footer {
|
||||
font-size: 14px;
|
||||
color: #999;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.empty-tip {
|
||||
text-align: center;
|
||||
padding: 50px;
|
||||
color: #999;
|
||||
font-size: 16px;
|
||||
}
|
||||
</style>
|
||||
346
src/views/pk-mini/Message.vue
Normal file
346
src/views/pk-mini/Message.vue
Normal file
@@ -0,0 +1,346 @@
|
||||
<template>
|
||||
<!-- 消息页面 -->
|
||||
<div class="message-page">
|
||||
<el-splitter class="message-splitter">
|
||||
<!-- 会话列表 -->
|
||||
<el-splitter-panel :size="25" :min="20" :max="35">
|
||||
<div class="conversation-list">
|
||||
<div
|
||||
v-for="(item, index) in chatList"
|
||||
:key="index"
|
||||
class="conversation-item"
|
||||
:class="{ active: selectedChat === item }"
|
||||
@click="selectChat(item)"
|
||||
>
|
||||
<el-badge :value="item.unread > 0 ? item.unread : ''" :max="99">
|
||||
<div class="conv-avatar">
|
||||
<img :src="item.data?.avatar || defaultAvatar" alt="" />
|
||||
</div>
|
||||
</el-badge>
|
||||
<div class="conv-info">
|
||||
<div class="conv-header">
|
||||
<span class="conv-name">{{ item.data?.nickname || '用户' }}</span>
|
||||
<span class="conv-time">{{ formatTime(item.lastMessage?.timestamp) }}</span>
|
||||
</div>
|
||||
<div class="conv-preview">{{ item.lastMessage?.payload?.text || '' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="chatList.length === 0" class="empty-tip">暂无会话</div>
|
||||
</div>
|
||||
</el-splitter-panel>
|
||||
|
||||
<!-- 消息列表 -->
|
||||
<el-splitter-panel>
|
||||
<div v-if="selectedChat" class="chat-container">
|
||||
<div class="chat-messages" ref="chatMessagesRef">
|
||||
<div
|
||||
v-for="(msg, index) in messagesList"
|
||||
:key="index"
|
||||
class="message-item"
|
||||
:class="{ mine: msg.senderId == currentUser.id }"
|
||||
>
|
||||
<div class="message-avatar">
|
||||
<img :src="msg.senderId == currentUser.id ? currentUser.headerIcon : selectedChat.data?.avatar" alt="" />
|
||||
</div>
|
||||
<div class="message-bubble">
|
||||
<div v-if="msg.type === 'text'" class="text-message">{{ msg.payload.text }}</div>
|
||||
<PictureMessage v-else-if="msg.type === 'image'" :item="msg" />
|
||||
<PKMessage v-else-if="msg.type === 'pk'" :item="msg" />
|
||||
<VoiceMessage v-else-if="msg.type === 'audio'" :item="msg.payload.url" :size="msg.payload.duration" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="chat-input-area">
|
||||
<div class="input-toolbar">
|
||||
<div class="toolbar-btn" @click="handleSendImage">
|
||||
<span class="material-icons-round">image</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="input-box">
|
||||
<textarea
|
||||
v-model="inputText"
|
||||
placeholder="输入消息..."
|
||||
@keydown.enter.prevent="sendMessage"
|
||||
></textarea>
|
||||
<el-button type="primary" @click="sendMessage">发送</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="chat-placeholder">
|
||||
<span class="material-icons-round placeholder-icon">chat_bubble_outline</span>
|
||||
<p>选择左侧会话开始聊天</p>
|
||||
</div>
|
||||
</el-splitter-panel>
|
||||
</el-splitter>
|
||||
|
||||
<!-- 隐藏的文件输入 -->
|
||||
<input
|
||||
ref="fileInputRef"
|
||||
type="file"
|
||||
accept="image/*"
|
||||
style="display: none"
|
||||
@change="handleFileSelect"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { getMainUserData } from '@/utils/pk-mini/storage'
|
||||
import { TimestamptolocalTime } from '@/utils/pk-mini/timeConversion'
|
||||
// GoEasy 暂时禁用(订阅未续费)
|
||||
// import {
|
||||
// goEasyGetConversations,
|
||||
// goEasyGetMessages,
|
||||
// goEasySendMessage,
|
||||
// goEasySendImageMessage,
|
||||
// goEasyMessageRead,
|
||||
// getPkGoEasy
|
||||
// } from '@/utils/pk-mini/goeasy'
|
||||
// import GoEasy from 'goeasy'
|
||||
import PictureMessage from '@/components/pk-mini/chat/PictureMessage.vue'
|
||||
import PKMessage from '@/components/pk-mini/chat/PKMessage.vue'
|
||||
import VoiceMessage from '@/components/pk-mini/chat/VoiceMessage.vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
|
||||
const defaultAvatar = 'https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/default-avatar.png'
|
||||
const chatList = ref([])
|
||||
const selectedChat = ref(null)
|
||||
const messagesList = ref([])
|
||||
const inputText = ref('')
|
||||
const currentUser = ref({})
|
||||
const chatMessagesRef = ref(null)
|
||||
const fileInputRef = ref(null)
|
||||
|
||||
const formatTime = TimestamptolocalTime
|
||||
|
||||
async function loadConversations() {
|
||||
// GoEasy 暂时禁用
|
||||
ElMessage.warning('消息功能暂时不可用(GoEasy 订阅未续费)')
|
||||
}
|
||||
|
||||
async function selectChat(item) {
|
||||
// GoEasy 暂时禁用
|
||||
}
|
||||
|
||||
function scrollToBottom() {
|
||||
if (chatMessagesRef.value) {
|
||||
chatMessagesRef.value.scrollTop = chatMessagesRef.value.scrollHeight
|
||||
}
|
||||
}
|
||||
|
||||
async function sendMessage() {
|
||||
// GoEasy 暂时禁用
|
||||
ElMessage.warning('消息功能暂时不可用(GoEasy 订阅未续费)')
|
||||
}
|
||||
|
||||
function handleSendImage() {
|
||||
// GoEasy 暂时禁用
|
||||
ElMessage.warning('消息功能暂时不可用(GoEasy 订阅未续费)')
|
||||
}
|
||||
|
||||
async function handleFileSelect(event) {
|
||||
event.target.value = ''
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
currentUser.value = getMainUserData() || {}
|
||||
// GoEasy 暂时禁用,不加载会话
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.message-page {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: white;
|
||||
border-radius: 16px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.message-splitter {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.conversation-list {
|
||||
height: 100%;
|
||||
overflow: auto;
|
||||
background: #fafafa;
|
||||
}
|
||||
|
||||
.conversation-item {
|
||||
display: flex;
|
||||
padding: 15px;
|
||||
cursor: pointer;
|
||||
transition: background 0.2s;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
|
||||
.conversation-item:hover, .conversation-item.active {
|
||||
background: #f0f0f0;
|
||||
}
|
||||
|
||||
.conv-avatar {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
margin-right: 12px;
|
||||
}
|
||||
|
||||
.conv-avatar img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.conv-info {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.conv-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.conv-name {
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.conv-time {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.conv-preview {
|
||||
font-size: 13px;
|
||||
color: #666;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.chat-container {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.chat-messages {
|
||||
flex: 1;
|
||||
overflow: auto;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.message-item {
|
||||
display: flex;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.message-item.mine {
|
||||
flex-direction: row-reverse;
|
||||
}
|
||||
|
||||
.message-avatar {
|
||||
width: 45px;
|
||||
height: 45px;
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
margin: 0 12px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.message-avatar img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.message-bubble {
|
||||
max-width: 60%;
|
||||
}
|
||||
|
||||
.text-message {
|
||||
padding: 12px 16px;
|
||||
background: #f5f5f5;
|
||||
border-radius: 12px;
|
||||
font-size: 15px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.message-item.mine .text-message {
|
||||
background: #7bbd0093;
|
||||
}
|
||||
|
||||
.chat-input-area {
|
||||
border-top: 1px solid #eee;
|
||||
}
|
||||
|
||||
.input-toolbar {
|
||||
display: flex;
|
||||
padding: 10px 15px;
|
||||
background: #e4f9f9;
|
||||
}
|
||||
|
||||
.toolbar-btn {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
border-radius: 8px;
|
||||
transition: background 0.2s;
|
||||
}
|
||||
|
||||
.toolbar-btn:hover {
|
||||
background: rgba(255, 255, 255, 0.8);
|
||||
}
|
||||
|
||||
.toolbar-btn .material-icons-round {
|
||||
color: #03aba8;
|
||||
}
|
||||
|
||||
.input-box {
|
||||
display: flex;
|
||||
padding: 10px 15px;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.input-box textarea {
|
||||
flex: 1;
|
||||
border: none;
|
||||
outline: none;
|
||||
resize: none;
|
||||
height: 50px;
|
||||
font-size: 14px;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.chat-placeholder {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #03aba8;
|
||||
}
|
||||
|
||||
.placeholder-icon {
|
||||
font-size: 80px;
|
||||
opacity: 0.3;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.empty-tip {
|
||||
text-align: center;
|
||||
padding: 50px;
|
||||
color: #999;
|
||||
}
|
||||
</style>
|
||||
142
src/views/pk-mini/Mine.vue
Normal file
142
src/views/pk-mini/Mine.vue
Normal file
@@ -0,0 +1,142 @@
|
||||
<template>
|
||||
<!-- 我的页面 -->
|
||||
<div class="mine-page">
|
||||
<!-- 顶部选项卡 -->
|
||||
<div class="tab-bar">
|
||||
<div
|
||||
v-for="item in tabs"
|
||||
:key="item.value"
|
||||
class="tab-item"
|
||||
:class="{ active: activeTab === item.value }"
|
||||
@click="activeTab = item.value"
|
||||
>
|
||||
<img class="tab-icon" :class="item.iconClass" :src="item.icon" alt="" />
|
||||
<span class="tab-label">{{ item.label }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 内容区 -->
|
||||
<div class="tab-content">
|
||||
<AnchorLibrary v-if="activeTab === 1" />
|
||||
<PKmessage v-if="activeTab === 2" />
|
||||
<PKRecord v-if="activeTab === 3" />
|
||||
<PointsList v-if="activeTab === 4" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import AnchorLibrary from '@/components/pk-mini/mine/AnchorLibrary.vue'
|
||||
import PKmessage from '@/components/pk-mini/mine/PKmessage.vue'
|
||||
import PKRecord from '@/components/pk-mini/mine/PKRecord.vue'
|
||||
import PointsList from '@/components/pk-mini/mine/PointsList.vue'
|
||||
|
||||
// 导入本地图片
|
||||
import iconAnchorLibrary from '@/assets/pk-mini/AnchorLibrary.png'
|
||||
import iconPKInformation from '@/assets/pk-mini/PKInformation.png'
|
||||
import iconPKRecord from '@/assets/pk-mini/PKRecord.png'
|
||||
import iconPointsList from '@/assets/pk-mini/PointsList.png'
|
||||
|
||||
const activeTab = ref(1)
|
||||
|
||||
const tabs = [
|
||||
{
|
||||
value: 1,
|
||||
label: '主播库',
|
||||
icon: iconAnchorLibrary
|
||||
},
|
||||
{
|
||||
value: 2,
|
||||
label: 'PK信息',
|
||||
icon: iconPKInformation,
|
||||
iconClass: 'pk-info-icon'
|
||||
},
|
||||
{
|
||||
value: 3,
|
||||
label: '我的PK记录',
|
||||
icon: iconPKRecord
|
||||
},
|
||||
{
|
||||
value: 4,
|
||||
label: '积分列表',
|
||||
icon: iconPointsList,
|
||||
iconClass: 'points-icon'
|
||||
}
|
||||
]
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.mine-page {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.tab-bar {
|
||||
width: 100%;
|
||||
height: 110px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
.tab-item {
|
||||
flex: 1;
|
||||
height: 90px;
|
||||
margin: 0 10px;
|
||||
border-radius: 24px;
|
||||
background-color: #cef1eb;
|
||||
border: 2px solid transparent;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.tab-item:hover {
|
||||
transform: scale(1.02);
|
||||
}
|
||||
|
||||
.tab-item.active {
|
||||
background: linear-gradient(90deg, #e4ffff, #ffffff);
|
||||
border-color: #03aba8;
|
||||
}
|
||||
|
||||
.tab-icon {
|
||||
width: 65px;
|
||||
height: 65px;
|
||||
margin-right: 20px;
|
||||
}
|
||||
|
||||
.tab-icon.pk-info-icon {
|
||||
width: 50px;
|
||||
height: 72px;
|
||||
}
|
||||
|
||||
.tab-icon.points-icon {
|
||||
width: 65px;
|
||||
height: 69px;
|
||||
}
|
||||
|
||||
.tab-label {
|
||||
font-size: 24px;
|
||||
color: #636363;
|
||||
}
|
||||
|
||||
.tab-item.active .tab-label {
|
||||
color: #03aba8;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.tab-content {
|
||||
flex: 1;
|
||||
height: calc(100% - 110px);
|
||||
background-color: #ffffff;
|
||||
border-radius: 16px;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
865
src/views/pk-mini/PkHall.vue
Normal file
865
src/views/pk-mini/PkHall.vue
Normal file
@@ -0,0 +1,865 @@
|
||||
<template>
|
||||
<!-- PK 大厅页面 -->
|
||||
<div class="pk-hall">
|
||||
<!-- 顶部筛选面板 - 固定高度 -->
|
||||
<div class="control-panel">
|
||||
<!-- PK大厅/今日PK 切换 -->
|
||||
<div class="switch-box">
|
||||
<div class="switch-text" @click="switchMode">PK大厅</div>
|
||||
<div class="switch-text" @click="switchMode">今日PK</div>
|
||||
<div class="switch-slider" :class="{ 'slide-right': !isHallMode }">
|
||||
{{ isHallMode ? 'PK大厅' : '今日PK' }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 国家和性别选择 -->
|
||||
<div class="select-box">
|
||||
<el-select-v2
|
||||
v-model="countryValue"
|
||||
:options="countryOptions"
|
||||
placeholder="国家"
|
||||
filterable
|
||||
clearable
|
||||
class="filter-select"
|
||||
/>
|
||||
<el-select-v2
|
||||
v-model="genderValue"
|
||||
:options="genderOptions"
|
||||
placeholder="性别"
|
||||
clearable
|
||||
class="filter-select"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- 金币数量 -->
|
||||
<div class="coin-box">
|
||||
<div class="coin-item">
|
||||
<div class="coin-label">最小金币数(单位为K)</div>
|
||||
<el-input-number v-model="minCoin" :min="0" controls-position="right" />
|
||||
</div>
|
||||
<div class="coin-item">
|
||||
<div class="coin-label">最大金币数(单位为K)</div>
|
||||
<el-input-number v-model="maxCoin" :min="0" controls-position="right" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 时间选择 (仅PK大厅模式) -->
|
||||
<div class="time-box" :class="{ 'is-hidden': !isHallMode }">
|
||||
|
||||
<el-date-picker
|
||||
v-model="timeRange"
|
||||
type="datetimerange"
|
||||
range-separator="至"
|
||||
start-placeholder="最小PK时间"
|
||||
end-placeholder="最大PK时间"
|
||||
format="YYYY/MM/DD HH:mm"
|
||||
value-format="x"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- 搜索和重置按钮 -->
|
||||
<div class="btn-box">
|
||||
<div class="search-btn" @click="handleSearch">
|
||||
<img class="btn-icon" :src="iconSearch" alt="" />
|
||||
<span>搜索</span>
|
||||
</div>
|
||||
<div class="reset-btn" @click="handleReset">
|
||||
<img class="btn-icon" :src="iconReset" alt="" />
|
||||
<span>重置</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 列表和聊天区域 -->
|
||||
<el-splitter class="pk-splitter">
|
||||
<el-splitter-panel>
|
||||
<el-splitter>
|
||||
<!-- 列表面板 -->
|
||||
<el-splitter-panel :size="70" :resizable="false">
|
||||
<div class="list-panel">
|
||||
<div
|
||||
v-infinite-scroll="loadMore"
|
||||
:infinite-scroll-distance="100"
|
||||
class="pk-list"
|
||||
>
|
||||
<div
|
||||
v-for="(item, index) in pkList"
|
||||
:key="index"
|
||||
class="pk-card"
|
||||
:class="{ selected: selectedItem === item }"
|
||||
@click="handleItemClick(item)"
|
||||
>
|
||||
<!-- 头像 -->
|
||||
<div class="pk-avatar">
|
||||
<img :src="item.anchorIcon" alt="" />
|
||||
</div>
|
||||
<div class="pk-info">
|
||||
<!-- 个人信息 -->
|
||||
<div class="pk-personal">
|
||||
<span class="pk-name">{{ item.disPlayId }}</span>
|
||||
<span class="pk-gender" :class="item.sex === 1 ? 'male' : 'female'">
|
||||
{{ item.sex === 1 ? '男' : '女' }}
|
||||
</span>
|
||||
<span class="pk-country">{{ item.country }}</span>
|
||||
</div>
|
||||
<!-- 时间 -->
|
||||
<div class="pk-time">PK时间(本地时间): {{ formatTime(item.pkTime * 1000) }}</div>
|
||||
<!-- PK信息 -->
|
||||
<div class="pk-stats">
|
||||
<img class="stat-icon" src="https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/gold.png" alt="" />
|
||||
<span>金币: {{ item.coin }}K</span>
|
||||
<img class="stat-icon session-icon" src="https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/session.png" alt="" />
|
||||
<span>场次: {{ item.pkNumber }}场</span>
|
||||
</div>
|
||||
<!-- 备注 -->
|
||||
<div class="pk-remark">{{ item.remark }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="pkList.length === 0" class="empty-tip">暂无数据</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-splitter-panel>
|
||||
|
||||
<!-- 聊天面板 -->
|
||||
<el-splitter-panel :size="30" :resizable="false">
|
||||
<div class="chat-panel">
|
||||
<div v-if="selectedItem" class="chat-container">
|
||||
<div class="chat-header">{{ chatUserInfo.nickName || '聊天' }}</div>
|
||||
<div class="chat-messages" ref="chatMessagesRef">
|
||||
<div
|
||||
v-for="(msg, index) in messagesList"
|
||||
:key="index"
|
||||
class="message-item"
|
||||
:class="{ mine: msg.senderId == currentUser.id }"
|
||||
>
|
||||
<div class="message-avatar">
|
||||
<img :src="msg.senderId == currentUser.id ? currentUser.headerIcon : chatUserInfo.headerIcon" alt="" />
|
||||
</div>
|
||||
<div class="message-triangle" v-if="msg.type === 'text'"></div>
|
||||
<div class="message-content">
|
||||
<div v-if="msg.type === 'text'" class="text-message">{{ msg.payload.text }}</div>
|
||||
<PictureMessage v-else-if="msg.type === 'image'" :item="msg" />
|
||||
<MiniPKMessage v-else-if="msg.type === 'pk'" :item="msg" />
|
||||
<VoiceMessage v-else-if="msg.type === 'audio'" :item="msg.payload.url" :size="msg.payload.duration" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 聊天输入区 -->
|
||||
<div class="chat-input-area">
|
||||
<div class="input-controls">
|
||||
<div class="control-btns">
|
||||
<div class="control-btn" @click="handleSendImage">
|
||||
<img src="https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/Album.png" alt="" />
|
||||
</div>
|
||||
<div class="control-btn" @click="handleInvite">
|
||||
<img src="https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/chat_invite.png" alt="" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="send-btn" @click="sendMessage">发送</div>
|
||||
</div>
|
||||
<div class="input-box">
|
||||
<textarea
|
||||
v-model="inputText"
|
||||
placeholder="输入消息..."
|
||||
@keydown.enter.prevent="sendMessage"
|
||||
></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="chat-placeholder">
|
||||
<span>右方选择主播立即聊天</span>
|
||||
</div>
|
||||
</div>
|
||||
</el-splitter-panel>
|
||||
</el-splitter>
|
||||
</el-splitter-panel>
|
||||
</el-splitter>
|
||||
|
||||
<!-- 隐藏的文件输入 -->
|
||||
<input
|
||||
ref="fileInputRef"
|
||||
type="file"
|
||||
accept="image/*"
|
||||
style="display: none"
|
||||
@change="handleFileSelect"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted, onUnmounted } from 'vue'
|
||||
import { getPkList, getUserInfo } from '@/api/pk-mini'
|
||||
import { getCountryNamesArray } from '@/utils/pk-mini/countryUtil'
|
||||
import { TimestamptolocalTime } from '@/utils/pk-mini/timeConversion'
|
||||
import { getMainUserData } from '@/utils/pk-mini/storage'
|
||||
// GoEasy 暂时禁用(订阅未续费)
|
||||
// import {
|
||||
// goEasyGetMessages,
|
||||
// goEasySendMessage,
|
||||
// goEasySendImageMessage,
|
||||
// goEasyMessageRead,
|
||||
// getPkGoEasy
|
||||
// } from '@/utils/pk-mini/goeasy'
|
||||
// import GoEasy from 'goeasy'
|
||||
import PictureMessage from '@/components/pk-mini/chat/PictureMessage.vue'
|
||||
import MiniPKMessage from '@/components/pk-mini/chat/MiniPKMessage.vue'
|
||||
import VoiceMessage from '@/components/pk-mini/chat/VoiceMessage.vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
|
||||
// 导入本地图片
|
||||
import iconSearch from '@/assets/pk-mini/Search.png'
|
||||
import iconReset from '@/assets/pk-mini/Reset.png'
|
||||
|
||||
// 获取用户 ID(兼容不同的字段名)
|
||||
function getUserId(user) {
|
||||
return user?.id || user?.userId || user?.uid || null
|
||||
}
|
||||
|
||||
// 状态
|
||||
const isHallMode = ref(true) // true: PK大厅, false: 今日PK
|
||||
const countryValue = ref(null)
|
||||
const genderValue = ref(null)
|
||||
const minCoin = ref(null)
|
||||
const maxCoin = ref(null)
|
||||
const timeRange = ref(null)
|
||||
const pkList = ref([])
|
||||
const hallList = ref([])
|
||||
const todayList = ref([])
|
||||
const page = ref(0)
|
||||
const selectedItem = ref(null)
|
||||
const chatUserInfo = ref({})
|
||||
const messagesList = ref([])
|
||||
const inputText = ref('')
|
||||
const currentUser = ref({})
|
||||
const chatMessagesRef = ref(null)
|
||||
const fileInputRef = ref(null)
|
||||
|
||||
const countryOptions = ref([])
|
||||
const genderOptions = [
|
||||
{ value: 1, label: '男' },
|
||||
{ value: 2, label: '女' }
|
||||
]
|
||||
|
||||
const formatTime = TimestamptolocalTime
|
||||
|
||||
// 切换 PK大厅/今日PK
|
||||
function switchMode() {
|
||||
isHallMode.value = !isHallMode.value
|
||||
selectedItem.value = null
|
||||
if (isHallMode.value) {
|
||||
pkList.value = hallList.value
|
||||
} else {
|
||||
pkList.value = todayList.value
|
||||
}
|
||||
}
|
||||
|
||||
// 搜索
|
||||
function handleSearch() {
|
||||
page.value = 0
|
||||
if (isHallMode.value) {
|
||||
hallList.value = []
|
||||
} else {
|
||||
todayList.value = []
|
||||
}
|
||||
pkList.value = []
|
||||
loadPkList()
|
||||
}
|
||||
|
||||
// 重置
|
||||
function handleReset() {
|
||||
countryValue.value = null
|
||||
genderValue.value = null
|
||||
minCoin.value = null
|
||||
maxCoin.value = null
|
||||
timeRange.value = null
|
||||
handleSearch()
|
||||
}
|
||||
|
||||
// 加载更多
|
||||
function loadMore() {
|
||||
loadPkList()
|
||||
}
|
||||
|
||||
// 加载PK列表
|
||||
async function loadPkList() {
|
||||
const userId = getUserId(currentUser.value)
|
||||
if (!userId) return
|
||||
|
||||
const body = {
|
||||
status: 0,
|
||||
page: page.value,
|
||||
size: 10,
|
||||
userId: userId,
|
||||
condition: {
|
||||
type: isHallMode.value ? 2 : 1
|
||||
}
|
||||
}
|
||||
|
||||
if (countryValue.value) body.condition.country = countryValue.value
|
||||
if (genderValue.value) body.condition.sex = genderValue.value
|
||||
|
||||
if (minCoin.value != null && maxCoin.value != null) {
|
||||
body.condition.coin = { start: minCoin.value, end: maxCoin.value }
|
||||
} else if (minCoin.value != null && maxCoin.value == null) {
|
||||
ElMessage.error('请输入最大金币数')
|
||||
return
|
||||
} else if (minCoin.value == null && maxCoin.value != null) {
|
||||
ElMessage.error('请输入最小金币数')
|
||||
return
|
||||
}
|
||||
|
||||
if (timeRange.value && isHallMode.value) {
|
||||
body.condition.pkTime = {
|
||||
start: timeRange.value[0] / 1000,
|
||||
end: timeRange.value[1] / 1000
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await getPkList(body)
|
||||
if (res && res.length > 0) {
|
||||
if (isHallMode.value) {
|
||||
hallList.value.push(...res)
|
||||
pkList.value = hallList.value
|
||||
} else {
|
||||
todayList.value.push(...res)
|
||||
pkList.value = todayList.value
|
||||
}
|
||||
page.value++
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('加载 PK 列表失败', e)
|
||||
}
|
||||
}
|
||||
|
||||
// 点击主播卡片
|
||||
async function handleItemClick(item) {
|
||||
selectedItem.value = item
|
||||
|
||||
try {
|
||||
const res = await getUserInfo({ id: item.senderId })
|
||||
chatUserInfo.value = res
|
||||
|
||||
// GoEasy 暂时禁用,聊天功能不可用
|
||||
messagesList.value = []
|
||||
ElMessage.warning('聊天功能暂时不可用(GoEasy 订阅未续费)')
|
||||
} catch (e) {
|
||||
console.error('获取聊天信息失败', e)
|
||||
}
|
||||
}
|
||||
|
||||
function onMessageReceived(message) {
|
||||
// GoEasy 暂时禁用
|
||||
}
|
||||
|
||||
function scrollToBottom() {
|
||||
if (chatMessagesRef.value) {
|
||||
chatMessagesRef.value.scrollTop = chatMessagesRef.value.scrollHeight
|
||||
}
|
||||
}
|
||||
|
||||
// 发送消息
|
||||
async function sendMessage() {
|
||||
// GoEasy 暂时禁用
|
||||
ElMessage.warning('聊天功能暂时不可用(GoEasy 订阅未续费)')
|
||||
}
|
||||
|
||||
// 发送图片
|
||||
function handleSendImage() {
|
||||
// GoEasy 暂时禁用
|
||||
ElMessage.warning('聊天功能暂时不可用(GoEasy 订阅未续费)')
|
||||
}
|
||||
|
||||
async function handleFileSelect(event) {
|
||||
// GoEasy 暂时禁用
|
||||
event.target.value = ''
|
||||
}
|
||||
|
||||
// PK邀请
|
||||
function handleInvite() {
|
||||
ElMessage.info('PK邀请功能开发中')
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
countryOptions.value = getCountryNamesArray()
|
||||
currentUser.value = getMainUserData() || {}
|
||||
const userId = getUserId(currentUser.value)
|
||||
|
||||
console.log('[PkHall] 当前用户数据:', currentUser.value)
|
||||
console.log('[PkHall] 解析的用户 ID:', userId)
|
||||
|
||||
// 同时加载今日PK和PK大厅数据
|
||||
if (userId) {
|
||||
// 加载今日PK
|
||||
getPkList({
|
||||
status: 0,
|
||||
page: 0,
|
||||
size: 10,
|
||||
userId: userId,
|
||||
condition: { type: 1 }
|
||||
}).then(res => {
|
||||
todayList.value = res || []
|
||||
}).catch(() => {})
|
||||
|
||||
// 加载PK大厅
|
||||
getPkList({
|
||||
status: 0,
|
||||
page: 0,
|
||||
size: 10,
|
||||
userId: userId,
|
||||
condition: { type: 2 }
|
||||
}).then(res => {
|
||||
hallList.value = res || []
|
||||
pkList.value = hallList.value
|
||||
page.value = 1
|
||||
}).catch(() => {})
|
||||
} else {
|
||||
console.warn('[PkHall] 未找到用户 ID,无法加载数据')
|
||||
}
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
// GoEasy 暂时禁用
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.pk-hall {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: white;
|
||||
border-radius: 16px;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
// 顶部控制面板 - 固定高度
|
||||
.control-panel {
|
||||
width: 100%;
|
||||
height: 100px;
|
||||
min-height: 100px;
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-around;
|
||||
padding: 0 20px;
|
||||
background: linear-gradient(180deg, #f0fffe, #ffffff);
|
||||
border-bottom: 1px solid #e0f0f0;
|
||||
}
|
||||
|
||||
.pk-splitter {
|
||||
flex: 1;
|
||||
height: calc(100% - 100px);
|
||||
}
|
||||
|
||||
// 切换按钮
|
||||
.switch-box {
|
||||
position: relative;
|
||||
width: 280px;
|
||||
height: 50px;
|
||||
background-color: #4fcacd;
|
||||
border-radius: 25px;
|
||||
box-shadow: -3px 3px 4px #45aaac inset;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.switch-text {
|
||||
width: 50%;
|
||||
height: 50px;
|
||||
text-align: center;
|
||||
color: #ffffff;
|
||||
font-size: 18px;
|
||||
line-height: 50px;
|
||||
cursor: pointer;
|
||||
z-index: 1;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.switch-slider {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 140px;
|
||||
height: 50px;
|
||||
border-radius: 25px;
|
||||
color: #03aba8;
|
||||
text-align: center;
|
||||
line-height: 50px;
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
background: linear-gradient(180deg, #e4ffff, #ffffff);
|
||||
transition: left 0.3s ease;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.switch-slider.slide-right {
|
||||
left: 140px;
|
||||
}
|
||||
|
||||
// 选择器
|
||||
.select-box {
|
||||
display: flex;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.filter-select {
|
||||
width: 140px;
|
||||
}
|
||||
|
||||
// 金币输入
|
||||
.coin-box {
|
||||
display: flex;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.coin-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.coin-label {
|
||||
font-size: 11px;
|
||||
color: #999;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
// 时间选择
|
||||
.time-box {
|
||||
width: 380px;
|
||||
}
|
||||
|
||||
// 按钮
|
||||
.btn-box {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.search-btn, .reset-btn {
|
||||
width: 80px;
|
||||
height: 30px;
|
||||
border-radius: 5px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 5px;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.search-btn {
|
||||
background: linear-gradient(0deg, #4FCACD, #5FDBDE);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.reset-btn {
|
||||
background: white;
|
||||
border: 1px solid #03aba8;
|
||||
color: #03aba8;
|
||||
}
|
||||
|
||||
.search-btn:hover, .reset-btn:hover {
|
||||
transform: scale(1.05);
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.btn-icon {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
// 列表面板
|
||||
.list-panel {
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.pk-list {
|
||||
height: 100%;
|
||||
overflow: auto;
|
||||
padding: 15px;
|
||||
background: white;
|
||||
border-radius: 16px 0 0 16px;
|
||||
}
|
||||
|
||||
.pk-card {
|
||||
display: flex;
|
||||
padding: 20px;
|
||||
margin-bottom: 15px;
|
||||
background: url('https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/PKbackground.png') no-repeat center/cover;
|
||||
border-radius: 12px;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.pk-card:hover {
|
||||
box-shadow: 0 0 10px rgba(0,0,0,0.2);
|
||||
transform: scale(1.02);
|
||||
}
|
||||
|
||||
.pk-card.selected {
|
||||
background-color: #fffbfa;
|
||||
border: 1px solid #f4d0c9;
|
||||
}
|
||||
|
||||
.pk-avatar {
|
||||
width: 90px;
|
||||
height: 90px;
|
||||
border-radius: 50%;
|
||||
overflow: hidden;
|
||||
margin-right: 20px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.pk-avatar img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.pk-info {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.pk-personal {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.pk-name {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.pk-gender {
|
||||
padding: 2px 12px;
|
||||
border-radius: 10px;
|
||||
font-size: 12px;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.pk-gender.male {
|
||||
background: #59d8db;
|
||||
}
|
||||
|
||||
.pk-gender.female {
|
||||
background: #f3876f;
|
||||
}
|
||||
|
||||
.pk-country {
|
||||
padding: 2px 10px;
|
||||
background: #e4f9f9;
|
||||
border-radius: 10px;
|
||||
font-size: 12px;
|
||||
color: #03aba8;
|
||||
}
|
||||
|
||||
.pk-time {
|
||||
font-size: 14px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.pk-stats {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.stat-icon {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.session-icon {
|
||||
margin-left: 40px;
|
||||
}
|
||||
|
||||
.pk-remark {
|
||||
font-size: 13px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.empty-tip {
|
||||
text-align: center;
|
||||
padding: 50px;
|
||||
color: #03aba8;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
// 聊天面板
|
||||
.chat-panel {
|
||||
height: 100%;
|
||||
border-left: 1px solid #03aba82f;
|
||||
background: white;
|
||||
}
|
||||
|
||||
.chat-container {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.chat-header {
|
||||
height: 50px;
|
||||
text-align: center;
|
||||
line-height: 50px;
|
||||
font-weight: bold;
|
||||
color: #666;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
|
||||
.chat-messages {
|
||||
flex: 1;
|
||||
overflow: auto;
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
.message-item {
|
||||
display: flex;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.message-item.mine {
|
||||
flex-direction: row-reverse;
|
||||
}
|
||||
|
||||
.message-avatar {
|
||||
width: 45px;
|
||||
height: 45px;
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
margin: 0 10px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.message-avatar img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.message-triangle {
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-top: 8px solid transparent;
|
||||
border-right: 8px solid #f5f5f5;
|
||||
border-bottom: 8px solid transparent;
|
||||
margin-top: 14px;
|
||||
}
|
||||
|
||||
.message-item.mine .message-triangle {
|
||||
border-right: none;
|
||||
border-left: 8px solid #7bbd0093;
|
||||
}
|
||||
|
||||
.message-content {
|
||||
max-width: 65%;
|
||||
}
|
||||
|
||||
.text-message {
|
||||
padding: 10px 15px;
|
||||
background: #f5f5f5;
|
||||
border-radius: 10px;
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.message-item.mine .text-message {
|
||||
background: #7bbd0093;
|
||||
}
|
||||
|
||||
// 输入区域
|
||||
.chat-input-area {
|
||||
border-top: 1px solid #eee;
|
||||
}
|
||||
|
||||
.input-controls {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 10px 15px;
|
||||
background: #e4f9f9;
|
||||
}
|
||||
|
||||
.control-btns {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.control-btn {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
border-radius: 8px;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.control-btn:hover {
|
||||
background: white;
|
||||
box-shadow: 2px 2px 5px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.control-btn img {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
}
|
||||
|
||||
.send-btn {
|
||||
padding: 8px 20px;
|
||||
color: #03aba8;
|
||||
cursor: pointer;
|
||||
border-radius: 8px;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.send-btn:hover {
|
||||
background: #03aba82d;
|
||||
}
|
||||
|
||||
.input-box {
|
||||
padding: 10px 15px;
|
||||
}
|
||||
|
||||
.input-box textarea {
|
||||
width: 100%;
|
||||
height: 50px;
|
||||
border: none;
|
||||
outline: none;
|
||||
resize: none;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.chat-placeholder {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #03aba8;
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
|
||||
.time-box {
|
||||
width: 380px;
|
||||
transition: opacity 0.2s ease;
|
||||
}
|
||||
|
||||
.time-box.is-hidden {
|
||||
opacity: 0;
|
||||
visibility: hidden; // 仍然占位,但看不见
|
||||
pointer-events: none; // 不能点击
|
||||
}
|
||||
</style>
|
||||
107
src/views/pk-mini/PkMiniWorkbench.vue
Normal file
107
src/views/pk-mini/PkMiniWorkbench.vue
Normal file
@@ -0,0 +1,107 @@
|
||||
<template>
|
||||
<div class="pk-mini-workbench">
|
||||
<el-container class="pk-container">
|
||||
<!-- 左侧导航栏 -->
|
||||
<el-aside class="pk-aside" width="80px">
|
||||
<PkAppaside :active="activeTab" @navigate="handleNavigate" />
|
||||
</el-aside>
|
||||
<!-- 右侧主体内容 -->
|
||||
<el-main class="pk-main">
|
||||
<KeepAlive>
|
||||
<component :is="currentComponent" />
|
||||
</KeepAlive>
|
||||
</el-main>
|
||||
</el-container>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted, onUnmounted } from 'vue'
|
||||
import PkAppaside from '@/components/pk-mini/PkAppaside.vue'
|
||||
import PkHall from './PkHall.vue'
|
||||
import Forum from './Forum.vue'
|
||||
import Message from './Message.vue'
|
||||
import Mine from './Mine.vue'
|
||||
import { initPkGoEasy, goEasyLink, goEasyDisConnect } from '@/utils/pk-mini/goeasy'
|
||||
import { getOtp } from '@/api/pk-mini'
|
||||
import { getMainUserData } from '@/utils/pk-mini/storage'
|
||||
import { ElMessage } from 'element-plus'
|
||||
|
||||
const activeTab = ref('pk')
|
||||
|
||||
const componentMap = {
|
||||
pk: PkHall,
|
||||
forum: Forum,
|
||||
message: Message,
|
||||
mine: Mine
|
||||
}
|
||||
|
||||
const currentComponent = computed(() => componentMap[activeTab.value])
|
||||
|
||||
const handleNavigate = (tab) => {
|
||||
activeTab.value = tab
|
||||
}
|
||||
|
||||
// 自动连接 IM
|
||||
async function autoLinkIM() {
|
||||
try {
|
||||
const userData = getMainUserData()
|
||||
if (!userData || !userData.id) {
|
||||
console.log('PK Mini: 用户未登录,跳过 IM 连接')
|
||||
return
|
||||
}
|
||||
|
||||
const otp = await getOtp()
|
||||
const data = {
|
||||
id: String(userData.id),
|
||||
avatar: userData.headerIcon || '',
|
||||
nickname: userData.nickName || userData.username || '',
|
||||
key: otp
|
||||
}
|
||||
|
||||
await goEasyLink(data)
|
||||
console.log('PK Mini: IM 连接成功')
|
||||
} catch (err) {
|
||||
console.error('PK Mini: IM 连接失败', err)
|
||||
ElMessage.warning('PK工作台聊天系统连接失败')
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
// 初始化 GoEasy
|
||||
initPkGoEasy()
|
||||
// 自动连接 IM
|
||||
autoLinkIM()
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
// 断开 IM 连接
|
||||
goEasyDisConnect().catch(() => {})
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.pk-mini-workbench {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-image: url(@/assets/pk-mini/bg.png);
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
}
|
||||
|
||||
.pk-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.pk-aside {
|
||||
height: 100%;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.pk-main {
|
||||
height: 100%;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user