const getServiceHost = api => { const apimodules = [{ OP: 5116 }, { BD: 5101 }, { DD: 5102 }, { EA: 5103 }, { ED: 5104 }, { EM: 5105 }, { FC: 5106 }, { FM: 5107 }, { KR: 5108 }, { LG: 5109 }, { MR: 5110 }, { NW: 5111 }, { PF: 5112 }, { PM: 5113 }, { QC: 5114 }, { FW: 5115 }, { OP: 5116 }, { HM: 5117 }, { PP: 5118 }, { FO: 5119 }, { UT: 5177 }, { BS: 5178 }, { SC: 5179 }, { TI: 5179 }, { SE: 5179 }, { AE: 5179 }, { PT: 5179 }, { LR: 5179 }, { OG: 5179 }, { PE: 5179 }, { OH: 5179 }, { CM: 5179 }, { PR: 5179 }, { DM: 5179 }, { BI: 5179 } ] let port = 5112 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' // release: 发行版 debug:开发环境 beta: 测试版 let configURL if (APP_ENV === "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:5199", // 资源地址 uni_app_web_local_api_url: "http://localhost", // 请求接口的地址 uni_app_url: "http://121.41.2.71:5100", qrcode_url: "http://121.41.2.71:5111" } } else if (APP_ENV === "beta") { //测试环境 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://121.41.2.71", // 请求接口的地址 uni_app_web_source_url: "http://121.41.2.71:5199", // 资源地址 uni_app_web_local_api_url: "http://121.41.2.71", // 请求接口的地址 uni_app_url: "http://121.41.2.71:5100", qrcode_url: "http://121.41.2.71:5111" } } else if (APP_ENV === "release") { //正式环境 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: "http://124.117.209.78", uni_app_web_source_url: "http://124.117.209.78:5199", qrcode_url: "http://124.117.209.78:5111", uni_app_url: "http://124.117.209.78:5100", uni_app_web_local_api_url: "http://124.117.209.78" } } else { //开发 debug 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: "http://121.41.2.71", uni_app_web_source_url: "http://121.41.2.71:5199", //附件 qrcode_url: "http://121.41.2.71:5111", //生成二维码 uni_app_url: "http://121.41.2.71:5100", //跳转进入app uni_app_web_local_api_url: "http://localhost" //打包测试: 121.41.2.71 开发可 localhost } } export default configURL