| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427 | 
							- <!DOCTYPE html>
 
- <html lang="zh-CN">
 
- <head>
 
-   <meta charset="UTF-8">
 
-   <meta name="viewport" content="width=device-width, initial-scale=1.0">
 
-   <title>创建测试群聊记录</title>
 
-   <style>
 
-     * {
 
-       margin: 0;
 
-       padding: 0;
 
-       box-sizing: border-box;
 
-     }
 
-     
 
-     body {
 
-       font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
 
-       background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
 
-       min-height: 100vh;
 
-       display: flex;
 
-       align-items: center;
 
-       justify-content: center;
 
-       padding: 20px;
 
-     }
 
-     
 
-     .container {
 
-       background: white;
 
-       border-radius: 20px;
 
-       box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
 
-       padding: 40px;
 
-       max-width: 600px;
 
-       width: 100%;
 
-     }
 
-     
 
-     h1 {
 
-       color: #333;
 
-       margin-bottom: 10px;
 
-       font-size: 28px;
 
-     }
 
-     
 
-     .subtitle {
 
-       color: #666;
 
-       margin-bottom: 30px;
 
-       font-size: 14px;
 
-     }
 
-     
 
-     .info-box {
 
-       background: #f8f9fa;
 
-       border-left: 4px solid #667eea;
 
-       padding: 15px;
 
-       margin-bottom: 20px;
 
-       border-radius: 4px;
 
-     }
 
-     
 
-     .info-box h3 {
 
-       color: #667eea;
 
-       margin-bottom: 10px;
 
-       font-size: 16px;
 
-     }
 
-     
 
-     .info-box p {
 
-       color: #666;
 
-       font-size: 14px;
 
-       line-height: 1.6;
 
-       margin: 5px 0;
 
-     }
 
-     
 
-     .info-box code {
 
-       background: #e9ecef;
 
-       padding: 2px 6px;
 
-       border-radius: 3px;
 
-       font-family: 'Courier New', monospace;
 
-       font-size: 13px;
 
-       color: #d63384;
 
-     }
 
-     
 
-     button {
 
-       width: 100%;
 
-       padding: 15px;
 
-       background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
 
-       color: white;
 
-       border: none;
 
-       border-radius: 10px;
 
-       font-size: 16px;
 
-       font-weight: 600;
 
-       cursor: pointer;
 
-       transition: transform 0.2s, box-shadow 0.2s;
 
-       margin-bottom: 15px;
 
-     }
 
-     
 
-     button:hover {
 
-       transform: translateY(-2px);
 
-       box-shadow: 0 10px 20px rgba(102, 126, 234, 0.4);
 
-     }
 
-     
 
-     button:active {
 
-       transform: translateY(0);
 
-     }
 
-     
 
-     button:disabled {
 
-       opacity: 0.6;
 
-       cursor: not-allowed;
 
-       transform: none;
 
-     }
 
-     
 
-     .btn-secondary {
 
-       background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
 
-     }
 
-     
 
-     .btn-success {
 
-       background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
 
-     }
 
-     
 
-     .result {
 
-       margin-top: 20px;
 
-       padding: 15px;
 
-       border-radius: 10px;
 
-       display: none;
 
-       animation: slideIn 0.3s ease-out;
 
-     }
 
-     
 
-     @keyframes slideIn {
 
-       from {
 
-         opacity: 0;
 
-         transform: translateY(-10px);
 
-       }
 
-       to {
 
-         opacity: 1;
 
-         transform: translateY(0);
 
-       }
 
-     }
 
-     
 
-     .result.success {
 
-       background: #d4edda;
 
-       border: 1px solid #c3e6cb;
 
-       color: #155724;
 
-       display: block;
 
-     }
 
-     
 
-     .result.error {
 
-       background: #f8d7da;
 
-       border: 1px solid #f5c6cb;
 
-       color: #721c24;
 
-       display: block;
 
-     }
 
-     
 
