Commit cfdcadd9 by liwk

commit

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