diff --git a/.env.production b/.env.production index 6592f042f..17eebff32 100644 --- a/.env.production +++ b/.env.production @@ -1,4 +1,4 @@ NODE_ENV=production -VUE_APP_API_SERVER = https://epmet-cloud.elinkservice.cn/api +VUE_APP_API_SERVER = https://epdc-shibei.elinkservice.cn/api VUE_APP_NODE_ENV=prod VUE_APP_PUBLIC_PATH=epmet-oper \ No newline at end of file diff --git a/.env.production.uat b/.env.production.uat index 14457f27c..0e4ab2af8 100644 --- a/.env.production.uat +++ b/.env.production.uat @@ -1,4 +1,4 @@ NODE_ENV=production -VUE_APP_API_SERVER = https://epmet-test.elinkservice.cn/api +VUE_APP_API_SERVER = http://120.27.18.76/api VUE_APP_NODE_ENV=prod:uat VUE_APP_PUBLIC_PATH=epmet-oper \ No newline at end of file diff --git a/public/index.html b/public/index.html index 9e19414c1..a1ac2eb12 100644 --- a/public/index.html +++ b/public/index.html @@ -57,13 +57,13 @@ <% if (process.env.VUE_APP_NODE_ENV==='prod:uat' ) { %> <% } %> <% if (process.env.VUE_APP_NODE_ENV==='prod' ) { %> <% } %> diff --git a/src/App.vue b/src/App.vue index 6226e0aa3..dbd953b13 100644 --- a/src/App.vue +++ b/src/App.vue @@ -19,7 +19,7 @@ export default { methods: { i18nHandle (val, oldVal) { - Cookies.set('language', val) + localStorage.setItem('language', val) document.querySelector('html').setAttribute('lang', val) document.title = messages[val].brand.lg // 非登录页面,切换语言刷新页面 diff --git a/src/assets/scss/common.scss b/src/assets/scss/common.scss index e8d4cfc52..7acb699ea 100644 --- a/src/assets/scss/common.scss +++ b/src/assets/scss/common.scss @@ -9,7 +9,7 @@ body { font-size: $--font-size-base; line-height: $base--line-height; color: $--color-text-primary; - background-color: #fff; + // background-color: #fff; } a { color: mix(#fff, $--color-primary, 20%); diff --git a/src/components/ren-process-detail/src/ren-process-detail.vue b/src/components/ren-process-detail/src/ren-process-detail.vue index 5eef7dfd2..0d0bfe91f 100644 --- a/src/components/ren-process-detail/src/ren-process-detail.vue +++ b/src/components/ren-process-detail/src/ren-process-detail.vue @@ -69,7 +69,7 @@ export default { // 获取流程(xml/image)url地址 getResourceURL () { var params = qs.stringify({ - 'token': Cookies.get('token'), + 'token': localStorage.getItem('token'), 'processInstanceId': this.dataForm.processInstanceId }) return `${window.SITE_CONFIG['apiURL']}/activiti/his/getInstImage?${params}` diff --git a/src/i18n/index.js b/src/i18n/index.js index 27bb75334..2491efa44 100644 --- a/src/i18n/index.js +++ b/src/i18n/index.js @@ -29,6 +29,6 @@ export const messages = { } export default new VueI18n({ - locale: Cookies.get('language') || 'zh-CN', + locale: localStorage.getItem('language') || 'zh-CN', messages }) diff --git a/src/js/ajax.js b/src/js/ajax.js index e8f95dc07..3c19cb31f 100644 --- a/src/js/ajax.js +++ b/src/js/ajax.js @@ -1,42 +1,40 @@ /* eslint-disable */ -import axios from 'axios' -import Cookies from 'js-cookie' -import router from '@/router' -import qs from 'qs' -import { clearLoginInfo } from '@/utils' -import isPlainObject from 'lodash/isPlainObject' - -import Vue from 'vue' - -import { Loading } from 'element-ui' //引入Loading服务 +import axios from "axios"; +import Cookies from "js-cookie"; +import router from "@/router"; +import qs from "qs"; +import { clearLoginInfo } from "@/utils"; +import isPlainObject from "lodash/isPlainObject"; +import Vue from "vue"; +import { Loading } from "element-ui"; //引入Loading服务 // 默认超时时间60s -axios.defaults.timeout = 60000 +axios.defaults.timeout = 60000; -let timer -let loading +let timer; +let loading; //请求时间超过300ms 提示加载 -function startLoading () { - if (timer) return +function startLoading() { + if (timer) return; timer = setTimeout(() => { loading = Loading.service({ lock: true, //是否锁定 - text: '正在加载……', //加载中需要显示的文字 - background: 'rgba(0,0,0,.7)', //背景颜色 - }) - }, 300) + text: "正在加载……", //加载中需要显示的文字 + background: "rgba(0,0,0,.7)", //背景颜色 + }); + }, 300); } //结束加载动画 -function endLoading () { +function endLoading() { if (timer) { - clearTimeout(timer) + clearTimeout(timer); } if (loading) { - loading.close() + loading.close(); } } @@ -45,71 +43,65 @@ function endLoading () { */ axios.interceptors.request.use( (config) => { - config.headers['Accept-Language'] = Cookies.get('language') || 'zh-CN' - config.headers['token'] = Cookies.get('token') || '' - config.headers['Authorization'] = Cookies.get('token') || '' + config.headers["Accept-Language"] = + localStorage.getItem("language") || "zh-CN"; + config.headers["token"] = localStorage.getItem("token") || ""; + config.headers["Authorization"] = localStorage.getItem("token") || ""; // 默认参数 - var defaults = {} + var defaults = {}; // 防止缓存,GET请求默认带_t参数 - if (config.method === 'get') { + if (config.method === "get") { config.params = { ...config.params, ...{ _t: new Date().getTime() }, - } + }; } if (isPlainObject(config.params)) { config.params = { ...defaults, ...config.params, - } + }; } if (isPlainObject(config.data)) { config.data = { ...defaults, ...config.data, - } + }; if ( /^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) => { - return Promise.reject(error) + return Promise.reject(error); } -) +); /** * 响应拦截 */ axios.interceptors.response.use( (response) => { - const code = [10007, 401, 10001, 10005] - if (code.includes(response.data.code) ) { + const code = [10007, 401, 10001, 10005]; + if (code.includes(response.data.code)) { // debugger; - clearLoginInfo() - // localStorage.setItem('userType', 'work') - // let userType = localStorage.getItem("userType"); - // if (userType === 'work'){ - // router.replace({ name: 'loginWork' }) - // }else { - // router.replace({ name: 'login' }) - // } - router.replace({ name: 'login' }) + clearLoginInfo(); + router.replace({ name: "login" }); - return Promise.reject(response.data.msg) + return Promise.reject(response.data.msg); } - return response + return response; }, (error) => { - console.error(error) - return Promise.reject(error) + console.error(error); + return Promise.reject(error); } -) +); const post = (url, params, headers) => { return new Promise((reslove, reject) => { @@ -119,14 +111,14 @@ const post = (url, params, headers) => { resolve(res); }) .catch((err) => { - reject(err) - }) - }) -} + reject(err); + }); + }); +}; -export const requestPost = async (url = '', params = {}, headers = {}) => { - const ret = await post(url, params, headers) - console.log(url, ret) +export const requestPost = async (url = "", params = {}, headers = {}) => { + const ret = await post(url, params, headers); + console.log(url, ret); // if (ret.status === 200) { // var data = res.data // if (data.code == 0) { @@ -141,7 +133,7 @@ export const requestPost = async (url = '', params = {}, headers = {}) => { // } else { // if (typeof cb_err === 'function') cb_err(res) // } -} +}; /* * 1、后台请求成功均返回(业务上的异常也属于请求成功) res.status=200的响应码 @@ -153,140 +145,137 @@ export const requestPost = async (url = '', params = {}, headers = {}) => { */ export default { // 并发请求 - all (gets, cb) { + all(gets, cb) { if (gets && gets.length > 0) { let functions = gets.map((get) => { return axios.get(processUrl(get.url), { params: get.params, - }) - }) + }); + }); axios.all(functions).then( axios.spread((..._results) => { let results = _results.map((_result) => { - return _result.data.data - }) - cb(results) + return _result.data.data; + }); + cb(results); }) - ) + ); } }, - get (url, params, cb_su, cb_err, headers) { + get(url, params, cb_su, cb_err, headers) { var p = { params: params, - } - if (headers && JSON.stringify(headers) != '{}') { + }; + if (headers && JSON.stringify(headers) != "{}") { var h = { headers: headers, - } + }; p = { ...p, ...h, - } + }; } - url = url + '?r=' + new Date().getTime() //时间戳作为随机码,防止IE从缓存获取数据 + url = url + "?r=" + new Date().getTime(); //时间戳作为随机码,防止IE从缓存获取数据 axios .get(processUrl(url), p) .then((res) => { if (res) { if (res.status === 200) { - - var data = res.data + var data = res.data; if (data.code == 0) { //业务成功 - if (typeof cb_su === 'function') { - cb_su(data.data, data.msg ) + if (typeof cb_su === "function") { + cb_su(data.data, data.msg); } } else { //业务失败 - if (typeof cb_err === 'function') cb_err(data.msg , data.data) + if (typeof cb_err === "function") cb_err(data.msg, data.data); } } else { - if (typeof cb_err === 'function') cb_err(res) + if (typeof cb_err === "function") cb_err(res); } } else { - if (typeof cb_err === 'function') cb_err(res) + if (typeof cb_err === "function") cb_err(res); } }) .catch((err) => { - if (typeof (cb_err === 'function')) { - cb_err(err) + if (typeof (cb_err === "function")) { + cb_err(err); } - }) + }); }, - put (url, data, cb_su, cb_err) { + put(url, data, cb_su, cb_err) { axios .put(processUrl(url), data) .then((res) => { if (res) { if (res.status === 200) { - var data = res.data - if (data.sysresultcode === 'success') { + var data = res.data; + if (data.sysresultcode === "success") { //业务成功 - if (typeof cb_su === 'function') { - cb_su(data.data, data.rspMsg) + if (typeof cb_su === "function") { + 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 { - if (typeof cb_err === 'function') cb_err(res) + if (typeof cb_err === "function") cb_err(res); } } else { - if (typeof cb_err === 'function') cb_err(res) + if (typeof cb_err === "function") cb_err(res); } }) .catch((err) => { - if (typeof cb_err === 'function') { - cb_err(err) + if (typeof cb_err === "function") { + cb_err(err); } - }) + }); }, - post (url, data, cb_su, cb_err, headers) { - var h = {} - if (headers && JSON.stringify(headers) != '{}') { + post(url, data, cb_su, cb_err, headers) { + var h = {}; + if (headers && JSON.stringify(headers) != "{}") { h = { headers, - } + }; } //var data = qs.stringify(paramas); axios .post(processUrl(url), data, h) .then((res) => { - if (res) { if (res.status === 200) { - - var data = res.data + var data = res.data; if (data.code == 0) { //业务成功 - if (typeof cb_su === 'function') { - cb_su(data.data, data.msg ) + if (typeof cb_su === "function") { + cb_su(data.data, data.msg); } } else { //业务失败 - if (typeof cb_err === 'function') cb_err(data.msg , data.data) + if (typeof cb_err === "function") cb_err(data.msg, data.data); } } else { - if (typeof cb_err === 'function') cb_err(res) + if (typeof cb_err === "function") cb_err(res); } } else { - if (typeof cb_err === 'function') cb_err(res) + if (typeof cb_err === "function") cb_err(res); } }) .catch((err) => { - if (typeof cb_err === 'function') { - cb_err(err) + if (typeof cb_err === "function") { + cb_err(err); } - }) + }); }, - post2 (url, data, cb_su, cb_err, headers) { - var h = {} - if (headers && JSON.stringify(headers) != '{}') { + post2(url, data, cb_su, cb_err, headers) { + var h = {}; + if (headers && JSON.stringify(headers) != "{}") { h = { headers, - } + }; } //var data = qs.stringify(paramas); axios @@ -294,22 +283,22 @@ export default { .then((res) => { if (res) { if (res.status === 200) { - var data = res.data - cb_su(data, data.msg ) + var data = res.data; + cb_su(data, data.msg); } else { - if (typeof cb_err === 'function') cb_err(data.msg , data) + if (typeof cb_err === "function") cb_err(data.msg, data); } } else { - if (typeof cb_err === 'function') cb_err(data.msg , data) + if (typeof cb_err === "function") cb_err(data.msg, data); } }) .catch((err) => { - if (typeof cb_err === 'function') { - cb_err(err) + if (typeof cb_err === "function") { + cb_err(err); } - }) + }); }, - delete (url, params, cb_su, cb_err) { + delete(url, params, cb_su, cb_err) { axios .delete(processUrl(url), { params: params, @@ -317,219 +306,217 @@ export default { .then((res) => { if (res) { if (res.status === 200) { - var data = res.data - if (data.sysresultcode === 'success') { + var data = res.data; + if (data.sysresultcode === "success") { //业务成功 - if (typeof cb_su === 'function') { - cb_su(data.data, data.rspMsg) + if (typeof cb_su === "function") { + 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 { - if (typeof cb_err === 'function') cb_err(res) + if (typeof cb_err === "function") cb_err(res); } } else { - if (typeof cb_err === 'function') cb_err(res) + if (typeof cb_err === "function") cb_err(res); } }) .catch((err) => { - if (typeof cb_err === 'function') { - cb_err(err) + if (typeof cb_err === "function") { + cb_err(err); } - }) + }); }, //导出文件,包括excel,word等 - exportFile (url, params, cb_su, cb_err, headers) { - var h = {} - if (headers && JSON.stringify(headers) != '{}') { - h = headers + exportFile(url, params, cb_su, cb_err, headers) { + var h = {}; + if (headers && JSON.stringify(headers) != "{}") { + h = headers; } - var errorMsg = '操作失败' - url = url + '?r=' + new Date().getTime() //时间戳作为随机码,防止IE从缓存获取数据 + var errorMsg = "操作失败"; + url = url + "?r=" + new Date().getTime(); //时间戳作为随机码,防止IE从缓存获取数据 axios({ - method: 'get', + method: "get", url: processUrl(url), params: params, headers: h, //{ tenantCode: "GDYXB" }, - responseType: 'blob', + responseType: "blob", }) .then((res) => { if (res) { if (res.status === 200) { - var data = res.data //直接返回blob + var data = res.data; //直接返回blob if (data) { //业务成功 - if (typeof cb_su === 'function') { - cb_su(data, '操作成功') + if (typeof cb_su === "function") { + cb_su(data, "操作成功"); } } else { //业务失败 - if (typeof cb_err === 'function') cb_err(errorMsg) + if (typeof cb_err === "function") cb_err(errorMsg); } } else { - if (typeof cb_err === 'function') cb_err(errorMsg) + if (typeof cb_err === "function") cb_err(errorMsg); } } else { - if (typeof cb_err === 'function') cb_err(errorMsg) + if (typeof cb_err === "function") cb_err(errorMsg); } }) .catch((err) => { - if (typeof (cb_err === 'function')) { - cb_err(errorMsg) + if (typeof (cb_err === "function")) { + cb_err(errorMsg); } - }) + }); }, //导出文件,包括excel,word等 - exportFilePost (url, params, cb_su, cb_err) { + exportFilePost(url, params, cb_su, cb_err) { //var data = qs.stringify(paramas); // axios // .post(processUrl(url), data) axios({ - method: 'post', + method: "post", url: processUrl(url), data: params, - responseType: 'blob', + responseType: "blob", }) .then((res) => { - if (res) { if (res.status === 200) { - var data = res.data //直接返回blob + var data = res.data; //直接返回blob // if (data.code == 0) { - //业务成功 - if (typeof cb_su === 'function') { - cb_su(data) - } - else { + //业务成功 + if (typeof cb_su === "function") { + cb_su(data); + } else { //业务失败 - if (typeof cb_err === 'function') cb_err(errorMsg) - } - // } else { + if (typeof cb_err === "function") cb_err(errorMsg); + } + // } else { // if (typeof cb_err === 'function') cb_err(errorMsg) } } else { - if (typeof cb_err === 'function') cb_err(errorMsg) + if (typeof cb_err === "function") cb_err(errorMsg); } }) .catch((err) => { - if (typeof cb_err === 'function') { - cb_err(err) + if (typeof cb_err === "function") { + cb_err(err); } - }) + }); }, //上传文件 - importFilePut (url, fileFormData, cb_su, cb_err) { - var errorMsg = '操作失败' + importFilePut(url, fileFormData, cb_su, cb_err) { + var errorMsg = "操作失败"; let requestConfig = { headers: { - 'Content-Type': 'multipart/form-data', + "Content-Type": "multipart/form-data", // Authorization: auth.loadTokenType() + ' ' + auth.loadAccessToken(), }, - } + }; Vue.http .put(processUrl(url), fileFormData, requestConfig) .then((res) => { 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) - } else if (data.sysresultcode === 'success') { + if (typeof cb_err === "function") cb_err(data.rspMsg); + } else if (data.sysresultcode === "success") { //业务成功 - if (typeof cb_su === 'function') { - cb_su(data, '操作成功') + if (typeof cb_su === "function") { + cb_su(data, "操作成功"); } } else { - if (typeof cb_err === 'function') cb_err(errorMsg) + if (typeof cb_err === "function") cb_err(errorMsg); } } else { - if (typeof cb_err === 'function') cb_err(errorMsg) + if (typeof cb_err === "function") cb_err(errorMsg); } }) .catch((err) => { - if (typeof (cb_err === 'function')) { - cb_err(errorMsg) + if (typeof (cb_err === "function")) { + cb_err(errorMsg); } - }) + }); }, //上传文件 - importFilePost (url, fileFormData, cb_su, cb_err) { - var errorMsg = '操作失败' + importFilePost(url, fileFormData, cb_su, cb_err) { + var errorMsg = "操作失败"; let requestConfig = { headers: { - 'Content-Type': 'multipart/form-data' + "Content-Type": "multipart/form-data", // Authorization: auth.loadTokenType() + ' ' + auth.loadAccessToken(), - } - } + }, + }; Vue.http .post(processUrl(url), fileFormData, requestConfig) .then((res) => { 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) - } else if (data.sysresultcode === 'success') { + if (typeof cb_err === "function") cb_err(data.rspMsg); + } else if (data.sysresultcode === "success") { //业务成功 - if (typeof cb_su === 'function') { - cb_su(data, '操作成功') + if (typeof cb_su === "function") { + cb_su(data, "操作成功"); } } else { - if (typeof cb_err === 'function') cb_err(errorMsg) + if (typeof cb_err === "function") cb_err(errorMsg); } } else { - if (typeof cb_err === 'function') cb_err(errorMsg) + if (typeof cb_err === "function") cb_err(errorMsg); } }) .catch((err) => { - if (typeof (cb_err === 'function')) { - cb_err(errorMsg) + if (typeof (cb_err === "function")) { + cb_err(errorMsg); } - }) + }); }, //登录获取token/刷新token - tokenPost (url, paramas, cb_su, cb_err) { - var data = qs.stringify(paramas) + tokenPost(url, paramas, cb_su, cb_err) { + var data = qs.stringify(paramas); axios .post(processUrl(url), data) .then((res) => { if (res) { if (res.status === 200) { - var data = res.data + var data = res.data; if (data) { - if (typeof cb_su === 'function') { - cb_su(data) + if (typeof cb_su === "function") { + cb_su(data); } } else { - if (typeof cb_err === 'function') cb_err('登录验证失败') + if (typeof cb_err === "function") cb_err("登录验证失败"); } } else { - if (typeof cb_err === 'function') cb_err(res) + if (typeof cb_err === "function") cb_err(res); } } else { - if (typeof cb_err === 'function') cb_err(res) + if (typeof cb_err === "function") cb_err(res); } }) .catch((err) => { - var rspMsg = '登录失败,请重试!' + var rspMsg = "登录失败,请重试!"; if ( err && err.response && err.response.status === 401 && err.response.data && - err.response.data.error === 'unauthorized' + err.response.data.error === "unauthorized" ) { // 用户名不存在时: 状态码401 // Response Body: @@ -537,92 +524,91 @@ export default { // "error": "unauthorized", // "error_description": null // } - rspMsg = err.response.data.error_description || '用户名不存在' + rspMsg = err.response.data.error_description || "用户名不存在"; } else if ( err && err.response && err.response.status === 400 && err.response.data && - err.response.data.error === 'invalid_grant' + err.response.data.error === "invalid_grant" ) { // 用户名存在,密码错误时:状态码400 // { // "error": "invalid_grant", // "error_description": "Bad credentials" // } - rspMsg = '用户名或密码输入错误' + rspMsg = "用户名或密码输入错误"; } - if (typeof cb_err === 'function') { - cb_err(rspMsg) + if (typeof cb_err === "function") { + cb_err(rspMsg); } - }) + }); }, //通过接口传递的token进行验证登录 lyx 20191210 - async interfacetokenPost (url, paramas, cb_su, cb_err) { - var data = qs.stringify(paramas) + async interfacetokenPost(url, paramas, cb_su, cb_err) { + var data = qs.stringify(paramas); await axios .post(processUrl(url), data) .then((res) => { if (res) { if (res.status === 200) { - var data = res.data + var data = res.data; if (data) { - if (typeof cb_su === 'function') { - cb_su(data) - return true + if (typeof cb_su === "function") { + cb_su(data); + return true; } } else { - if (typeof cb_err === 'function') { - cb_err('接口验证失败') - return false + if (typeof cb_err === "function") { + cb_err("接口验证失败"); + return false; } } } else { - if (typeof cb_err === 'function') { - cb_err(res) - return false + if (typeof cb_err === "function") { + cb_err(res); + return false; } } } else { - if (typeof cb_err === 'function') { - cb_err(res) - return false + if (typeof cb_err === "function") { + cb_err(res); + return false; } } }) .catch((err) => { - var rspMsg = '接口验证失败,请重试!' + var rspMsg = "接口验证失败,请重试!"; if ( err && err.response && err.response.status === 401 && err.response.data && - err.response.data.error === 'unauthorized' + err.response.data.error === "unauthorized" ) { - rspMsg = '用户名不存在' + rspMsg = "用户名不存在"; } else if ( err && err.response && err.response.status === 400 && err.response.data && - err.response.data.error === 'invalid_grant' + err.response.data.error === "invalid_grant" ) { - rspMsg = '用户名或密码输入错误' + rspMsg = "用户名或密码输入错误"; } - if (typeof cb_err === 'function') { - cb_err(rspMsg) - return false + if (typeof cb_err === "function") { + cb_err(rspMsg); + return false; } - }) + }); }, -} +}; // 添加服务器端URL -function processUrl (url) { - - if (url.indexOf('http://') > -1 || url.indexOf('https://') > -1) { - return url +function processUrl(url) { + if (url.indexOf("http://") > -1 || url.indexOf("https://") > -1) { + return url; } - return process.env.VUE_APP_API_SERVER + url + return process.env.VUE_APP_API_SERVER + url; } diff --git a/src/main.js b/src/main.js index 05b7580e0..6d65da32e 100644 --- a/src/main.js +++ b/src/main.js @@ -33,7 +33,9 @@ import getQueryPara from "dai-js/modules/getQueryPara"; // 兼容token传参登录 if (getQueryPara("token")) { console.log('token', getQueryPara("token")); - Cookies.set("token", getQueryPara("token")); + localStorage.setItem("token", getQueryPara("token")); + console.log('token222222', localStorage.getItem('token')); + } window.app = Object.assign( diff --git a/src/mixins/view-module.js b/src/mixins/view-module.js index cfc165b37..f881711c7 100644 --- a/src/mixins/view-module.js +++ b/src/mixins/view-module.js @@ -142,7 +142,7 @@ export default { // 导出 exportHandle () { var params = qs.stringify({ - 'token': Cookies.get('token'), + 'token': localStorage.getItem('token'), ...this.dataForm }) window.location.href = `${window.SITE_CONFIG['apiURL']}${this.mixinViewModuleOptions.exportURL}?${params}` diff --git a/src/router/index.js b/src/router/index.js index 30405144f..809d5ec84 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -161,179 +161,129 @@ router.beforeEach((to, from, next) => { const customerId = localStorage.getItem("customerId"); console.log("customerId:", customerId); - // if(customerId==='1e68188b8f7e9ab15658c164bd5b3676'){ - // // if(customerId==='45687aa479955f9d06204d415238f7cc'){ - // const menuList=[ - // { - // children: [], - // createdBy: "a76fc711807ac9827d7611b0f94ec220", - // createdTime: "2020-08-26 16:38", - // delFlag: null, - // icon: "icon-database", - // id: "abe812eb350f6b5eda575e268e50ac1c", - // name: "定制功能配置", - // parentName: null, - // permissions: "", - // pid: "0", - // resourceList: null, - // revision: 0, - // showFlag: 1, - // sort: 2, - // type: 0, - // updatedBy: "a76fc711807ac9827d7611b0f94ec220", - // updatedTime: "2020-09-02 14:49", - // url: "customer/customize/ConfigItem", - // }, - // { - // children: [], - // createdBy: "a76fc711807ac9827d7611b0f94ec220", - // createdTime: "2020-08-26 16:38", - // delFlag: null, - // icon: "icon-file-text", - // id: "8e55eba74c920c00c44c125e3bc73ddc", - // name: "居民端首页配置", - // parentName: null, - // permissions: "", - // pid: "0", - // resourceList: null, - // revision: 0, - // showFlag: 1, - // sort: 3, - // type: 0, - // updatedBy: "a76fc711807ac9827d7611b0f94ec220", - // updatedTime: "2020-09-02 14:49", - // url: "customer/customize/MiniHome", - // } - // ] - // window.SITE_CONFIG['menuList'] = menuList - // fnAddDynamicMenuRoutes(window.SITE_CONFIG['menuList']) - // // next({ ...to, replace: true }) - // next({ ...to, replace: true }) - // }else{ + // http + // .get("/gov/access/menu/nav") + // .then(({ data: res }) => { + // if (res.code !== 0) { + // // Vue.prototype.$message.error(res.msg) + // return next({ + // name: "login", + // }); + // } - http - .get("/gov/access/menu/nav") - .then(({ data: res }) => { - if (res.code !== 0) { - // Vue.prototype.$message.error(res.msg) - return next({ - name: "login", - }); - } - window.SITE_CONFIG["menuShujuList"] = [ + // next({ + // ...to, + // replace: true, + // }); + // }) + // .catch(() => { + // next({ + // name: "login", + // }); + // }); + window.SITE_CONFIG["menuShujuList"] = [ + { + icon: "icon-setting", + id: "22213213", + name: "基础信息", + // url: "visual/basicinfo/basicInfoMain", + children: [ { - icon: "icon-setting", - id: "22213213", + url: "/visual/basicinfo/basicInfoMain", name: "基础信息", - // url: "visual/basicinfo/basicInfoMain", - children: [ - { - url: "/visual/basicinfo/basicInfoMain", - name: "基础信息", - id: "5feawfwaefwa5", - }, - { - url: "/visual/basicinfo/personCategory/index", - name: "人员类别分析", - id: "5fwaefwaefawef5", - }, - ], + id: "5feawfwaefwa5", }, { - icon: "icon-setting", - id: "3", - name: "人员预警", - url: "visual/warning/index", + url: "/visual/basicinfo/personCategory/index", + name: "人员类别分析", + id: "5fwaefwaefawef5", }, + ], + }, + { + icon: "icon-setting", + id: "3", + name: "人员预警", + url: "visual/warning/index", + }, + { + icon: "icon-setting", + id: "6", + name: "社区治理", + children: [ { - icon: "icon-setting", - id: "6", - name: "社区治理", - children: [ - { - url: "visual/communityGovern/processAnalyze", - name: "项目处理分析", - id: "processAnalyze", - }, - { - url: "/visual/communityGovern/typeAnalyze", - name: "项目分类分析", - id: "typeAnalyze", - }, - { - url: "/visual/communityGovern/resibuzz", - name: "居民热议", - id: "resibuzz", - }, - { - url: "/visual/communityGovern/distributionAnalyze", - name: "项目分布分析", - id: "distributionAnalyze", - }, - ], + url: "visual/communityGovern/processAnalyze", + name: "项目处理分析", + id: "processAnalyze", }, { - icon: "icon-setting", - id: "2221321001", - name: "社区党建", - // url: "visual/basicinfo/basicInfoMain", - children: [ - { - url: "/visual/communityParty/party", - name: "党员信息统计", - id: "5feawfwaefwa578", - }, - { - url: "/visual/communityParty/community", - name: "区域化党建", - id: "5fwaefwaefawef588", - }, - { - url: "/visual/communityParty/elegant", - name: "党员风采", - id: "5fwaefwaefawef589", - } - ], + url: "/visual/communityGovern/typeAnalyze", + name: "项目分类分析", + id: "typeAnalyze", }, { - icon: "icon-setting", - id: "2221321123", - name: "措施清单", - // url: "visual/basicinfo/basicInfoMain", - children: [ - { - url: "/visual/measure/service", - name: "服务措施分析", - id: "5feawfwaefwa57", - }, - { - url: "/visual/measure/volunteer", - name: "志愿者服务分析", - id: "5fwaefwaefawef58", - }, - ], + url: "/visual/communityGovern/resibuzz", + name: "居民热议", + id: "resibuzz", }, { - icon: "icon-setting", - id: "2221321fefefaewfa123", - name: "初心互助", - url: "visual/heart/index", - children: [], + url: "/visual/communityGovern/distributionAnalyze", + name: "项目分布分析", + id: "distributionAnalyze", }, - ]; - fnAddDynamicMenuRoutes2(window.SITE_CONFIG["menuShujuList"]); - // next({ ...to, replace: true }) - next({ - ...to, - replace: true, - }); - }) - .catch(() => { - next({ - name: "login", - }); - }); + ], + }, + { + icon: "icon-setting", + id: "2221321001", + name: "社区党建", + // url: "visual/basicinfo/basicInfoMain", + children: [ + { + url: "/visual/communityParty/party", + name: "党员信息统计", + id: "5feawfwaefwa578", + }, + { + url: "/visual/communityParty/community", + name: "区域化党建", + id: "5fwaefwaefawef588", + }, + { + url: "/visual/communityParty/elegant", + name: "党员风采", + id: "5fwaefwaefawef589", + }, + ], + }, + { + icon: "icon-setting", + id: "2221321123", + name: "措施清单", + // url: "visual/basicinfo/basicInfoMain", + children: [ + { + url: "/visual/measure/service", + name: "服务措施分析", + id: "5feawfwaefwa57", + }, + { + url: "/visual/measure/volunteer", + name: "志愿者服务分析", + id: "5fwaefwaefawef58", + }, + ], + }, + { + icon: "icon-setting", + id: "2221321fefefaewfa123", + name: "初心互助", + url: "visual/heart/index", + children: [], + }, + ]; + fnAddDynamicMenuRoutes2(window.SITE_CONFIG["menuShujuList"]); http .get("/gov/access/menu/nav") @@ -426,9 +376,9 @@ function fnAddDynamicMenuRoutes(menuList = [], routes = []) { }, { path: "*", - redirect: { - name: "404", - }, + // redirect: { + // name: "404", + // }, }, ]); window.SITE_CONFIG["dynamicMenuRoutes"] = routes; @@ -479,9 +429,9 @@ function fnAddDynamicMenuRoutes2(menuList = [], routes = []) { }, { path: "*", - redirect: { - name: "404", - }, + // redirect: { + // name: "404", + // }, }, ]); window.SITE_CONFIG["dynamicMenuRoutesShuju"] = routes; diff --git a/src/utils/request.js b/src/utils/request.js index 419f83ec4..d51a48a96 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -15,9 +15,9 @@ const http = axios.create({ * 请求拦截 */ http.interceptors.request.use(config => { - config.headers['Accept-Language'] = Cookies.get('language') || 'zh-CN' - config.headers['token'] = Cookies.get('token') || '' - config.headers['Authorization'] = Cookies.get('token') || '' + config.headers['Accept-Language'] = localStorage.getItem('language') || 'zh-CN' + config.headers['token'] = localStorage.getItem('token') || '' + config.headers['Authorization'] = localStorage.getItem('token') || '' // 默认参数 var defaults = {} // 防止缓存,GET请求默认带_t参数 diff --git a/src/views/components/tinymce/index.vue b/src/views/components/tinymce/index.vue index 8403b43cb..73c48e26a 100644 --- a/src/views/components/tinymce/index.vue +++ b/src/views/components/tinymce/index.vue @@ -137,7 +137,7 @@ export default { }) }, getUserToken () { - let token = Cookie.get('token') + let token = localStorage.getItem('token') // console.log('获取token', token) // return this.$store.getters['user/isLogin'] return token diff --git a/src/views/main-content.vue b/src/views/main-content.vue index 890964127..08c7e2491 100644 --- a/src/views/main-content.vue +++ b/src/views/main-content.vue @@ -87,7 +87,7 @@ export default { // this.$nextTick(() => { // this.sendMessage() // }) - this.token = Cookie.get("token"); + this.token = localStorage.getItem("token"); this.customerId = localStorage.getItem("customerId"); }, methods: { @@ -100,7 +100,7 @@ export default { this.iframeUrl = url + "?token=" + - Cookie.get("token") + + localStorage.getItem("token") + "&customerId=" + localStorage.getItem("customerId"); return isURL(url); @@ -169,7 +169,7 @@ export default { console.log("iframe", iframe); // iframe.postMessage({ - // token: Cookie.get('token'), + // token: localStorage.getItem('token'), // customerId: localStorage.getItem('customerId') // }, '*') iframe.postMessage({ name: "lalalal" }, "*"); diff --git a/src/views/main-shuju/main-content.vue b/src/views/main-shuju/main-content.vue index b2da8855f..e78235c60 100644 --- a/src/views/main-shuju/main-content.vue +++ b/src/views/main-shuju/main-content.vue @@ -24,7 +24,7 @@ export default { // this.$nextTick(() => { // this.sendMessage() // }) - this.token = Cookie.get('token') + this.token = localStorage.getItem('token') this.customerId = localStorage.getItem('customerId') }, methods: { @@ -34,7 +34,7 @@ export default { // tabs, 是否通过iframe展示 tabIsIframe (url) { // this.appendIframe(url) - this.iframeUrl = url + '?token=' + Cookie.get('token') + '&customerId=' + localStorage.getItem('customerId') + this.iframeUrl = url + '?token=' + localStorage.getItem('token') + '&customerId=' + localStorage.getItem('customerId') return isURL(url) }, // tabs, 选中tab @@ -85,7 +85,7 @@ export default { console.log('iframe', iframe) // iframe.postMessage({ - // token: Cookie.get('token'), + // token: localStorage.getItem('token'), // customerId: localStorage.getItem('customerId') // }, '*') iframe.postMessage({ name: 'lalalal' }, '*') diff --git a/src/views/main-shuju/main-navbar.vue b/src/views/main-shuju/main-navbar.vue index 35c58586a..9fccdcd9c 100644 --- a/src/views/main-shuju/main-navbar.vue +++ b/src/views/main-shuju/main-navbar.vue @@ -45,7 +45,7 @@