// 新增商户时 需要在prod_brand_config 配置相应的信息 key是商户Id

// 发生产环境配置流程
// PROJECT_ENV 修改 为 prod 
// project.config.json 中appId 更换为生成
// 修改 BRANCH_ID 为对应的商户id
// app.js 中brandId 修改为对应

const PROJECT_ENV = 'prod' // 生产 prod, 开发 dev, 测试 test, 预生产 pre
//仅生产环境时 配置 ： 
//3001 3001 , 
//泰华 2006 , 
//多多一上 2007 ，
//雪岛书屋 2008
//苏州邻里 2006
const BRANCH_ID = 3001 
const isMall = true

const needMock = '' //
// 舞象联系我 ：766c50920993bf9c41c6c3d2761a2df5
//泰华 联系我 ：6e4314d558e55fbc64fe2e757e24d61f

//配置信息 
/** ***********************************开发环境************************************ */
//舞象开发环境
/**
 * appId = wxc3b64b09b1d3dfc2
 * tunnel-token = brand1001
 * brandId = 1001
 */
/** ***********************************测试环境************************************ */
/**
 * 舞象测试环境1
 * appId = wx857ea77f4f7f4f34
 * tunnel-token = aa8a1bfb7f6c5031d172d94b6574293ef954a6f2d4e16657da008e0cc15588feD
 * brandId = 1002
 */

/**
 * 舞象测试环境2 常用
 * appId = wxac09792264c49b5c
 * tunnel-token = aa8a1bfb7f6c5031d172d94b6574293ef954a6f2d4e16657da008e0cc15588feD
 * brandId = 1002
 */

/** ***********************************生产环境************************************ */
/**
 * 舞象测试 3001商户
 * appId = wx313ec36b710125d4
 * tunnel-token = d6db651f8b9c7db4176465accfc1c913843fd9ad328cd5f4fe201d918072c9e8
 * brandId=3001
 * contactUspluginId = 766c50920993bf9c41c6c3d2761a2df5 联系我插件id
 */

/**
 * 711 生产环境配置
 * appId = wx700028bf32a3be66
 * tunnel-token = d6db651f8b9c7db4176465accfc1c913843fd9ad328cd5f4fe201d918072c9e8
 * brandId= 2711
 */

/**
 * 泰华 商城生产环境配置
 * appId = wx40fec8944623c8b3
 * tunnel-token = 8724303981a00b56869f3d26f7a6c643
 * brandId= 2006
 * contactUspluginId = a6ea55b56eb09ced8f9aeeaa14383b52 联系我插件id
 * 
 * 泰华 门户生产环境配置
 * appId = wx833d5ece112fc3fd
 * tunnel-token = 8724303981a00b56869f3d26f7a6c643
 * brandId= 2006
 * contactUspluginId = a6ea55b56eb09ced8f9aeeaa14383b52 联系我插件id
 */

/**
 * 多多一上 生产环境配置
 * appId = wxf7bc302c51166dc0  //小程序 appId
 * tunnel-token = 1ea3f0c0dd0c91ee54e546a99beafbfb //token 杨辰提供
 * brandId= 2007 //商户Id
 * contactUspluginId = 64bf88d82b3f0d506bd00ed90d5706f1 联系我插件id
 */

/** 
 * 雪岛书屋 生产环境配置
 * appId = wx207f8a95bbc9d3ab  //小程序 appId
 * tunnel-token = d93a5def7511da3d0f2d171d9c344e91 //token 杨辰提供
 * brandId= 2008 //商户Id
 * contactUspluginId =  联系我插件id
 * 
*/
/** 
 * 苏州邻里 生产环境配置
 * appId = wxe7770946f9d93d38  //小程序 appId
 * tunnel-token = fde4fde168dd5aabe962643843c19290 //token 杨辰提供
 * brandId= 2003 //商户Id
 * contactUspluginId =  联系我插件id
 * 
*/

