| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458 | 
							- /**
 
-  * 会话激活功能 - 一键测试数据设置脚本
 
-  * 
 
-  * 使用方法:
 
-  * 1. 在浏览器控制台中复制粘贴此脚本
 
-  * 2. 或者在 HTML 中引入: <script src="/test-setup.js"></script>
 
-  * 3. 调用 setupTestData() 函数
 
-  */
 
- function setupTestData() {
 
-   console.log('🚀 开始设置测试数据...\n');
 
-   
 
-   // ========== 1. 设置公司ID ==========
 
-   localStorage.setItem('company', 'test-company-001');
 
-   console.log('✅ 1/7 公司ID设置完成');
 
-   
 
-   // ========== 2. 设置当前用户 ==========
 
-   const mockUser = {
 
-     objectId: 'user-001',
 
-     id: 'user-001',
 
-     userid: 'wxwork-user-001',
 
-     name: '测试技术员',
 
-     realName: '张三',
 
-     roleName: '技术',
 
-     department: {
 
-       __type: 'Pointer',
 
-       className: 'Department',
 
-       objectId: 'dept-001'
 
-     },
 
-     company: {
 
-       __type: 'Pointer',
 
-       className: 'Company',
 
-       objectId: 'test-company-001'
 
-     }
 
-   };
 
-   localStorage.setItem('currentUser', JSON.stringify(mockUser));
 
-   console.log('✅ 2/7 当前用户设置完成:', mockUser.name);
 
-   
 
-   // ========== 3. 设置项目数据 ==========
 
-   const mockProject = {
 
-     objectId: 'project-001',
 
-     id: 'project-001',
 
-     title: '测试项目 - 现代简约风格装修',
 
-     description: '客厅、卧室、厨房三室一厅装修,预算15-20万',
 
-     status: '进行中',
 
-     contact: {
 
-       __type: 'Pointer',
 
-       className: 'ContactInfo',
 
-       objectId: 'contact-001'
 
-     },
 
-     assignee: {
 
-       __type: 'Pointer',
 
-       className: 'Profile',
 
-       objectId: 'user-001'
 
-     },
 
-     department: {
 
-       __type: 'Pointer',
 
-       className: 'Department',
 
-       objectId: 'dept-001'
 
-     }
 
-   };
 
-   localStorage.setItem('mockProject', JSON.stringify(mockProject));
 
-   console.log('✅ 3/7 项目数据设置完成:', mockProject.title);
 
-   
 
-   // ========== 4. 设置客户数据 ==========
 
-   const mockContact = {
 
-     objectId: 'contact-001',
 
-     id: 'contact-001',
 
-     name: '李女士',
 
-     external_userid: 'external-user-001',
 
-     mobile: '138****8888',
 
-     company: 'test-company-001',
 
-     data: {
 
-       avatar: 'https://via.placeholder.com/100',
 
-       wechat: 'lixiaojie123',
 
-       tags: {
 
-         preference: '现代简约',
 
-         budget: { min: 150000, max: 200000 },
 
-         colorAtmosphere: '暖色调'
 
-       }
 
-     }
 
-   };
 
-   localStorage.setItem('mockContact', JSON.stringify(mockContact));
 
-   console.log('✅ 4/7 客户数据设置完成:', mockContact.name);
 
-   
 
-   // ========== 5. 设置群聊数据 ==========
 
-   const now = Math.floor(Date.now() / 1000);
 
-   const mockGroupChat = {
 
-     objectId: 'groupchat-001',
 
-     id: 'groupchat-001',
 
-     chat_id: 'wrkSFfCgAAXXXXXXXXXXXXXXXXXXXX',
 
-     name: '【李女士】现代简约装修项目群',
 
-     company: 'test-company-001',
 
-     project: {
 
-       __type: 'Pointer',
 
-       className: 'Project',
 
-       objectId: 'project-001'
 
-     },
 
-     introSent: false,
 
-     introSentAt: null,
 
-     joinQrcode: {
 
-       qr_code: 'https://via.placeholder.com/300?text=QR+Code'
 
-     },
 
-     joinUrl: {
 
-       join_url: 'https://work.weixin.qq.com/ca/cawcde123456'
 
-     },
 
-     member_list: [
 
-       {
 
-         userid: 'wxwork-user-001',
 
-         type: 1,
 
-         name: '张三',
 
-         invitor: {
 
-           userid: 'admin-001'
 
-         }
 
-       },
 
-       {
 
-         userid: 'external-user-001',
 
-         type: 2,
 
-         name: '李女士',
 
-         invitor: {
 
-           userid: 'wxwork-user-001'
 
-         }
 
-       },
 
-       {
 
-         userid: 'wxwork-user-002',
 
-         type: 1,
 
-         name: '王组长',
 
-         invitor: {
 
-           userid: 'admin-001'
 
-         }
 
-       }
 
-     ],
 
-     messages: [
 
-       {
 
-         msgid: 'msg-001',
 
-         from: 'external-user-001',
 
-         msgtime: now - 3600, // 1小时前
 
-         msgtype: 'text',
 
-         text: {
 
-           content: '你好,我想了解一下项目的进度'
 
-         }
 
-       },
 
-       {
 
-         msgid: 'msg-002',
 
-         from: 'wxwork-user-001',
 
-         msgtime: now - 3500,
 
-         msgtype: 'text',
 
-         text: {
 
-           content: '您好李女士,目前我们正在进行方案设计,预计明天可以给您看初稿'
 
-         }
 
-       },
 
-       {
 
-         msgid: 'msg-003',
 
-         from: 'external-user-001',
 
-         msgtime: now - 3400,
 
-         msgtype: 'text',
 
-         text: {
 
-           content: '好的,那我等你们的消息'
 
-         }
 
-       },
 
-       {
 
-         msgid: 'msg-004',
 
-         from: 'external-user-001',
 
-         msgtime: now - 700, // 11分钟前(超过10分钟)
 
-         msgtype: 'text',
 
-         text: {
 
-           content: '对了,我想把客厅的颜色改成浅灰色,可以吗?'
 
-         }
 
-       },
 
-       {
 
-         msgid: 'msg-005',
 
-         from: 'external-user-001',
 
-         msgtime: now - 650, // 10分钟前(刚好10分钟)
 
-         msgtype: 'text',
 
-         text: {
 
-           content: '还有厨房的橱柜我想换个品牌'
 
-         }
 
-       }
 
-     ]
 
-   };
 
-   localStorage.setItem('mockGroupChat', JSON.stringify(mockGroupChat));
 
-   console.log('✅ 5/7 群聊数据设置完成:', mockGroupChat.name);
 
-   console.log('   - 消息数量:', mockGroupChat.messages.length);
 
-   console.log('   - 成员数量:', mockGroupChat.member_list.length);
 
-   
 
-   // ========== 6. 设置部门数据 ==========
 
-   const mockDepartment = {
 
-     objectId: 'dept-001',
 
-     id: 'dept-001',
 
-     name: '设计部',
 
-     leader: {
 
-       __type: 'Pointer',
 
-       className: 'Profile',
 
-       objectId: 'leader-001'
 
-     }
 
-   };
 
-   localStorage.setItem('mockDepartment', JSON.stringify(mockDepartment));
 
-   console.log('✅ 6/7 部门数据设置完成:', mockDepartment.name);
 
-   
 
-   // ========== 7. 设置组长数据 ==========
 
-   const mockLeader = {
 
-     objectId: 'leader-001',
 
-     id: 'leader-001',
 
-     name: '王组长',
 
-     userid: 'wxwork-user-002',
 
-     roleName: '组长'
 
-   };
 
-   localStorage.setItem('mockLeader', JSON.stringify(mockLeader));
 
-   console.log('✅ 7/7 组长数据设置完成:', mockLeader.name);
 
-   
 
-   console.log('\n🎉 所有测试数据设置完成!\n');
 
-   console.log('📊 数据摘要:');
 
-   console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
 
-   console.log('公司ID:', localStorage.getItem('company'));
 
-   console.log('当前用户:', mockUser.name, '(' + mockUser.roleName + ')');
 
-   console.log('项目:', mockProject.title);
 
-   console.log('客户:', mockContact.name);
 
-   console.log('群聊:', mockGroupChat.name);
 
-   console.log('消息数:', mockGroupChat.messages.length, '条');
 
-   console.log('客户消息:', mockGroupChat.messages.filter(m => m.from === 'external-user-001').length, '条');
 
-   console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
 
-   
 
-   console.log('🔗 测试链接:');
 
-   console.log('http://localhost:4200/wxwork/test-company-001/project/project-001/chat-activation\n');
 
-   
 
-   console.log('💡 提示:');
 
-   console.log('- 直接访问上面的链接即可开始测试');
 
-   console.log('- 如需清除数据,执行: clearTestData()');
 
-   console.log('- 如需查看数据,执行: viewTestData()');
 
-   
 
-   return {
 
-     success: true,
 
-     message: '测试数据设置完成',
 
-     testUrl: 'http://localhost:4200/wxwork/test-company-001/project/project-001/chat-activation'
 
-   };
 
- }
 