-     .result h3 {
 
-       margin-bottom: 10px;
 
-       font-size: 16px;
 
-     }
 
-     
 
-     .result p {
 
-       margin: 5px 0;
 
-       font-size: 14px;
 
-       line-height: 1.6;
 
-     }
 
-     
 
-     .result a {
 
-       color: #0056b3;
 
-       text-decoration: none;
 
-       word-break: break-all;
 
-       font-weight: 600;
 
-     }
 
-     
 
-     .result a:hover {
 
-       text-decoration: underline;
 
-     }
 
-     
 
-     .loading {
 
-       display: none;
 
-       text-align: center;
 
-       padding: 20px;
 
-     }
 
-     
 
-     .loading.active {
 
-       display: block;
 
-     }
 
-     
 
-     .spinner {
 
-       border: 3px solid #f3f3f3;
 
-       border-top: 3px solid #667eea;
 
-       border-radius: 50%;
 
-       width: 40px;
 
-       height: 40px;
 
-       animation: spin 1s linear infinite;
 
-       margin: 0 auto 10px;
 
-     }
 
-     
 
-     @keyframes spin {
 
-       0% { transform: rotate(0deg); }
 
-       100% { transform: rotate(360deg); }
 
-     }
 
-   </style>
 
- </head>
 
- <body>
 
-   <div class="container">
 
-     <h1>🚀 创建测试群聊记录</h1>
 
-     <p class="subtitle">在Parse数据库中创建群聊记录,用于测试会话激活页面</p>
 
-     
 
-     <div class="info-box">
 
-       <h3>📋 你的企微信息</h3>
 
-       <p><strong>公司ID (cid):</strong> <code>cDL6R1hgSi</code></p>
 
-       <p><strong>用户ID (userid):</strong> <code>woAs2qCQAAGQckyg7AQBxhMEoSwnlTvg</code></p>
 
-       <p><strong>群聊ID (chat_id):</strong> <code>wrgKCxBwAALwOgUC9jMwdHiVTFmyXs_A</code></p>
 
-     </div>
 
-     
 
-     <button onclick="createGroupChat()" id="createBtn">
 
-       📝 创建群聊记录
 
-     </button>
 
-     
 
-     <button onclick="queryExisting()" id="queryBtn" class="btn-secondary">
 
-       🔍 查询现有记录
 
-     </button>
 
-     
 
-     <button onclick="openTestPage()" id="openBtn" class="btn-success" disabled>
 
-       🌐 打开测试页面
 
-     </button>
 
-     
 
-     <div class="loading" id="loading">
 
-       <div class="spinner"></div>
 
-       <p>处理中...</p>
 
-     </div>
 
-     
 
-     <div class="result" id="result"></div>
 
-   </div>
 
-   <script type="module">
 
-     const CONFIG = {
 
-       cid: 'cDL6R1hgSi',
 
-       userid: 'woAs2qCQAAGQckyg7AQBxhMEoSwnlTvg',
 
-       wxworkChatId: 'wrgKCxBwAALwOgUC9jMwdHiVTFmyXs_A'
 
-     };
 
-     
 
-     let currentGroupChatId = null;
 
-     
 
-     // 配置localStorage
 
-     function setupLocalStorage() {
 
-       localStorage.setItem('company', CONFIG.cid);
 
-       localStorage.setItem(`${CONFIG.cid}/USERINFO`, JSON.stringify({
 
-         userid: CONFIG.userid,
 
-         errcode: 0,
 
-         errmsg: 'ok',
 
-         cid: CONFIG.cid
 
-       }));
 
-       console.log('✅ localStorage配置成功');
 
-     }
 
-     
 
-     // 显示结果
 
-     function showResult(type, title, content) {
 
-       const resultDiv = document.getElementById('result');
 
-       resultDiv.className = `result ${type}`;
 
-       resultDiv.innerHTML = `<h3>${title}</h3>${content}`;
 
-     }
 
-     
 
-     // 显示加载
 