// 生产环境配置信息
const prod_brand_config = {
  //3001舞象
  3001 : {
    appId: 'wx313ec36b710125d4',// 小程序AppID
    tunnelToken: 'd6db651f8b9c7db4176465accfc1c913843fd9ad328cd5f4fe201d918072c9e8',//商户默认token
    brandId: 3001,//商户ID
    plusIsOpen: true, //是否开启plus
    contactUsIsOpen: true,//是否开启联系我
    contactUsPluginId: '766c50920993bf9c41c6c3d2761a2df5',//联系我们插件PluginID
    hasTrial: false, // 是否有体验账号
    isMall: isMall,// 商城或门户 true 商城 false 门户
    orderingMustOpenCard : false, //下单是否必须卡开
  },
  //泰华配置
  2006: {
    appId: 'wx40fec8944623c8b3', //商城小程序appid
    storeAppId: 'wx833d5ece112fc3fd',//门户小程序appid
    tunnelToken: '8724303981a00b56869f3d26f7a6c643',
    brandId: 2006,
    plusIsOpen: false,
    contactUsIsOpen: isMall ? true : false,
    contactUsPluginId: 'a6ea55b56eb09ced8f9aeeaa14383b52',
    hasTrial: false,
    isMall: isMall,
    orderingMustOpenCard: true,
  },
  //多多一上
  2007 : {
    appId: 'wxf7bc302c51166dc0',
    tunnelToken: '1ea3f0c0dd0c91ee54e546a99beafbfb',
    brandId: 2007,
    plusIsOpen: false,
    contactUsIsOpen: true,
    contactUsPluginId: '64bf88d82b3f0d506bd00ed90d5706f1',
    hasTrial: false,
    isMall: isMall,
    orderingMustOpenCard: false,
  },
  //雪岛书屋 
  2008 : {
    appId: 'wx207f8a95bbc9d3ab',
    tunnelToken: 'd93a5def7511da3d0f2d171d9c344e91',
    brandId: 2008,
    plusIsOpen: false,
    contactUsIsOpen: false,
    contactUsPluginId: '',
    hasTrial: false,
    isMall: isMall,
    orderingMustOpenCard: false,
  },
  //苏州邻里
  2003 : {
    appId: 'wxe7770946f9d93d38',
    tunnelToken: 'fde4fde168dd5aabe962643843c19290',
    brandId: 2003,
    plusIsOpen: false,
    contactUsIsOpen: false,
    contactUsPluginId: '',
    hasTrial: false,
    isMall: isMall,
    orderingMustOpenCard: false,
  }
}


// 开启联系我时 app.json plugin中添加此代码
// "contactPlugin": {
//   "version": "1.0.12",
//     "provider": "wx104a1a20c3f81ec2"
// }


// appid_dev_wx   wxc3b64b09b1d3dfc2 
// appid_test_wx  wx857ea77f4f7f4f34//  wxac09792264c49b5c // 1002商城
// appid_pre_711  wx358b56af62edbde1 tunnel-token: d6db651f8b9c7db4176465accfc1c913843fd9ad328cd5f4fe201d918072c9e8
// appid_prod_711  wx700028bf32a3be66 tunnel-token: d6db651f8b9c7db4176465accfc1c913843fd9ad328cd5f4fe201d918072c9e8

// appid_prod_3001 wx313ec36b710125d4 
// 3001测试商城 tunnel-token: d6db651f8b9c7db4176465accfc1c913843fd9ad328cd5f4fe201d918072c9e8 brandId : 3001

//泰华 appid : wx40fec8944623c8b3 brandId : 2006 tunnel-token : 8724303981a00b56869f3d26f7a6c643


// 1 2 3 4步!!!!!!!!!!!!!!!!!!!!!!  prod appid brandId tunnel-token

