index.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import Taro from '@tarojs/taro'
  2. import { SHARE_CHANNEL } from '../constant'
  3. // Determine if the environment is `weapp` and get the `envVersion`
  4. const isWeApp = process.env.TARO_ENV === 'weapp'
  5. const accountInfo = isWeApp ? Taro.getAccountInfoSync() : null
  6. const envVersion = isWeApp
  7. ? accountInfo?.miniProgram.envVersion || 'release'
  8. : null
  9. // Helper function to determine base URL based on environment
  10. const getBaseUrl = (releaseUrl: string, preUrl: string) => {
  11. if (isWeApp) {
  12. return envVersion === 'release' ? releaseUrl : preUrl
  13. } else {
  14. return process.env.XLB_ENV !== 'pre_env' ? releaseUrl : preUrl
  15. }
  16. }
  17. // Define base URLs
  18. export const bluebookBaseConst = getBaseUrl(
  19. 'https://api.xiaolanben.com/bluebook/',
  20. 'https://api.xiaolanben.com/bluebook-pre/',
  21. )
  22. export const blueServiceBaseConst = getBaseUrl(
  23. 'https://api.xiaolanben.com/blue-service/',
  24. 'https://api.xiaolanben.com/blue-service-pre/',
  25. )
  26. export const blueUserBaseConst = getBaseUrl(
  27. 'https://api.xiaolanben.com/blue-user/',
  28. 'https://api.xiaolanben.com/blue-user-pre/',
  29. )
  30. export const blueConnBaseConst = getBaseUrl(
  31. 'https://api.xiaolanben.com/blue-conn/',
  32. 'https://api.xiaolanben.com/blue-conn-pre/',
  33. )
  34. export const xlbGatewayBaseConst = getBaseUrl(
  35. 'https://api.xiaolanben.com/',
  36. 'https://blue-book-pre.u51.com/',
  37. )
  38. export const bluebookGatewayBaseConst = getBaseUrl(
  39. 'https://api.xiaolanben.com/xlb-gateway/blue-book/',
  40. 'https://api.xiaolanben.com/blue-book-idc/blue-book/',
  41. )
  42. export const blueServicePrefix = isWeApp
  43. ? 'https://api.xiaolanben.com/'
  44. : '/api.xiaolanben.com/'
  45. export const usercenterbase = 'https://api.u51.com/'
  46. export function getUserCenterParams() {
  47. return {
  48. big_app_id: 35,
  49. app_id: 2035,
  50. plat: 4,
  51. channel: SHARE_CHANNEL,
  52. invitationCode: undefined,
  53. }
  54. }