const getServiceHost = api => { const apimodules = [{ OP: 7116 }, { BD: 7101 }, { DD: 7102 }, { EA: 7103 }, { ED: 7104 }, { EM: 7105 }, { FC: 7106 }, { FM: 7107 }, { KR: 7108 }, { LG: 7109 }, { MR: 7110 }, { NW: 7111 }, { PF: 7112 }, { PM: 7113 }, { QC: 7114 }, { FW: 7115 }, { OP: 7116 }, { HM: 7117 }, { PP: 7118 }, { FO: 7119 }, { UT: 7177 }, { BS: 7178 }, { SC: 7179 }, { TI: 7179 }, { SE: 7179 }, { AE: 7179 }, { PT: 7179 }, { LR: 7179 }, { OG: 7179 }, { PE: 7179 }, { OH: 7179 }, { CM: 7179 }, { PR: 7179 }, { DM: 7179 }, { BI: 7179 } ] let port = 7112 for (let i = 0; i < apimodules.length; i++) { const apimodule = apimodules[i] const key = Object.keys(apimodule)[0] if (api.indexOf(`/${key}/`) > -1) { port = apimodule[key] break } } return `${port}/api${api}` } // 发行APP前先确定,要发布的版本 let APP_ENV = 'beta' // beta: 测试版,release: 发行版 let configURL if (process.env.CUSTOM_PLATFORM === "dev") { //本地环境 configURL = { web_name: "", serviceHost(api) { const apis = getServiceHost(api) return `${this.uni_app_web_api_url}:${apis}` //测试环境 }, uni_app_web_url: "", // uni_app_web_api_url: "http://localhost", // 请求接口的地址 uni_app_web_source_url: "http://localhost:7199", // 资源地址 uni_app_web_local_api_url: "http://localhost", // 请求接口的地址 } } else if (process.env.CUSTOM_PLATFORM === "test") { //测试环境 configURL = { web_name: "", serviceHost(api) { const apis = getServiceHost(api) return `${this.uni_app_web_api_url}:${apis}` //测试环境 }, uni_app_web_url: "", // uni_app_web_api_url: "http://47.122.43.22", // 请求接口的地址 uni_app_web_source_url: "http://47.122.43.22:7199", // 资源地址 uni_app_web_local_api_url: "http://47.122.43.22", // 请求接口的地址 } } else //生产环境 发布等 configURL = { web_name: "", serviceHost(api) { const apis = getServiceHost(api) return `${this.uni_app_web_local_api_url}:${apis}` }, uni_app_web_url: "", uni_app_web_api_url: APP_ENV === 'release' ? "http://xmmhe.com" : "http://47.122.43.22", uni_app_web_source_url: APP_ENV === 'release' ? "http://xmmhe.com:7199" : "http://47.122.43.22:7199", uni_app_web_local_api_url: APP_ENV === 'release' ? "http://xmmhe.com" : "http://localhost" //打包测试: 47.122.43.22 开发可 localhost } export default configURL