Browse Source

啥都没改

shibei_master
dai 4 years ago
parent
commit
b10f81d226
  1. 472
      src/js/ajax.js

472
src/js/ajax.js

@ -1,42 +1,40 @@
/* eslint-disable */ /* eslint-disable */
import axios from 'axios' import axios from "axios";
import Cookies from 'js-cookie' import Cookies from "js-cookie";
import router from '@/router' import router from "@/router";
import qs from 'qs' import qs from "qs";
import { clearLoginInfo } from '@/utils' import { clearLoginInfo } from "@/utils";
import isPlainObject from 'lodash/isPlainObject' import isPlainObject from "lodash/isPlainObject";
import Vue from 'vue'
import { Loading } from 'element-ui' //引入Loading服务
import Vue from "vue";
import { Loading } from "element-ui"; //引入Loading服务
// 默认超时时间60s // 默认超时时间60s
axios.defaults.timeout = 60000 axios.defaults.timeout = 60000;
let timer let timer;
let loading let loading;
//请求时间超过300ms 提示加载 //请求时间超过300ms 提示加载
function startLoading () { function startLoading() {
if (timer) return if (timer) return;
timer = setTimeout(() => { timer = setTimeout(() => {
loading = Loading.service({ loading = Loading.service({
lock: true, //是否锁定 lock: true, //是否锁定
text: '正在加载……', //加载中需要显示的文字 text: "正在加载……", //加载中需要显示的文字
background: 'rgba(0,0,0,.7)', //背景颜色 background: "rgba(0,0,0,.7)", //背景颜色
}) });
}, 300) }, 300);
} }
//结束加载动画 //结束加载动画
function endLoading () { function endLoading() {
if (timer) { if (timer) {
clearTimeout(timer) clearTimeout(timer);
} }
if (loading) { if (loading) {
loading.close() loading.close();
} }
} }
@ -45,71 +43,65 @@ function endLoading () {
*/ */
axios.interceptors.request.use( axios.interceptors.request.use(
(config) => { (config) => {
config.headers['Accept-Language'] = localStorage.getItem('language') || 'zh-CN' config.headers["Accept-Language"] =
config.headers['token'] = localStorage.getItem('token') || '' localStorage.getItem("language") || "zh-CN";
config.headers['Authorization'] = localStorage.getItem('token') || '' config.headers["token"] = localStorage.getItem("token") || "";
config.headers["Authorization"] = localStorage.getItem("token") || "";
// 默认参数 // 默认参数
var defaults = {} var defaults = {};
// 防止缓存,GET请求默认带_t参数 // 防止缓存,GET请求默认带_t参数
if (config.method === 'get') { if (config.method === "get") {
config.params = { config.params = {
...config.params, ...config.params,
...{ _t: new Date().getTime() }, ...{ _t: new Date().getTime() },
} };
} }
if (isPlainObject(config.params)) { if (isPlainObject(config.params)) {
config.params = { config.params = {
...defaults, ...defaults,
...config.params, ...config.params,
} };
} }
if (isPlainObject(config.data)) { if (isPlainObject(config.data)) {
config.data = { config.data = {
...defaults, ...defaults,
...config.data, ...config.data,
} };
if ( if (
/^application\/x-www-form-urlencoded/.test( /^application\/x-www-form-urlencoded/.test(
config.headers['content-type'] config.headers["content-type"]
) )
) { ) {
config.data = qs.stringify(config.data) config.data = qs.stringify(config.data);
} }
} }
return config return config;
}, },
(error) => { (error) => {
return Promise.reject(error) return Promise.reject(error);
} }
) );
/** /**
* 响应拦截 * 响应拦截
*/ */
axios.interceptors.response.use( axios.interceptors.response.use(
(response) => { (response) => {
const code = [10007, 401, 10001, 10005] const code = [10007, 401, 10001, 10005];
if (code.includes(response.data.code) ) { if (code.includes(response.data.code)) {
// debugger; // debugger;
clearLoginInfo() clearLoginInfo();
// localStorage.setItem('userType', 'work') router.replace({ name: "login" });
// let userType = localStorage.getItem("userType");
// if (userType === 'work'){
// router.replace({ name: 'loginWork' })
// }else {
// router.replace({ name: 'login' })
// }
router.replace({ name: 'login' })
return Promise.reject(response.data.msg) return Promise.reject(response.data.msg);
} }
return response return response;
}, },
(error) => { (error) => {
console.error(error) console.error(error);
return Promise.reject(error) return Promise.reject(error);
} }
) );
const post = (url, params, headers) => { const post = (url, params, headers) => {
return new Promise((reslove, reject) => { return new Promise((reslove, reject) => {
@ -119,14 +111,14 @@ const post = (url, params, headers) => {
resolve(res); resolve(res);
}) })
.catch((err) => { .catch((err) => {
reject(err) reject(err);
}) });
}) });
} };
export const requestPost = async (url = '', params = {}, headers = {}) => { export const requestPost = async (url = "", params = {}, headers = {}) => {
const ret = await post(url, params, headers) const ret = await post(url, params, headers);
console.log(url, ret) console.log(url, ret);
// if (ret.status === 200) { // if (ret.status === 200) {
// var data = res.data // var data = res.data
// if (data.code == 0) { // if (data.code == 0) {
@ -141,7 +133,7 @@ export const requestPost = async (url = '', params = {}, headers = {}) => {
// } else { // } else {
// if (typeof cb_err === 'function') cb_err(res) // if (typeof cb_err === 'function') cb_err(res)
// } // }
} };
/* /*
* 1后台请求成功均返回业务上的异常也属于请求成功 res.status=200的响应码 * 1后台请求成功均返回业务上的异常也属于请求成功 res.status=200的响应码
@ -153,140 +145,137 @@ export const requestPost = async (url = '', params = {}, headers = {}) => {
*/ */
export default { export default {
// 并发请求 // 并发请求
all (gets, cb) { all(gets, cb) {
if (gets && gets.length > 0) { if (gets && gets.length > 0) {
let functions = gets.map((get) => { let functions = gets.map((get) => {
return axios.get(processUrl(get.url), { return axios.get(processUrl(get.url), {
params: get.params, params: get.params,
}) });
}) });
axios.all(functions).then( axios.all(functions).then(
axios.spread((..._results) => { axios.spread((..._results) => {
let results = _results.map((_result) => { let results = _results.map((_result) => {
return _result.data.data return _result.data.data;
}) });
cb(results) cb(results);
}) })
) );
} }
}, },
get (url, params, cb_su, cb_err, headers) { get(url, params, cb_su, cb_err, headers) {
var p = { var p = {
params: params, params: params,
} };
if (headers && JSON.stringify(headers) != '{}') { if (headers && JSON.stringify(headers) != "{}") {
var h = { var h = {
headers: headers, headers: headers,
} };
p = { p = {
...p, ...p,
...h, ...h,
} };
} }
url = url + '?r=' + new Date().getTime() //时间戳作为随机码,防止IE从缓存获取数据 url = url + "?r=" + new Date().getTime(); //时间戳作为随机码,防止IE从缓存获取数据
axios axios
.get(processUrl(url), p) .get(processUrl(url), p)
.then((res) => { .then((res) => {
if (res) { if (res) {
if (res.status === 200) { if (res.status === 200) {
var data = res.data;
var data = res.data
if (data.code == 0) { if (data.code == 0) {
//业务成功 //业务成功
if (typeof cb_su === 'function') { if (typeof cb_su === "function") {
cb_su(data.data, data.msg ) cb_su(data.data, data.msg);
} }
} else { } else {
//业务失败 //业务失败
if (typeof cb_err === 'function') cb_err(data.msg , data.data) if (typeof cb_err === "function") cb_err(data.msg, data.data);
} }
} else { } else {
if (typeof cb_err === 'function') cb_err(res) if (typeof cb_err === "function") cb_err(res);
} }
} else { } else {
if (typeof cb_err === 'function') cb_err(res) if (typeof cb_err === "function") cb_err(res);
} }
}) })
.catch((err) => { .catch((err) => {
if (typeof (cb_err === 'function')) { if (typeof (cb_err === "function")) {
cb_err(err) cb_err(err);
} }
}) });
}, },
put (url, data, cb_su, cb_err) { put(url, data, cb_su, cb_err) {
axios axios
.put(processUrl(url), data) .put(processUrl(url), data)
.then((res) => { .then((res) => {
if (res) { if (res) {
if (res.status === 200) { if (res.status === 200) {
var data = res.data var data = res.data;
if (data.sysresultcode === 'success') { if (data.sysresultcode === "success") {
//业务成功 //业务成功
if (typeof cb_su === 'function') { if (typeof cb_su === "function") {
cb_su(data.data, data.rspMsg) cb_su(data.data, data.rspMsg);
} }
} else if (data.sysresultcode === 'fail') { } else if (data.sysresultcode === "fail") {
//业务失败 //业务失败
if (typeof cb_err === 'function') cb_err(data.rspMsg, data.data) if (typeof cb_err === "function") cb_err(data.rspMsg, data.data);
} }
} else { } else {
if (typeof cb_err === 'function') cb_err(res) if (typeof cb_err === "function") cb_err(res);
} }
} else { } else {
if (typeof cb_err === 'function') cb_err(res) if (typeof cb_err === "function") cb_err(res);
} }
}) })
.catch((err) => { .catch((err) => {
if (typeof cb_err === 'function') { if (typeof cb_err === "function") {
cb_err(err) cb_err(err);
} }
}) });
}, },
post (url, data, cb_su, cb_err, headers) { post(url, data, cb_su, cb_err, headers) {
var h = {} var h = {};
if (headers && JSON.stringify(headers) != '{}') { if (headers && JSON.stringify(headers) != "{}") {
h = { h = {
headers, headers,
} };
} }
//var data = qs.stringify(paramas); //var data = qs.stringify(paramas);
axios axios
.post(processUrl(url), data, h) .post(processUrl(url), data, h)
.then((res) => { .then((res) => {
if (res) { if (res) {
if (res.status === 200) { if (res.status === 200) {
var data = res.data;
var data = res.data
if (data.code == 0) { if (data.code == 0) {
//业务成功 //业务成功
if (typeof cb_su === 'function') { if (typeof cb_su === "function") {
cb_su(data.data, data.msg ) cb_su(data.data, data.msg);
} }
} else { } else {
//业务失败 //业务失败
if (typeof cb_err === 'function') cb_err(data.msg , data.data) if (typeof cb_err === "function") cb_err(data.msg, data.data);
} }
} else { } else {
if (typeof cb_err === 'function') cb_err(res) if (typeof cb_err === "function") cb_err(res);
} }
} else { } else {
if (typeof cb_err === 'function') cb_err(res) if (typeof cb_err === "function") cb_err(res);
} }
}) })
.catch((err) => { .catch((err) => {
if (typeof cb_err === 'function') { if (typeof cb_err === "function") {
cb_err(err) cb_err(err);
} }
}) });
}, },
post2 (url, data, cb_su, cb_err, headers) { post2(url, data, cb_su, cb_err, headers) {
var h = {} var h = {};
if (headers && JSON.stringify(headers) != '{}') { if (headers && JSON.stringify(headers) != "{}") {
h = { h = {
headers, headers,
} };
} }
//var data = qs.stringify(paramas); //var data = qs.stringify(paramas);
axios axios
@ -294,22 +283,22 @@ export default {
.then((res) => { .then((res) => {
if (res) { if (res) {
if (res.status === 200) { if (res.status === 200) {
var data = res.data var data = res.data;
cb_su(data, data.msg ) cb_su(data, data.msg);
} else { } else {
if (typeof cb_err === 'function') cb_err(data.msg , data) if (typeof cb_err === "function") cb_err(data.msg, data);
} }
} else { } else {
if (typeof cb_err === 'function') cb_err(data.msg , data) if (typeof cb_err === "function") cb_err(data.msg, data);
} }
}) })
.catch((err) => { .catch((err) => {
if (typeof cb_err === 'function') { if (typeof cb_err === "function") {
cb_err(err) cb_err(err);
} }
}) });
}, },
delete (url, params, cb_su, cb_err) { delete(url, params, cb_su, cb_err) {
axios axios
.delete(processUrl(url), { .delete(processUrl(url), {
params: params, params: params,
@ -317,219 +306,217 @@ export default {
.then((res) => { .then((res) => {
if (res) { if (res) {
if (res.status === 200) { if (res.status === 200) {
var data = res.data var data = res.data;
if (data.sysresultcode === 'success') { if (data.sysresultcode === "success") {
//业务成功 //业务成功
if (typeof cb_su === 'function') { if (typeof cb_su === "function") {
cb_su(data.data, data.rspMsg) cb_su(data.data, data.rspMsg);
} }
} else if (data.sysresultcode === 'fail') { } else if (data.sysresultcode === "fail") {
//业务失败 //业务失败
if (typeof cb_err === 'function') cb_err(data.rspMsg, data.data) if (typeof cb_err === "function") cb_err(data.rspMsg, data.data);
} }
} else { } else {
if (typeof cb_err === 'function') cb_err(res) if (typeof cb_err === "function") cb_err(res);
} }
} else { } else {
if (typeof cb_err === 'function') cb_err(res) if (typeof cb_err === "function") cb_err(res);
} }
}) })
.catch((err) => { .catch((err) => {
if (typeof cb_err === 'function') { if (typeof cb_err === "function") {
cb_err(err) cb_err(err);
} }
}) });
}, },
//导出文件,包括excel,word等 //导出文件,包括excel,word等
exportFile (url, params, cb_su, cb_err, headers) { exportFile(url, params, cb_su, cb_err, headers) {
var h = {} var h = {};
if (headers && JSON.stringify(headers) != '{}') { if (headers && JSON.stringify(headers) != "{}") {
h = headers h = headers;
} }
var errorMsg = '操作失败' var errorMsg = "操作失败";
url = url + '?r=' + new Date().getTime() //时间戳作为随机码,防止IE从缓存获取数据 url = url + "?r=" + new Date().getTime(); //时间戳作为随机码,防止IE从缓存获取数据
axios({ axios({
method: 'get', method: "get",
url: processUrl(url), url: processUrl(url),
params: params, params: params,
headers: h, //{ tenantCode: "GDYXB" }, headers: h, //{ tenantCode: "GDYXB" },
responseType: 'blob', responseType: "blob",
}) })
.then((res) => { .then((res) => {
if (res) { if (res) {
if (res.status === 200) { if (res.status === 200) {
var data = res.data //直接返回blob var data = res.data; //直接返回blob
if (data) { if (data) {
//业务成功 //业务成功
if (typeof cb_su === 'function') { if (typeof cb_su === "function") {
cb_su(data, '操作成功') cb_su(data, "操作成功");
} }
} else { } else {
//业务失败 //业务失败
if (typeof cb_err === 'function') cb_err(errorMsg) if (typeof cb_err === "function") cb_err(errorMsg);
} }
} else { } else {
if (typeof cb_err === 'function') cb_err(errorMsg) if (typeof cb_err === "function") cb_err(errorMsg);
} }
} else { } else {
if (typeof cb_err === 'function') cb_err(errorMsg) if (typeof cb_err === "function") cb_err(errorMsg);
} }
}) })
.catch((err) => { .catch((err) => {
if (typeof (cb_err === 'function')) { if (typeof (cb_err === "function")) {
cb_err(errorMsg) cb_err(errorMsg);
} }
}) });
}, },
//导出文件,包括excel,word等 //导出文件,包括excel,word等
exportFilePost (url, params, cb_su, cb_err) { exportFilePost(url, params, cb_su, cb_err) {
//var data = qs.stringify(paramas); //var data = qs.stringify(paramas);
// axios // axios
// .post(processUrl(url), data) // .post(processUrl(url), data)
axios({ axios({
method: 'post', method: "post",
url: processUrl(url), url: processUrl(url),
data: params, data: params,
responseType: 'blob', responseType: "blob",
}) })
.then((res) => { .then((res) => {
if (res) { if (res) {
if (res.status === 200) { if (res.status === 200) {
var data = res.data //直接返回blob var data = res.data; //直接返回blob
// if (data.code == 0) { // if (data.code == 0) {
//业务成功 //业务成功
if (typeof cb_su === 'function') { if (typeof cb_su === "function") {
cb_su(data) cb_su(data);
} } else {
else {
//业务失败 //业务失败
if (typeof cb_err === 'function') cb_err(errorMsg) if (typeof cb_err === "function") cb_err(errorMsg);
} }
// } else { // } else {
// if (typeof cb_err === 'function') cb_err(errorMsg) // if (typeof cb_err === 'function') cb_err(errorMsg)
} }
} else { } else {
if (typeof cb_err === 'function') cb_err(errorMsg) if (typeof cb_err === "function") cb_err(errorMsg);
} }
}) })
.catch((err) => { .catch((err) => {
if (typeof cb_err === 'function') { if (typeof cb_err === "function") {
cb_err(err) cb_err(err);
} }
}) });
}, },
//上传文件 //上传文件
importFilePut (url, fileFormData, cb_su, cb_err) { importFilePut(url, fileFormData, cb_su, cb_err) {
var errorMsg = '操作失败' var errorMsg = "操作失败";
let requestConfig = { let requestConfig = {
headers: { headers: {
'Content-Type': 'multipart/form-data', "Content-Type": "multipart/form-data",
// Authorization: auth.loadTokenType() + ' ' + auth.loadAccessToken(), // Authorization: auth.loadTokenType() + ' ' + auth.loadAccessToken(),
}, },
} };
Vue.http Vue.http
.put(processUrl(url), fileFormData, requestConfig) .put(processUrl(url), fileFormData, requestConfig)
.then((res) => { .then((res) => {
if (res && res.status === 200) { if (res && res.status === 200) {
var data = res.body //直接返回blob var data = res.body; //直接返回blob
if (data.sysresultcode === 'fail') { if (data.sysresultcode === "fail") {
//业务失败 //业务失败
if (typeof cb_err === 'function') cb_err(data.rspMsg) if (typeof cb_err === "function") cb_err(data.rspMsg);
} else if (data.sysresultcode === 'success') { } else if (data.sysresultcode === "success") {
//业务成功 //业务成功
if (typeof cb_su === 'function') { if (typeof cb_su === "function") {
cb_su(data, '操作成功') cb_su(data, "操作成功");
} }
} else { } else {
if (typeof cb_err === 'function') cb_err(errorMsg) if (typeof cb_err === "function") cb_err(errorMsg);
} }
} else { } else {
if (typeof cb_err === 'function') cb_err(errorMsg) if (typeof cb_err === "function") cb_err(errorMsg);
} }
}) })
.catch((err) => { .catch((err) => {
if (typeof (cb_err === 'function')) { if (typeof (cb_err === "function")) {
cb_err(errorMsg) cb_err(errorMsg);
} }
}) });
}, },
//上传文件 //上传文件
importFilePost (url, fileFormData, cb_su, cb_err) { importFilePost(url, fileFormData, cb_su, cb_err) {
var errorMsg = '操作失败' var errorMsg = "操作失败";
let requestConfig = { let requestConfig = {
headers: { headers: {
'Content-Type': 'multipart/form-data' "Content-Type": "multipart/form-data",
// Authorization: auth.loadTokenType() + ' ' + auth.loadAccessToken(), // Authorization: auth.loadTokenType() + ' ' + auth.loadAccessToken(),
} },
} };
Vue.http Vue.http
.post(processUrl(url), fileFormData, requestConfig) .post(processUrl(url), fileFormData, requestConfig)
.then((res) => { .then((res) => {
if (res && res.status === 200) { if (res && res.status === 200) {
var data = res.body //直接返回blob var data = res.body; //直接返回blob
if (data.sysresultcode === 'fail') { if (data.sysresultcode === "fail") {
//业务失败 //业务失败
if (typeof cb_err === 'function') cb_err(data.rspMsg) if (typeof cb_err === "function") cb_err(data.rspMsg);
} else if (data.sysresultcode === 'success') { } else if (data.sysresultcode === "success") {
//业务成功 //业务成功
if (typeof cb_su === 'function') { if (typeof cb_su === "function") {
cb_su(data, '操作成功') cb_su(data, "操作成功");
} }
} else { } else {
if (typeof cb_err === 'function') cb_err(errorMsg) if (typeof cb_err === "function") cb_err(errorMsg);
} }
} else { } else {
if (typeof cb_err === 'function') cb_err(errorMsg) if (typeof cb_err === "function") cb_err(errorMsg);
} }
}) })
.catch((err) => { .catch((err) => {
if (typeof (cb_err === 'function')) { if (typeof (cb_err === "function")) {
cb_err(errorMsg) cb_err(errorMsg);
} }
}) });
}, },
//登录获取token/刷新token //登录获取token/刷新token
tokenPost (url, paramas, cb_su, cb_err) { tokenPost(url, paramas, cb_su, cb_err) {
var data = qs.stringify(paramas) var data = qs.stringify(paramas);
axios axios
.post(processUrl(url), data) .post(processUrl(url), data)
.then((res) => { .then((res) => {
if (res) { if (res) {
if (res.status === 200) { if (res.status === 200) {
var data = res.data var data = res.data;
if (data) { if (data) {
if (typeof cb_su === 'function') { if (typeof cb_su === "function") {
cb_su(data) cb_su(data);
} }
} else { } else {
if (typeof cb_err === 'function') cb_err('登录验证失败') if (typeof cb_err === "function") cb_err("登录验证失败");
} }
} else { } else {
if (typeof cb_err === 'function') cb_err(res) if (typeof cb_err === "function") cb_err(res);
} }
} else { } else {
if (typeof cb_err === 'function') cb_err(res) if (typeof cb_err === "function") cb_err(res);
} }
}) })
.catch((err) => { .catch((err) => {
var rspMsg = '登录失败,请重试!' var rspMsg = "登录失败,请重试!";
if ( if (
err && err &&
err.response && err.response &&
err.response.status === 401 && err.response.status === 401 &&
err.response.data && err.response.data &&
err.response.data.error === 'unauthorized' err.response.data.error === "unauthorized"
) { ) {
// 用户名不存在时: 状态码401 // 用户名不存在时: 状态码401
// Response Body: // Response Body:
@ -537,92 +524,91 @@ export default {
// "error": "unauthorized", // "error": "unauthorized",
// "error_description": null // "error_description": null
// } // }
rspMsg = err.response.data.error_description || '用户名不存在' rspMsg = err.response.data.error_description || "用户名不存在";
} else if ( } else if (
err && err &&
err.response && err.response &&
err.response.status === 400 && err.response.status === 400 &&
err.response.data && err.response.data &&
err.response.data.error === 'invalid_grant' err.response.data.error === "invalid_grant"
) { ) {
// 用户名存在,密码错误时:状态码400 // 用户名存在,密码错误时:状态码400
// { // {
// "error": "invalid_grant", // "error": "invalid_grant",
// "error_description": "Bad credentials" // "error_description": "Bad credentials"
// } // }
rspMsg = '用户名或密码输入错误' rspMsg = "用户名或密码输入错误";
} }
if (typeof cb_err === 'function') { if (typeof cb_err === "function") {
cb_err(rspMsg) cb_err(rspMsg);
} }
}) });
}, },
//通过接口传递的token进行验证登录 lyx 20191210 //通过接口传递的token进行验证登录 lyx 20191210
async interfacetokenPost (url, paramas, cb_su, cb_err) { async interfacetokenPost(url, paramas, cb_su, cb_err) {
var data = qs.stringify(paramas) var data = qs.stringify(paramas);
await axios await axios
.post(processUrl(url), data) .post(processUrl(url), data)
.then((res) => { .then((res) => {
if (res) { if (res) {
if (res.status === 200) { if (res.status === 200) {
var data = res.data var data = res.data;
if (data) { if (data) {
if (typeof cb_su === 'function') { if (typeof cb_su === "function") {
cb_su(data) cb_su(data);
return true return true;
} }
} else { } else {
if (typeof cb_err === 'function') { if (typeof cb_err === "function") {
cb_err('接口验证失败') cb_err("接口验证失败");
return false return false;
} }
} }
} else { } else {
if (typeof cb_err === 'function') { if (typeof cb_err === "function") {
cb_err(res) cb_err(res);
return false return false;
} }
} }
} else { } else {
if (typeof cb_err === 'function') { if (typeof cb_err === "function") {
cb_err(res) cb_err(res);
return false return false;
} }
} }
}) })
.catch((err) => { .catch((err) => {
var rspMsg = '接口验证失败,请重试!' var rspMsg = "接口验证失败,请重试!";
if ( if (
err && err &&
err.response && err.response &&
err.response.status === 401 && err.response.status === 401 &&
err.response.data && err.response.data &&
err.response.data.error === 'unauthorized' err.response.data.error === "unauthorized"
) { ) {
rspMsg = '用户名不存在' rspMsg = "用户名不存在";
} else if ( } else if (
err && err &&
err.response && err.response &&
err.response.status === 400 && err.response.status === 400 &&
err.response.data && err.response.data &&
err.response.data.error === 'invalid_grant' err.response.data.error === "invalid_grant"
) { ) {
rspMsg = '用户名或密码输入错误' rspMsg = "用户名或密码输入错误";
} }
if (typeof cb_err === 'function') { if (typeof cb_err === "function") {
cb_err(rspMsg) cb_err(rspMsg);
return false return false;
} }
}) });
}, },
} };
// 添加服务器端URL // 添加服务器端URL
function processUrl (url) { function processUrl(url) {
if (url.indexOf("http://") > -1 || url.indexOf("https://") > -1) {
if (url.indexOf('http://') > -1 || url.indexOf('https://') > -1) { return url;
return url
} }
return process.env.VUE_APP_API_SERVER + url return process.env.VUE_APP_API_SERVER + url;
} }

Loading…
Cancel
Save