Commit 24e96d74 by songbingqi

区分不同环境请求地址配置

parent 66cd83a1
const ENV_TYPE = {
baseUrl:'https://hooloo-dev-api.gdatac.com'
}
module.exports = ENV_TYPE
\ No newline at end of file
const ENV_TYPE = {
baseUrl:'https://hooloo-api.gdatac.com'
}
module.exports = ENV_TYPE
\ No newline at end of file
{
"dependencies": {
"uview-ui": "^2.0.31"
}
},
"uni-app": {
"scripts": {
"weixin:test": {
"title": "微信测试环境",
"env": {
"UNI_PLATFORM": "mp-weixin",
"ENV_PATH": "../env/dev.js"
},
"define": {
"WXCS-PLATFORM": true
}
},
"weixin:pro": {
"title": "微信生产环境",
"env": {
"UNI_PLATFORM": "mp-weixin",
"ENV_PATH": "../env/prod.js"
},
"define": {
"WXSC-PLATFORM": true
}
}
}
}
}
......@@ -2,15 +2,25 @@ import appConfig from '@/static/config/index.js';
import User from '@/request/user';
import context from '../main.js'
export function getBaseUrl() {
if (process.env.NODE_ENV === 'development') {
return appConfig.devApi;
} else {
return appConfig.prodApi;
}
let path = process.env.ENV_PATH == undefined?require('../env/dev.js'): require(process.env.ENV_PATH)
// #ifdef MP-WEIXIN
// ---------------- 根据微信开发环境配置请求地址 --------------------
// 获取当前帐号信息
const accountInfo = wx.getAccountInfoSync();
console.log(accountInfo)
// env类型 develop:开发版、trial:体验版、release:正式版
const envWx = accountInfo.miniProgram.envVersion;
if(envWx === 'release'){
path = require('../env/prod.js')
}else{
path = require('../env/dev.js')
}
// #endif
return path
}
module.exports = (vm) => {
uni.$u.http.setConfig((config) => {
config.baseURL = getBaseUrl();
config.baseURL = getBaseUrl().baseUrl;
// showLoading: process.env.NODE_ENV === 'development',
config.method = 'POST';
// 设置为json,返回后会对数据进行一次JSON.parse()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment