appidConfiguration.js 1.6 KB

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