page-crm-home.ts 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. import { RouterModule } from '@angular/router';
  2. import { Component, OnInit } from '@angular/core';
  3. import { CommonModule } from '@angular/common';
  4. import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
  5. import {
  6. faBrain, faBell, faUser, faRobot, faComments,
  7. faDatabase, faUserTie, faTimes, faHistory, faStar,
  8. faChartLine, faFileAlt, faBullhorn, faUserCircle,
  9. faFire, faTrophy, faCheck
  10. } from '@fortawesome/free-solid-svg-icons';
  11. @Component({
  12. imports: [RouterModule, CommonModule, FontAwesomeModule],
  13. templateUrl: './page-crm-home.html',
  14. styleUrl: './page-crm-home.scss',
  15. selector: 'page-crm-home',
  16. standalone: true,
  17. })
  18. export class PageCrmHome implements OnInit {
  19. // Font Awesome 图标
  20. icons = {
  21. faBrain, faBell, faUser, faRobot, faComments,
  22. faDatabase, faUserTie, faTimes, faHistory, faStar,
  23. faChartLine, faFileAlt, faBullhorn, faUserCircle,
  24. faFire, faTrophy, faCheck
  25. };
  26. // 弹窗状态
  27. showMessagePopup: boolean = false;
  28. showProfilePopup: boolean = false;
  29. selectedMessage: any = null;
  30. unreadMessagesCount: number = 0;
  31. // 数据
  32. motivationalText: string = '每一次对话都是展现专业的机会,每一次练习都在提升成功的概率!今天,让AI成为您最强大的销售伙伴';
  33. features = [
  34. {
  35. id: 'virtual-practice',
  36. title: '虚拟陪练',
  37. description: '与AI客户进行真实销售对话练习,提升沟通技巧',
  38. icon: 'fas fa-robot',
  39. statIcon: 'fas fa-history',
  40. stat1: '86次练习',
  41. stat2: '92%得分',
  42. hasNotification: true
  43. },
  44. {
  45. id: 'speech-strategy',
  46. title: '话术决策',
  47. description: '智能生成最佳沟通策略,应对各种销售场景',
  48. icon: 'fas fa-comments',
  49. statIcon: 'fas fa-star',
  50. stat1: '34个策略',
  51. stat2: '89%有效'
  52. },
  53. {
  54. id: 'data-training',
  55. title: '数据训练',
  56. description: '上传销售数据训练AI模型,优化决策能力',
  57. icon: 'fas fa-database',
  58. statIcon: 'fas fa-chart-line',
  59. stat1: '1.2GB',
  60. stat2: '95%准确'
  61. },
  62. {
  63. id: 'customer-profile',
  64. title: '客户画像',
  65. description: '生成详细客户分析报告,洞察客户需求',
  66. icon: 'fas fa-user-tie',
  67. statIcon: 'fas fa-file-alt',
  68. stat1: '28份',
  69. stat2: '更新中'
  70. }
  71. ];
  72. messages = [
  73. {
  74. id: 1,
  75. title: '新的陪练挑战',
  76. content: '您有一个新的虚拟陪练挑战等待完成,主题:高端客户价格谈判。请尽快完成以获得最佳学习效果。',
  77. time: '10分钟前',
  78. unread: true
  79. },
  80. {
  81. id: 2,
  82. title: '话术策略更新',
  83. content: '您收藏的"投诉处理"话术策略已更新至3.2版本,包含了最新的客户反馈数据。',
  84. time: '1小时前',
  85. unread: true
  86. },
  87. {
  88. id: 3,
  89. title: '系统维护通知',
  90. content: '系统将于本周六凌晨2:00-4:00进行维护升级,期间将无法使用服务。',
  91. time: '昨天',
  92. unread: true
  93. },
  94. {
  95. id: 4,
  96. title: '陪练成绩通知',
  97. content: '您最近的虚拟陪练成绩为92分,超过89%的销售同事,继续保持!',
  98. time: '2天前',
  99. unread: true
  100. },
  101. {
  102. id: 5,
  103. title: '团队周报',
  104. content: '本周团队陪练报告已生成,点击查看详细分析。',
  105. time: '3天前',
  106. unread: true
  107. }
  108. ];
  109. user = {
  110. name: '张明',
  111. role: '高级销售经理',
  112. age: 32,
  113. birthDate: '1991-05-15',
  114. trainingCount: 86
  115. };
  116. motivationalPhrases = [
  117. "每一次对话都是展现专业的机会,每一次练习都在提升成功的概率!今天,让AI成为您最强大的销售伙伴",
  118. "每一次拒绝都是离成功更近一步!",
  119. "卓越的销售不是推销产品,而是解决问题!",
  120. "今天的练习,明天的签约!",
  121. "客户的需求是您成功的地图,AI是您的导航仪!",
  122. "专业来自准备,成功源于坚持!",
  123. "您不是一个人在战斗,AI是您最强大的后援!"
  124. ];
  125. ngOnInit(): void {
  126. this.updateUnreadCount();
  127. this.updateMotivationalText();
  128. // 每10秒更新一次激励语句
  129. setInterval(() => this.updateMotivationalText(), 10000);
  130. }
  131. updateMotivationalText(): void {
  132. const randomIndex = Math.floor(Math.random() * this.motivationalPhrases.length);
  133. this.motivationalText = this.motivationalPhrases[randomIndex];
  134. }
  135. toggleMessagePopup(): void {
  136. this.showMessagePopup = !this.showMessagePopup;
  137. if (this.showMessagePopup) {
  138. this.updateUnreadCount();
  139. }
  140. }
  141. toggleProfilePopup(): void {
  142. this.showProfilePopup = !this.showProfilePopup;
  143. }
  144. showMessageDetail(message: any, event?: Event): void {
  145. if (event) event.stopPropagation();
  146. this.selectedMessage = message;
  147. // 如果消息未读,则标记为已读
  148. if (message.unread) {
  149. message.unread = false;
  150. this.updateUnreadCount();
  151. }
  152. }
  153. closeMessageDetail(): void {
  154. this.selectedMessage = null;
  155. }
  156. markMessageAsRead(message: any, event: Event): void {
  157. event.stopPropagation();
  158. if (message.unread) {
  159. message.unread = false;
  160. this.updateUnreadCount();
  161. }
  162. }
  163. markAllAsRead(): void {
  164. this.messages.forEach(message => message.unread = false);
  165. this.updateUnreadCount();
  166. }
  167. markAsRead(message: any): void {
  168. if (message.unread) {
  169. message.unread = false;
  170. this.updateUnreadCount();
  171. }
  172. }
  173. updateUnreadCount(): void {
  174. this.unreadMessagesCount = this.messages.filter(m => m.unread).length;
  175. }
  176. navigateTo(featureId: string): void {
  177. console.log('导航至:', featureId);
  178. // 实际项目中这里会有路由导航逻辑
  179. // this.router.navigate([`/${featureId}`]);
  180. }
  181. }