- /**
 
-  * 清除所有测试数据
 
-  */
 
- function clearTestData() {
 
-   console.log('🗑️  开始清除测试数据...\n');
 
-   
 
-   const keys = [
 
-     'company',
 
-     'currentUser',
 
-     'mockProject',
 
-     'mockContact',
 
-     'mockGroupChat',
 
-     'mockDepartment',
 
-     'mockLeader'
 
-   ];
 
-   
 
-   keys.forEach((key, index) => {
 
-     localStorage.removeItem(key);
 
-     console.log(`✅ ${index + 1}/${keys.length} ${key} 已清除`);
 
-   });
 
-   
 
-   console.log('\n🎉 所有测试数据已清除!\n');
 
-   
 
-   return {
 
-     success: true,
 
-     message: '测试数据已清除'
 
-   };
 
- }
 
- /**
 
-  * 查看当前测试数据
 
-  */
 
- function viewTestData() {
 
-   console.log('📊 当前测试数据:\n');
 
-   console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
 
-   
 
-   const company = localStorage.getItem('company');
 
-   const user = localStorage.getItem('currentUser');
 
-   const project = localStorage.getItem('mockProject');
 
-   const contact = localStorage.getItem('mockContact');
 
-   const groupChat = localStorage.getItem('mockGroupChat');
 
-   const department = localStorage.getItem('mockDepartment');
 
-   const leader = localStorage.getItem('mockLeader');
 
-   
 
-   if (company) {
 
-     console.log('✅ 公司ID:', company);
 
-   } else {
 
-     console.log('❌ 公司ID: 未设置');
 
-   }
 
-   
 
-   if (user) {
 
-     const userData = JSON.parse(user);
 
-     console.log('✅ 当前用户:', userData.name, '(' + userData.roleName + ')');
 
-   } else {
 
-     console.log('❌ 当前用户: 未设置');
 
-   }
 
-   
 
-   if (project) {
 
-     const projectData = JSON.parse(project);
 
-     console.log('✅ 项目:', projectData.title);
 
-   } else {
 
-     console.log('❌ 项目: 未设置');
 
-   }
 
-   
 
-   if (contact) {
 
-     const contactData = JSON.parse(contact);
 
-     console.log('✅ 客户:', contactData.name);
 
-   } else {
 
-     console.log('❌ 客户: 未设置');
 
-   }
 
-   
 
-   if (groupChat) {
 
-     const groupChatData = JSON.parse(groupChat);
 
-     console.log('✅ 群聊:', groupChatData.name);
 
-     console.log('   - 消息数:', groupChatData.messages.length);
 
-     console.log('   - 成员数:', groupChatData.member_list.length);
 
-     console.log('   - 群介绍已发送:', groupChatData.introSent ? '是' : '否');
 
-   } else {
 
-     console.log('❌ 群聊: 未设置');
 
-   }
 
-   
 
-   if (department) {
 
-     const deptData = JSON.parse(department);
 
-     console.log('✅ 部门:', deptData.name);
 
-   } else {
 
-     console.log('❌ 部门: 未设置');
 
-   }
 
-   
 
-   if (leader) {
 
-     const leaderData = JSON.parse(leader);
 
-     console.log('✅ 组长:', leaderData.name);
 
-   } else {
 
-     console.log('❌ 组长: 未设置');
 
-   }
 
-   
 
-   console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
 
-   
 
-   const allSet = company && user && project && contact && groupChat && department && leader;
 
-   
 
-   if (allSet) {
 
-     console.log('✅ 所有数据已设置,可以开始测试!');
 
-     console.log('🔗 测试链接: http://localhost:4200/wxwork/test-company-001/project/project-001/chat-activation\n');
 
-   } else {
 
-     console.log('⚠️  部分数据未设置,请执行: setupTestData()\n');
 
-   }
 
-   
 
-   return {
 
-     allSet,
 
-     data: {
 
-       company: !!company,
 
-       user: !!user,
 
-       project: !!project,
 
-       contact: !!contact,
 
-       groupChat: !!groupChat,
 
-       department: !!department,
 
-       leader: !!leader
 
-     }
 
-   };
 
- }
 