-     function showLoading(show) {
 
-       document.getElementById('loading').className = show ? 'loading active' : 'loading';
 
-       document.getElementById('createBtn').disabled = show;
 
-       document.getElementById('queryBtn').disabled = show;
 
-     }
 
-     
 
-     // 查询现有记录
 
-     window.queryExisting = async function() {
 
-       try {
 
-         showLoading(true);
 
-         setupLocalStorage();
 
-         
 
-         const { FmodeParse } = await import('fmode-ng/parse');
 
-         const Parse = FmodeParse.with('nova');
 
-         
 
-         console.log('🔍 查询现有群聊记录...');
 
-         
 
-         const query = new Parse.Query('GroupChat');
 
-         query.equalTo('chat_id', CONFIG.wxworkChatId);
 
-         query.equalTo('company', { __type: 'Pointer', className: 'Company', objectId: CONFIG.cid });
 
-         query.include('project');
 
-         
 
-         const groupChat = await query.first();
 
-         
 
-         if (groupChat) {
 
-           currentGroupChatId = groupChat.id;
 
-           document.getElementById('openBtn').disabled = false;
 
-           
 
-           const url = `http://localhost:4200/wxwork/${CONFIG.cid}/chat-activation/${groupChat.id}`;
 
-           
 
-           showResult('success', '✅ 找到现有记录!', `
 
-             <p><strong>群聊名称:</strong> ${groupChat.get('name') || '未命名'}</p>
 
-             <p><strong>Parse ID:</strong> ${groupChat.id}</p>
 
-             <p><strong>企微 chat_id:</strong> ${groupChat.get('chat_id')}</p>
 
-             <p><strong>成员数量:</strong> ${(groupChat.get('member_list') || []).length}</p>
 
-             <p><strong>测试地址:</strong></p>
 
-             <p><a href="${url}" target="_blank">${url}</a></p>
 
-             <p style="margin-top: 10px; color: #666;">点击上方"打开测试页面"按钮或直接点击链接</p>
 
-           `);
 
-           
 
-           console.log('✅ 找到群聊:', groupChat.toJSON());
 
-         } else {
 
-           showResult('error', '⚠️ 未找到记录', `
 
-             <p>Parse数据库中没有该群聊记录</p>
 
-             <p>请点击"创建群聊记录"按钮创建新记录</p>
 
-           `);
 
-         }
 
-         
 
-       } catch (error) {
 
-         console.error('❌ 查询失败:', error);
 
-         showResult('error', '❌ 查询失败', `
 
-           <p>${error.message}</p>
 
-           <p>请确保项目已启动且Parse Server已连接</p>
 
-         `);
 
-       } finally {
 
-         showLoading(false);
 
-       }
 
-     };
 
-     
 
-     // 创建群聊记录
 
