-
我的积分余额: 200分
+
+ 我的积分余额: {{ integral }}分
+
{{ name }}
@@ -33,7 +35,7 @@ export default {
return {};
},
computed: {
- ...mapGetters(["avatar", "name"]),
+ ...mapGetters(["avatar", "name", "integral", "roles"]),
},
methods: {
async logout() {
@@ -44,7 +46,8 @@ export default {
})
.then(() => {
this.$store.dispatch("LogOut").then(() => {
- location.href = "/index";
+ // location.href = "/index";
+ this.$router.replace("/login");
});
})
.catch(() => {});
diff --git a/src/layout/index.vue b/src/layout/index.vue
index ef598fc..b9fc486 100644
--- a/src/layout/index.vue
+++ b/src/layout/index.vue
@@ -107,7 +107,8 @@ export default {
.left-sidebar {
height: 100%;
background: url("~@/assets/images/sidebar.png");
- background-size: cover;
+ background-size: 100% 100%;
+ padding: 20px;
}
.right-page {
background: #f5f5f5;
diff --git a/src/store/getters.js b/src/store/getters.js
index 8adb1b6..960e9fc 100644
--- a/src/store/getters.js
+++ b/src/store/getters.js
@@ -1,19 +1,21 @@
const getters = {
- sidebar: state => state.app.sidebar,
- size: state => state.app.size,
- device: state => state.app.device,
- dict: state => state.dict.dict,
- visitedViews: state => state.tagsView.visitedViews,
- cachedViews: state => state.tagsView.cachedViews,
- token: state => state.user.token,
- avatar: state => state.user.avatar,
- name: state => state.user.name,
- introduction: state => state.user.introduction,
- roles: state => state.user.roles,
- permissions: state => state.user.permissions,
- permission_routes: state => state.permission.routes,
- topbarRouters:state => state.permission.topbarRouters,
- defaultRoutes:state => state.permission.defaultRoutes,
- sidebarRouters:state => state.permission.sidebarRouters,
-}
-export default getters
+ sidebar: (state) => state.app.sidebar,
+ size: (state) => state.app.size,
+ device: (state) => state.app.device,
+ dict: (state) => state.dict.dict,
+ visitedViews: (state) => state.tagsView.visitedViews,
+ cachedViews: (state) => state.tagsView.cachedViews,
+ token: (state) => state.user.token,
+ avatar: (state) => state.user.avatar,
+ name: (state) => state.user.name,
+ userId: (state) => state.user.userId,
+ introduction: (state) => state.user.introduction,
+ roles: (state) => state.user.roles,
+ permissions: (state) => state.user.permissions,
+ permission_routes: (state) => state.permission.routes,
+ topbarRouters: (state) => state.permission.topbarRouters,
+ defaultRoutes: (state) => state.permission.defaultRoutes,
+ sidebarRouters: (state) => state.permission.sidebarRouters,
+ integral: (state) => state.permission.integral,
+};
+export default getters;
diff --git a/src/store/modules/permission.js b/src/store/modules/permission.js
index 2246238..cae3194 100644
--- a/src/store/modules/permission.js
+++ b/src/store/modules/permission.js
@@ -4,6 +4,7 @@ import { getRouters } from "@/api/menu";
import Layout from "@/layout/index";
import ParentView from "@/components/ParentView";
import InnerLink from "@/layout/components/InnerLink";
+import { findIntegral } from "@/api/volunteer/gxhzs/gxhzsgl/index.js";
const permission = {
state: {
@@ -12,6 +13,7 @@ const permission = {
defaultRoutes: [],
topbarRouters: [],
sidebarRouters: [],
+ integral: 0,
},
mutations: {
SET_ROUTES: (state, routes) => {
@@ -28,13 +30,24 @@ const permission = {
// console.log(routes)
state.sidebarRouters = routes;
},
+ SET_INTEGRAL: (state, integral) => {
+ state.integral = integral;
+ },
},
actions: {
+ FindIntegralData({ commit }) {
+ getFindIntegral().then((integral) => {
+ commit("SET_INTEGRAL", integral);
+ });
+ },
// 生成路由
GenerateRoutes({ commit }) {
return new Promise((resolve) => {
// 向后端请求路由数据
getRouters().then((res) => {
+ getFindIntegral().then((integral) => {
+ commit("SET_INTEGRAL", integral);
+ });
const sdata = JSON.parse(JSON.stringify(res.data));
const rdata = JSON.parse(JSON.stringify(res.data));
const sidebarRoutes = filterAsyncRouter(sdata);
@@ -81,6 +94,19 @@ function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) {
});
}
+//获取用户积分
+function getFindIntegral() {
+ return new Promise((resolve, reject) => {
+ findIntegral()
+ .then((res) => {
+ resolve(res.data);
+ })
+ .catch((error) => {
+ reject(error);
+ });
+ });
+}
+
function filterChildren(childrenMap, lastRouter = false) {
var children = [];
childrenMap.forEach((el, index) => {
diff --git a/src/store/modules/user.js b/src/store/modules/user.js
index eda05fc..6d9517d 100644
--- a/src/store/modules/user.js
+++ b/src/store/modules/user.js
@@ -5,6 +5,7 @@ const user = {
state: {
token: getToken(),
name: "",
+ userId: "",
avatar: "",
roles: [],
permissions: [],
@@ -17,6 +18,9 @@ const user = {
SET_NAME: (state, name) => {
state.name = name;
},
+ SET_USER_ID: (state, userId) => {
+ state.userId = userId;
+ },
SET_AVATAR: (state, avatar) => {
state.avatar = avatar;
},
@@ -66,6 +70,7 @@ const user = {
commit("SET_ROLES", ["ROLE_DEFAULT"]);
}
commit("SET_NAME", user.nickName);
+ commit("SET_USER_ID", user.userId);
commit("SET_AVATAR", avatar);
resolve(res);
})
diff --git a/src/utils/request.js b/src/utils/request.js
index ffb0d21..21b8745 100644
--- a/src/utils/request.js
+++ b/src/utils/request.js
@@ -1,114 +1,149 @@
-import axios from 'axios'
-import { Notification, MessageBox, Message, Loading } from 'element-ui'
-import store from '@/store'
-import { getToken } from '@/utils/auth'
-import errorCode from '@/utils/errorCode'
+import axios from "axios";
+import { Notification, MessageBox, Message, Loading } from "element-ui";
+import store from "@/store";
+import { getToken } from "@/utils/auth";
+import errorCode from "@/utils/errorCode";
import { tansParams, blobValidate } from "@/utils/ruoyi";
-import cache from '@/plugins/cache'
-import { saveAs } from 'file-saver'
+import cache from "@/plugins/cache";
+import { saveAs } from "file-saver";
let downloadLoadingInstance;
// 是否显示重新登录
export let isRelogin = { show: false };
-axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
+axios.defaults.headers["Content-Type"] = "application/json;charset=utf-8";
// 创建axios实例
const service = axios.create({
// axios中请求配置有baseURL选项,表示请求URL公共部分
baseURL: process.env.VUE_APP_BASE_API,
// 超时
- timeout: 10000
-})
+ timeout: 10000,
+});
// request拦截器
-service.interceptors.request.use(config => {
- // 是否需要设置 token
- const isToken = (config.headers || {}).isToken === false
- // 是否需要防止数据重复提交
- const isRepeatSubmit = (config.headers || {}).repeatSubmit === false
- if (getToken() && !isToken) {
- config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
- }
- // get请求映射params参数
- if (config.method === 'get' && config.params) {
- let url = config.url + '?' + tansParams(config.params);
- url = url.slice(0, -1);
- config.params = {};
- config.url = url;
- }
- if (!isRepeatSubmit && (config.method === 'post' || config.method === 'put')) {
- const requestObj = {
- url: config.url,
- data: typeof config.data === 'object' ? JSON.stringify(config.data) : config.data,
- time: new Date().getTime()
+service.interceptors.request.use(
+ (config) => {
+ // 是否需要设置 token
+ const isToken = (config.headers || {}).isToken === false;
+ // 是否需要防止数据重复提交
+ const isRepeatSubmit = (config.headers || {}).repeatSubmit === false;
+ if (getToken() && !isToken) {
+ config.headers["Authorization"] = "Bearer " + getToken(); // 让每个请求携带自定义token 请根据实际情况自行修改
}
- const requestSize = Object.keys(JSON.stringify(requestObj)).length; // 请求数据大小
- const limitSize = 5 * 1024 * 1024; // 限制存放数据5M
- if (requestSize >= limitSize) {
- console.warn(`[${config.url}]: ` + '请求数据大小超出允许的5M限制,无法进行防重复提交验证。')
- return config;
+ // get请求映射params参数
+ if (config.method === "get" && config.params) {
+ let url = config.url + "?" + tansParams(config.params);
+ url = url.slice(0, -1);
+ config.params = {};
+ config.url = url;
}
- const sessionObj = cache.session.getJSON('sessionObj')
- if (sessionObj === undefined || sessionObj === null || sessionObj === '') {
- cache.session.setJSON('sessionObj', requestObj)
- } else {
- const s_url = sessionObj.url; // 请求地址
- const s_data = sessionObj.data; // 请求数据
- const s_time = sessionObj.time; // 请求时间
- const interval = 1000; // 间隔时间(ms),小于此时间视为重复提交
- if (s_data === requestObj.data && requestObj.time - s_time < interval && s_url === requestObj.url) {
- const message = '数据正在处理,请勿重复提交';
- console.warn(`[${s_url}]: ` + message)
- return Promise.reject(new Error(message))
+ if (
+ !isRepeatSubmit &&
+ (config.method === "post" || config.method === "put")
+ ) {
+ const requestObj = {
+ url: config.url,
+ data:
+ typeof config.data === "object"
+ ? JSON.stringify(config.data)
+ : config.data,
+ time: new Date().getTime(),
+ };
+ const requestSize = Object.keys(JSON.stringify(requestObj)).length; // 请求数据大小
+ const limitSize = 5 * 1024 * 1024; // 限制存放数据5M
+ if (requestSize >= limitSize) {
+ console.warn(
+ `[${config.url}]: ` +
+ "请求数据大小超出允许的5M限制,无法进行防重复提交验证。"
+ );
+ return config;
+ }
+ const sessionObj = cache.session.getJSON("sessionObj");
+ if (
+ sessionObj === undefined ||
+ sessionObj === null ||
+ sessionObj === ""
+ ) {
+ cache.session.setJSON("sessionObj", requestObj);
} else {
- cache.session.setJSON('sessionObj', requestObj)
+ const s_url = sessionObj.url; // 请求地址
+ const s_data = sessionObj.data; // 请求数据
+ const s_time = sessionObj.time; // 请求时间
+ const interval = 1000; // 间隔时间(ms),小于此时间视为重复提交
+ if (
+ s_data === requestObj.data &&
+ requestObj.time - s_time < interval &&
+ s_url === requestObj.url
+ ) {
+ const message = "数据正在处理,请勿重复提交";
+ console.warn(`[${s_url}]: ` + message);
+ return Promise.reject(new Error(message));
+ } else {
+ cache.session.setJSON("sessionObj", requestObj);
+ }
}
}
+ return config;
+ },
+ (error) => {
+ console.log(error);
+ Promise.reject(error);
}
- return config
-}, error => {
- console.log(error)
- Promise.reject(error)
-})
+);
// 响应拦截器
-service.interceptors.response.use(res => {
+service.interceptors.response.use(
+ (res) => {
// 未设置状态码则默认成功状态
const code = res.data.code || 200;
// 获取错误信息
- const msg = errorCode[code] || res.data.msg || errorCode['default']
+ const msg = errorCode[code] || res.data.msg || errorCode["default"];
// 二进制数据则直接返回
- if (res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer') {
- return res.data
+ if (
+ res.request.responseType === "blob" ||
+ res.request.responseType === "arraybuffer"
+ ) {
+ return res.data;
}
if (code === 401) {
if (!isRelogin.show) {
isRelogin.show = true;
- MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { confirmButtonText: '重新登录', cancelButtonText: '取消', type: 'warning' }).then(() => {
- isRelogin.show = false;
- store.dispatch('LogOut').then(() => {
- location.href = '/index';
+ MessageBox.confirm(
+ "登录状态已过期,您可以继续留在该页面,或者重新登录",
+ "系统提示",
+ {
+ confirmButtonText: "重新登录",
+ cancelButtonText: "取消",
+ type: "warning",
+ }
+ )
+ .then(() => {
+ isRelogin.show = false;
+ store.dispatch("LogOut").then(() => {
+ // location.href = '/index';
+ router.replace("/login");
+ });
})
- }).catch(() => {
- isRelogin.show = false;
- });
- }
- return Promise.reject('无效的会话,或者会话已过期,请重新登录。')
+ .catch(() => {
+ isRelogin.show = false;
+ });
+ }
+ return Promise.reject("无效的会话,或者会话已过期,请重新登录。");
} else if (code === 500) {
- Message({ message: msg, type: 'error' })
- return Promise.reject(new Error(msg))
+ Message({ message: msg, type: "error" });
+ return Promise.reject(new Error(msg));
} else if (code === 601) {
- Message({ message: msg, type: 'warning' })
- return Promise.reject('error')
+ Message({ message: msg, type: "warning" });
+ return Promise.reject("error");
} else if (code !== 200) {
- Notification.error({ title: msg })
- return Promise.reject('error')
+ Notification.error({ title: msg });
+ return Promise.reject("error");
} else {
- return res.data
+ return res.data;
}
},
- error => {
- console.log('err' + error)
+ (error) => {
+ console.log("err" + error);
let { message } = error;
if (message == "Network Error") {
message = "后端接口连接异常";
@@ -117,36 +152,48 @@ service.interceptors.response.use(res => {
} else if (message.includes("Request failed with status code")) {
message = "系统接口" + message.substr(message.length - 3) + "异常";
}
- Message({ message: message, type: 'error', duration: 5 * 1000 })
- return Promise.reject(error)
+ Message({ message: message, type: "error", duration: 5 * 1000 });
+ return Promise.reject(error);
}
-)
+);
// 通用下载方法
export function download(url, params, filename, config) {
- downloadLoadingInstance = Loading.service({ text: "正在下载数据,请稍候", spinner: "el-icon-loading", background: "rgba(0, 0, 0, 0.7)", })
- return service.post(url, params, {
- transformRequest: [(params) => { return tansParams(params) }],
- headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
- responseType: 'blob',
- ...config
- }).then(async (data) => {
- const isBlob = blobValidate(data);
- if (isBlob) {
- const blob = new Blob([data])
- saveAs(blob, filename)
- } else {
- const resText = await data.text();
- const rspObj = JSON.parse(resText);
- const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode['default']
- Message.error(errMsg);
- }
- downloadLoadingInstance.close();
- }).catch((r) => {
- console.error(r)
- Message.error('下载文件出现错误,请联系管理员!')
- downloadLoadingInstance.close();
- })
+ downloadLoadingInstance = Loading.service({
+ text: "正在下载数据,请稍候",
+ spinner: "el-icon-loading",
+ background: "rgba(0, 0, 0, 0.7)",
+ });
+ return service
+ .post(url, params, {
+ transformRequest: [
+ (params) => {
+ return tansParams(params);
+ },
+ ],
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
+ responseType: "blob",
+ ...config,
+ })
+ .then(async (data) => {
+ const isBlob = blobValidate(data);
+ if (isBlob) {
+ const blob = new Blob([data]);
+ saveAs(blob, filename);
+ } else {
+ const resText = await data.text();
+ const rspObj = JSON.parse(resText);
+ const errMsg =
+ errorCode[rspObj.code] || rspObj.msg || errorCode["default"];
+ Message.error(errMsg);
+ }
+ downloadLoadingInstance.close();
+ })
+ .catch((r) => {
+ console.error(r);
+ Message.error("下载文件出现错误,请联系管理员!");
+ downloadLoadingInstance.close();
+ });
}
-export default service
+export default service;
diff --git a/src/views/index.vue b/src/views/index.vue
index 7cbe3e3..0f66a29 100644
--- a/src/views/index.vue
+++ b/src/views/index.vue
@@ -1,1036 +1,9 @@
-
+
-
+
diff --git a/src/views/login.vue b/src/views/login.vue
index e124a76..ef8445d 100644
--- a/src/views/login.vue
+++ b/src/views/login.vue
@@ -6,7 +6,7 @@
:rules="loginRules"
class="login-form"
>
-
志愿者管理系统
+
苏州园区志愿服务活动区块链平台
- 地址管理
+
+
+
+
+
+
+
+
+
+
+
+
+ 提 交
+
+
+
-
+
diff --git a/src/views/volunteer/gxhzs/gxhzsdh/index.vue b/src/views/volunteer/gxhzs/gxhzsdh/index.vue
index 1c6b224..e779c70 100644
--- a/src/views/volunteer/gxhzs/gxhzsdh/index.vue
+++ b/src/views/volunteer/gxhzs/gxhzsdh/index.vue
@@ -4,13 +4,13 @@
-