144 lines
5.2 KiB
Vue
144 lines
5.2 KiB
Vue
<!-- 长城项目 登录页 -->
|
|
<template>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
import { mapMutations, mapActions } from 'vuex'
|
|
import axios from 'axios'
|
|
import util from 'util'
|
|
import { get_verify_by_instance,loginIdm,getMenu,checkPageNoEncryption } from 'api/process'
|
|
import { getTokenToWeLink } from 'api/phoneWeLink'
|
|
import { ssoLoginUrlDev,ssoLogoutUrlDev,ssoLoginUrl,webLoginType,devWebUrl } from '@/sysConfig'
|
|
import HWH5 from '../../api/hwh5-cloudonline.js';
|
|
|
|
export default {
|
|
name: 'loginVerifyPhone',
|
|
data () {
|
|
return {
|
|
username: this.$store.state.laws_urm || '', // 用户名
|
|
password: this.$store.state.laws_prm || '', // 密码
|
|
loading: false,
|
|
isRemember: false, // 记住密码
|
|
showIETips: false
|
|
}
|
|
},
|
|
methods: {
|
|
logout(){
|
|
this.$store.dispatch('logout')
|
|
this.$alert('您没有系统访问权限,请联系管理员进行授权', '提示', {
|
|
confirmButtonText: '确定',
|
|
type: 'warning',
|
|
showClose: false,
|
|
showCancelButton: false,
|
|
}).then(() => {
|
|
HWH5.close()
|
|
})
|
|
},
|
|
/**
|
|
* @description: 获取菜单logout
|
|
* @author: chenxiaoxi
|
|
* @date: 2018/11/11 13:42:14
|
|
*/
|
|
getMenu () {
|
|
return new Promise((resolve, reject) => {
|
|
this.$http.get('sarUser/user/menu', {
|
|
userId: this.$store.getters.userInfo.userId,
|
|
}, {
|
|
_this: this,
|
|
}, res => {
|
|
if (res.ok) {
|
|
resolve(res.data)
|
|
}
|
|
}, e => {
|
|
reject(e)
|
|
})
|
|
})
|
|
},
|
|
loginNew (res) {
|
|
let Base64 = require('js-base64').Base64
|
|
let userInfoStr = Base64.decode(res.data)
|
|
let userInfo2 = decodeURIComponent(userInfoStr)
|
|
let userInfoObj = JSON.parse(userInfo2)
|
|
userInfoObj.userId = userInfoObj.usid
|
|
window.sessionStorage.setItem('userInfoObj', userInfoObj); // del
|
|
this.setToken(userInfoObj.token) // vuex存储token
|
|
let userInfo = {}
|
|
for (let key in userInfoObj) {
|
|
if (key !== 'uname') {
|
|
userInfo[key] = userInfoObj[key]
|
|
} else {
|
|
userInfo.uName = userInfoObj[key]
|
|
}
|
|
}
|
|
this.setUserInfo(JSON.stringify((userInfo)))
|
|
// this.resetTime()
|
|
// 获取用户菜单
|
|
window.sessionStorage.setItem('userInfo', userInfo); // del
|
|
this.getMenu().then((menuList) => {
|
|
let hasHomeMenu = false
|
|
menuList.map((menuItem) => {
|
|
if (menuItem.id === 'asdfadf') {
|
|
hasHomeMenu = true
|
|
}
|
|
})
|
|
window.sessionStorage.setItem('hasHomeMenu', hasHomeMenu); // del
|
|
window.sessionStorage.setItem('menuList', menuList); // del
|
|
if (hasHomeMenu) {
|
|
this.setMenu(JSON.stringify(menuList)).then(res => {
|
|
this.$router.push('phoneHome')
|
|
}, e => {
|
|
this.logout()
|
|
})
|
|
} else {
|
|
this.logout()
|
|
}
|
|
})
|
|
},
|
|
...mapMutations(['setToken', 'setUserInfo', 'resetTime', 'rememberPwd', 'setJESSCookie']),
|
|
...mapActions(['setMenu'])
|
|
},
|
|
computed: {
|
|
},
|
|
mounted () {
|
|
window.HWH5.getAuthCode().then(data => {
|
|
console.log(data)
|
|
if(data){
|
|
let code = data.code
|
|
getTokenToWeLink({
|
|
code: code,
|
|
name: encodeURIComponent("standards"+"-"+"regulations"),
|
|
type:"",
|
|
corpCode:"",
|
|
}, {
|
|
_this: this
|
|
}).then(res => {
|
|
if (res.ok) {
|
|
this.loginNew(res)
|
|
} else {
|
|
if(res.respCode && res.respCode === 'r0011'){
|
|
this.logout()
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}).catch(error => {
|
|
console.log('获取异常', error);
|
|
});
|
|
|
|
|
|
if (this.$store.state.laws_urm !== '') {
|
|
this.isRemember = true
|
|
}
|
|
const UA = navigator.userAgent.toLocaleLowerCase()
|
|
if (UA.match(/msie/) != null || UA.match(/trident/) != null) {
|
|
this.showIETips = true
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="less" scoped>
|
|
|
|
</style>
|