会话激活页面是一个全新的独立功能模块,用于管理项目群聊的激活和沟通。该模块提供了以下核心功能:
在项目路由配置文件中添加会话激活页面路由:
// 在 app.routes.ts 或相应的路由配置文件中添加
{
  path: 'wxwork/:cid/project/:projectId/chat-activation',
  component: ChatActivationComponent,
  canActivate: [WxAuthGuard]
}
从项目详情页跳转到会话激活页面:
// 在项目详情组件中
navigateToChatActivation() {
  this.router.navigate([
    '/wxwork', 
    this.cid, 
    'project', 
    this.projectId, 
    'chat-activation'
  ], {
    queryParams: {
      chatId: this.groupChat?.get('chat_id') // 可选:直接指定群聊ID
    }
  });
}
确保 Parse 数据库中存在以下表和字段:
{
  chat_id: String,          // 企微群聊ID
  name: String,             // 群聊名称
  project: Pointer,         // 关联项目
  company: String,          // 公司ID
  member_list: Array,       // 成员列表
  messages: Array,          // 消息列表
  introSent: Boolean,       // 是否已发送群介绍
  introSentAt: Date,        // 群介绍发送时间
  joinQrcode: Object,       // 入群二维码信息
  joinUrl: Object           // 入群链接信息
}
{
  title: String,            // 项目名称
  description: String,      // 项目描述
  contact: Pointer,         // 客户信息
  assignee: Pointer,        // 执行技术
  department: Pointer       // 部门(包含leader)
}
{
  external_userid: String,  // 企微外部联系人ID
  name: String,             // 客户姓名
  mobile: String,           // 手机号
  company: String           // 公司ID
}
功能说明:
实现原理:
// 根据 member_list 判断消息发送者是否为客户
const isCustomer = msg.from === customerUserId || 
                   memberList.some((m: any) => 
                     m.type === 2 && m.userid === msg.from
                   );
