feat(咨询页面): 添加咨询页面tab切换功能并优化首页布局

This commit is contained in:
yangzhe 2025-10-28 11:49:44 +08:00
parent 32005433fc
commit 9327eb673a
7 changed files with 134 additions and 53 deletions

View File

@ -8,16 +8,29 @@
@click="handleLeftClick" @click="handleLeftClick"
></u-icon> ></u-icon>
</div> </div>
<text class="header-title">招办在线</text> <text class="header-title">在线咨询</text>
<div></div> <div></div>
</view> </view>
<view class="admissions-content"> <view class="admissions-content">
<!-- 自定义tab -->
<view class="custom-tab">
<view
v-for="tab in tabList"
:key="tab.id"
:class="['tab-item', { active: activeTab === tab.id }]"
@click="switchTab(tab.id)"
>
<text class="tab-text">{{ tab.name }}</text>
<view class="tab-underline" v-if="activeTab === tab.id"></view>
</view>
</view>
<view class="teacher-list"> <view class="teacher-list">
<!-- 教师列表 --> <!-- 教师列表 -->
<view <view
class="teacher-item" class="teacher-item"
v-for="(teacher, index) in teacherList" v-for="(teacher, index) in currentList"
:key="index" :key="index"
> >
<image class="teacher-avatar" :src="teacher.avatar"></image> <image class="teacher-avatar" :src="teacher.avatar"></image>
@ -32,9 +45,9 @@
</view> </view>
<view class="teacher-department">{{ teacher.department }}</view> <view class="teacher-department">{{ teacher.department }}</view>
</view> </view>
<view class="ask-button" @click="handleAskQuestion(teacher)">{{ <view class="ask-button" @click="handleAskQuestion(teacher)">
teacher.online ? "立即提问" : "留言" 立即提问
}}</view> </view>
</view> </view>
</view> </view>
</view> </view>
@ -58,6 +71,11 @@ export default {
}, },
data() { data() {
return { return {
activeTab: "1", // tab
tabList: [
{ id: "1", name: "招生在线", key: "admissions" },
{ id: "2", name: "迎新在线", key: "welcome" },
],
showLeaveMessage: false, showLeaveMessage: false,
teacherList: [ teacherList: [
{ {
@ -89,10 +107,41 @@ export default {
online: false, online: false,
}, },
], ],
welcomeList: [
{
id: 5,
name: "李老师",
department: "学生处",
avatar: "/static/common/images/avatar.png",
online: true,
},
{
id: 6,
name: "张老师",
department: "宿管中心",
avatar: "/static/common/images/student.png",
online: true,
},
{
id: 7,
name: "迎新办陈老师",
department: "后勤服务中心",
avatar: "/static/common/images/student.png",
online: false,
},
],
currentTeacher: null, currentTeacher: null,
}; };
}, },
computed: {
currentList() {
return this.activeTab === "1" ? this.teacherList : this.welcomeList;
},
},
methods: { methods: {
switchTab(tab) {
this.activeTab = tab;
},
handleLeftClick() { handleLeftClick() {
uni.navigateBack(); uni.navigateBack();
}, },
@ -159,6 +208,44 @@ export default {
} }
.admissions-content { .admissions-content {
.custom-tab {
padding: 0 30rpx;
margin: 24rpx 0;
display: flex;
align-items: center;
.tab-item {
position: relative;
padding: 12rpx 0;
margin-right: 60rpx;
cursor: pointer;
.tab-text {
font-size: 32rpx;
font-weight: 500;
color: #505866;
letter-spacing: 0.04rpx;
}
&.active .tab-text {
color: #4f6aff;
font-weight: 600;
}
.tab-underline {
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
right: 0;
width: 80rpx;
height: 4rpx;
background-color: #4f6aff;
border-radius: 2rpx;
}
}
}
.teacher-list { .teacher-list {
.teacher-item { .teacher-item {
display: flex; display: flex;

View File

@ -19,7 +19,7 @@
> >
</view> </view>
<!-- <view class="qa-section"> <view class="qa-section">
<view class="qa-header"> <view class="qa-header">
<text class="qa-title">大家都在问</text> <text class="qa-title">大家都在问</text>
<view class="more-link"> <view class="more-link">
@ -37,16 +37,6 @@
</view> </view>
</view> </view>
<button class="chat-button" @click="isChat = true">
<image
class="chat-icon"
src="/static/common/images/icon_chat.png"
></image>
<text class="chat-text">开启对话</text>
</button>
</view> -->
<view class="start-chat">
<button class="chat-button" @click="handleStartChat"> <button class="chat-button" @click="handleStartChat">
<image <image
class="chat-icon" class="chat-icon"
@ -61,6 +51,9 @@
class="feature-item" class="feature-item"
v-for="(item, index) in features" v-for="(item, index) in features"
:key="index" :key="index"
:style="{
background: item.background,
}"
@click="handleFeatureClick(item)" @click="handleFeatureClick(item)"
> >
<image :src="item.icon" class="feature-icon"></image> <image :src="item.icon" class="feature-icon"></image>
@ -111,7 +104,7 @@
<view class="loading-more" v-if="isLoading"> <view class="loading-more" v-if="isLoading">
<u-loading mode="circle" color="#4370fe"></u-loading> <u-loading mode="circle" color="#4370fe"></u-loading>
</view> </view>
<!-- 到顶部提示 --> <!-- 到顶部提示 -->
<view class="no-more-data" v-if="noMoreData"> <view class="no-more-data" v-if="noMoreData">
<text>已经到顶了</text> <text>已经到顶了</text>
@ -279,7 +272,7 @@ export default {
isLoadingMore: false, // isLoadingMore: false, //
noMoreData: false, // noMoreData: false, //
isSwitchingConversation: false, // isSwitchingConversation: false, //
pageQuery: { pageQuery: {
PageIndex: 1, PageIndex: 1,
PageSize: 20, PageSize: 20,
@ -294,18 +287,20 @@ export default {
], ],
features: [ features: [
{ {
title: "招办在线", title: "在线咨询",
icon: "/static/common/images/icon_admissions.png", icon: "/static/common/images/icon_admissions.png",
path: "/pages/home/admissions/index", path: "/pages/home/admissions/index",
background: "linear-gradient(0deg, #F4FBFE 0%, #F4FBFE 100%)",
}, },
{ // {
title: "留言板", // title: "",
icon: "/static/common/images/icon_messageBoard.png", // icon: "/static/common/images/icon_messageBoard.png",
path: "/pages/home/messageBoard/index", // path: "/pages/home/messageBoard/index",
}, // },
{ {
title: "电话咨询", title: "电话咨询",
icon: "/static/common/images/icon_phone.png", icon: "/static/common/images/icon_phone.png",
background: "linear-gradient(0deg, #F4FBF9 0%, #F4FBF9 100%)",
}, },
], ],
popupShow: false, popupShow: false,
@ -505,7 +500,7 @@ export default {
// //
this.messageGroups.push(userMessage); this.messageGroups.push(userMessage);
this.messageValue = ""; this.messageValue = "";
// AI // AI
const loadingMessage = { const loadingMessage = {
id: "loading_" + Math.random().toString(36).substring(2, 15), id: "loading_" + Math.random().toString(36).substring(2, 15),
@ -519,7 +514,7 @@ export default {
displayTime: "", displayTime: "",
isLoading: true, // isLoading: true, //
}; };
// //
this.messageGroups.push(loadingMessage); this.messageGroups.push(loadingMessage);
@ -559,12 +554,12 @@ export default {
}) })
.catch((error) => { .catch((error) => {
console.error("API请求失败:", error); console.error("API请求失败:", error);
// //
this.messageGroups = this.messageGroups.filter( this.messageGroups = this.messageGroups.filter(
(msg) => !msg.isLoading (msg) => !msg.isLoading
); );
// //
const errorMessage = { const errorMessage = {
id: "error_" + Math.random().toString(36).substring(2, 15), id: "error_" + Math.random().toString(36).substring(2, 15),
@ -577,7 +572,7 @@ export default {
timeLabel: 0, timeLabel: 0,
displayTime: "", displayTime: "",
}; };
this.messageGroups.push(errorMessage); this.messageGroups.push(errorMessage);
}); });
}, },
@ -645,18 +640,18 @@ export default {
// //
this.popupShow = false; this.popupShow = false;
this.isChat = true; this.isChat = true;
// //
this.isSwitchingConversation = true; this.isSwitchingConversation = true;
this.currentConversationId = ""; this.currentConversationId = "";
this.messageGroups = []; this.messageGroups = [];
// //
this.pageQuery.PageIndex = 1; this.pageQuery.PageIndex = 1;
this.isLoadingMore = false; this.isLoadingMore = false;
this.noMoreData = false; this.noMoreData = false;
// //
setTimeout(() => { setTimeout(() => {
this.isSwitchingConversation = false; this.isSwitchingConversation = false;
@ -666,18 +661,18 @@ export default {
// //
handleStartChat() { handleStartChat() {
this.isChat = true; this.isChat = true;
// //
this.isSwitchingConversation = true; this.isSwitchingConversation = true;
this.currentConversationId = ""; this.currentConversationId = "";
this.messageGroups = []; this.messageGroups = [];
// //
this.pageQuery.PageIndex = 1; this.pageQuery.PageIndex = 1;
this.isLoadingMore = false; this.isLoadingMore = false;
this.noMoreData = false; this.noMoreData = false;
// //
setTimeout(() => { setTimeout(() => {
this.isSwitchingConversation = false; this.isSwitchingConversation = false;
@ -692,7 +687,7 @@ export default {
// //
onScrollToUpper() { onScrollToUpper() {
console.log("触发上拉刷新"); console.log("触发上拉刷新");
// //
if (this.noMoreData || this.isSwitchingConversation) { if (this.noMoreData || this.isSwitchingConversation) {
return; return;
@ -771,7 +766,7 @@ export default {
.main-content { .main-content {
padding: 30rpx; padding: 30rpx;
padding-top: 100rpx; padding-top: 60rpx;
.welcome-message { .welcome-message {
// display: inline-block; // display: inline-block;
@ -784,8 +779,8 @@ export default {
.avatar { .avatar {
display: inline-block; display: inline-block;
width: 42rpx; width: 50rpx;
height: 34rpx; height: 44rpx;
margin-right: 12rpx; margin-right: 12rpx;
} }
@ -894,20 +889,19 @@ export default {
gap: 30rpx; gap: 30rpx;
.feature-item { .feature-item {
height: 210rpx; height: 150rpx;
border-radius: 16rpx; border-radius: 16rpx;
background-color: #fafafc;
display: flex; display: flex;
flex-direction: column; justify-content: flex-start;
align-items: center; align-items: center;
justify-content: center; padding-left: 30rpx;
// gap: 20rpx; gap: 20rpx;
flex: 1; flex: 1;
.feature-icon { .feature-icon {
width: 80rpx; width: 80rpx;
height: 80rpx; height: 80rpx;
margin-bottom: 12rpx; margin-top: 16rpx;
} }
.feature-text { .feature-text {
@ -982,7 +976,7 @@ export default {
text-align: center; text-align: center;
margin-bottom: 32rpx; margin-bottom: 32rpx;
} }
.no-more-data { .no-more-data {
text-align: center; text-align: center;
font-size: 24rpx; font-size: 24rpx;
@ -1030,7 +1024,7 @@ export default {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: flex-start; justify-content: flex-start;
.dot { .dot {
display: inline-block; display: inline-block;
width: 12rpx; width: 12rpx;
@ -1040,20 +1034,20 @@ export default {
margin: 0 6rpx; margin: 0 6rpx;
opacity: 0.6; opacity: 0.6;
animation: dot-flashing 1.5s infinite linear alternate; animation: dot-flashing 1.5s infinite linear alternate;
&:nth-child(1) { &:nth-child(1) {
animation-delay: 0s; animation-delay: 0s;
} }
&:nth-child(2) { &:nth-child(2) {
animation-delay: 0.5s; animation-delay: 0.5s;
} }
&:nth-child(3) { &:nth-child(3) {
animation-delay: 1s; animation-delay: 1s;
} }
} }
@keyframes dot-flashing { @keyframes dot-flashing {
0% { 0% {
opacity: 0.6; opacity: 0.6;

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

After

Width:  |  Height:  |  Size: 22 KiB