|
@@ -35,8 +35,19 @@
|
|
|
<i class="el-icon-info"></i>
|
|
<i class="el-icon-info"></i>
|
|
|
<p>暂无会话数据</p>
|
|
<p>暂无会话数据</p>
|
|
|
</div>
|
|
</div>
|
|
|
- <!-- 聊天窗口 -->
|
|
|
|
|
- <div v-else id="chat-container" ref="chatContainer"></div>
|
|
|
|
|
|
|
+ <!-- 聊天窗口(含消息类型筛选) -->
|
|
|
|
|
+ <div v-else class="chat-wrapper">
|
|
|
|
|
+ <div class="msg-type-filter">
|
|
|
|
|
+ <span
|
|
|
|
|
+ v-for="opt in msgTypeOptions"
|
|
|
|
|
+ :key="String(opt.value)"
|
|
|
|
|
+ class="filter-item"
|
|
|
|
|
+ :class="{ active: msgTypeFilter === opt.value }"
|
|
|
|
|
+ @click="handleFilterChange(opt.value)"
|
|
|
|
|
+ >{{ opt.label }}</span>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div id="chat-container" ref="chatContainer"></div>
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
@@ -49,6 +60,17 @@ window._QW_CONFIG_CACHE = window._QW_CONFIG_CACHE || new Map();
|
|
|
window._QW_CONFIG_PENDING = window._QW_CONFIG_PENDING || new Map();
|
|
window._QW_CONFIG_PENDING = window._QW_CONFIG_PENDING || new Map();
|
|
|
const CACHE_TTL = 5 * 60 * 1000;
|
|
const CACHE_TTL = 5 * 60 * 1000;
|
|
|
|
|
|
|
|
|
|
+// 消息类型筛选选项(value 为 msgtype,null 表示全部)
|
|
|
|
|
+const MSG_TYPE_FILTER_OPTIONS = [
|
|
|
|
|
+ { value: null, label: '全部' },
|
|
|
|
|
+ { value: 1, label: '文本' },
|
|
|
|
|
+ { value: 6, label: '语音' },
|
|
|
|
|
+ { value: 2, label: '图片' },
|
|
|
|
|
+ { value: 7, label: '视频' },
|
|
|
|
|
+ { value: 4, label: '链接' },
|
|
|
|
|
+ { value: 22, label: '语音通话' }
|
|
|
|
|
+];
|
|
|
|
|
+
|
|
|
function getCachedConfig(corpId) {
|
|
function getCachedConfig(corpId) {
|
|
|
if (!corpId) return null;
|
|
if (!corpId) return null;
|
|
|
const cached = window._QW_CONFIG_CACHE.get(corpId);
|
|
const cached = window._QW_CONFIG_CACHE.get(corpId);
|
|
@@ -77,6 +99,8 @@ export default {
|
|
|
isLoggedIn: false,
|
|
isLoggedIn: false,
|
|
|
isReady: false,
|
|
isReady: false,
|
|
|
msgList: [],
|
|
msgList: [],
|
|
|
|
|
+ msgTypeFilter: null,
|
|
|
|
|
+ msgTypeOptions: MSG_TYPE_FILTER_OPTIONS,
|
|
|
cursor: '',
|
|
cursor: '',
|
|
|
hasMore: true,
|
|
hasMore: true,
|
|
|
loadingMore: false,
|
|
loadingMore: false,
|
|
@@ -93,6 +117,12 @@ export default {
|
|
|
_loginPanelTimer: null
|
|
_loginPanelTimer: null
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
|
|
+ computed: {
|
|
|
|
|
+ filteredMsgList() {
|
|
|
|
|
+ if (!this.msgTypeFilter) return this.msgList;
|
|
|
|
|
+ return this.msgList.filter(m => m.msgtype === this.msgTypeFilter);
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
watch: {
|
|
watch: {
|
|
|
customerId(newId, oldId) {
|
|
customerId(newId, oldId) {
|
|
|
if (newId && newId !== oldId && this.isLoggedIn && (this.staffUserId || this.chatId) && this.configReady && !this.configError) {
|
|
if (newId && newId !== oldId && this.isLoggedIn && (this.staffUserId || this.chatId) && this.configReady && !this.configError) {
|
|
@@ -432,7 +462,7 @@ export default {
|
|
|
this.msgList.push(...processed);
|
|
this.msgList.push(...processed);
|
|
|
this.cursor = data.next_cursor || '';
|
|
this.cursor = data.next_cursor || '';
|
|
|
this.hasMore = data.has_more === 1;
|
|
this.hasMore = data.has_more === 1;
|
|
|
- if (this.chatInstance) this.chatInstance.setData({ msgList: this.msgList });
|
|
|
|
|
|
|
+ if (this.chatInstance) this.chatInstance.setData({ msgList: this.filteredMsgList });
|
|
|
else await this.renderOrUpdateChat();
|
|
else await this.renderOrUpdateChat();
|
|
|
} else {
|
|
} else {
|
|
|
this.hasMore = false;
|
|
this.hasMore = false;
|
|
@@ -465,12 +495,25 @@ export default {
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
|
|
+
|
|
|
|
|
+ // 消息类型筛选
|
|
|
|
|
+ handleFilterChange(type) {
|
|
|
|
|
+ this.msgTypeFilter = type;
|
|
|
|
|
+ if (this.chatInstance) {
|
|
|
|
|
+ this.chatInstance.setData({
|
|
|
|
|
+ msgList: this.filteredMsgList,
|
|
|
|
|
+ hasMore: this.hasMore,
|
|
|
|
|
+ loadingMore: this.loadingMore
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
async renderOrUpdateChat() {
|
|
async renderOrUpdateChat() {
|
|
|
if (this.msgList.length === 0 || this.configError) return;
|
|
if (this.msgList.length === 0 || this.configError) return;
|
|
|
const container = document.getElementById('chat-container');
|
|
const container = document.getElementById('chat-container');
|
|
|
if (!container) return;
|
|
if (!container) return;
|
|
|
if (this.chatInstance) {
|
|
if (this.chatInstance) {
|
|
|
- this.chatInstance.setData({ msgList: this.msgList });
|
|
|
|
|
|
|
+ this.chatInstance.setData({ msgList: this.filteredMsgList });
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
const ok = await this.initSDKOnce();
|
|
const ok = await this.initSDKOnce();
|
|
@@ -563,7 +606,7 @@ export default {
|
|
|
}
|
|
}
|
|
|
`,
|
|
`,
|
|
|
data: {
|
|
data: {
|
|
|
- msgList: this.msgList,
|
|
|
|
|
|
|
+ msgList: this.filteredMsgList,
|
|
|
hasMore: this.hasMore,
|
|
hasMore: this.hasMore,
|
|
|
loadingMore: this.loadingMore
|
|
loadingMore: this.loadingMore
|
|
|
},
|
|
},
|
|
@@ -649,6 +692,37 @@ export default {
|
|
|
background: #f5f6f7;
|
|
background: #f5f6f7;
|
|
|
position: relative;
|
|
position: relative;
|
|
|
}
|
|
}
|
|
|
|
|
+.chat-wrapper {
|
|
|
|
|
+ flex: 1;
|
|
|
|
|
+ min-height: 0;
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ flex-direction: column;
|
|
|
|
|
+ overflow: hidden;
|
|
|
|
|
+}
|
|
|
|
|
+.msg-type-filter {
|
|
|
|
|
+ flex-shrink: 0;
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ gap: 4px;
|
|
|
|
|
+ padding: 8px 12px;
|
|
|
|
|
+ background: #fff;
|
|
|
|
|
+ border-bottom: 1px solid #e8e8e8;
|
|
|
|
|
+ flex-wrap: wrap;
|
|
|
|
|
+}
|
|
|
|
|
+.filter-item {
|
|
|
|
|
+ padding: 4px 12px;
|
|
|
|
|
+ font-size: 13px;
|
|
|
|
|
+ color: #606266;
|
|
|
|
|
+ cursor: pointer;
|
|
|
|
|
+ border-radius: 14px;
|
|
|
|
|
+ user-select: none;
|
|
|
|
|
+}
|
|
|
|
|
+.filter-item:hover {
|
|
|
|
|
+ color: #409eff;
|
|
|
|
|
+}
|
|
|
|
|
+.filter-item.active {
|
|
|
|
|
+ background: #409eff;
|
|
|
|
|
+ color: #fff;
|
|
|
|
|
+}
|
|
|
.login-area, .empty-tip, .loading-tip {
|
|
.login-area, .empty-tip, .loading-tip {
|
|
|
display: flex;
|
|
display: flex;
|
|
|
flex-direction: column;
|
|
flex-direction: column;
|
|
@@ -672,8 +746,8 @@ export default {
|
|
|
}
|
|
}
|
|
|
#chat-container {
|
|
#chat-container {
|
|
|
flex: 1;
|
|
flex: 1;
|
|
|
|
|
+ min-height: 0;
|
|
|
width: 100%;
|
|
width: 100%;
|
|
|
- height: 100%;
|
|
|
|
|
background: #f0f2f5;
|
|
background: #f0f2f5;
|
|
|
}
|
|
}
|
|
|
.login-container {
|
|
.login-container {
|
|
@@ -686,7 +760,9 @@ export default {
|
|
|
</style>
|
|
</style>
|
|
|
|
|
|
|
|
<style>
|
|
<style>
|
|
|
-#chat-container,
|
|
|
|
|
|
|
+#chat-container {
|
|
|
|
|
+ width: 100% !important;
|
|
|
|
|
+}
|
|
|
#chat-container > div,
|
|
#chat-container > div,
|
|
|
#chat-container iframe {
|
|
#chat-container iframe {
|
|
|
width: 100% !important;
|
|
width: 100% !important;
|