🎨 修改获取的企业名称,以及获取黑名单的分页条件
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
// 当popup页面的DOM内容完全加载后执行
|
// 当popup页面的DOM内容完全加载后执行
|
||||||
document.addEventListener('DOMContentLoaded', function () {
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
// 获取页面中的按钮元素
|
// 获取页面中的按钮元素
|
||||||
const getStudentsBtn = document.getElementById('get-students-btn');
|
// const getStudentsBtn = document.getElementById('get-students-btn');
|
||||||
const getBlacklistBtn = document.getElementById('get-blacklist-btn');
|
const getBlacklistBtn = document.getElementById('get-blacklist-btn');
|
||||||
const dataDisplay = document.getElementById('data-display');
|
const dataDisplay = document.getElementById('data-display');
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
if (enterpriseData && enterpriseData.data && enterpriseData.data.basecertinfo) {
|
if (enterpriseData && enterpriseData.data && enterpriseData.data.basecertinfo) {
|
||||||
const info = {
|
const info = {
|
||||||
corpId: enterpriseData.data.basecertinfo.appid,
|
corpId: enterpriseData.data.basecertinfo.appid,
|
||||||
corpName: enterpriseData.data.basecertinfo.subject_name
|
corpName: enterpriseData.data.basecertinfo.nickname
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log('企业信息获取成功:', info);
|
console.log('企业信息获取成功:', info);
|
||||||
@@ -47,32 +47,32 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取学员列表按钮的点击事件监听器
|
// // 获取学员列表按钮的点击事件监听器
|
||||||
getStudentsBtn.addEventListener('click', async () => {
|
// getStudentsBtn.addEventListener('click', async () => {
|
||||||
// 获取当前激活的标签页
|
// // 获取当前激活的标签页
|
||||||
const [tab] = await chrome.tabs.query({active: true, currentWindow: true});
|
// const [tab] = await chrome.tabs.query({active: true, currentWindow: true});
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
// 第一步:获取企业信息
|
// // 第一步:获取企业信息
|
||||||
dataDisplay.textContent = '正在获取企业信息...';
|
// dataDisplay.textContent = '正在获取企业信息...';
|
||||||
enterpriseInfo = await getEnterpriseInfo(tab.id);
|
// enterpriseInfo = await getEnterpriseInfo(tab.id);
|
||||||
|
//
|
||||||
// 第二步:获取所有学员数据
|
// // 第二步:获取所有学员数据
|
||||||
dataDisplay.textContent = '正在获取学员数据...';
|
// dataDisplay.textContent = '正在获取学员数据...';
|
||||||
const allStudentsData = await getAllStudentsData(tab.id);
|
// const allStudentsData = await getAllStudentsData(tab.id);
|
||||||
|
//
|
||||||
// 第三步:发送数据到指定接口
|
// // 第三步:发送数据到指定接口
|
||||||
dataDisplay.textContent = '正在发送数据...';
|
// dataDisplay.textContent = '正在发送数据...';
|
||||||
await sendStudentsData(allStudentsData, enterpriseInfo);
|
// await sendStudentsData(allStudentsData, enterpriseInfo);
|
||||||
|
//
|
||||||
// 完成
|
// // 完成
|
||||||
dataDisplay.textContent = `✅ 学员数据处理完成!\n\n企业信息:\nAppID: ${enterpriseInfo.corpId}\n企业名称: ${enterpriseInfo.corpName}\n\n学员数量: ${allStudentsData.length}\n\n数据已成功发送到服务器。`;
|
// dataDisplay.textContent = `✅ 学员数据处理完成!\n\n企业信息:\nAppID: ${enterpriseInfo.corpId}\n企业名称: ${enterpriseInfo.corpName}\n\n学员数量: ${allStudentsData.length}\n\n数据已成功发送到服务器。`;
|
||||||
|
//
|
||||||
} catch (error) {
|
// } catch (error) {
|
||||||
console.error('处理失败:', error);
|
// console.error('处理失败:', error);
|
||||||
dataDisplay.textContent = `❌ 处理失败: ${error.message}`;
|
// dataDisplay.textContent = `❌ 处理失败: ${error.message}`;
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
|
||||||
// 获取黑名单按钮的点击事件监听器
|
// 获取黑名单按钮的点击事件监听器
|
||||||
getBlacklistBtn.addEventListener('click', async () => {
|
getBlacklistBtn.addEventListener('click', async () => {
|
||||||
@@ -174,6 +174,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
async function getAllBlacklistData(tabId) {
|
async function getAllBlacklistData(tabId) {
|
||||||
let allBlockedCustomers = [];
|
let allBlockedCustomers = [];
|
||||||
let lastPageMaxId = '';
|
let lastPageMaxId = '';
|
||||||
|
let createTime = '';
|
||||||
let isEnd = false;
|
let isEnd = false;
|
||||||
let pageCount = 0;
|
let pageCount = 0;
|
||||||
|
|
||||||
@@ -182,7 +183,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
dataDisplay.textContent = `正在获取黑名单数据... 第${pageCount}页,已获取${allBlockedCustomers.length}条`;
|
dataDisplay.textContent = `正在获取黑名单数据... 第${pageCount}页,已获取${allBlockedCustomers.length}条`;
|
||||||
|
|
||||||
// 构建请求URL
|
// 构建请求URL
|
||||||
const url = `https://work.weixin.qq.com/wework_admin/groupchat/blockedCustomers?lang=zh_CN&f=json&pageSize=15000&last_page_max_id=${lastPageMaxId}`;
|
const url = `https://work.weixin.qq.com/wework_admin/groupchat/blockedCustomers?lang=zh_CN&f=json&pageSize=15000&last_page_max_id=${lastPageMaxId}&create_time=${createTime}`;
|
||||||
|
|
||||||
const result = await chrome.scripting.executeScript({
|
const result = await chrome.scripting.executeScript({
|
||||||
target: {tabId: tabId},
|
target: {tabId: tabId},
|
||||||
@@ -206,6 +207,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
// 更新分页参数
|
// 更新分页参数
|
||||||
isEnd = data.data.is_end;
|
isEnd = data.data.is_end;
|
||||||
lastPageMaxId = data.data.last_page_max_id || '';
|
lastPageMaxId = data.data.last_page_max_id || '';
|
||||||
|
createTime = data.data.create_time || '';
|
||||||
|
|
||||||
console.log(`第${pageCount}页黑名单获取完成,本页${data.data.blockedCustomers?.length || 0}条,总计${allBlockedCustomers.length}条,is_end: ${isEnd}`);
|
console.log(`第${pageCount}页黑名单获取完成,本页${data.data.blockedCustomers?.length || 0}条,总计${allBlockedCustomers.length}条,is_end: ${isEnd}`);
|
||||||
|
|
||||||
@@ -287,7 +289,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// TODO: 替换为您的实际接口地址
|
// TODO: 替换为您的实际接口地址
|
||||||
const apiEndpoint = 'http://192.168.0.133:7788/wework/blacklist/import';
|
const apiEndpoint = 'https://scrm.xyzhstackd.com/api/wework/blacklist/import';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(apiEndpoint, {
|
const response = await fetch(apiEndpoint, {
|
||||||
|
|||||||
Reference in New Issue
Block a user