appidConfiguration.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /**
  2. * 各个公司企业微信的配置, 更具域名来解析
  3. * @path 完整域名
  4. * @appId 企业微信的appId
  5. */
  6. const config = {
  7. "worktime.ttkuaiban.com": {
  8. // 工时管家
  9. path: "https://worktime.ttkuaiban.com",
  10. appId: "ww4e237fd6abb635af",
  11. agentId: "",
  12. },
  13. "blue.blovelight.net": {
  14. // 蓝光研发
  15. path: "http://blue.blovelight.net:2021",
  16. appId: "wwb12ec40df8c35139",
  17. agentId: "1000075",
  18. },
  19. };
  20. const fixedPath = `/api/corpWXAuth`; // 授权回调页面 (需要拼接)
  21. const fixedPathAgentId = `/api/corpInsideWXAuth`
  22. export function obtainCorrespondingConfigurationInformation() {
  23. const hostname = window.location.hostname; // 获取域名和端口,(不包括http 和 https)
  24. const row = config[hostname];
  25. const agentId = row.agentId;
  26. const appId = row.appId;
  27. const tokenUrl = `${row.path}${fixedPath}`;
  28. const tokenUrlAgentId = `${row.path}${fixedPathAgentId}`;
  29. const authorizationCallback = agentId
  30. ? `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appId}&redirect_uri=${encodeURI(tokenUrlAgentId)}&response_type=code&scope=snsapi_base&state=index&agentid=${agentId}#wechat_redirect`
  31. : `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appId}&redirect_uri=${encodeURI(tokenUrl)}&response_type=code&scope=snsapi_base&state=1#wechat_redirect`;
  32. return {
  33. appId,
  34. tokenUrl,
  35. authorizationCallback,
  36. };
  37. }