使用方法:
数据获取:
// 从企微API获取入群方式
const chatInfo = await this.wecorp.externalContact.groupChat.get(this.chatId);
// 保存到数据库
this.groupChat.set('joinQrcode', { qr_code: chatInfo.group_chat.qr_code });
this.groupChat.set('joinUrl', { join_url: chatInfo.group_chat.join_url });
功能说明:
文案模板:
欢迎加入【项目名称】项目群!
👤 项目主管:XXX
🔧 执行技术:XXX
📋 项目需求:XXX
我们将为您提供专业的服务,有任何问题随时沟通!
实现代码:
// 生成文案
generateIntroTemplate() {
  const leader = this.project.get('department')?.get('leader');
  const assignee = this.project.get('assignee');
  const projectTitle = this.project.get('title') || '项目';
  
  this.introTemplate = `欢迎加入【${projectTitle}】项目群!\n\n` +
                      `👤 项目主管:${leader?.get('name') || '待定'}\n` +
                      `🔧 执行技术:${assignee?.get('name') || '待定'}\n` +
                      `📋 项目需求:${this.project.get('description') || '详见需求文档'}\n\n` +
                      `我们将为您提供专业的服务,有任何问题随时沟通!`;
}
// 发送文案
async sendGroupIntro() {
  await this.wecorp.message.sendText({
    chatid: this.chatId,
    text: { content: this.introTemplate }
  });
  
  // 标记已发送
  this.groupChat.set('introSent', true);
  this.groupChat.set('introSentAt', new Date());
  await this.groupChat.save();
}
功能说明:
实现原理:
// 启动定时检查
private startUnreadCheck() {
  this.checkTimer = setInterval(() => {
    this.checkUnreadMessages();
  }, 60 * 1000); // 每分钟检查一次
}
// 检查未回复消息
private async checkUnreadMessages() {
  const unreadMessages = this.messages.filter(m => m.needsReply);
  
  for (const msg of unreadMessages) {
    const timeDiff = Date.now() - msg.time.getTime();
    
    // 10分钟未回复,发送通知
    if (timeDiff >= 10 * 60 * 1000 && timeDiff < 11 * 60 * 1000) {
      await this.sendUnreadNotification(msg);
    }
  }
}
// 发送通知
private async sendUnreadNotification(message: ChatMessage) {
  const groupName = this.groupChat?.get('name') || '项目群';
  const notificationText = `【${groupName}】客户消息已超10分钟未回复,请及时处理!\n\n` +
                          `客户:${message.senderName}\n` +
                          `消息:${message.content}`;
  
  await this.wecorp.message.sendText({
    touser: userId,
    agentid: '1000017',
    text: { content: notificationText }
  });
}
判断逻辑:
功能说明:
智能匹配规则:
| 关键词 | 建议回复 | 
|---|---|
| 需求、要求、想要 | "您说的需求已记录,我会在1小时内反馈详细方案给您。" | 
| 进度、什么时候、多久 | "目前项目进度正常,预计本周五前完成,届时会第一时间通知您。" | 
| 修改、调整、改 | "收到,我会马上按您的要求进行调整,调整完成后发送给您确认。" | 
| 通用 | "好的,我明白了,马上处理。" | 
实现代码:
async generateSuggestedReplies(message: ChatMessage) {
  const content = message.content.toLowerCase();
  this.suggestedReplies = [];
  
  // 根据关键词匹配回复
  if (content.includes('需求') || content.includes('要求')) {
    this.suggestedReplies.push({
      id: '1',
      text: '您说的需求已记录,我会在1小时内反馈详细方案给您。',
      icon: '📝'
    });
  }
  
  if (content.includes('进度') || content.includes('什么时候')) {
    this.suggestedReplies.push({
      id: '2',
      text: '目前项目进度正常,预计本周五前完成,届时会第一时间通知您。',
      icon: '⏰'
    });
  }
  
  // 通用回复
  this.suggestedReplies.push({
    id: '3',
    text: '好的,我明白了,马上处理。',
    icon: '👌'
  });
  
  // 限制最多5条
  this.suggestedReplies = this.suggestedReplies.slice(0, 5);
}
// 发送建议回复
async sendSuggestedReply(reply: SuggestedReply) {
  await this.wecorp.message.sendText({
    chatid: this.chatId,
    text: { content: reply.text }
  });
  
  // 刷新消息列表
  await this.loadChatMessages();
}
| 屏幕尺寸 | 布局调整 | 
|---|---|
| > 768px | 桌面端:三列网格布局 | 
| 481px - 768px | 平板端:两列布局 | 
| ≤ 480px | 手机端:单列布局 | 
@media (max-width: 768px) {
  .join-methods-grid {
    grid-template-columns: 1fr !important;
  }
  
  .filter-bar {
    flex-direction: column;
    .filter-btn {
      width: 100%;
    }
  }
}
@media (max-width: 480px) {
  .page-header {
    padding: 12px 16px;
    .page-title {
      font-size: 18px;
    }
  }
  
  .messages-list {
    max-height: 400px;
    .message-item {
      padding: 12px;
    }
  }
}
import { WxworkSDK, WxworkCorp, WxworkAuth } from 'fmode-ng/core';
import { FmodeParse, FmodeObject } from 'fmode-ng/parse';
1. 初始化SDK → WxworkAuth.authenticateAndLogin()
2. 加载项目数据 → Parse.Query('Project').get()
3. 加载群聊数据 → Parse.Query('GroupChat').first()
4. 加载消息列表 → groupChat.get('messages')
5. 筛选客户消息 → 根据member_list判断
6. 检测未回复 → 定时器每分钟检查
7. 发送通知 → wecorp.message.sendText()
// 加载状态
loading: boolean = true;
loadingMessages: boolean = false;
sendingIntro: boolean = false;
// 筛选状态
showOnlyCustomer: boolean = false;
showOnlyUnread: boolean = false;
// 统计数据
totalMessages: number = 0;
customerMessageCount: number = 0;
unreadCount: number = 0;
| 用途 | 颜色值 | 说明 | 
|---|---|---|
| 主色调 | #007aff | iOS蓝色 | 
| 成功色 | #34c759 | 绿色 | 
| 警告色 | #ff9500 | 橙色 | 
| 危险色 | #ff3b30 | 红色 | 
| 背景色 | #f5f7fa | 浅灰色 | 
// 卡片阴影
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
// 悬停阴影
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
// 按钮阴影
box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
A: 检查以下几点:
A:
A:
A:
添加搜索框,支持按关键词搜索历史消息
支持导出聊天记录为Excel或PDF
接入AI大模型,生成更智能的回复建议
添加回复率、响应时间等统计图表
支持同时管理多个项目群聊
如有问题,请联系技术团队或查阅以下文档:
文档版本: v1.0.0
最后更新: 2025年11月1日
维护者: 开发团队