diff --git a/src/utils/auth.js b/src/utils/auth.js index 08a43d6..12d08bb 100644 --- a/src/utils/auth.js +++ b/src/utils/auth.js @@ -3,13 +3,16 @@ import Cookies from 'js-cookie' const TokenKey = 'Admin-Token' export function getToken() { - return Cookies.get(TokenKey) + // return Cookies.get(TokenKey) + return localStorage.getItem(TokenKey) } export function setToken(token) { - return Cookies.set(TokenKey, token) + // return Cookies.set(TokenKey, token) + return localStorage.setItem(TokenKey,token) } export function removeToken() { - return Cookies.remove(TokenKey) + // return Cookies.remove(TokenKey) + return localStorage.removeItem(TokenKey) } diff --git a/src/utils/index.js b/src/utils/index.js index 0a37274..e4da15e 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -367,7 +367,7 @@ export function errorCodeMap(code) { 200102: '账号验证不通过', 200103: '账号已被禁用', 200010: '权限资源不存在', - 401: '未经授权', + 401: '未在APP进行实名认证,暂无访问权限', 403: '无访问权限', 404: '接口不存在', 400001: '请求参数错误', diff --git a/src/utils/request.js b/src/utils/request.js index d59112a..21df101 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -1,15 +1,15 @@ -import axios from 'axios' -import { MessageBox, Message } from 'element-ui' -import store from '@/store' -import { getToken } from '@/utils/auth' -import { errorCodeMap } from '@/utils/index' +import axios from "axios"; +import { MessageBox, Message } from "element-ui"; +import store from "@/store"; +import { getToken } from "@/utils/auth"; +import { errorCodeMap } from "@/utils/index"; // 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( @@ -20,23 +20,23 @@ service.interceptors.request.use( // let each request carry token // ['X-Token'] is a custom headers key // please modify it according to the actual situation - config.headers['Authorization'] = `bearer ${getToken()}` + config.headers["Authorization"] = `bearer ${getToken()}`; } - return config + return config; }, error => { // do something with request error - console.log(error) // for debug - return Promise.reject(error) + console.log(error); // for debug + return Promise.reject(error); } -) +); // response interceptor service.interceptors.response.use( /** * If you want to get http information such as headers or status * Please return response => response - */ + */ /** * Determine the request status by custom code @@ -44,22 +44,17 @@ service.interceptors.response.use( * You can also judge the status by HTTP Status Code */ response => { - const res = response.data + const res = response.data; // if the custom code is not 20000, it is judged as an error. if (res.c !== 200) { if (res.c === 500) { + // console.log(123); Message({ message: errorCodeMap(res.c), - type: 'error', + type: "error", duration: 5 * 1000 - }) - } else { - Message({ - message: res.m || 'Error', - type: 'error', - duration: 5 * 1000 - }) + }); } // 50008: Illegal token; 50012: Other clients logged in; 50014: Token expired; @@ -74,21 +69,22 @@ service.interceptors.response.use( location.reload() }) }) - } - return Promise.reject(new Error(res.data.m || 'Error')) + } + // return Promise.reject(new Error(res.data.m || "Error")); + return Promise.reject(new Error(errorCodeMap(res.c)||"Error")) } else { - return res + return res; } }, error => { - console.log('err' + error) // for debug + console.log("err" + error); // for debug Message({ - message: '服务器连接失败,请稍后重试', - type: 'error', + message: "服务器连接失败,请稍后重试", + type: "error", duration: 5 * 1000 - }) - return Promise.reject(error) + }); + return Promise.reject(error); } -) +); -export default service +export default service; diff --git a/src/views/dashboard/admin/components/PanelGroup.vue b/src/views/dashboard/admin/components/PanelGroup.vue index b70f32a..15b384d 100644 --- a/src/views/dashboard/admin/components/PanelGroup.vue +++ b/src/views/dashboard/admin/components/PanelGroup.vue @@ -33,6 +33,13 @@ 数据统计统计图表更新时间:{{ new Date() | parseTime("{y}-{m}-{d} {h}:00:00") }} { - this.statisticalData = { - all: 318, - 平均办结时间: 61722, - 平均受理时间: 22349, - 未受理量: 0, - 未受理率: 0, - 按时受理量: 318, - 按时受理率: 1.0, - 超时受理量: 0, - 超时受理率: 0.0, - 按时办结量: 307, - 按时办结率: 1.0, - 超时办结量: 0, - 超时办结率: 0.0, - 未办结量: 11, - 未办结率: 0.0346, - 非常满意量: 274, - 非常满意率: 0.8925, - 满意量: 33, - 满意率: 0.1075, - 不满意量: 0, - 不满意率: 0.0 - }; - // this.statisticalData = res.d; + // this.statisticalData = { + // all: 318, + // 平均办结时间: 61722, + // 平均受理时间: 22349, + // 未受理量: 0, + // 未受理率: 0, + // 按时受理量: 318, + // 按时受理率: 1.0, + // 超时受理量: 0, + // 超时受理率: 0.0, + // 按时办结量: 307, + // 按时办结率: 1.0, + // 超时办结量: 0, + // 超时办结率: 0.0, + // 未办结量: 11, + // 未办结率: 0.0346, + // 非常满意量: 274, + // 非常满意率: 0.8925, + // 满意量: 33, + // 满意率: 0.1075, + // 不满意量: 0, + // 不满意率: 0.0 + // }; + this.statisticalData = res.d; }); }, formatUnit(key, value) { @@ -147,6 +154,10 @@ export default { : Math.floor(((timeStamp % 86400) % 3600) % 60) }`; return timeStr; + }, + toTj(){ + window.open('http://new.rtmedia.myntv.cn/static/largeScreen/leaderForTv.html') + console.log(window); } } }; diff --git a/src/views/login/index.vue b/src/views/login/index.vue index 5fd2b49..83a3228 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -126,10 +126,10 @@ export default { // password: '111111' // }, loginForm: { - // username: "", //18882564006 - // captcha: "", - username: "18882564006", //18882564006 - captcha: "111111", + username: "", //18882564006 + captcha: "", + //username: "18882564006", //18882564006 + //captcha: "111111", appVersion: "1.0.0", system: "IOS", device: navigator.userAgent, @@ -224,19 +224,21 @@ export default { "basic YW5kcm9pZC1jbGllbnQ6YW5kcm9pZC1zZWNyZXQtMjAyMA==" } }).then(res => { - console.log(res); + // console.log(res); if (res.data.c === 200) { this.$store.dispatch("user/setToken", res.data.d.access_token); this.$router.push({ path: this.redirect || "/", query: this.otherQuery }); - this.$notify({ - title: "成功", - message: "登录成功", - type: "success", - duration: 2000 - }); + // if (res.data.c === 200) { + // this.$notify({ + // title: "成功", + // message: "登录成功", + // type: "success", + // duration: 2000 + // }); + // } } else { this.$notify.error(res.data.m); } diff --git a/src/views/residentInformation/list.vue b/src/views/residentInformation/list.vue index f750126..b2076b6 100644 --- a/src/views/residentInformation/list.vue +++ b/src/views/residentInformation/list.vue @@ -253,6 +253,7 @@ value="RESIDENT_SET_ADMIN" > +