| | |
| | | let hrefIdx = window.location.href.indexOf('token=') // url中是否携带token |
| | | |
| | | var tag = false |
| | | if (to.fullPath.indexOf("token") > 0) { |
| | | tag = true |
| | | } |
| | | const meta = to.meta || {} |
| | | const isMenu = meta.menu === undefined ? to.query.menu : meta.menu |
| | | store.commit('SET_IS_MENU', isMenu === undefined) |
| | | |
| | | if (hrefIdx > -1) { |
| | | tag = true |
| | | let token = window.location.href.slice(hrefIdx + 6) |
| | | store.commit('SET_TOKEN', token) |
| | | } |
| | |
| | | if (meta.isAuth === false) { |
| | | next() |
| | | } else { |
| | | // console.log(to.path, 66666) |
| | | // if (to.path == '/security/security') { |
| | | // // console.log('进入首页-----') |
| | | // var a = to.query.securitySupervisionSystem |
| | | // if (a == undefined || typeof a != "string") { |
| | | // // console.log("无securitySupervisionSystem参数 跳回登入"); |
| | | // next('/login') |
| | | // next('/login') |
| | | // return |
| | | // } |
| | | // // console.log("有securitySupervisionSystem参数"); |
| | | // try { |
| | | // // console.log("判断securitySupervisionSystem是否能被JSOn解码"); |
| | | // var obj = JSON.parse(a) |
| | | // if (typeof obj == "object" && obj && obj.tokenMY == '987654321S') { |
| | | // debugger |
| | | // var data = { |
| | | // tenantId: obj.data.dip, |
| | | // username: obj.data.rese, |
| | | // password: md5(obj.data.sap), |
| | | // grant_type: 'password', |
| | | // scope: 'all', |
| | | // type: 'account' |
| | | // } |
| | | // request({ |
| | | // url: '/api/blade-auth/oauth/token', |
| | | // method: 'post', |
| | | // headers: { |
| | | // 'Authorization': 'Basic c2FiZXI6c2FiZXJfc2VjcmV0', |
| | | // "Tenant-Id": "000000" |
| | | // }, |
| | | // params: data |
| | | // }).then(res => { |
| | | // const data = res.data |
| | | // if (data.error_description) { |
| | | // // console.log("登入失败"); |
| | | // Message({ |
| | | // message: data.error_description, |
| | | // type: 'error' |
| | | // }) |
| | | // next('/login') |
| | | // next('/login') |
| | | // return |
| | | // } else { |
| | | // // console.log("登入成功"); |
| | | // store.commit('SET_TOKEN', data.access_token) |
| | | // store.commit('SET_REFRESH_TOKEN', data.refresh_token) |
| | | // store.commit('SET_TENANT_ID', data.tenant_id) |
| | | // store.commit('SET_USER_INFO', data) |
| | | // store.commit('DEL_ALL_TAG') |
| | | // store.commit('CLEAR_LOCK') |
| | | // next(to.path) |
| | | // return |
| | | // } |
| | | // }) |
| | | // return |
| | | // } else { |
| | | // // console.log("成功解码 不是对象"); |
| | | // next('/login') |
| | | // return |
| | | // } |
| | | // } catch { |
| | | // // console.log('不是Json对象 跳回登入'); |
| | | // next('/login') |
| | | // return |
| | | // } |
| | | // } |
| | | next('/login') |
| | | } |
| | | } |