| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661 |
- <template>
- <view class="sales-home">
- <!-- 顶部山水背景 banner -->
- <view class="banner">
- <image class="banner-bg" src="/static/index-backpage.jpg" mode="aspectFill" />
- <view class="banner-veil"></view>
- <StatusBar />
- <view class="banner-inner px-4">
- <view class="flex items-center flex-1 min-w-0">
- <view class="avatar mr-3">
- <text class="uni-icons uniui-person-filled avatar-icon"></text>
- </view>
- <view class="min-w-0">
- <text class="greet block">{{ greetText }},欢迎回来</text>
- <text class="username truncate">{{ userName }}</text>
- </view>
- </view>
- <view
- class="notify-btn flex-shrink-0"
- hover-class="notify-hover"
- :hover-start-time="0"
- :hover-stay-time="120"
- @click="goToNotification"
- >
- <text class="uni-icons uniui-notification-filled notify-icon"></text>
- <view v-if="notificationCount > 0" class="notify-badge">
- {{ notificationCount > 99 ? '99+' : notificationCount }}
- </view>
- </view>
- </view>
- </view>
- <!-- 内容区 -->
- <view class="content-wrap px-4 pb-24">
- <!-- 统计卡片 -->
- <view class="glass-card p-4">
- <view class="grid grid-cols-3 gap-3">
- <view
- class="stat-card"
- hover-class="stat-hover"
- :hover-start-time="0"
- :hover-stay-time="120"
- @click="goToProjectList"
- >
- <view class="stat-bar"></view>
- <text class="stat-value">{{ projectStore.totalCount }}</text>
- <text class="stat-label">本月项目</text>
- </view>
- <view
- class="stat-card"
- hover-class="stat-hover"
- :hover-start-time="0"
- :hover-stay-time="120"
- @click="goToTaskList"
- >
- <view class="stat-bar"></view>
- <text class="stat-value">{{ taskStore.pendingCount }}</text>
- <text class="stat-label">待确认</text>
- </view>
- <view
- class="stat-card"
- hover-class="stat-hover"
- :hover-start-time="0"
- :hover-stay-time="120"
- @click="goToTaskList"
- >
- <view class="stat-bar"></view>
- <text class="stat-value">{{ taskStore.todayCount }}</text>
- <text class="stat-label">进行中</text>
- </view>
- </view>
- </view>
- <!-- 快捷入口 -->
- <view class="glass-card p-4">
- <view class="grid grid-cols-3 gap-3">
- <view
- class="entry-card"
- hover-class="entry-hover"
- :hover-start-time="0"
- :hover-stay-time="120"
- @click="goToProjectList"
- >
- <view class="icon-chip">
- <text class="uni-icons uniui-folder-add chip-glyph"></text>
- </view>
- <text class="entry-label">项目库</text>
- </view>
- <view
- class="entry-card"
- hover-class="entry-hover"
- :hover-start-time="0"
- :hover-stay-time="120"
- @click="goToCustomer"
- >
- <view class="icon-chip">
- <text class="uni-icons uniui-personadd chip-glyph"></text>
- </view>
- <text class="entry-label">客户管理</text>
- </view>
- <view
- class="entry-card"
- hover-class="entry-hover"
- :hover-start-time="0"
- :hover-stay-time="120"
- @click="goToContract"
- >
- <view class="icon-chip">
- <text class="uni-icons uniui-compose chip-glyph"></text>
- </view>
- <text class="entry-label">合同管理</text>
- </view>
- </view>
- </view>
- <!-- 任务提醒入口 -->
- <view
- class="glass-card reminder-row"
- hover-class="reminder-hover"
- :hover-start-time="0"
- :hover-stay-time="120"
- @click="goToTaskReminder"
- >
- <view class="icon-chip mr-3">
- <text class="uni-icons uniui-notification-filled chip-glyph"></text>
- </view>
- <text class="flex-1 reminder-text">任务提醒</text>
- <view class="reminder-count">{{ taskStore.pendingCount }}</view>
- <text class="uni-icons uniui-arrowright row-arrow ml-2"></text>
- </view>
- <!-- 最新任务 -->
- <view class="glass-card">
- <view class="section-head">
- <view class="section-bar mr-2"></view>
- <text class="section-title flex-1">最新任务</text>
- <text class="section-more" @click="goToTaskList">查看全部</text>
- </view>
- <view v-if="taskStore.tasks.length === 0" class="py-6 text-center">
- <text class="empty-text">暂无任务</text>
- </view>
- <view v-else>
- <view
- v-for="task in latestTasks"
- :key="task.id"
- class="list-row"
- hover-class="row-hover"
- :hover-start-time="0"
- :hover-stay-time="120"
- @click="goToTaskDetail(task.id)"
- >
- <view class="icon-chip mr-3">
- <text class="uni-icons uniui-flag chip-glyph"></text>
- </view>
- <view class="flex-1 min-w-0 mr-2">
- <text class="row-title truncate">{{ task.projectName }}</text>
- <text class="row-sub truncate">{{ task.address || task.scheduleDate }}</text>
- </view>
- <StatusTag :status="task.status" />
- </view>
- </view>
- </view>
- <!-- 通知公告 -->
- <view class="glass-card">
- <view class="section-head">
- <view class="section-bar mr-2"></view>
- <text class="section-title flex-1">通知公告</text>
- <text class="section-more" @click="goToNoticeList">更多</text>
- </view>
- <view
- v-for="(notice, index) in notices"
- :key="notice.noticeId"
- class="list-row"
- hover-class="row-hover"
- :hover-start-time="0"
- :hover-stay-time="120"
- @click="goToNoticeDetail(notice.noticeId)"
- >
- <view class="dot mr-3" :class="index === 0 ? 'dot-active' : 'dot-muted'"></view>
- <text class="flex-1 row-title truncate mr-2">{{ notice.title }}</text>
- <text class="row-date flex-shrink-0">{{ formatDate(notice.publishTime, 'YYYY-MM-DD') }}</text>
- </view>
- <view v-if="notices.length === 0" class="list-row">
- <text style="font-size: 12px; color: #9ca3af;">暂无通知</text>
- </view>
- </view>
- <!-- 行业知识 -->
- <view class="glass-card">
- <view class="section-head">
- <view class="section-bar mr-2"></view>
- <text class="section-title flex-1">行业知识</text>
- <text class="section-more" @click="goToKnowledgeList">更多</text>
- </view>
- <view
- v-for="item in knowledgeList"
- :key="item.id"
- class="list-row"
- hover-class="row-hover"
- :hover-start-time="0"
- :hover-stay-time="120"
- @click="goToKnowledgeDetail(item.id)"
- >
- <view class="icon-chip mr-3">
- <text class="uni-icons uniui-chart chip-glyph"></text>
- </view>
- <view class="flex-1 min-w-0">
- <text class="row-title truncate">{{ item.title }}</text>
- <text class="row-sub truncate">{{ summaryOf(item.content) }}</text>
- </view>
- </view>
- <view v-if="knowledgeList.length === 0" class="list-row">
- <text style="font-size: 12px; color: #9ca3af;">暂无知识内容</text>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script setup lang="ts">
- import { ref, computed, onMounted } from 'vue'
- import { useAuthStore } from '@/stores/auth'
- import { useProjectStore } from '@/stores/project'
- import { useTaskStore } from '@/stores/task'
- import { useNotificationStore } from '@/stores/notification'
- import StatusBar from '@/components/common/StatusBar.vue'
- import StatusTag from '@/components/common/StatusTag.vue'
- import { getNoticeList } from '@/api/notice'
- import { getKnowledgeList, summaryOf, type KnowledgeItem } from '@/api/knowledge'
- import { formatDate } from '@/utils'
- const authStore = useAuthStore()
- const projectStore = useProjectStore()
- const taskStore = useTaskStore()
- const notificationStore = useNotificationStore()
- const userName = ref(authStore.user?.name || '张销售')
- const notificationCount = computed(() => notificationStore.unreadCount)
- const latestTasks = computed(() => taskStore.tasks.slice(0, 3))
- const greetText = computed(() => {
- const hour = new Date().getHours()
- if (hour < 6) return '凌晨好'
- if (hour < 12) return '上午好'
- if (hour < 14) return '中午好'
- if (hour < 18) return '下午好'
- return '晚上好'
- })
- const notices = ref<any[]>([])
- const knowledgeList = ref<KnowledgeItem[]>([])
- function goToProjectList() {
- uni.navigateTo({ url: '/subPackages/pages-common/projectList' })
- }
- function goToTaskList() {
- uni.switchTab({ url: '/pages/task/task' })
- }
- function goToTaskDetail(taskId: string) {
- taskStore.setCurrentTask(taskId)
- uni.navigateTo({ url: `/subPackages/pages-common/taskDetail?id=${taskId}` })
- }
- function goToTaskReminder() {
- uni.navigateTo({ url: '/subPackages/pages-sales/taskReminder' })
- }
- function goToNotification() {
- uni.navigateTo({ url: '/subPackages/pages-common/messageList' })
- }
- function goToNoticeList() {
- uni.navigateTo({ url: '/subPackages/pages-common/noticeList' })
- }
- function goToNoticeDetail(noticeId: number) {
- uni.navigateTo({ url: `/subPackages/pages-common/noticeDetail?id=${noticeId}` })
- }
- function goToKnowledgeList() {
- uni.navigateTo({ url: '/subPackages/pages-common/knowledgeList' })
- }
- function goToKnowledgeDetail(id: number) {
- uni.navigateTo({ url: `/subPackages/pages-common/knowledgeDetail?id=${id}` })
- }
- function goToCustomer() {
- uni.navigateTo({ url: '/subPackages/pages-customer/customer' })
- }
- function goToContract() {
- uni.navigateTo({ url: '/subPackages/pages-contract/contract' })
- }
- onMounted(async () => {
- projectStore.fetchProjects()
- taskStore.fetchTasks()
- notificationStore.fetchUnreadCount()
- try {
- const res = await getNoticeList(1, 3)
- notices.value = res.rows || []
- } catch (error) {
- console.error('获取通知列表失败:', error)
- }
- try {
- const res = await getKnowledgeList(1, 2)
- knowledgeList.value = res.rows || []
- } catch (error) {
- console.error('获取知识列表失败:', error)
- }
- })
- </script>
- <style scoped>
- /* ==================== 页面外壳 ==================== */
- .sales-home {
- position: relative;
- max-width: 430px;
- margin: 0 auto;
- min-height: 100vh;
- background-color: #f6fbf9; /* 云雾白 */
- }
- /* ==================== 顶部 banner(山水背景) ==================== */
- .banner {
- position: relative;
- height: 168px;
- overflow: hidden;
- background-color: #dff0e8; /* 图片加载前的浅青绿兜底 */
- }
- .banner-bg {
- position: absolute;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- z-index: 0;
- }
- /* 蒙版:顶部提亮保文字、底部淡出衔接云雾白 */
- .banner-veil {
- position: absolute;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- z-index: 1;
- background: linear-gradient(
- 180deg,
- rgba(255, 255, 255, 0.5) 0%,
- rgba(255, 255, 255, 0.16) 45%,
- rgba(246, 251, 249, 0.66) 100%
- );
- }
- .banner-inner {
- position: relative;
- z-index: 2;
- display: flex;
- align-items: center;
- padding-top: 14px;
- padding-bottom: 24px;
- }
- .avatar {
- width: 48px;
- height: 48px;
- border-radius: 50%;
- background-color: rgba(255, 255, 255, 0.9);
- backdrop-filter: blur(8px);
- -webkit-backdrop-filter: blur(8px);
- display: flex;
- align-items: center;
- justify-content: center;
- box-shadow: 0 8px 22px -8px rgba(31, 41, 37, 0.4);
- flex-shrink: 0;
- }
- .avatar-icon {
- font-size: 24px;
- color: #368f6f;
- }
- .greet {
- font-size: 12px;
- color: rgba(31, 41, 37, 0.62);
- }
- .username {
- display: block;
- margin-top: 2px;
- font-size: 18px;
- font-weight: 800;
- letter-spacing: 0.5px;
- color: #1f2937;
- }
- /* 通知铃铛 */
- .notify-btn {
- position: relative;
- width: 40px;
- height: 40px;
- border-radius: 50%;
- display: flex;
- align-items: center;
- justify-content: center;
- background-color: rgba(255, 255, 255, 0.6);
- backdrop-filter: blur(8px);
- -webkit-backdrop-filter: blur(8px);
- box-shadow: 0 6px 18px -8px rgba(31, 41, 37, 0.35);
- }
- .notify-icon {
- font-size: 20px;
- color: #368f6f;
- }
- .notify-badge {
- position: absolute;
- top: -4px;
- right: -4px;
- min-width: 18px;
- height: 18px;
- padding: 0 4px;
- border-radius: 9px;
- background-color: #ef4444;
- border: 1.5px solid rgba(255, 255, 255, 0.9);
- color: #ffffff;
- font-size: 10px;
- font-weight: 700;
- line-height: 15px;
- text-align: center;
- }
- .notify-hover {
- background-color: rgba(255, 255, 255, 0.88);
- }
- /* ==================== 内容区(轻微上叠 banner) ==================== */
- .content-wrap {
- position: relative;
- z-index: 2;
- margin-top: -18px;
- }
- /* 磨砂玻璃卡 */
- .glass-card {
- background-color: rgba(255, 255, 255, 0.85);
- backdrop-filter: blur(14px);
- -webkit-backdrop-filter: blur(14px);
- border: 1px solid rgba(164, 216, 152, 0.35);
- border-radius: 24px;
- box-shadow: 0 18px 50px -12px rgba(54, 143, 111, 0.28);
- overflow: hidden;
- margin-bottom: 12px;
- }
- /* ==================== 统计卡 ==================== */
- .stat-card {
- position: relative;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- min-height: 88px;
- padding: 14px 6px 12px;
- border-radius: 16px;
- background-color: rgba(164, 216, 152, 0.14);
- border: 1px solid rgba(164, 216, 152, 0.3);
- overflow: hidden;
- }
- .stat-bar {
- position: absolute;
- top: 0;
- left: 50%;
- transform: translateX(-50%);
- width: 26px;
- height: 3px;
- border-radius: 0 0 3px 3px;
- background: linear-gradient(135deg, #368f6f 0%, #5ab8d0 100%);
- }
- .stat-value {
- font-size: 24px;
- font-weight: 800;
- line-height: 1.1;
- color: #368f6f;
- }
- .stat-label {
- margin-top: 6px;
- font-size: 12px;
- color: #6b7280;
- }
- .stat-hover {
- transform: scale(0.97);
- background-color: rgba(164, 216, 152, 0.24);
- }
- /* ==================== 快捷入口 ==================== */
- .entry-card {
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- padding: 14px 4px 12px;
- border-radius: 16px;
- }
- .entry-label {
- margin-top: 8px;
- font-size: 13px;
- font-weight: 500;
- color: #374151;
- }
- .entry-hover {
- background-color: rgba(164, 216, 152, 0.14);
- transform: scale(0.97);
- }
- /* 嫩芽浅底图标块(与个人中心 menu-icon 一致) */
- .icon-chip {
- width: 42px;
- height: 42px;
- border-radius: 12px;
- flex-shrink: 0;
- display: flex;
- align-items: center;
- justify-content: center;
- background-color: rgba(164, 216, 152, 0.2);
- }
- .chip-glyph {
- font-size: 20px;
- color: #368f6f;
- }
- /* ==================== 任务提醒入口 ==================== */
- .reminder-row {
- display: flex;
- align-items: center;
- padding: 14px 16px;
- }
- .reminder-text {
- font-size: 15px;
- font-weight: 600;
- color: #1f2937;
- }
- .reminder-count {
- min-width: 22px;
- height: 22px;
- padding: 0 7px;
- border-radius: 11px;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 12px;
- font-weight: 700;
- color: #368f6f;
- background-color: rgba(164, 216, 152, 0.24);
- }
- .row-arrow {
- font-size: 16px;
- color: #c4d0cb;
- }
- .reminder-hover {
- background-color: rgba(164, 216, 152, 0.12);
- }
- /* ==================== 区块标题栏 ==================== */
- .section-head {
- display: flex;
- align-items: center;
- padding: 16px 16px 12px;
- }
- .section-bar {
- width: 4px;
- height: 16px;
- border-radius: 2px;
- background: linear-gradient(180deg, #368f6f 0%, #5ab8d0 100%);
- }
- .section-title {
- font-size: 16px;
- font-weight: 700;
- color: #1f2937;
- }
- .section-more {
- font-size: 13px;
- color: #368f6f;
- }
- /* ==================== 列表行 ==================== */
- .list-row {
- display: flex;
- align-items: center;
- padding: 13px 16px;
- border-top: 1px solid rgba(164, 216, 152, 0.18);
- }
- .row-title {
- display: block;
- font-size: 14px;
- font-weight: 500;
- color: #1f2937;
- }
- .row-sub {
- display: block;
- margin-top: 3px;
- font-size: 12px;
- color: #9ca3af;
- }
- .row-date {
- font-size: 12px;
- color: #9ca3af;
- }
- .row-hover {
- background-color: rgba(164, 216, 152, 0.1);
- }
- /* 通知圆点 */
- .dot {
- width: 8px;
- height: 8px;
- border-radius: 50%;
- flex-shrink: 0;
- }
- .dot-active {
- background-color: #368f6f;
- box-shadow: 0 0 0 3px rgba(164, 216, 152, 0.3);
- }
- .dot-muted {
- background-color: #c4d0cb;
- }
- .empty-text {
- font-size: 13px;
- color: #9ca3af;
- }
- </style>
|