Commit e1d900bc by 姜雷

Merge branch 'test' into 'master'

Test See merge request !115
parents 1daefbe1 a68bd9bf
const removeConsolePlugin = []; const removeConsolePlugin = [];
if (process.env.NODE_ENV === 'production') { if (process.env.NODE_ENV === 'production') {
removeConsolePlugin.push('transform-remove-console'); removeConsolePlugin.push([
'transform-remove-console',
{
exclude: ['error', 'warn'],
},
]);
} }
module.exports = { module.exports = {
......
...@@ -17,9 +17,14 @@ export const validateCode = res => { ...@@ -17,9 +17,14 @@ export const validateCode = res => {
type: 'warning', type: 'warning',
} }
).then(() => { ).then(() => {
store.dispatch('FedLogOut').then(() => { store
location.reload(); // 为了重新实例化vue-router对象 避免bug .dispatch('FedLogOut')
}); .then(() => {
location.reload(); // 为了重新实例化vue-router对象 避免bug
})
.catch(err => {
console.error('FedLogOutErr: ', err);
});
}); });
return Promise.reject(res); return Promise.reject(res);
default: default:
......
import axios from 'axios'; import axios from 'axios';
import { Message, MessageBox } from 'element-ui'; import { Message, MessageBox } from 'element-ui';
import store from '../store'; import store from '../store';
import { SUCCESS_CODE } from '@/config'; import { SUCCESS_CODE, LOGOUT_CODE } from '@/config';
import { errorHandle } from '@/api/validate'; import { errorHandle } from '@/api/validate';
import { getYourIP } from '@/utils/getIp.js'; import { getYourIP } from '@/utils/getIp.js';
...@@ -24,16 +24,16 @@ const createBaseFetch = config => { ...@@ -24,16 +24,16 @@ const createBaseFetch = config => {
store.dispatch('fetchStart', notLoading); store.dispatch('fetchStart', notLoading);
if (store.getters.token) { if (store.getters.token) {
conf.headers = { conf.headers = {
...conf.headers,
reqSource: 'pc', reqSource: 'pc',
token: store.getters.token, token: store.getters.token,
ip: ip, ip: ip,
...conf.headers,
}; };
} else { } else {
conf.headers = { conf.headers = {
...conf.headers,
reqSource: 'pc', reqSource: 'pc',
ip: ip, ip: ip,
...conf.headers,
}; };
} }
...@@ -73,7 +73,7 @@ const createBaseFetch = config => { ...@@ -73,7 +73,7 @@ const createBaseFetch = config => {
}); });
// -2:其他客户端登录了;Token 过期了; // -2:其他客户端登录了;Token 过期了;
if (res.code === '-2') { if (res.code === LOGOUT_CODE) {
if (logout) return; if (logout) return;
logout = true; logout = true;
MessageBox.confirm( MessageBox.confirm(
...@@ -86,9 +86,14 @@ const createBaseFetch = config => { ...@@ -86,9 +86,14 @@ const createBaseFetch = config => {
} }
) )
.then(() => { .then(() => {
store.dispatch('FedLogOut').then(() => { store
location.reload(); // 为了重新实例化vue-router对象 避免bug .dispatch('FedLogOut')
}); .then(() => {
location.reload(); // 为了重新实例化vue-router对象 避免bug
})
.catch(err => {
console.error('FedLogOutErr: ', err);
});
}) })
.catch(err => { .catch(err => {
console.error(err); console.error(err);
......
...@@ -66,6 +66,7 @@ const actions = { ...@@ -66,6 +66,7 @@ const actions = {
// 前端 登出 // 前端 登出
FedLogOut({ commit }) { FedLogOut({ commit }) {
return new Promise(resolve => { return new Promise(resolve => {
console.debug('in FedLogOut');
commit(SET_TOKEN, ''); commit(SET_TOKEN, '');
removeToken(); removeToken();
resolve(); resolve();
......
...@@ -354,6 +354,7 @@ export const allowLetterNumber = value => { ...@@ -354,6 +354,7 @@ export const allowLetterNumber = value => {
export const formatterMoneyToDouble = val => { export const formatterMoneyToDouble = val => {
return val ? Number(val).toFixed(2) : Number(0).toFixed(2); return val ? Number(val).toFixed(2) : Number(0).toFixed(2);
}; };
export const formatPrice = price => { export const formatPrice = price => {
var result = [], var result = [],
counter = 0; counter = 0;
...@@ -361,6 +362,9 @@ export const formatPrice = price => { ...@@ -361,6 +362,9 @@ export const formatPrice = price => {
result.push(price.slice(-3).join('')); result.push(price.slice(-3).join(''));
for (var i = price.length - 4; i >= 0; i--) { for (var i = price.length - 4; i >= 0; i--) {
counter++; counter++;
if (i == 0 && isNaN(Number(price[i])) && result[0] === ',') {
result.shift();
}
result.unshift(price[i]); result.unshift(price[i]);
if (!(counter % 3) && i != 0) { if (!(counter % 3) && i != 0) {
result.unshift(','); result.unshift(',');
......
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