Files
ks-app-employment-service/pages/chat/chat.vue

329 lines
9.4 KiB
Vue
Raw Normal View History

2025-03-28 15:19:42 +08:00
<template>
<view class="container">
<!-- 抽屉遮罩层 -->
<view v-if="isDrawerOpen" class="overlay" @click="toggleDrawer"></view>
<!-- 抽屉窗口 -->
<view class="drawer" :class="{ open: isDrawerOpen }">
<view class="drawer-content">
2025-03-28 16:26:04 +08:00
<view class="drawer-title">AI+</view>
2025-03-29 11:51:48 +08:00
<view class="drawer-input-content">
<input
class="drawer-input"
type="text"
v-model="searchText"
placeholder-class="input-placeholder"
placeholder="请输入搜索历史对话"
/>
<uni-icons class="input-search" type="search" size="20"></uni-icons>
</view>
2025-03-28 15:19:42 +08:00
<scroll-view scroll-y :show-scrollbar="false" class="chat-scroll">
<view
class="drawer-rows"
@click="changeDialogue(item)"
2025-03-28 16:26:04 +08:00
v-for="(item, index) in filteredList"
2025-03-28 15:19:42 +08:00
:key="item.id"
>
<view
v-if="!item.isTitle"
class="drawer-row-list"
:class="{ 'drawer-row-active': item.sessionId === chatSessionID }"
>
{{ item.title }}
</view>
<view class="drawer-row-title" v-else>
{{ item.title }}
</view>
</view>
</scroll-view>
2025-03-29 11:51:48 +08:00
<view class="drawer-user">
2025-04-07 09:10:55 +08:00
<image class="drawer-user-img" v-if="userInfo.age === '0'" src="/static/icon/boy.png"></image>
<image class="drawer-user-img" v-else src="/static/icon/girl.png"></image>
<text>{{ userInfo.name || '暂无用户名' }}</text>
2025-05-13 11:10:38 +08:00
<!-- <image
2025-04-07 09:10:55 +08:00
class="drawer-user-setting button-click"
src="/static/icon/setting.png"
@click="updateSetting"
2025-05-13 11:10:38 +08:00
></image> -->
2025-03-29 11:51:48 +08:00
</view>
2025-03-28 15:19:42 +08:00
</view>
</view>
<!-- 主要内容挤压效果 -->
<view class="main-content" :class="{ shift: isDrawerOpen }">
<!-- header -->
<header class="head">
<view class="main-header">
<image src="/static/icon/Hamburger-button.png" @click="toggleDrawer"></image>
2025-09-29 11:53:10 +08:00
<view class="title">{{ config.appInfo.areaName }}岗位推荐</view>
2025-03-28 15:19:42 +08:00
<image src="/static/icon/Comment-one.png" @click="addNewDialogue"></image>
</view>
</header>
<view class="chatmain-warpper">
<ai-paging ref="paging"></ai-paging>
</view>
2025-06-26 08:56:42 +08:00
<!-- 自定义tabbar -->
<view class="chatmain-footer" v-show="!isDrawerOpen">
<Tabbar :currentpage="2"></Tabbar>
</view>
2025-03-28 15:19:42 +08:00
</view>
</view>
</template>
<script setup>
2025-03-28 16:26:04 +08:00
import { ref, inject, nextTick, computed } from 'vue';
2025-09-29 11:53:10 +08:00
const { $api, navTo, insertSortData, config } = inject('globalFunction');
2025-04-07 09:10:55 +08:00
import { onLoad, onShow, onHide } from '@dcloudio/uni-app';
2025-06-26 08:56:42 +08:00
import Tabbar from '@/components/tabbar/midell-box.vue';
2025-03-28 15:19:42 +08:00
import useChatGroupDBStore from '@/stores/userChatGroupStore';
2025-04-07 09:10:55 +08:00
import useUserStore from '@/stores/useUserStore';
2025-03-28 15:19:42 +08:00
import aiPaging from './components/ai-paging.vue';
import { storeToRefs } from 'pinia';
const { isTyping, tabeList, chatSessionID } = storeToRefs(useChatGroupDBStore());
2025-04-07 09:10:55 +08:00
const { userInfo } = storeToRefs(useUserStore());
2025-03-28 15:19:42 +08:00
const isDrawerOpen = ref(false);
const scrollIntoView = ref(false);
2025-03-28 16:26:04 +08:00
const searchText = ref('');
2025-03-28 15:19:42 +08:00
const paging = ref(null);
2025-03-28 16:26:04 +08:00
// 实时过滤
const filteredList = computed(() => {
2025-07-09 15:15:37 +08:00
// console.log(tabeList.value);
2025-03-28 16:26:04 +08:00
if (!searchText.value) return tabeList.value;
const list = tabeList.value.filter((item) => !item.isTitle && item.title.includes(searchText.value));
const [result, lastData] = $api.insertSortData(list);
return result;
});
2025-03-28 15:19:42 +08:00
onLoad(() => {
// useChatGroupDBStore().getHistory();
});
onShow(() => {
nextTick(() => {
paging.value?.colseFile();
});
});
2025-04-07 09:10:55 +08:00
onHide(() => {
paging.value?.handleTouchCancel();
2025-04-10 10:59:25 +08:00
if (isDrawerOpen.value) {
isDrawerOpen.value = false;
2025-06-26 08:56:42 +08:00
// uni.showTabBar();
2025-04-10 10:59:25 +08:00
}
2025-04-07 09:10:55 +08:00
});
2025-03-28 15:19:42 +08:00
const toggleDrawer = () => {
isDrawerOpen.value = !isDrawerOpen.value;
2025-04-10 10:59:25 +08:00
if (isDrawerOpen.value) {
2025-06-26 08:56:42 +08:00
// uni.hideTabBar();
2025-04-10 10:59:25 +08:00
} else {
2025-06-26 08:56:42 +08:00
// uni.showTabBar();
2025-04-10 10:59:25 +08:00
}
2025-03-28 15:19:42 +08:00
};
const addNewDialogue = () => {
$api.msg('新对话');
2025-04-07 09:10:55 +08:00
paging.value?.changeQueries();
2025-03-28 15:19:42 +08:00
useChatGroupDBStore().addNewDialogue();
};
const changeDialogue = (item) => {
if (item.sessionId) {
paging.value?.closeGuess();
useChatGroupDBStore().changeDialogue(item);
toggleDrawer();
nextTick(() => {
paging.value?.scrollToBottom();
});
}
};
2025-04-07 09:10:55 +08:00
function updateSetting() {
$api.msg('该功能正在开发中,敬请期待后续更新!');
}
2025-03-28 15:19:42 +08:00
</script>
<style lang="stylus" scoped>
2025-04-10 10:59:25 +08:00
header-height = 88rpx
2025-06-26 08:56:42 +08:00
footer-height = 98rpx
2025-04-16 14:24:06 +08:00
2025-03-28 15:19:42 +08:00
/* 页面容器 */
.container {
position: fixed;
2025-04-16 14:24:06 +08:00
z-index: 1000;
2025-03-28 15:19:42 +08:00
width: 100vw;
2025-04-16 14:24:06 +08:00
height: calc(100% - var(--window-bottom));
2025-03-28 15:19:42 +08:00
overflow: hidden;
}
/* 遮罩层 */
.overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.4);
z-index: 999;
}
/* 抽屉窗口 */
.drawer {
position: fixed;
top: 0;
left: 0; /* 如果要右侧弹出改为 right: 0; */
2025-03-28 16:26:04 +08:00
width: 523rpx;
2025-04-16 14:24:06 +08:00
height: 100%;
2025-03-28 15:19:42 +08:00
background: #e7e7e6;
transform: translateX(-100%);
transition: transform 0.3s ease-in-out;
z-index: 1000;
}
/* 抽屉展开 */
.drawer.open {
box-shadow: 4rpx 0 20rpx rgba(0, 0, 0, 0.2);
transform: translateX(0);
}
2025-03-28 16:26:04 +08:00
.drawer-input-content
margin: 0 28rpx
padding: 0 24rpx
height: 72rpx;
background: #F6F6F6;
border-radius: 16rpx 16rpx 16rpx 16rpx;
display: flex
align-items: center
justify-content: center
.drawer-input
font-size: 28rpx
width: 100%
.input-placeholder
font-weight: 500;
font-size: 28rpx;
color: #A6A6A6;
.input-search
margin-left: 20rpx
2025-03-28 15:19:42 +08:00
/* 抽屉内容 */
.drawer-content
height: 100%
2025-03-28 16:26:04 +08:00
background: #FFFFFF;
2025-03-29 11:51:48 +08:00
display: flex
flex-direction: column
.drawer-user
border-top: 1rpx solid rgba(0,0,0,.1);
padding: 20rpx 28rpx
display: flex
font-weight: 500;
align-items: center
position: relative
2025-04-10 10:59:25 +08:00
margin-bottom: calc( 32rpx + var(--window-bottom)); /*兼容 IOS<11.2*/
margin-bottom: calc( 32rpx +var(--window-bottom)); /*兼容 IOS>11.2*/
2025-04-07 09:10:55 +08:00
color: #000000
2025-03-29 11:51:48 +08:00
.drawer-user-img
width: 57.2rpx;
height: 57.2rpx
margin-right: 20rpx
.drawer-user-setting
2025-04-07 09:10:55 +08:00
width: 48rpx
height: 48rpx
2025-03-29 11:51:48 +08:00
position: absolute
top: 50%
right: 28rpx
transform: translate(0,-50%)
2025-03-28 15:19:42 +08:00
.drawer-title
2025-04-10 10:59:25 +08:00
height: header-height;
line-height: header-height;
2025-03-28 16:26:04 +08:00
padding: 0 52rpx;
color: #333333;
font-size: 32rpx
font-weight: bold
2025-03-28 15:19:42 +08:00
.chat-scroll
2025-03-29 11:51:48 +08:00
flex: 1
overflow: hidden
2025-03-28 15:19:42 +08:00
.drawer-rows
2025-03-28 16:26:04 +08:00
padding: 0 28rpx;
2025-03-28 15:19:42 +08:00
// border-bottom: 2rpx dashed #e8e8e8
overflow:hidden; //超出的文本隐藏
text-overflow:ellipsis; //溢出用省略号显示
white-space:nowrap; //溢出不换行
.drawer-row-title
2025-03-28 16:26:04 +08:00
color: #A6A6A6;
font-weight: 500;
2025-03-28 15:19:42 +08:00
font-weight: bold;
2025-03-28 16:26:04 +08:00
font-size: 28rpx
padding: 0 24rpx
margin-top: 50rpx
margin-bottom: 16rpx
2025-03-28 15:19:42 +08:00
.drawer-row-list
height: 66rpx;
line-height: 66rpx
font-size: 28rpx
overflow: hidden
text-overflow: ellipsis
2025-03-28 16:26:04 +08:00
font-weight: 500;
color: #595959;
padding: 0 24rpx
2025-03-28 15:19:42 +08:00
.drawer-row-active
.drawer-row-list:active
2025-03-28 16:26:04 +08:00
color: #333333;
background: #F6F6F6;
border-radius: 16rpx 16rpx 16rpx 16rpx;
2025-03-28 15:19:42 +08:00
/* 主要内容区域 */
.main-content
width: 100%;
2025-04-16 14:24:06 +08:00
height: 100%;
2025-03-28 15:19:42 +08:00
transition: margin-left 0.3s ease-in-out;
position: relative
background: #FFFFFF
2025-06-26 08:56:42 +08:00
display: flex
flex-direction: column
2025-03-28 15:19:42 +08:00
.head
display: block;
box-sizing: border-box;
2025-04-10 10:59:25 +08:00
height: header-height;
2025-03-28 15:19:42 +08:00
user-select: none;
.main-header
position: fixed;
left: var(--window-left);
right: var(--window-right);
2025-04-10 10:59:25 +08:00
height:header-height;
padding-top: calc(14rpx);
2025-03-28 15:19:42 +08:00
background: #FFFFFF
2025-04-16 14:24:06 +08:00
z-index: 1;
2025-03-28 15:19:42 +08:00
transition-property: all;
display: flex;
align-items: center;
justify-content: space-between
2025-04-07 09:10:55 +08:00
font-size: 32rpx
2025-03-28 15:19:42 +08:00
color: #000000
padding: 0 30rpx;
font-weight: bold
text-align: center
image
width: 36rpx;
height: 37rpx;
.chatmain-warpper
2025-06-26 08:56:42 +08:00
height: 'calc(100% - %s)' %( header-height + footer-height)
2025-03-28 15:19:42 +08:00
position: relative;
display: block;
box-sizing: border-box;
width: 100%;
2025-04-16 14:24:06 +08:00
border-top: 2rpx solid #F4F4F4;
2025-06-26 08:56:42 +08:00
flex: 1
2025-03-28 15:19:42 +08:00
/* 页面被挤压时向右移动 */
.main-content.shift {
margin-left: 500rpx;
}
2025-06-26 08:56:42 +08:00
.chatmain-footer{
height: footer-height;
}
</style>