SalesHome.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  1. <template>
  2. <view class="sales-home">
  3. <!-- 顶部山水背景 banner -->
  4. <view class="banner">
  5. <image class="banner-bg" src="/static/index-backpage.jpg" mode="aspectFill" />
  6. <view class="banner-veil"></view>
  7. <StatusBar />
  8. <view class="banner-inner px-4">
  9. <view class="flex items-center flex-1 min-w-0">
  10. <view class="avatar mr-3">
  11. <text class="uni-icons uniui-person-filled avatar-icon"></text>
  12. </view>
  13. <view class="min-w-0">
  14. <text class="greet block">{{ greetText }},欢迎回来</text>
  15. <text class="username truncate">{{ userName }}</text>
  16. </view>
  17. </view>
  18. <view
  19. class="notify-btn flex-shrink-0"
  20. hover-class="notify-hover"
  21. :hover-start-time="0"
  22. :hover-stay-time="120"
  23. @click="goToNotification"
  24. >
  25. <text class="uni-icons uniui-notification-filled notify-icon"></text>
  26. <view v-if="notificationCount > 0" class="notify-badge">
  27. {{ notificationCount > 99 ? '99+' : notificationCount }}
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. <!-- 内容区 -->
  33. <view class="content-wrap px-4 pb-24">
  34. <!-- 统计卡片 -->
  35. <view class="glass-card p-4">
  36. <view class="grid grid-cols-3 gap-3">
  37. <view
  38. class="stat-card"
  39. hover-class="stat-hover"
  40. :hover-start-time="0"
  41. :hover-stay-time="120"
  42. @click="goToProjectList"
  43. >
  44. <view class="stat-bar"></view>
  45. <text class="stat-value">{{ projectStore.totalCount }}</text>
  46. <text class="stat-label">本月项目</text>
  47. </view>
  48. <view
  49. class="stat-card"
  50. hover-class="stat-hover"
  51. :hover-start-time="0"
  52. :hover-stay-time="120"
  53. @click="goToTaskList"
  54. >
  55. <view class="stat-bar"></view>
  56. <text class="stat-value">{{ taskStore.pendingCount }}</text>
  57. <text class="stat-label">待确认</text>
  58. </view>
  59. <view
  60. class="stat-card"
  61. hover-class="stat-hover"
  62. :hover-start-time="0"
  63. :hover-stay-time="120"
  64. @click="goToTaskList"
  65. >
  66. <view class="stat-bar"></view>
  67. <text class="stat-value">{{ taskStore.todayCount }}</text>
  68. <text class="stat-label">进行中</text>
  69. </view>
  70. </view>
  71. </view>
  72. <!-- 快捷入口 -->
  73. <view class="glass-card p-4">
  74. <view class="grid grid-cols-3 gap-3">
  75. <view
  76. class="entry-card"
  77. hover-class="entry-hover"
  78. :hover-start-time="0"
  79. :hover-stay-time="120"
  80. @click="goToProjectList"
  81. >
  82. <view class="icon-chip">
  83. <text class="uni-icons uniui-folder-add chip-glyph"></text>
  84. </view>
  85. <text class="entry-label">项目库</text>
  86. </view>
  87. <view
  88. class="entry-card"
  89. hover-class="entry-hover"
  90. :hover-start-time="0"
  91. :hover-stay-time="120"
  92. @click="goToCustomer"
  93. >
  94. <view class="icon-chip">
  95. <text class="uni-icons uniui-personadd chip-glyph"></text>
  96. </view>
  97. <text class="entry-label">客户管理</text>
  98. </view>
  99. <view
  100. class="entry-card"
  101. hover-class="entry-hover"
  102. :hover-start-time="0"
  103. :hover-stay-time="120"
  104. @click="goToContract"
  105. >
  106. <view class="icon-chip">
  107. <text class="uni-icons uniui-compose chip-glyph"></text>
  108. </view>
  109. <text class="entry-label">合同管理</text>
  110. </view>
  111. </view>
  112. </view>
  113. <!-- 任务提醒入口 -->
  114. <view
  115. class="glass-card reminder-row"
  116. hover-class="reminder-hover"
  117. :hover-start-time="0"
  118. :hover-stay-time="120"
  119. @click="goToTaskReminder"
  120. >
  121. <view class="icon-chip mr-3">
  122. <text class="uni-icons uniui-notification-filled chip-glyph"></text>
  123. </view>
  124. <text class="flex-1 reminder-text">任务提醒</text>
  125. <view class="reminder-count">{{ taskStore.pendingCount }}</view>
  126. <text class="uni-icons uniui-arrowright row-arrow ml-2"></text>
  127. </view>
  128. <!-- 最新任务 -->
  129. <view class="glass-card">
  130. <view class="section-head">
  131. <view class="section-bar mr-2"></view>
  132. <text class="section-title flex-1">最新任务</text>
  133. <text class="section-more" @click="goToTaskList">查看全部</text>
  134. </view>
  135. <view v-if="taskStore.tasks.length === 0" class="py-6 text-center">
  136. <text class="empty-text">暂无任务</text>
  137. </view>
  138. <view v-else>
  139. <view
  140. v-for="task in latestTasks"
  141. :key="task.id"
  142. class="list-row"
  143. hover-class="row-hover"
  144. :hover-start-time="0"
  145. :hover-stay-time="120"
  146. @click="goToTaskDetail(task.id)"
  147. >
  148. <view class="icon-chip mr-3">
  149. <text class="uni-icons uniui-flag chip-glyph"></text>
  150. </view>
  151. <view class="flex-1 min-w-0 mr-2">
  152. <text class="row-title truncate">{{ task.projectName }}</text>
  153. <text class="row-sub truncate">{{ task.address || task.scheduleDate }}</text>
  154. </view>
  155. <StatusTag :status="task.status" />
  156. </view>
  157. </view>
  158. </view>
  159. <!-- 通知公告 -->
  160. <view class="glass-card">
  161. <view class="section-head">
  162. <view class="section-bar mr-2"></view>
  163. <text class="section-title flex-1">通知公告</text>
  164. <text class="section-more" @click="goToNoticeList">更多</text>
  165. </view>
  166. <view
  167. v-for="(notice, index) in notices"
  168. :key="notice.noticeId"
  169. class="list-row"
  170. hover-class="row-hover"
  171. :hover-start-time="0"
  172. :hover-stay-time="120"
  173. @click="goToNoticeDetail(notice.noticeId)"
  174. >
  175. <view class="dot mr-3" :class="index === 0 ? 'dot-active' : 'dot-muted'"></view>
  176. <text class="flex-1 row-title truncate mr-2">{{ notice.title }}</text>
  177. <text class="row-date flex-shrink-0">{{ formatDate(notice.publishTime, 'YYYY-MM-DD') }}</text>
  178. </view>
  179. <view v-if="notices.length === 0" class="list-row">
  180. <text style="font-size: 12px; color: #9ca3af;">暂无通知</text>
  181. </view>
  182. </view>
  183. <!-- 行业知识 -->
  184. <view class="glass-card">
  185. <view class="section-head">
  186. <view class="section-bar mr-2"></view>
  187. <text class="section-title flex-1">行业知识</text>
  188. <text class="section-more" @click="goToKnowledgeList">更多</text>
  189. </view>
  190. <view
  191. v-for="item in knowledgeList"
  192. :key="item.id"
  193. class="list-row"
  194. hover-class="row-hover"
  195. :hover-start-time="0"
  196. :hover-stay-time="120"
  197. @click="goToKnowledgeDetail(item.id)"
  198. >
  199. <view class="icon-chip mr-3">
  200. <text class="uni-icons uniui-chart chip-glyph"></text>
  201. </view>
  202. <view class="flex-1 min-w-0">
  203. <text class="row-title truncate">{{ item.title }}</text>
  204. <text class="row-sub truncate">{{ summaryOf(item.content) }}</text>
  205. </view>
  206. </view>
  207. <view v-if="knowledgeList.length === 0" class="list-row">
  208. <text style="font-size: 12px; color: #9ca3af;">暂无知识内容</text>
  209. </view>
  210. </view>
  211. </view>
  212. </view>
  213. </template>
  214. <script setup lang="ts">
  215. import { ref, computed, onMounted } from 'vue'
  216. import { useAuthStore } from '@/stores/auth'
  217. import { useProjectStore } from '@/stores/project'
  218. import { useTaskStore } from '@/stores/task'
  219. import { useNotificationStore } from '@/stores/notification'
  220. import StatusBar from '@/components/common/StatusBar.vue'
  221. import StatusTag from '@/components/common/StatusTag.vue'
  222. import { getNoticeList } from '@/api/notice'
  223. import { getKnowledgeList, summaryOf, type KnowledgeItem } from '@/api/knowledge'
  224. import { formatDate } from '@/utils'
  225. const authStore = useAuthStore()
  226. const projectStore = useProjectStore()
  227. const taskStore = useTaskStore()
  228. const notificationStore = useNotificationStore()
  229. const userName = ref(authStore.user?.name || '张销售')
  230. const notificationCount = computed(() => notificationStore.unreadCount)
  231. const latestTasks = computed(() => taskStore.tasks.slice(0, 3))
  232. const greetText = computed(() => {
  233. const hour = new Date().getHours()
  234. if (hour < 6) return '凌晨好'
  235. if (hour < 12) return '上午好'
  236. if (hour < 14) return '中午好'
  237. if (hour < 18) return '下午好'
  238. return '晚上好'
  239. })
  240. const notices = ref<any[]>([])
  241. const knowledgeList = ref<KnowledgeItem[]>([])
  242. function goToProjectList() {
  243. uni.navigateTo({ url: '/subPackages/pages-common/projectList' })
  244. }
  245. function goToTaskList() {
  246. uni.switchTab({ url: '/pages/task/task' })
  247. }
  248. function goToTaskDetail(taskId: string) {
  249. taskStore.setCurrentTask(taskId)
  250. uni.navigateTo({ url: `/subPackages/pages-common/taskDetail?id=${taskId}` })
  251. }
  252. function goToTaskReminder() {
  253. uni.navigateTo({ url: '/subPackages/pages-sales/taskReminder' })
  254. }
  255. function goToNotification() {
  256. uni.navigateTo({ url: '/subPackages/pages-common/messageList' })
  257. }
  258. function goToNoticeList() {
  259. uni.navigateTo({ url: '/subPackages/pages-common/noticeList' })
  260. }
  261. function goToNoticeDetail(noticeId: number) {
  262. uni.navigateTo({ url: `/subPackages/pages-common/noticeDetail?id=${noticeId}` })
  263. }
  264. function goToKnowledgeList() {
  265. uni.navigateTo({ url: '/subPackages/pages-common/knowledgeList' })
  266. }
  267. function goToKnowledgeDetail(id: number) {
  268. uni.navigateTo({ url: `/subPackages/pages-common/knowledgeDetail?id=${id}` })
  269. }
  270. function goToCustomer() {
  271. uni.navigateTo({ url: '/subPackages/pages-customer/customer' })
  272. }
  273. function goToContract() {
  274. uni.navigateTo({ url: '/subPackages/pages-contract/contract' })
  275. }
  276. onMounted(async () => {
  277. projectStore.fetchProjects()
  278. taskStore.fetchTasks()
  279. notificationStore.fetchUnreadCount()
  280. try {
  281. const res = await getNoticeList(1, 3)
  282. notices.value = res.rows || []
  283. } catch (error) {
  284. console.error('获取通知列表失败:', error)
  285. }
  286. try {
  287. const res = await getKnowledgeList(1, 2)
  288. knowledgeList.value = res.rows || []
  289. } catch (error) {
  290. console.error('获取知识列表失败:', error)
  291. }
  292. })
  293. </script>
  294. <style scoped>
  295. /* ==================== 页面外壳 ==================== */
  296. .sales-home {
  297. position: relative;
  298. max-width: 430px;
  299. margin: 0 auto;
  300. min-height: 100vh;
  301. background-color: #f6fbf9; /* 云雾白 */
  302. }
  303. /* ==================== 顶部 banner(山水背景) ==================== */
  304. .banner {
  305. position: relative;
  306. height: 168px;
  307. overflow: hidden;
  308. background-color: #dff0e8; /* 图片加载前的浅青绿兜底 */
  309. }
  310. .banner-bg {
  311. position: absolute;
  312. top: 0;
  313. left: 0;
  314. width: 100%;
  315. height: 100%;
  316. z-index: 0;
  317. }
  318. /* 蒙版:顶部提亮保文字、底部淡出衔接云雾白 */
  319. .banner-veil {
  320. position: absolute;
  321. top: 0;
  322. left: 0;
  323. width: 100%;
  324. height: 100%;
  325. z-index: 1;
  326. background: linear-gradient(
  327. 180deg,
  328. rgba(255, 255, 255, 0.5) 0%,
  329. rgba(255, 255, 255, 0.16) 45%,
  330. rgba(246, 251, 249, 0.66) 100%
  331. );
  332. }
  333. .banner-inner {
  334. position: relative;
  335. z-index: 2;
  336. display: flex;
  337. align-items: center;
  338. padding-top: 14px;
  339. padding-bottom: 24px;
  340. }
  341. .avatar {
  342. width: 48px;
  343. height: 48px;
  344. border-radius: 50%;
  345. background-color: rgba(255, 255, 255, 0.9);
  346. backdrop-filter: blur(8px);
  347. -webkit-backdrop-filter: blur(8px);
  348. display: flex;
  349. align-items: center;
  350. justify-content: center;
  351. box-shadow: 0 8px 22px -8px rgba(31, 41, 37, 0.4);
  352. flex-shrink: 0;
  353. }
  354. .avatar-icon {
  355. font-size: 24px;
  356. color: #368f6f;
  357. }
  358. .greet {
  359. font-size: 12px;
  360. color: rgba(31, 41, 37, 0.62);
  361. }
  362. .username {
  363. display: block;
  364. margin-top: 2px;
  365. font-size: 18px;
  366. font-weight: 800;
  367. letter-spacing: 0.5px;
  368. color: #1f2937;
  369. }
  370. /* 通知铃铛 */
  371. .notify-btn {
  372. position: relative;
  373. width: 40px;
  374. height: 40px;
  375. border-radius: 50%;
  376. display: flex;
  377. align-items: center;
  378. justify-content: center;
  379. background-color: rgba(255, 255, 255, 0.6);
  380. backdrop-filter: blur(8px);
  381. -webkit-backdrop-filter: blur(8px);
  382. box-shadow: 0 6px 18px -8px rgba(31, 41, 37, 0.35);
  383. }
  384. .notify-icon {
  385. font-size: 20px;
  386. color: #368f6f;
  387. }
  388. .notify-badge {
  389. position: absolute;
  390. top: -4px;
  391. right: -4px;
  392. min-width: 18px;
  393. height: 18px;
  394. padding: 0 4px;
  395. border-radius: 9px;
  396. background-color: #ef4444;
  397. border: 1.5px solid rgba(255, 255, 255, 0.9);
  398. color: #ffffff;
  399. font-size: 10px;
  400. font-weight: 700;
  401. line-height: 15px;
  402. text-align: center;
  403. }
  404. .notify-hover {
  405. background-color: rgba(255, 255, 255, 0.88);
  406. }
  407. /* ==================== 内容区(轻微上叠 banner) ==================== */
  408. .content-wrap {
  409. position: relative;
  410. z-index: 2;
  411. margin-top: -18px;
  412. }
  413. /* 磨砂玻璃卡 */
  414. .glass-card {
  415. background-color: rgba(255, 255, 255, 0.85);
  416. backdrop-filter: blur(14px);
  417. -webkit-backdrop-filter: blur(14px);
  418. border: 1px solid rgba(164, 216, 152, 0.35);
  419. border-radius: 24px;
  420. box-shadow: 0 18px 50px -12px rgba(54, 143, 111, 0.28);
  421. overflow: hidden;
  422. margin-bottom: 12px;
  423. }
  424. /* ==================== 统计卡 ==================== */
  425. .stat-card {
  426. position: relative;
  427. display: flex;
  428. flex-direction: column;
  429. align-items: center;
  430. justify-content: center;
  431. min-height: 88px;
  432. padding: 14px 6px 12px;
  433. border-radius: 16px;
  434. background-color: rgba(164, 216, 152, 0.14);
  435. border: 1px solid rgba(164, 216, 152, 0.3);
  436. overflow: hidden;
  437. }
  438. .stat-bar {
  439. position: absolute;
  440. top: 0;
  441. left: 50%;
  442. transform: translateX(-50%);
  443. width: 26px;
  444. height: 3px;
  445. border-radius: 0 0 3px 3px;
  446. background: linear-gradient(135deg, #368f6f 0%, #5ab8d0 100%);
  447. }
  448. .stat-value {
  449. font-size: 24px;
  450. font-weight: 800;
  451. line-height: 1.1;
  452. color: #368f6f;
  453. }
  454. .stat-label {
  455. margin-top: 6px;
  456. font-size: 12px;
  457. color: #6b7280;
  458. }
  459. .stat-hover {
  460. transform: scale(0.97);
  461. background-color: rgba(164, 216, 152, 0.24);
  462. }
  463. /* ==================== 快捷入口 ==================== */
  464. .entry-card {
  465. display: flex;
  466. flex-direction: column;
  467. align-items: center;
  468. justify-content: center;
  469. padding: 14px 4px 12px;
  470. border-radius: 16px;
  471. }
  472. .entry-label {
  473. margin-top: 8px;
  474. font-size: 13px;
  475. font-weight: 500;
  476. color: #374151;
  477. }
  478. .entry-hover {
  479. background-color: rgba(164, 216, 152, 0.14);
  480. transform: scale(0.97);
  481. }
  482. /* 嫩芽浅底图标块(与个人中心 menu-icon 一致) */
  483. .icon-chip {
  484. width: 42px;
  485. height: 42px;
  486. border-radius: 12px;
  487. flex-shrink: 0;
  488. display: flex;
  489. align-items: center;
  490. justify-content: center;
  491. background-color: rgba(164, 216, 152, 0.2);
  492. }
  493. .chip-glyph {
  494. font-size: 20px;
  495. color: #368f6f;
  496. }
  497. /* ==================== 任务提醒入口 ==================== */
  498. .reminder-row {
  499. display: flex;
  500. align-items: center;
  501. padding: 14px 16px;
  502. }
  503. .reminder-text {
  504. font-size: 15px;
  505. font-weight: 600;
  506. color: #1f2937;
  507. }
  508. .reminder-count {
  509. min-width: 22px;
  510. height: 22px;
  511. padding: 0 7px;
  512. border-radius: 11px;
  513. display: flex;
  514. align-items: center;
  515. justify-content: center;
  516. font-size: 12px;
  517. font-weight: 700;
  518. color: #368f6f;
  519. background-color: rgba(164, 216, 152, 0.24);
  520. }
  521. .row-arrow {
  522. font-size: 16px;
  523. color: #c4d0cb;
  524. }
  525. .reminder-hover {
  526. background-color: rgba(164, 216, 152, 0.12);
  527. }
  528. /* ==================== 区块标题栏 ==================== */
  529. .section-head {
  530. display: flex;
  531. align-items: center;
  532. padding: 16px 16px 12px;
  533. }
  534. .section-bar {
  535. width: 4px;
  536. height: 16px;
  537. border-radius: 2px;
  538. background: linear-gradient(180deg, #368f6f 0%, #5ab8d0 100%);
  539. }
  540. .section-title {
  541. font-size: 16px;
  542. font-weight: 700;
  543. color: #1f2937;
  544. }
  545. .section-more {
  546. font-size: 13px;
  547. color: #368f6f;
  548. }
  549. /* ==================== 列表行 ==================== */
  550. .list-row {
  551. display: flex;
  552. align-items: center;
  553. padding: 13px 16px;
  554. border-top: 1px solid rgba(164, 216, 152, 0.18);
  555. }
  556. .row-title {
  557. display: block;
  558. font-size: 14px;
  559. font-weight: 500;
  560. color: #1f2937;
  561. }
  562. .row-sub {
  563. display: block;
  564. margin-top: 3px;
  565. font-size: 12px;
  566. color: #9ca3af;
  567. }
  568. .row-date {
  569. font-size: 12px;
  570. color: #9ca3af;
  571. }
  572. .row-hover {
  573. background-color: rgba(164, 216, 152, 0.1);
  574. }
  575. /* 通知圆点 */
  576. .dot {
  577. width: 8px;
  578. height: 8px;
  579. border-radius: 50%;
  580. flex-shrink: 0;
  581. }
  582. .dot-active {
  583. background-color: #368f6f;
  584. box-shadow: 0 0 0 3px rgba(164, 216, 152, 0.3);
  585. }
  586. .dot-muted {
  587. background-color: #c4d0cb;
  588. }
  589. .empty-text {
  590. font-size: 13px;
  591. color: #9ca3af;
  592. }
  593. </style>