Commit cfdcadd9 by liwk

commit

1 parent 8295007d
...@@ -22,7 +22,6 @@ import './utils/util' ...@@ -22,7 +22,6 @@ import './utils/util'
import 'components' import 'components'
import { components } from '@/plugins/vant' import { components } from '@/plugins/vant'
components.forEach(component => Vue.use(component)) components.forEach(component => Vue.use(component))
import { Http } from 'glsx-common'
Vue.prototype.api = api Vue.prototype.api = api
Vue.prototype.bus = bus Vue.prototype.bus = bus
Vue.prototype.tools = tools Vue.prototype.tools = tools
...@@ -47,9 +46,7 @@ fetchConfig(!isMock).then(res => { ...@@ -47,9 +46,7 @@ fetchConfig(!isMock).then(res => {
// 从配置服务器获取动态配置 // 从配置服务器获取动态配置
// 设置 js中可以访问 $cdn // 设置 js中可以访问 $cdn
Vue.use(cfg) Vue.use(cfg)
window.$baseUrl = res.request.baseURL window.$fetchConfig = res
window.$HTTP = new Http({...res, alert: components.Notify })
/**登录过期 重新登录 */ /**登录过期 重新登录 */
window.reLogin = () => { window.reLogin = () => {
console.log(123) console.log(123)
......
...@@ -7,8 +7,10 @@ ...@@ -7,8 +7,10 @@
* @LastEditTime: 2021-07-06 12:02:21 * @LastEditTime: 2021-07-06 12:02:21
*/ */
import { ssoApi } from '@/api' import { ssoApi } from '@/api'
import { store } from 'utils' import { store, util } from 'utils'
import util from '@/utils/util' import { Http } from 'glsx-common'
import { Notify } from 'vant'
const state = { const state = {
pageMeta: '', pageMeta: '',
keepAlives: [], keepAlives: [],
...@@ -79,7 +81,8 @@ const actions = { ...@@ -79,7 +81,8 @@ const actions = {
} else { } else {
let [userInfo] = data.loginList let [userInfo] = data.loginList
util.setLocalStorage('dj_scrm_userInfo', userInfo) util.setLocalStorage('dj_scrm_userInfo', userInfo)
util.setLocalStorage('dj_scrm_session_id', userInfo.sessionId) util.setSessionId(userInfo.sessionId)
registerHttp(userInfo.sessionId)
// 只有一个账号 history.back() // 只有一个账号 history.back()
console.log(`${redirectUrl}${route}`) console.log(`${redirectUrl}${route}`)
window.location.replace(`${redirectUrl}${route}`) window.location.replace(`${redirectUrl}${route}`)
...@@ -107,10 +110,11 @@ const actions = { ...@@ -107,10 +110,11 @@ const actions = {
navigation({ dispatch }) { navigation({ dispatch }) {
util.showLoading() util.showLoading()
const sessionId = getParams('sessionId') const sessionId = getParams('sessionId')
const storage_sessionId = util.getLocalStorage('dj_scrm_session_id') const storage_sessionId = util.getSessionId()
if (sessionId || storage_sessionId) { if (sessionId || storage_sessionId) {
state.showWindow = true state.showWindow = true
util.setLocalStorage('dj_scrm_session_id', sessionId || storage_sessionId) util.setSessionId(sessionId || storage_sessionId)
registerHttp(sessionId || storage_sessionId)
} else { } else {
dispatch('login') dispatch('login')
return return
...@@ -118,6 +122,10 @@ const actions = { ...@@ -118,6 +122,10 @@ const actions = {
state.showWindow = true state.showWindow = true
} }
} }
const registerHttp = sessionId => {
window.$HTTP = new Http({...window.$fetchConfig, alert: Notify, headers: { token: sessionId } })
console.log(window.$HTTP)
}
const getParams = name => { const getParams = name => {
let [url, paramsList] = window.location.href.split('?') let [url, paramsList] = window.location.href.split('?')
if (!paramsList) return name ? null : {} if (!paramsList) return name ? null : {}
......
...@@ -7,8 +7,9 @@ ...@@ -7,8 +7,9 @@
* @LastEditTime: 2021-06-20 12:49:11 * @LastEditTime: 2021-06-20 12:49:11
*/ */
import bus from './eventBus' import bus from './eventBus'
import util from './util'
import * as tool from './tools' import * as tool from './tools'
const { debounce, throttle, ...tools } = tool const { debounce, throttle, ...tools } = tool
import * as constants from './constants' import * as constants from './constants'
import store from './store' import store from './store'
export { bus, tools, debounce, throttle, constants, store }
\ No newline at end of file \ No newline at end of file
export { bus, tools, debounce, throttle, constants, store ,util}
\ No newline at end of file \ No newline at end of file
...@@ -79,6 +79,12 @@ const touchstart = e => { ...@@ -79,6 +79,12 @@ const touchstart = e => {
const touchend = e => { const touchend = e => {
e.target.classList.remove('btn-on-leave') e.target.classList.remove('btn-on-leave')
} }
const setSessionId = val => {
window.localStorage.setItem('dj_scrm_session_id', val)
}
const getSessionId = () => {
return window.localStorage.getItem('dj_scrm_session_id')
}
const setLocalStorage = (key, item) => { const setLocalStorage = (key, item) => {
window.localStorage.setItem(key, JSON.stringify(item)) window.localStorage.setItem(key, JSON.stringify(item))
} }
...@@ -164,6 +170,8 @@ const utils = { ...@@ -164,6 +170,8 @@ const utils = {
makePhoneCall, makePhoneCall,
isFullSucreen, isFullSucreen,
watchPageBack, watchPageBack,
setSessionId,
getSessionId,
showLoading, showLoading,
hideLoading, hideLoading,
refreshPage, refreshPage,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!