environment.js 4.8 KB
import { preReleaseAppId } from '~/config'
const target = ['ip', 'dev', 'uat', 'prod', 'preRelease']
const mockObj = {
  test: 'https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=business-assistant-config&env=test',
  product: 'https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=business-assistant-config&env=production'
}
// const mockObj = {
//   test: 'https://oss-config.dev.glsx.com.cn/mock/63fd6c2034c4d918e2f4df4d/config',
//   product: 'https://oss-config.test.glsx.com.cn/mock/63ff0b507dc47c4edc786e82/config'
// }
const h5Obj = {
  test: 'https://dj.test.glsx.com.cn/dj-car-revenue-analysis/#/',
  product: 'https://dj.glsx.com.cn/dj-car-revenue-analysis/#/'
}

/**
 * 
0本地 
1开发 
2测试
3生产
 */
// const index = 1
const accountInfo = wx.getAccountInfoSync()
const systemInfo = wx.getSystemInfoSync()
// console.log(systemInfo);
// console.log(accountInfo.miniProgram.envVersion)
//手动控制体验版环境的请求 true就依据下面index false就默认为2
const manual = false
const release = false

let index = 2

// 判断小程序环境
// develop:开发版(正常开发工具,测试时)
// trial:体验版
// release:正式版
// console.log( systemInfo.platform);
// console.log(accountInfo.miniProgram.envVersion);
// 对比一下appkey
// console.log();
if (systemInfo.platform != 'devtools') {
  // 判断预发布的appid 是强制锁定为4(预发布的地址)
  if (accountInfo.miniProgram.appId == preReleaseAppId) {
    index = 4
  } else {
    switch (accountInfo.miniProgram.envVersion) {
      case 'develop':
        // this.globalData.url = 'http://192.168.0.252:3000/api'; //
        break
      case 'trial':
        index = manual ? index : 2
        break
      case 'release':
        index = release ? index : 3
        break
      default:
        index = 3
        break
    }
  }
}

const secretKey = {
  ip: {},
  dev: {
    sso: {
      appKey: '8b31ae1009ccb0f96130ca4bd90e3d89',
      secret: '02d60f17ae714872845d2aa9d3b087e109ccb0f96130ca4b'
    }
  },
  uat: {
    sso: {
      appKey: '8b31ae1009ccb0f96130ca4bd90e3d89',
      secret: '02d60f17ae714872845d2aa9d3b087e109ccb0f96130ca4b'
    }
  },
  prod: {
    sso: {
      appKey: '8b31ae1009ccb0f96130ca4bd90e3d89',
      secret: '02d60f17ae714872845d2aa9d3b087e109ccb0f96130ca4b'
    }
  },
  preRelease: {
    sso: {
      appKey: '8b31ae1009ccb0f96130ca4bd90e3d89',
      secret: '02d60f17ae714872845d2aa9d3b087e109ccb0f96130ca4b'
    }
  }
}[target[index]]

const djSecretKey = {
  ip: {
    appKey: '48e5e13229b82c1b4e6e8c96151f0637',
    secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
  },
  dev: {
    appKey: '48e5e13229b82c1b4e6e8c96151f0637',
    secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
  },
  uat: {
    appKey: '48e5e13229b82c1b4e6e8c96151f0637',
    secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
  },
  prod: {
    appKey: 'd7ffc3346fc9a45bccaaa35300d59022',
    secret: '4bc07f8868374c49a4661d603377e3106fc9a45bccaaa353'
  },
  preRelease: {
    appKey: '48e5e13229b82c1b4e6e8c96151f0637',
    secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
  }
}[target[index]]

const domain = {
  ip: {
    // dj: 'http://192.168.1.165:8292',
    dj: 'http://192.168.1.170:8292',
    scrm: 'http://192.168.1.165:8292'
  },
  dev: {
    dj: 'http://192.168.3.122:9203',
    scrm: 'https://scrm.dev.glsx.com.cn'
  },
  uat: {
    dj: 'https://dj.test.glsx.com.cn',
    scrm: 'https://scrm.test.glsx.com.cn'
  },
  prod: {
    dj: 'https://dj.glsx.com.cn',
    scrm: 'https://scrm.glsx.com.cn'
  },
  preRelease: {
    dj: 'https://dj.beta.glsx.com.cn',
    scrm: 'https://scrm.beta.glsx.com.cn'
  }
}[target[index]]

const pathEnum = {
  sso: '/rop-scrm-sso/',
  shopmall: '/rop-scrm-shopmall/',
  coupon: '/rop-scrm-coupon/',
  carlife: '/rop-scrm-carlife/',
  live: '/rop-scrm-live/',
  equity: '/rop-scrm-equity/',
  entmicro: '/rop-scrm-entmicro/',
  wechat: '/rop-scrm-wechat/',
  boutiquecoupon: '/rop-scrm-boutiquecoupon/',
  material: '/rop-scrm-marketing/', //素材
  sop: '/rop-scrm-sop/',
  customercollect: '/rop-scrm-bigdatautil/',
  drac: '/rop-scrm-entmicro/',
  busassistant: '/rop-scrm-busassistant/',
  assistant: '/rop-scrm-stoassistant/',
  smartcarlife: '/rop-dj-car-boutique/',
  djsmart: '/rop-dj-smartcarlife/'
}
const defaultMerchantId = {
  ip: '44184606',
  dev: '44184606',
  uat: '44184606',
  preRelease: '44184606',
  prod: '44189923'
}[target[index]]

let mockUrl = {
  ip: mockObj.test,
  dev: mockObj.test,
  uat: mockObj.test,
  preRelease: mockObj.product,
  prod: mockObj.product
}[target[index]]

let h5Url = {
  ip: h5Obj.test,
  dev: h5Obj.test,
  uat: h5Obj.test,
  preRelease: h5Obj.product,
  prod: h5Obj.product
}[target[index]]
module.exports = {
  index,
  domain,
  pathEnum,
  secretKey,
  djSecretKey,
  defaultMerchantId,
  mockUrl,
  h5Url
}