-     window.createGroupChat = async function() {
 
-       try {
 
-         showLoading(true);
 
-         setupLocalStorage();
 
-         
 
-         const { FmodeParse } = await import('fmode-ng/parse');
 
-         const Parse = FmodeParse.with('nova');
 
-         
 
-         console.log('📝 创建群聊记录...');
 
-         
 
-         // 先检查是否已存在
 
-         const existQuery = new Parse.Query('GroupChat');
 
-         existQuery.equalTo('chat_id', CONFIG.wxworkChatId);
 
-         existQuery.equalTo('company', { __type: 'Pointer', className: 'Company', objectId: CONFIG.cid });
 
-         
 
-         const existing = await existQuery.first();
 
-         
 
-         if (existing) {
 
-           currentGroupChatId = existing.id;
 
-           document.getElementById('openBtn').disabled = false;
 
-           
 
-           const url = `http://localhost:4200/wxwork/${CONFIG.cid}/chat-activation/${existing.id}`;
 
-           
 
-           showResult('success', '✅ 记录已存在!', `
 
-             <p>该群聊记录已存在,无需重复创建</p>
 
-             <p><strong>群聊名称:</strong> ${existing.get('name') || '未命名'}</p>
 
-             <p><strong>Parse ID:</strong> ${existing.id}</p>
 
-             <p><strong>测试地址:</strong></p>
 
-             <p><a href="${url}" target="_blank">${url}</a></p>
 
-           `);
 
-           
 
-           return;
 
-         }
 
-         
 
-         // 创建新记录
 
-         const GroupChat = Parse.Object.extend('GroupChat');
 
-         const newGroupChat = new GroupChat();
 
-         
 
-         newGroupChat.set('chat_id', CONFIG.wxworkChatId);
 
-         newGroupChat.set('name', '测试群聊 - ' + new Date().toLocaleString('zh-CN'));
 
-         newGroupChat.set('company', { __type: 'Pointer', className: 'Company', objectId: CONFIG.cid });
 
-         newGroupChat.set('member_list', [
 
-           {
 
-             userid: CONFIG.userid,
 
-             type: 1,
 
-             join_time: Math.floor(Date.now() / 1000),
 
-             join_scene: 1
 
-           }
 
-         ]);
 
-         newGroupChat.set('data', {
 
-           createdFrom: 'test-html',
 
-           createdAt: new Date(),
 
-           wxworkChatId: CONFIG.wxworkChatId,
 
-           note: '通过测试页面创建'
 
-         });
 
-         
 
-         const savedGroupChat = await newGroupChat.save();
 
-         currentGroupChatId = savedGroupChat.id;
 
-         document.getElementById('openBtn').disabled = false;
 
-         
 
-         const url = `http://localhost:4200/wxwork/${CONFIG.cid}/chat-activation/${savedGroupChat.id}`;
 
-         
 
-         showResult('success', '✅ 创建成功!', `
 
-           <p><strong>群聊名称:</strong> ${savedGroupChat.get('name')}</p>
 
-           <p><strong>Parse ID:</strong> ${savedGroupChat.id}</p>
 
-           <p><strong>企微 chat_id:</strong> ${savedGroupChat.get('chat_id')}</p>
 
-           <p><strong>测试地址:</strong></p>
 
-           <p><a href="${url}" target="_blank">${url}</a></p>
 
-           <p style="margin-top: 15px; padding: 10px; background: #fff3cd; border-radius: 5px; color: #856404;">
 
-             💡 <strong>提示:</strong> 页面加载时会自动尝试从企微API同步最新数据(成员列表、群名称等)
 
-           </p>
 
-         `);
 
-         
 
-         console.log('✅ 群聊记录已创建:', savedGroupChat.toJSON());
 
-         
 
-       } catch (error) {
 
-         console.error('❌ 创建失败:', error);
 
-         showResult('error', '❌ 创建失败', `
 
-           <p>${error.message}</p>
 
-           <p>请确保:</p>
 
-           <ul style="margin-left: 20px; margin-top: 10px;">
 
-             <li>项目已启动 (npm start)</li>
 
-             <li>Parse Server已连接</li>
 
-             <li>网络连接正常</li>
 
-           </ul>
 
-         `);
 
-       } finally {
 
-         showLoading(false);
 
-       }
 
-     };
 
-     
 
-     // 打开测试页面
 
-     window.openTestPage = function() {
 
-       if (!currentGroupChatId) {
 
-         alert('请先创建或查询群聊记录');
 
-         return;
 
-       }
 
-       
 
-       const url = `http://localhost:4200/wxwork/${CONFIG.cid}/chat-activation/${currentGroupChatId}`;
 
-       window.open(url, '_blank');
 
-     };
 
-     
 
-     // 页面加载时自动查询
 
-     window.addEventListener('load', () => {
 
-       console.log('🚀 页面已加载,可以开始测试');
 
-       // 自动查询现有记录
 
-       setTimeout(() => {
 
-         queryExisting();
 
-       }, 500);
 
-     });
 
-   </script>
 
- </body>
 
- </html>
 
 
  |