chat-activation.component.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <div class="chat-activation-page">
  2. <!-- 加载状态 -->
  3. @if (loading) {
  4. <div class="loading-container">
  5. <div class="spinner"></div>
  6. <p>加载中...</p>
  7. </div>
  8. } @else if (error) {
  9. <!-- 错误状态 -->
  10. <div class="error-container">
  11. <svg class="icon-error" viewBox="0 0 512 512">
  12. <path fill="currentColor" d="M256 48C141.31 48 48 141.31 48 256s93.31 208 208 208 208-93.31 208-208S370.69 48 256 48zm0 62.5a52.5 52.5 0 1152.5 52.5A52.5 52.5 0 01256 110.5zm21.72 206.41l-5.74 122a16 16 0 01-32 0l-5.74-122a21.74 21.74 0 1143.44 0z"/>
  13. </svg>
  14. <p>{{ error }}</p>
  15. <button class="btn-retry" (click)="refresh()">重试</button>
  16. </div>
  17. } @else {
  18. <!-- 主内容 -->
  19. <div class="page-content">
  20. <!-- 头部 -->
  21. <div class="page-header">
  22. <button class="btn-back" (click)="goBack()">
  23. <svg viewBox="0 0 512 512">
  24. <path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="48" d="M244 400L100 256l144-144M120 256h292"/>
  25. </svg>
  26. </button>
  27. <div class="header-info">
  28. <h1 class="group-name">{{ groupChat?.get('name') || '群聊' }}</h1>
  29. <p class="group-meta">{{ messages.length }}条消息</p>
  30. </div>
  31. <button class="btn-refresh" (click)="refresh()">
  32. <svg viewBox="0 0 512 512">
  33. <path fill="none" stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="32" d="M320 146s24.36-12-64-12a160 160 0 10160 160"/>
  34. <path fill="currentColor" d="M256 58l80 80-80 80"/>
  35. </svg>
  36. </button>
  37. </div>
  38. <!-- 统计卡片 -->
  39. <div class="stats-cards">
  40. <div class="stat-card">
  41. <div class="stat-icon messages">
  42. <svg viewBox="0 0 512 512">
  43. <path fill="currentColor" d="M431 320.6c-1-3.6 1.2-8.6 3.3-12.2a33.68 33.68 0 012.1-3.1A162 162 0 00464 215c.3-92.2-77.5-167-173.7-167-83.9 0-153.9 57.1-170.3 132.9a160.7 160.7 0 00-3.7 34.2c0 92.3 74.8 169.1 171 169.1 15.3 0 35.9-4.6 47.2-7.7s22.5-7.2 25.4-8.3a26.44 26.44 0 019.3-1.7 26 26 0 0110.1 2l56.7 20.1a13.52 13.52 0 003.9 1 8 8 0 008-8 12.85 12.85 0 00-.5-2.7z"/>
  44. </svg>
  45. </div>
  46. <div class="stat-info">
  47. <div class="stat-value">{{ messages.length }}</div>
  48. <div class="stat-label">总消息</div>
  49. </div>
  50. </div>
  51. <div class="stat-card">
  52. <div class="stat-icon customers">
  53. <svg viewBox="0 0 512 512">
  54. <path fill="currentColor" d="M258.9 48C141.92 46.42 46.42 141.92 48 258.9c1.56 112.19 92.91 203.54 205.1 205.1 117 1.6 212.48-93.9 210.88-210.88C462.44 140.91 371.09 49.56 258.9 48z"/>
  55. </svg>
  56. </div>
  57. <div class="stat-info">
  58. <div class="stat-value">{{ customerMessageCount }}</div>
  59. <div class="stat-label">客户消息</div>
  60. </div>
  61. </div>
  62. <div class="stat-card" [class.alert]="unreadCount > 0">
  63. <div class="stat-icon unread">
  64. <svg viewBox="0 0 512 512">
  65. <path fill="currentColor" d="M256 48C141.31 48 48 141.31 48 256s93.31 208 208 208 208-93.31 208-208S370.69 48 256 48zm0 62.5a52.5 52.5 0 1152.5 52.5A52.5 52.5 0 01256 110.5zm21.72 206.41l-5.74 122a16 16 0 01-32 0l-5.74-122a21.74 21.74 0 1143.44 0z"/>
  66. </svg>
  67. </div>
  68. <div class="stat-info">
  69. <div class="stat-value">{{ unreadCount }}</div>
  70. <div class="stat-label">未回复</div>
  71. </div>
  72. </div>
  73. </div>
  74. <!-- 入群方式卡片 -->
  75. <div class="section-card join-methods-card">
  76. <div class="card-header" (click)="showJoinMethods = !showJoinMethods">
  77. <div class="header-left">
  78. <svg class="icon" viewBox="0 0 512 512">
  79. <path fill="currentColor" d="M336 208v-95a80 80 0 00-160 0v95" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"/>
  80. <rect x="96" y="208" width="320" height="272" rx="48" ry="48" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"/>
  81. </svg>
  82. <span>入群方式</span>
  83. </div>
  84. <svg class="chevron" [class.open]="showJoinMethods" viewBox="0 0 512 512">
  85. <path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="48" d="M112 184l144 144 144-144"/>
  86. </svg>
  87. </div>
  88. @if (showJoinMethods) {
  89. <div class="card-content">
  90. <!-- 介绍文案 -->
  91. <div class="intro-section">
  92. <div class="intro-header">
  93. <svg class="icon" viewBox="0 0 512 512">
  94. <path fill="currentColor" d="M256 48C141.31 48 48 141.31 48 256s93.31 208 208 208 208-93.31 208-208S370.69 48 256 48zm0 62.5a52.5 52.5 0 1152.5 52.5A52.5 52.5 0 01256 110.5zm80 291.5H176a16 16 0 010-32h28v-88h-16a16 16 0 010-32h40a16 16 0 0116 16v104h28a16 16 0 010 32z"/>
  95. </svg>
  96. <span>群介绍文案</span>
  97. </div>
  98. @if (introSent) {
  99. <div class="intro-sent">
  100. <svg class="icon" viewBox="0 0 512 512">
  101. <path fill="currentColor" d="M448 256c0-106-86-192-192-192S64 150 64 256s86 192 192 192 192-86 192-192z"/>
  102. <path fill="none" stroke="#fff" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M352 176L217.6 336 160 272"/>
  103. </svg>
  104. <span>介绍文案已发送</span>
  105. </div>
  106. } @else {
  107. <button class="btn-primary" (click)="sendIntroMessage()">
  108. <svg class="icon" viewBox="0 0 512 512">
  109. <path fill="currentColor" d="M476.59 227.05l-.16-.07L49.35 49.84A23.56 23.56 0 0027.14 52 24.65 24.65 0 0016 72.59v113.29a24 24 0 0019.52 23.57l232.93 43.07a4 4 0 010 7.86L35.53 303.45A24 24 0 0016 327v113.31A23.57 23.57 0 0026.59 460a23.94 23.94 0 0013.22 4 24.55 24.55 0 009.52-1.93L476.4 285.94l.19-.09a32 32 0 000-58.8z"/>
  110. </svg>
  111. <span>自动发送群介绍</span>
  112. </button>
  113. }
  114. </div>
  115. <!-- 入群二维码和链接 -->
  116. <div class="join-ways">
  117. @if (joinQrCode) {
  118. <div class="join-way-item">
  119. <div class="join-way-label">
  120. <svg class="icon" viewBox="0 0 512 512">
  121. <rect x="336" y="336" width="80" height="80" rx="8" ry="8" fill="currentColor"/>
  122. <rect x="272" y="272" width="64" height="64" rx="8" ry="8" fill="currentColor"/>
  123. <rect x="416" y="416" width="64" height="64" rx="8" ry="8" fill="currentColor"/>
  124. <rect x="432" y="272" width="48" height="48" rx="8" ry="8" fill="currentColor"/>
  125. <rect x="272" y="432" width="48" height="48" rx="8" ry="8" fill="currentColor"/>
  126. <rect x="336" y="96" width="80" height="80" rx="8" ry="8" fill="currentColor"/>
  127. <rect x="288" y="48" width="176" height="176" rx="16" ry="16" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"/>
  128. <rect x="96" y="96" width="80" height="80" rx="8" ry="8" fill="currentColor"/>
  129. <rect x="48" y="48" width="176" height="176" rx="16" ry="16" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"/>
  130. <rect x="96" y="336" width="80" height="80" rx="8" ry="8" fill="currentColor"/>
  131. <rect x="48" y="288" width="176" height="176" rx="16" ry="16" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"/>
  132. </svg>
  133. <span>入群二维码</span>
  134. </div>
  135. <div class="qrcode-container">
  136. <img [src]="joinQrCode" alt="入群二维码" />
  137. </div>
  138. </div>
  139. }
  140. @if (joinLink) {
  141. <div class="join-way-item">
  142. <div class="join-way-label">
  143. <svg class="icon" viewBox="0 0 512 512">
  144. <path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="48" d="M200.66 352H144a96 96 0 010-192h55.41M312.59 160H368a96 96 0 010 192h-56.66M169.07 256h175.86"/>
  145. </svg>
  146. <span>入群链接</span>
  147. </div>
  148. <div class="link-container">
  149. <input type="text" [value]="joinLink" readonly />
  150. <button class="btn-copy" (click)="copyJoinLink()">
  151. <svg viewBox="0 0 512 512">
  152. <rect x="128" y="128" width="336" height="336" rx="57" ry="57" fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32"/>
  153. <path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M383.5 128l.5-24a56.16 56.16 0 00-56-56H112a64.19 64.19 0 00-64 64v216a56.16 56.16 0 0056 56h24"/>
  154. </svg>
  155. 复制
  156. </button>
  157. </div>
  158. </div>
  159. }
  160. </div>
  161. </div>
  162. }
  163. </div>
  164. <!-- 聊天记录卡片 -->
  165. <div class="section-card chat-history-card">
  166. <div class="card-header" (click)="showChatHistory = !showChatHistory">
  167. <div class="header-left">
  168. <svg class="icon" viewBox="0 0 512 512">
  169. <path fill="currentColor" d="M408 64H104a56.16 56.16 0 00-56 56v192a56.16 56.16 0 0056 56h40v80l93.72-78.14a8 8 0 015.13-1.86H408a56.16 56.16 0 0056-56V120a56.16 56.16 0 00-56-56z"/>
  170. </svg>
  171. <span>往期聊天记录</span>
  172. @if (unreadCount > 0) {
  173. <span class="unread-badge">{{ unreadCount }}</span>
  174. }
  175. </div>
  176. <svg class="chevron" [class.open]="showChatHistory" viewBox="0 0 512 512">
  177. <path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="48" d="M112 184l144 144 144-144"/>
  178. </svg>
  179. </div>
  180. @if (showChatHistory) {
  181. <div class="card-content">
  182. <!-- 筛选按钮 -->
  183. <div class="filter-bar">
  184. <button
  185. class="filter-btn"
  186. [class.active]="filterType === 'all'"
  187. (click)="setFilter('all')">
  188. <svg class="icon" viewBox="0 0 512 512">
  189. <rect x="48" y="80" width="416" height="352" rx="48" ry="48" fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32"/>
  190. </svg>
  191. <span>全部 ({{ messages.length }})</span>
  192. </button>
  193. <button
  194. class="filter-btn"
  195. [class.active]="filterType === 'customer'"
  196. (click)="setFilter('customer')">
  197. <svg class="icon" viewBox="0 0 512 512">
  198. <path fill="currentColor" d="M258.9 48C141.92 46.42 46.42 141.92 48 258.9c1.56 112.19 92.91 203.54 205.1 205.1 117 1.6 212.48-93.9 210.88-210.88C462.44 140.91 371.09 49.56 258.9 48z"/>
  199. </svg>
  200. <span>客户 ({{ customerMessageCount }})</span>
  201. </button>
  202. <button
  203. class="filter-btn"
  204. [class.active]="filterType === 'unread'"
  205. [class.alert]="unreadCount > 0"
  206. (click)="setFilter('unread')">
  207. <svg class="icon" viewBox="0 0 512 512">
  208. <path fill="currentColor" d="M256 48C141.31 48 48 141.31 48 256s93.31 208 208 208 208-93.31 208-208S370.69 48 256 48zm0 62.5a52.5 52.5 0 1152.5 52.5A52.5 52.5 0 01256 110.5zm21.72 206.41l-5.74 122a16 16 0 01-32 0l-5.74-122a21.74 21.74 0 1143.44 0z"/>
  209. </svg>
  210. <span>未回复 ({{ unreadCount }})</span>
  211. </button>
  212. </div>
  213. <!-- 消息列表 -->
  214. <div class="message-list">
  215. @if (getFilteredMessages().length === 0) {
  216. <div class="empty-state">
  217. <svg class="icon" viewBox="0 0 512 512">
  218. <path fill="currentColor" d="M448 341.37V170.61A32 32 0 00416 138.61H96a32 32 0 00-32 32v170.76a32 32 0 0032 32h320a32 32 0 0032-32z"/>
  219. </svg>
  220. <span>暂无消息</span>
  221. </div>
  222. } @else {
  223. @for (message of getFilteredMessages(); track message.id) {
  224. <div
  225. class="message-item"
  226. [class.customer]="message.isCustomer"
  227. [class.needs-reply]="message.needsReply"
  228. (click)="message.isCustomer && message.needsReply ? selectMessageForReply(message) : null">
  229. <div class="message-header">
  230. <div class="sender-info">
  231. <span class="sender-name">{{ message.senderName }}</span>
  232. @if (message.isCustomer) {
  233. <span class="customer-badge">客户</span>
  234. }
  235. </div>
  236. <span class="message-time">{{ formatTime(message.time) }}</span>
  237. </div>
  238. <div class="message-content">
  239. {{ message.content }}
  240. </div>
  241. @if (message.needsReply) {
  242. <div class="reply-warning">
  243. <svg class="icon" viewBox="0 0 512 512">
  244. <path fill="currentColor" d="M256 48C141.31 48 48 141.31 48 256s93.31 208 208 208 208-93.31 208-208S370.69 48 256 48zm0 62.5a52.5 52.5 0 1152.5 52.5A52.5 52.5 0 01256 110.5zm21.72 206.41l-5.74 122a16 16 0 01-32 0l-5.74-122a21.74 21.74 0 1143.44 0z"/>
  245. </svg>
  246. <span>{{ getUnreadDuration(message.time) }}未回复,点击获取AI回复建议</span>
  247. </div>
  248. }
  249. </div>
  250. }
  251. }
  252. </div>
  253. <!-- 快捷操作 -->
  254. <div class="quick-actions">
  255. <button class="action-btn" (click)="openGroupChat()">
  256. <svg class="icon" viewBox="0 0 512 512">
  257. <path fill="currentColor" d="M408 64H104a56.16 56.16 0 00-56 56v192a56.16 56.16 0 0056 56h40v80l93.72-78.14a8 8 0 015.13-1.86H408a56.16 56.16 0 0056-56V120a56.16 56.16 0 00-56-56z"/>
  258. </svg>
  259. <span>打开群聊</span>
  260. </button>
  261. </div>
  262. </div>
  263. }
  264. </div>
  265. </div>
  266. <!-- AI回复建议弹窗 -->
  267. @if (selectedMessage) {
  268. <div class="modal-overlay" (click)="selectedMessage = null; replySuggestions = []">
  269. <div class="modal-content" (click)="$event.stopPropagation()">
  270. <div class="modal-header">
  271. <h3>AI回复建议</h3>
  272. <button class="btn-close" (click)="selectedMessage = null; replySuggestions = []">
  273. <svg viewBox="0 0 512 512">
  274. <path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M368 368L144 144M368 144L144 368"/>
  275. </svg>
  276. </button>
  277. </div>
  278. <div class="modal-body">
  279. <!-- 原消息 -->
  280. <div class="original-message">
  281. <div class="label">客户消息:</div>
  282. <div class="content">{{ selectedMessage.content }}</div>
  283. </div>
  284. <!-- AI生成中 -->
  285. @if (generatingAI) {
  286. <div class="generating-state">
  287. <div class="spinner"></div>
  288. <p>AI正在生成回复建议...</p>
  289. </div>
  290. }
  291. <!-- 回复建议 -->
  292. @if (!generatingAI && replySuggestions.length > 0) {
  293. <div class="suggestions-list">
  294. <div class="label">选择一个回复:</div>
  295. @for (suggestion of replySuggestions; track $index) {
  296. <button class="suggestion-item" (click)="useSuggestion(suggestion)">
  297. <span class="suggestion-icon">{{ suggestion.icon }}</span>
  298. <span class="suggestion-text">{{ suggestion.text }}</span>
  299. <svg class="icon-send" viewBox="0 0 512 512">
  300. <path fill="currentColor" d="M476.59 227.05l-.16-.07L49.35 49.84A23.56 23.56 0 0027.14 52 24.65 24.65 0 0016 72.59v113.29a24 24 0 0019.52 23.57l232.93 43.07a4 4 0 010 7.86L35.53 303.45A24 24 0 0016 327v113.31A23.57 23.57 0 0026.59 460a23.94 23.94 0 0013.22 4 24.55 24.55 0 009.52-1.93L476.4 285.94l.19-.09a32 32 0 000-58.8z"/>
  301. </svg>
  302. </button>
  303. }
  304. </div>
  305. }
  306. </div>
  307. </div>
  308. </div>
  309. }
  310. }
  311. </div>