// const devCtx = 'http://111.231.86.64'
const devCtx = 'http://buyer.devapi.bigaka.net' // 开发环境 1
// const devCtx = 'http://dev-sellerapi.bigaka.net' // 开发环境 2
const testCtx = 'https://crm-b.bigaka.net/api' // 发测试时解开此注释
const preCtx = 'https://crm-b.bigaka.com/api' // 发预生产时解开此注释
const prodCtx = 'https://crm-b.bigaka.com/api' // 发生产时解开此注释

const devImgCtx = 'https://img3.bigaka.com/test' // 开发环境图片地址
const testImgCtx = 'https://img3.bigaka.com/test' // 测试环境图片地址
const preImgCtx = 'https://img3.bigaka.com/test' // 预生产环境图片地址
const prodImgCtx = 'https://img3.bigaka.com/prd' // 生产环境图片地址
// const prodImgCtx = 'https://img3.bigaka.com' // 生产环境图片地址

const config = {
  dev: devCtx,
  test: testCtx,
  pre: preCtx,
  prod: prodCtx
}

const appId = {
  dev: 'wxc3b64b09b1d3dfc2',//appid_dev_wx
  test: 'wxac09792264c49b5c',//appid_test_wx 1002商城
  pre: 'wxac09792264c49b5c',//appid_test_wx 1002商城
}

const imgConfig = {
  dev: devImgCtx,
  test: testImgCtx,
  pre: preImgCtx,
  prod: prodImgCtx
}

const token = {
  dev: 'brand1001', //开发
  test: 'aa8a1bfb7f6c5031d172d94b6574293ef954a6f2d4e16657da008e0cc15588feD', //测试
  pre: 'aa8a1bfb7f6c5031d172d94b6574293ef954a6f2d4e16657da008e0cc15588feD', //预生产
}

//获取配置信息
let brandId = PROJECT_ENV == 'prod' ? prod_brand_config[BRANCH_ID].brandId : (PROJECT_ENV == 'dev' ? 1001 : 1002);
let fixed_appId = PROJECT_ENV == 'prod' ? 
(isMall ? prod_brand_config[BRANCH_ID].appId : prod_brand_config[BRANCH_ID].storeAppId) : appId[PROJECT_ENV];
let tunnelToken = PROJECT_ENV == 'prod' ? prod_brand_config[BRANCH_ID].tunnelToken : token[PROJECT_ENV];
let plusIsOpen = PROJECT_ENV == 'prod' ? prod_brand_config[BRANCH_ID].plusIsOpen : true;
let contactUsPluginId = PROJECT_ENV == 'prod' ? prod_brand_config[BRANCH_ID].contactUsPluginId : '766c50920993bf9c41c6c3d2761a2df5';
let contactUsIsOpen = PROJECT_ENV == 'prod' ? prod_brand_config[BRANCH_ID].contactUsIsOpen : true;
let hasTrial = PROJECT_ENV == 'prod' ? prod_brand_config[BRANCH_ID].hasTrial : true;
let fixed_IsMall = PROJECT_ENV == 'prod' ? prod_brand_config[BRANCH_ID].isMall : true;
let orderingMustOpenCard = PROJECT_ENV == 'prod' ? prod_brand_config[BRANCH_ID].orderingMustOpenCard : false;

//配置信息导出
const envInfo = (() => {
  return {
    ctx: config[PROJECT_ENV],
    env: PROJECT_ENV,
    imgCtx: imgConfig[PROJECT_ENV],
    tunnelToken: tunnelToken,
    appId: fixed_appId,
    brandId: brandId,// 1001 1002 3001 3002 //2711 711生产brandId,
    plusIsOpen: plusIsOpen, //是否开启plus
    contactUsPluginId: contactUsPluginId,
    contactUsIsOpen: contactUsIsOpen,//是否开启联系我
    hasTrial: hasTrial , //是否开启体验者功能
    isMall: fixed_IsMall,//商城和门户区分 门户时 false; 商城 true
    orderingMustOpenCard: orderingMustOpenCard,//下单时是否强校验必须开卡 true 必须开卡才可下单 false 不开卡可以下单
  }
})()

module.exports = {
  envInfo
}
