new files
30
pro_v3.5.1/view/admin/src/plugins/auth/index.js
Normal file
@@ -0,0 +1,30 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
/**
|
||||
* @description 鉴权指令
|
||||
* 当传入的权限当前用户没有时,会移除该组件
|
||||
* 用例:<Tag v-auth="['admin']">text</Tag>
|
||||
* */
|
||||
import store from '@/store';
|
||||
import { includeArray } from '@/libs/system';
|
||||
|
||||
export default {
|
||||
inserted (el, binding, vnode) {
|
||||
const { value } = binding;
|
||||
const access = store.state.admin.user.info.access;
|
||||
|
||||
if (value && value instanceof Array && value.length && access && access.length) {
|
||||
const isPermission = includeArray(value, access);
|
||||
if (!isPermission) {
|
||||
el.parentNode && el.parentNode.removeChild(el);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
115
pro_v3.5.1/view/admin/src/plugins/cache/index.js
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
const sessionCache = {
|
||||
set(key, value) {
|
||||
if (!sessionStorage) {
|
||||
return;
|
||||
}
|
||||
if (key != null && value != null) {
|
||||
sessionStorage.setItem(key, value);
|
||||
}
|
||||
},
|
||||
get(key) {
|
||||
if (!sessionStorage) {
|
||||
return null;
|
||||
}
|
||||
if (key == null) {
|
||||
return null;
|
||||
}
|
||||
return sessionStorage.getItem(key);
|
||||
},
|
||||
setJSON(key, jsonValue) {
|
||||
if (jsonValue != null) {
|
||||
this.set(key, JSON.stringify(jsonValue));
|
||||
}
|
||||
},
|
||||
getJSON(key) {
|
||||
const value = this.get(key);
|
||||
if (value != null) {
|
||||
return JSON.parse(value);
|
||||
}
|
||||
},
|
||||
remove(key) {
|
||||
sessionStorage.removeItem(key);
|
||||
},
|
||||
// 检测缓存是否存在
|
||||
has(key)
|
||||
{
|
||||
return sessionStorage.getItem(key) ? true:false;
|
||||
},
|
||||
};
|
||||
const localCache = {
|
||||
set(key, value) {
|
||||
if (!localStorage) {
|
||||
return;
|
||||
}
|
||||
if (key != null && value != null) {
|
||||
localStorage.setItem(key, value);
|
||||
}
|
||||
},
|
||||
get(key) {
|
||||
if (!localStorage) {
|
||||
return null;
|
||||
}
|
||||
if (key == null) {
|
||||
return null;
|
||||
}
|
||||
return localStorage.getItem(key);
|
||||
},
|
||||
setJSON(key, jsonValue) {
|
||||
if (jsonValue != null) {
|
||||
this.set(key, JSON.stringify(jsonValue));
|
||||
}
|
||||
},
|
||||
getJSON(key) {
|
||||
const value = this.get(key);
|
||||
if (value != null) {
|
||||
return JSON.parse(value);
|
||||
}
|
||||
},
|
||||
remove(key) {
|
||||
localStorage.removeItem(key);
|
||||
},
|
||||
// 检测缓存是否存在
|
||||
has(key)
|
||||
{
|
||||
return localStorage.getItem(key) ? true:false;
|
||||
},
|
||||
setItem(params){
|
||||
let obj = {
|
||||
name:'',
|
||||
value:'',
|
||||
expires:"",
|
||||
startTime:new Date().getTime()
|
||||
}
|
||||
let options = {};
|
||||
//将obj和传进来的params合并
|
||||
Object.assign(options,obj,params);
|
||||
if(options.expires){
|
||||
//如果options.expires设置了的话
|
||||
//以options.name为key,options为值放进去
|
||||
localStorage.setItem(options.name,JSON.stringify(options));
|
||||
}else{
|
||||
//如果options.expires没有设置,就判断一下value的类型
|
||||
let type = Object.prototype.toString.call(options.value);
|
||||
//如果value是对象或者数组对象的类型,就先用JSON.stringify转一下,再存进去
|
||||
if(Object.prototype.toString.call(options.value) == '[object Object]'){
|
||||
options.value = JSON.stringify(options.value);
|
||||
}
|
||||
if(Object.prototype.toString.call(options.value) == '[object Array]'){
|
||||
options.value = JSON.stringify(options.value);
|
||||
}
|
||||
localStorage.setItem(options.name,options.value);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default {
|
||||
/**
|
||||
* 会话级缓存
|
||||
*/
|
||||
session: sessionCache,
|
||||
/**
|
||||
* 本地缓存
|
||||
*/
|
||||
local: localCache
|
||||
};
|
||||
|
||||
1
pro_v3.5.1/view/admin/src/plugins/emoji-awesome/css/apple.min.css
vendored
Normal file
1
pro_v3.5.1/view/admin/src/plugins/emoji-awesome/css/emojione.min.css
vendored
Normal file
1
pro_v3.5.1/view/admin/src/plugins/emoji-awesome/css/facebook.min.css
vendored
Normal file
303
pro_v3.5.1/view/admin/src/plugins/emoji-awesome/css/google.min.css
vendored
Normal file
@@ -0,0 +1,303 @@
|
||||
.em {
|
||||
display: inline-block;
|
||||
height: 1em;
|
||||
width: 1em;
|
||||
overflow: hidden;
|
||||
line-height: 18px;
|
||||
font-size: 22px;
|
||||
vertical-align: middle;
|
||||
margin-top: -4px;
|
||||
color: transparent !important;
|
||||
background-size: 4100%;
|
||||
background-image: url(../img/look.png) !important;
|
||||
}
|
||||
.em.em-tlj-1 {
|
||||
background-position: 0% 0%;
|
||||
}
|
||||
.em.em-tlj-2 {
|
||||
background-position: 0% 2.5%;
|
||||
}
|
||||
.em.em-tlj-3 {
|
||||
background-position: 0% 5%;
|
||||
}
|
||||
.em.em-tlj-4 {
|
||||
background-position: 0% 7.5%;
|
||||
}
|
||||
.em.em-tlj-5 {
|
||||
background-position: 0% 10%;
|
||||
}
|
||||
.em.em-tlj-6 {
|
||||
background-position: 0% 12.5%;
|
||||
}
|
||||
.em.em-tlj-7 {
|
||||
background-position: 0% 15%;
|
||||
}
|
||||
.em.em-tlj-8 {
|
||||
background-position: 0% 17.5%;
|
||||
}
|
||||
.em.em-tlj-9 {
|
||||
background-position: 0% 20%;
|
||||
}
|
||||
.em.em-tlj-10 {
|
||||
background-position: 0% 22.5%;
|
||||
}
|
||||
.em.em-tlj-11 {
|
||||
background-position: 0% 25%;
|
||||
}
|
||||
.em.em-tlj-12 {
|
||||
background-position: 0% 27.5%;
|
||||
}
|
||||
.em.em-tlj-13 {
|
||||
background-position: 0% 30%;
|
||||
}
|
||||
.em.em-tlj-14 {
|
||||
background-position: 0% 32.5%;
|
||||
}
|
||||
.em.em-tlj-15 {
|
||||
background-position: 0% 35%;
|
||||
}
|
||||
.em.em-tlj-16 {
|
||||
background-position: 0% 37.5%;
|
||||
}
|
||||
.em.em-tlj-17 {
|
||||
background-position: 0% 40%;
|
||||
}
|
||||
.em.em-tlj-18 {
|
||||
background-position: 0% 42.5%;
|
||||
}
|
||||
.em.em-tlj-19 {
|
||||
background-position: 0% 45%;
|
||||
}
|
||||
.em.em-tlj-20 {
|
||||
background-position: 0% 47.5%;
|
||||
}
|
||||
.em.em-tlj-21 {
|
||||
background-position: 0% 50%;
|
||||
}
|
||||
.em.em-tlj-22 {
|
||||
background-position: 0% 52.5%;
|
||||
}
|
||||
.em.em-tlj-23 {
|
||||
background-position: 0% 55%;
|
||||
}
|
||||
.em.em-tlj-24 {
|
||||
background-position: 0% 57.5%;
|
||||
}
|
||||
.em.em-tlj-25 {
|
||||
background-position: 0% 60%;
|
||||
}
|
||||
.em.em-tlj-26 {
|
||||
background-position: 0% 62.5%;
|
||||
}
|
||||
.em.em-tlj-27 {
|
||||
background-position: 0% 65%;
|
||||
}
|
||||
.em.em-tlj-28 {
|
||||
background-position: 0% 67.5%;
|
||||
}
|
||||
.em.em-tlj-29 {
|
||||
background-position: 0% 70%;
|
||||
}
|
||||
.em.em-tlj-30 {
|
||||
background-position: 0% 72.5%;
|
||||
}
|
||||
.em.em-tlj-31 {
|
||||
background-position: 0% 75%;
|
||||
}
|
||||
.em.em-tlj-32 {
|
||||
background-position: 0% 77.5%;
|
||||
}
|
||||
.em.em-tlj-33 {
|
||||
background-position: 0% 80%;
|
||||
}
|
||||
.em.em-tlj-34 {
|
||||
background-position: 0% 82.5%;
|
||||
}
|
||||
.em.em-tlj-35 {
|
||||
background-position: 0% 85%;
|
||||
}
|
||||
.em.em-tlj-36 {
|
||||
background-position: 0% 87.5%;
|
||||
}
|
||||
.em.em-tlj-37 {
|
||||
background-position: 0% 90%;
|
||||
}
|
||||
.em.em-tlj-38 {
|
||||
background-position: 0% 92.5%;
|
||||
}
|
||||
.em.em-tlj-39 {
|
||||
background-position: 0% 95%;
|
||||
}
|
||||
.em.em-tlj-40 {
|
||||
background-position: 0% 97.5%;
|
||||
}
|
||||
.em.em-tlj-41 {
|
||||
background-position: 0% 100%;
|
||||
}
|
||||
.em.em-tlj-42 {
|
||||
background-position: 2.5% 0%;
|
||||
}
|
||||
.em.em-tlj-43 {
|
||||
background-position: 2.5% 2.5%;
|
||||
}
|
||||
.em.em-tlj-44 {
|
||||
background-position: 2.5% 5%;
|
||||
}
|
||||
.em.em-tlj-45 {
|
||||
background-position: 2.5% 7.5%;
|
||||
}
|
||||
.em.em-tlj-46 {
|
||||
background-position: 2.5% 10%;
|
||||
}
|
||||
.em.em-tlj-47 {
|
||||
background-position: 2.5% 12.5%;
|
||||
}
|
||||
.em.em-tlj-48 {
|
||||
background-position: 2.5% 15%;
|
||||
}
|
||||
.em.em-tlj-49 {
|
||||
background-position: 2.5% 17.5%;
|
||||
}
|
||||
.em.em-tlj-50 {
|
||||
background-position: 2.5% 20%;
|
||||
}
|
||||
.em.em-tlj-51 {
|
||||
background-position: 2.5% 22.5%;
|
||||
}
|
||||
.em.em-tlj-52 {
|
||||
background-position: 2.5% 25%;
|
||||
}
|
||||
.em.em-tlj-53 {
|
||||
background-position: 2.5% 27.5%;
|
||||
}
|
||||
.em.em-tlj-54 {
|
||||
background-position: 2.5% 30%;
|
||||
}
|
||||
.em.em-tlj-55 {
|
||||
background-position: 2.5% 32.5%;
|
||||
}
|
||||
.em.em-tlj-56 {
|
||||
background-position: 2.5% 35%;
|
||||
}
|
||||
.em.em-tlj-57 {
|
||||
background-position: 2.5% 37.5%;
|
||||
}
|
||||
.em.em-tlj-58 {
|
||||
background-position: 2.5% 40%;
|
||||
}
|
||||
.em.em-tlj-59 {
|
||||
background-position: 2.5% 42.5%;
|
||||
}
|
||||
.em.em-tlj-60 {
|
||||
background-position: 2.5% 45%;
|
||||
}
|
||||
.em.em-tlj-61 {
|
||||
background-position: 2.5% 47.5%;
|
||||
}
|
||||
.em.em-tlj-62 {
|
||||
background-position: 2.5% 50%;
|
||||
}
|
||||
.em.em-tlj-63 {
|
||||
background-position: 2.5% 52.5%;
|
||||
}
|
||||
.em.em-tlj-64 {
|
||||
background-position: 2.5% 55%;
|
||||
}
|
||||
.em.em-tlj-65 {
|
||||
background-position: 2.5% 57.5%;
|
||||
}
|
||||
.em.em-tlj-66 {
|
||||
background-position: 2.5% 60%;
|
||||
}
|
||||
.em.em-tlj-67 {
|
||||
background-position: 2.5% 62.5%;
|
||||
}
|
||||
.em.em-tlj-68 {
|
||||
background-position: 2.5% 65%;
|
||||
}
|
||||
.em.em-tlj-69 {
|
||||
background-position: 2.5% 67.5%;
|
||||
}
|
||||
.em.em-tlj-70 {
|
||||
background-position: 2.5% 70%;
|
||||
}
|
||||
.em.em-tlj-71 {
|
||||
background-position: 2.5% 72.5%;
|
||||
}
|
||||
.em.em-tlj-72 {
|
||||
background-position: 2.5% 75%;
|
||||
}
|
||||
.em.em-tlj-73 {
|
||||
background-position: 2.5% 77.5%;
|
||||
}
|
||||
.em.em-tlj-74 {
|
||||
background-position: 2.5% 80%;
|
||||
}
|
||||
.em.em-tlj-75 {
|
||||
background-position: 2.5% 82.5%;
|
||||
}
|
||||
.em.em-tlj-76 {
|
||||
background-position: 2.5% 85%;
|
||||
}
|
||||
.em.em-tlj-77 {
|
||||
background-position: 2.5% 87.5%;
|
||||
}
|
||||
.em.em-tlj-78 {
|
||||
background-position: 2.5% 90%;
|
||||
}
|
||||
.em.em-tlj-79 {
|
||||
background-position: 2.5% 92.5%;
|
||||
}
|
||||
.em.em-tlj-80 {
|
||||
background-position: 2.5% 95%;
|
||||
}
|
||||
.em.em-tlj-81 {
|
||||
background-position: 2.5% 97.5%;
|
||||
}
|
||||
.em.em-tlj-82 {
|
||||
background-position: 2.5% 100%;
|
||||
}
|
||||
.em.em-tlj-83 {
|
||||
background-position: 5% 0%
|
||||
}
|
||||
.em.em-tlj-84 {
|
||||
background-position: 5% 2.5%
|
||||
}
|
||||
.em.em-tlj-85 {
|
||||
background-position: 5% 5%
|
||||
}
|
||||
.em.em-tlj-86 {
|
||||
background-position: 5% 7.5%
|
||||
}
|
||||
.em.em-tlj-87 {
|
||||
background-position: 5% 10%
|
||||
}
|
||||
.em.em-tlj-88 {
|
||||
background-position: 5% 12.5%
|
||||
}
|
||||
.em.em-tlj-89 {
|
||||
background-position: 5% 15%
|
||||
}
|
||||
.em.em-tlj-90 {
|
||||
background-position: 5% 17.5%
|
||||
}
|
||||
.em.em-tlj-91 {
|
||||
background-position: 5% 20%
|
||||
}
|
||||
.em.em-tlj-92 {
|
||||
background-position: 5% 22.5%
|
||||
}
|
||||
.em.em-tlj-93 {
|
||||
background-position: 5% 25%
|
||||
}
|
||||
.em.em-tlj-94 {
|
||||
background-position: 5% 27.5%
|
||||
}
|
||||
.em.em-tlj-95 {
|
||||
background-position: 5% 30%
|
||||
}
|
||||
.em.em-tlj-96 {
|
||||
background-position: 5% 32.5%
|
||||
}
|
||||
|
||||
|
||||
1
pro_v3.5.1/view/admin/src/plugins/emoji-awesome/css/messenger.min.css
vendored
Normal file
1
pro_v3.5.1/view/admin/src/plugins/emoji-awesome/css/twitter.min.css
vendored
Normal file
BIN
pro_v3.5.1/view/admin/src/plugins/emoji-awesome/img/look.png
Normal file
|
After Width: | Height: | Size: 1.0 MiB |
|
After Width: | Height: | Size: 1.6 MiB |
|
After Width: | Height: | Size: 898 KiB |
|
After Width: | Height: | Size: 1.1 MiB |
|
After Width: | Height: | Size: 943 KiB |
|
After Width: | Height: | Size: 1.1 MiB |
|
After Width: | Height: | Size: 862 KiB |
30
pro_v3.5.1/view/admin/src/plugins/error/index.js
Normal file
@@ -0,0 +1,30 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
import store from '@/store';
|
||||
import util from '@/libs/util';
|
||||
import axios from 'axios';
|
||||
|
||||
export default {
|
||||
install (Vue, options) {
|
||||
Vue.config.errorHandler = function (error, instance, info) {
|
||||
Vue.nextTick(() => {
|
||||
// store 追加 log
|
||||
store.dispatch('admin/log/push', {
|
||||
message: `${info}: ${error.message}`,
|
||||
type: 'error',
|
||||
meta: {
|
||||
error
|
||||
// instance
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
30
pro_v3.5.1/view/admin/src/plugins/index.js
Normal file
@@ -0,0 +1,30 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
/**
|
||||
* 插件
|
||||
* */
|
||||
|
||||
// 错误捕获
|
||||
import pluginError from '@/plugins/error';
|
||||
// 日志插件
|
||||
import pluginLog from '@/plugins/log';
|
||||
// 鉴权指令
|
||||
import directiveAuth from '@/plugins/auth';
|
||||
|
||||
export default {
|
||||
async install (Vue, options) {
|
||||
// 插件
|
||||
Vue.use(pluginError);
|
||||
Vue.use(pluginLog);
|
||||
|
||||
// 指令
|
||||
Vue.directive('auth', directiveAuth);
|
||||
}
|
||||
}
|
||||
34
pro_v3.5.1/view/admin/src/plugins/log/index.js
Normal file
@@ -0,0 +1,34 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
import store from '@/store';
|
||||
import util from '@/libs/util';
|
||||
|
||||
export default {
|
||||
install (Vue, options) {
|
||||
// 快速打印 log
|
||||
Vue.prototype.$log = {
|
||||
...util.log,
|
||||
push (data) {
|
||||
if (typeof data === 'string') {
|
||||
// 如果传递来的数据是字符串
|
||||
// 赋值给 message 字段
|
||||
// 为了方便使用
|
||||
// eg: this.$log.push('foo text')
|
||||
store.dispatch('admin/log/push', {
|
||||
message: data
|
||||
});
|
||||
} else if (typeof data === 'object') {
|
||||
// 如果传递来的数据是对象
|
||||
store.dispatch('admin/log/push', data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
43
pro_v3.5.1/view/admin/src/plugins/propertyList.js
Normal file
@@ -0,0 +1,43 @@
|
||||
let propertyList = [
|
||||
{
|
||||
label: "余额",
|
||||
value: 0,
|
||||
k: "now_money",
|
||||
},
|
||||
{
|
||||
label: "优惠券",
|
||||
value: 1,
|
||||
k: "couponCount",
|
||||
},
|
||||
{
|
||||
label: "积分",
|
||||
value: 2,
|
||||
k: "integral",
|
||||
},
|
||||
{
|
||||
label: "收藏",
|
||||
value: 3,
|
||||
k: "collectCount",
|
||||
},
|
||||
{
|
||||
label: "浏览记录",
|
||||
value: 5,
|
||||
k: "visit_num",
|
||||
},
|
||||
{
|
||||
label: "推广佣金",
|
||||
value: 6,
|
||||
k: "brokerade_price",
|
||||
},
|
||||
{
|
||||
label: "推广人",
|
||||
value: 7,
|
||||
k: "number",
|
||||
},
|
||||
{
|
||||
label: "推广订单",
|
||||
value: 8,
|
||||
k: "order_num",
|
||||
},
|
||||
];
|
||||
export default propertyList;
|
||||
219
pro_v3.5.1/view/admin/src/plugins/request/index.js
Normal file
@@ -0,0 +1,219 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
import store from "@/store";
|
||||
import axios from "axios";
|
||||
import util from "@/libs/util";
|
||||
import Setting from "@/setting";
|
||||
import { Message, Notice, LoadingBar } from "view-design";
|
||||
import Vue from "vue";
|
||||
// 创建一个错误
|
||||
// function errorCreate (msg) {
|
||||
// const err = new Error(msg);
|
||||
// errorLog(err);
|
||||
// throw err;
|
||||
// }
|
||||
|
||||
// 记录和显示错误
|
||||
function errorLog(err) {
|
||||
// 添加到日志
|
||||
store.dispatch("admin/log/push", {
|
||||
message: "数据请求异常",
|
||||
type: "error",
|
||||
meta: {
|
||||
error: err,
|
||||
},
|
||||
});
|
||||
// 打印到控制台
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
util.log.error(">>>>>> Error >>>>>>");
|
||||
}
|
||||
// 显示提示,可配置使用 iView 的 $Message 还是 $Notice 组件来显示
|
||||
if (Setting.errorModalType === "Message") {
|
||||
Message.error({
|
||||
content: err.message,
|
||||
duration: Setting.modalDuration,
|
||||
});
|
||||
} else if (Setting.errorModalType === "Notice") {
|
||||
Notice.error({
|
||||
title: "提示",
|
||||
desc: err.message,
|
||||
duration: Setting.modalDuration,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 创建一个 axios 实例
|
||||
const service = axios.create({
|
||||
baseURL: Setting.apiBaseURL,
|
||||
timeout: 100000, // 请求超时时间
|
||||
});
|
||||
|
||||
axios.defaults.withCredentials = true; // 携带cookie
|
||||
|
||||
// 网络加载
|
||||
// function startLoading () {
|
||||
// LoadingBar.start();
|
||||
// }
|
||||
//
|
||||
// function endLoading () {
|
||||
// LoadingBar.finish();
|
||||
// }
|
||||
|
||||
// 那么 showFullScreenLoading() tryHideFullScreenLoading() 要干的事儿就是将同一时刻的请求合并。
|
||||
// 声明一个变量 needLoadingRequestCount,每次调用showFullScreenLoading方法 needLoadingRequestCount + 1。
|
||||
// 调用tryHideFullScreenLoading()方法,needLoadingRequestCount - 1。needLoadingRequestCount为 0 时,结束 loading。
|
||||
let needLoadingRequestCount = 0;
|
||||
export function showFullScreenLoading() {
|
||||
if (needLoadingRequestCount === 0) {
|
||||
// startLoading()
|
||||
}
|
||||
needLoadingRequestCount++;
|
||||
}
|
||||
export function tryHideFullScreenLoading() {
|
||||
if (needLoadingRequestCount <= 0) return;
|
||||
needLoadingRequestCount--;
|
||||
if (needLoadingRequestCount === 0) {
|
||||
// endLoading()
|
||||
}
|
||||
}
|
||||
|
||||
// 请求拦截器
|
||||
service.interceptors.request.use(
|
||||
async (config) => {
|
||||
if (config.kefu) {
|
||||
let baseUrl = Setting.apiBaseURL.replace(/adminapi/, "kefuapi");
|
||||
config.baseURL = baseUrl;
|
||||
} else {
|
||||
config.baseURL = Setting.apiBaseURL;
|
||||
}
|
||||
config.headers["X-Source"] = "370474988fa2275c";
|
||||
const token = Vue.prototype.__getToken() || util.cookies.get("token");
|
||||
|
||||
// const token = util.cookies.get("token");
|
||||
const kefuToken = util.cookies.kefuGet("token");
|
||||
if (token || kefuToken) {
|
||||
config.headers["Authori-zation"] = config.kefu
|
||||
? "Bearer " + kefuToken
|
||||
: "Bearer " + token;
|
||||
}
|
||||
// 开启loading
|
||||
showFullScreenLoading();
|
||||
return config;
|
||||
},
|
||||
(error) => {
|
||||
// 发送失败
|
||||
Promise.reject(error);
|
||||
}
|
||||
);
|
||||
// 响应拦截器
|
||||
service.interceptors.response.use(
|
||||
(response) => {
|
||||
// 获取服务器类型
|
||||
if (!sessionStorage.getItem("SERVER_TYPE")) {
|
||||
sessionStorage.setItem("SERVER_TYPE", response.headers["server"]);
|
||||
}
|
||||
// 关闭loading
|
||||
tryHideFullScreenLoading();
|
||||
const code = response.data.status;
|
||||
switch (code) {
|
||||
case 200:
|
||||
// [ 示例 ] code === 0 代表没有错误
|
||||
return response.data;
|
||||
case 400:
|
||||
case 400011:
|
||||
case 400012:
|
||||
return Promise.reject(response.data || { msg: "未知错误" });
|
||||
// [ 示例 ] 其它和后台约定的 code
|
||||
// errorCreate(response.data.msg);
|
||||
// break;
|
||||
case 410000:
|
||||
case 410001:
|
||||
case 410002:
|
||||
let route = this.__isSupplierPath()
|
||||
? Setting.routePreSupplier
|
||||
: Setting.roterPre;
|
||||
window.router.replace(`${route}/login`);
|
||||
if (this.__isSupplierPath()) {
|
||||
util.cookies.remove("supplier_token");
|
||||
util.cookies.remove("supplier_uuid");
|
||||
// 删除localStorage
|
||||
store.dispatch("admin/db/databaseClear", {
|
||||
user: true,
|
||||
isSupplier: true,
|
||||
});
|
||||
} else {
|
||||
localStorage.clear();
|
||||
sessionStorage.clear();
|
||||
util.cookies.remove("token");
|
||||
util.cookies.remove("expires_time");
|
||||
util.cookies.remove("uuid");
|
||||
// 删除localStorage
|
||||
store.dispatch("admin/db/databaseClear", {
|
||||
user: true,
|
||||
});
|
||||
// 清空 vuex 用户信息
|
||||
store.dispatch("admin/user/set", {}, { root: true });
|
||||
}
|
||||
break;
|
||||
case 410003:
|
||||
window.router.replace("/kefu");
|
||||
break;
|
||||
default:
|
||||
// 不是正确的 code
|
||||
// errorCreate(`${dataAxios.msg}: ${response.config.url}`);
|
||||
break;
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
if (error && error.response) {
|
||||
switch (error.response.status) {
|
||||
case 400:
|
||||
error.message = "请求错误";
|
||||
break;
|
||||
case 401:
|
||||
error.message = "未授权,请登录";
|
||||
break;
|
||||
case 403:
|
||||
error.message = "拒绝访问";
|
||||
break;
|
||||
case 404:
|
||||
error.message = `请求地址出错: ${error.response.config.url}`;
|
||||
break;
|
||||
case 408:
|
||||
error.message = "请求超时";
|
||||
break;
|
||||
case 500:
|
||||
error.message = "服务器内部错误";
|
||||
break;
|
||||
case 501:
|
||||
error.message = "服务未实现";
|
||||
break;
|
||||
case 502:
|
||||
error.message = "网关错误";
|
||||
break;
|
||||
case 503:
|
||||
error.message = "服务不可用";
|
||||
break;
|
||||
case 504:
|
||||
error.message = "网关超时";
|
||||
break;
|
||||
case 505:
|
||||
error.message = "HTTP版本不受支持";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
errorLog(error);
|
||||
// return Promise.reject(error);
|
||||
}
|
||||
);
|
||||
|
||||
export default service;
|
||||