diff --git a/.env.development b/.env.development
index fa55c83..a16346b 100644
--- a/.env.development
+++ b/.env.development
@@ -1,8 +1,8 @@
-NODE_ENV
-# just a flag
-ENV = 'development'
+NODE_ENV='development'
+# must start with VUE_APP_
+VUE_APP_ENV = 'development'
#base url
-BASE_URL = https://www.xxx.com/
+BASE_URL = 'https://www.xxx.com/'
# base api
VUE_APP_BASE_API = '/dev-api'
VUE_CLI_BABEL_TRANSPILE_MODULES = true
diff --git a/.env.production b/.env.production
index 0129ea1..d866b25 100644
--- a/.env.production
+++ b/.env.production
@@ -1,5 +1,6 @@
-# just a flag
-ENV = 'production'
+NODE_ENV='production'
+# must start with VUE_APP_
+VUE_APP_ENV = 'production'
#base url
BASE_URL = https://www.top1buyer.com/
# base api
diff --git a/.env.staging b/.env.staging
index 0daf630..8c97e2a 100644
--- a/.env.staging
+++ b/.env.staging
@@ -1,7 +1,7 @@
-NODE_ENV = production
-
-# just a flag
-ENV = 'staging'
+NODE_ENV='production'
+# must start with VUE_APP_
+VUE_APP_ENV = 'staging'
+#base url
#base url
BASE_URL = https://www.top1buyer.com/
# base api
diff --git a/src/api/user.js b/src/api/user.js
index a2e4c40..bff532e 100644
--- a/src/api/user.js
+++ b/src/api/user.js
@@ -3,6 +3,7 @@ import request from '@/utils/request'
import { api } from '@/config'
// api
const { common_api } = api
+
// 登录
export function login(params) {
return request({
diff --git a/src/config/index.js b/src/config/index.js
index 43a4df1..a05c731 100644
--- a/src/config/index.js
+++ b/src/config/index.js
@@ -1,4 +1,3 @@
// 根据环境引入不同配置 process.env.NODE_ENV
- const config = require('./env.' + process.env.ENV)
- console.log( process.env.ENV)
+const config = require('./env.' + process.env.VUE_APP_ENV)
module.exports = config
diff --git a/src/utils/request.1.js b/src/utils/request.1.js
deleted file mode 100644
index b16d651..0000000
--- a/src/utils/request.1.js
+++ /dev/null
@@ -1,76 +0,0 @@
-import axios from 'axios'
-import store from '@/store'
-
-// create an axios instance
-const service = axios.create({
- baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url
- withCredentials: true, // send cookies when cross-domain requests
- timeout: 5000 // request timeout
-})
-
-// request interceptor
-service.interceptors.request.use(
- config => {
- // do something before request is sent
- if (store.getters.token) {
- // let each request carry token
- // ['X-Token'] is a custom headers key
- // please modify it according to the actual situation
- config.headers['X-Token'] = ''
- }
- return config
- },
- error => {
- // do something with request error
- console.log(error) // for debug
- return Promise.reject(error)
- }
-)
-
-// response interceptor
-service.interceptors.response.use(
- response => {
- const res = response.data
-
- // if the custom code is not 20000, it is judged as an error.
- if (res.code !== 20000) {
- Message({
- message: res.message || 'error',
- type: 'error',
- duration: 5 * 1000
- })
-
- // 50008: Illegal token; 50012: Other clients logged in; 50014: Token expired;
- if (res.code === 50008 || res.code === 50012 || res.code === 50014) {
- // to re-login
- MessageBox.confirm(
- 'You have been logged out, you can cancel to stay on this page, or log in again',
- 'Confirm logout',
- {
- confirmButtonText: 'Re-Login',
- cancelButtonText: 'Cancel',
- type: 'warning'
- }
- ).then(() => {
- store.dispatch('user/resetToken').then(() => {
- location.reload()
- })
- })
- }
- return Promise.reject(res.message || 'error')
- } else {
- return res
- }
- },
- error => {
- console.log('err' + error) // for debug
- Message({
- message: error.message,
- type: 'error',
- duration: 5 * 1000
- })
- return Promise.reject(error)
- }
-)
-
-export default service
diff --git a/src/utils/request.js b/src/utils/request.js
index f9e5eea..3ba1a15 100644
--- a/src/utils/request.js
+++ b/src/utils/request.js
@@ -1,9 +1,10 @@
import axios from 'axios'
import store from '@/store'
import { Toast } from 'vant'
+import { api } from '@/config'
// create an axios instance
const service = axios.create({
- baseURL: process.env.BASE_URL, // url = base url + request url
+ baseURL: api.base_api, // url = base url + request url
withCredentials: true, // send cookies when cross-domain requests
timeout: 5000 // request timeout
})
diff --git a/src/views/home/index.vue b/src/views/home/index.vue
index 82c99a1..e3a1e2a 100644
--- a/src/views/home/index.vue
+++ b/src/views/home/index.vue
@@ -7,30 +7,32 @@
diff --git a/vue.config.js b/vue.config.js
index 8ec82b8..8344979 100644
--- a/vue.config.js
+++ b/vue.config.js
@@ -1,6 +1,6 @@
'use strict'
const path = require('path')
-const defaultSettings = require('./src/config/index.js')
+const defaultSettings = require('./src/config/index.js')
function resolve(dir) {
return path.join(__dirname, dir)
}