- /**
 
-  * 添加超时未回复的消息(用于测试超时提醒功能)
 
-  */
 
- function addOverdueMessages() {
 
-   console.log('⏰ 添加超时未回复消息...\n');
 
-   
 
-   const groupChatStr = localStorage.getItem('mockGroupChat');
 
-   if (!groupChatStr) {
 
-     console.error('❌ 群聊数据不存在,请先执行 setupTestData()');
 
-     return;
 
-   }
 
-   
 
-   const groupChat = JSON.parse(groupChatStr);
 
-   const now = Math.floor(Date.now() / 1000);
 
-   
 
-   // 添加15分钟前的客户消息(未回复)
 
-   groupChat.messages.push({
 
-     msgid: 'msg-overdue-1',
 
-     from: 'external-user-001',
 
-     msgtime: now - 900, // 15分钟前
 
-     msgtype: 'text',
 
-     text: {
 
-       content: '请问什么时候可以开始施工?'
 
-     }
 
-   });
 
-   
 
-   // 添加20分钟前的客户消息(未回复)
 
-   groupChat.messages.push({
 
-     msgid: 'msg-overdue-2',
 
-     from: 'external-user-001',
 
-     msgtime: now - 1200, // 20分钟前
 
-     msgtype: 'text',
 
-     text: {
 
-       content: '预算能不能再优化一下?'
 
-     }
 
-   });
 
-   
 
-   localStorage.setItem('mockGroupChat', JSON.stringify(groupChat));
 
-   
 
-   console.log('✅ 已添加2条超时未回复消息');
 
-   console.log('   - 15分钟前: "请问什么时候可以开始施工?"');
 
-   console.log('   - 20分钟前: "预算能不能再优化一下?"');
 
-   console.log('\n💡 刷新页面查看效果\n');
 
-   
 
-   return {
 
-     success: true,
 
-     message: '超时消息已添加'
 
-   };
 
- }
 
- /**
 
-  * 模拟发送群介绍
 
-  */
 
- function simulateSendIntro() {
 
-   console.log('📤 模拟发送群介绍...\n');
 
-   
 
-   const groupChatStr = localStorage.getItem('mockGroupChat');
 
-   if (!groupChatStr) {
 
-     console.error('❌ 群聊数据不存在,请先执行 setupTestData()');
 
-     return;
 
-   }
 
-   
 
-   const groupChat = JSON.parse(groupChatStr);
 
-   groupChat.introSent = true;
 
-   groupChat.introSentAt = new Date().toISOString();
 
-   
 
-   localStorage.setItem('mockGroupChat', JSON.stringify(groupChat));
 
-   
 
-   console.log('✅ 群介绍已标记为已发送');
 
-   console.log('   发送时间:', groupChat.introSentAt);
 
-   console.log('\n💡 刷新页面查看效果\n');
 
-   
 
-   return {
 
-     success: true,
 
-     message: '群介绍已标记为已发送'
 
-   };
 
- }
 
- // 自动执行提示
 
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
 
- console.log('🧪 会话激活功能 - 测试工具已加载');
 
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
 
- console.log('\n可用命令:');
 
- console.log('  setupTestData()      - 一键设置所有测试数据');
 
- console.log('  clearTestData()      - 清除所有测试数据');
 
- console.log('  viewTestData()       - 查看当前测试数据');
 
- console.log('  addOverdueMessages() - 添加超时未回复消息');
 
- console.log('  simulateSendIntro()  - 模拟发送群介绍');
 
- console.log('\n💡 快速开始: 执行 setupTestData() 即可开始测试\n');
 
- // 导出函数(如果在模块环境中)
 
- if (typeof module !== 'undefined' && module.exports) {
 
-   module.exports = {
 
-     setupTestData,
 
-     clearTestData,
 
-     viewTestData,
 
-     addOverdueMessages,
 
-     simulateSendIntro
 
-   };
 
- }
 
 
  |