|
|
|
@ -1,5 +1,13 @@
|
|
|
|
|
<template>
|
|
|
|
|
<div class="login-mobile-contain">
|
|
|
|
|
<div v-if="qw">
|
|
|
|
|
<div style="padding-top: 150px; text-align: center">
|
|
|
|
|
<img style="width: 100px; height: 100px" src="@/assets/chahao.png" />
|
|
|
|
|
</div>
|
|
|
|
|
<div style="padding-top: 20px; text-align: center">
|
|
|
|
|
<h4>请在客户端打开链接</h4>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div v-else class="login-mobile-contain">
|
|
|
|
|
<div class="login-contaion flex-c flex-c-center">
|
|
|
|
|
<div class="contain-topbg flex flex-center flex-c flex-c-center">
|
|
|
|
|
<img class="logo-img" src="@/assets/logo.png" alt="" />
|
|
|
|
@ -69,12 +77,15 @@
|
|
|
|
|
import { mapGetters, mapActions } from 'vuex'
|
|
|
|
|
import { getCaptchaEnable, getTenantEnable } from '@/utils/ruoyi'
|
|
|
|
|
import { getTenantIdByName } from '@/api/system/tenant'
|
|
|
|
|
import { Wxlogin, sendCode } from '@/api/login'
|
|
|
|
|
import { setTenantId } from '@/utils/auth'
|
|
|
|
|
import { Wxlogin, sendCode, userBind, isProhibited } from '@/api/login'
|
|
|
|
|
import { setTenantId, setToken } from '@/utils/auth'
|
|
|
|
|
import { Toast } from 'vant'
|
|
|
|
|
import { getUserProfile } from '@/api/system/user'
|
|
|
|
|
import { setAccessToken, setLocalStorage } from '@/utils'
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
qw: false,
|
|
|
|
|
loginForm: {
|
|
|
|
|
loginType: '',
|
|
|
|
|
username: '', // admin
|
|
|
|
@ -91,6 +102,8 @@ export default {
|
|
|
|
|
captchaEnable: false,
|
|
|
|
|
isRemeber: false,
|
|
|
|
|
firstLogin: true,
|
|
|
|
|
code: '',
|
|
|
|
|
state: '',
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
components: {
|
|
|
|
@ -100,10 +113,27 @@ export default {
|
|
|
|
|
...mapGetters(['devSystemList', 'devUserList']),
|
|
|
|
|
},
|
|
|
|
|
created() {
|
|
|
|
|
// 是否禁止账号密码登录
|
|
|
|
|
isProhibited().then((res) => {
|
|
|
|
|
if (res.data) {
|
|
|
|
|
console.log(res.data, 'isProhibited')
|
|
|
|
|
if (/wxwork/i.test(navigator.userAgent)) {
|
|
|
|
|
// 在企业微信中打开
|
|
|
|
|
} else {
|
|
|
|
|
// 不在企业微信中打开,可以做一些限制或提示
|
|
|
|
|
this.qw = true
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
alert('请在企业微信中打开此页面!')
|
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
// 租户开关
|
|
|
|
|
// this.tenantEnable = getTenantEnable();
|
|
|
|
|
// if (this.tenantEnable) {
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
if (window.localStorage.getItem('isRemeber')) {
|
|
|
|
|
this.isRemeber = true
|
|
|
|
|
} else {
|
|
|
|
@ -114,6 +144,51 @@ export default {
|
|
|
|
|
// 验证码开关
|
|
|
|
|
// this.captchaEnable = getCaptchaEnable();
|
|
|
|
|
},
|
|
|
|
|
mounted() {
|
|
|
|
|
// 重定向之后 获取用户信息 token
|
|
|
|
|
if (window.location.href.includes('code')) {
|
|
|
|
|
this.$loading(true)
|
|
|
|
|
let urlParams = new URLSearchParams(window.location.href.split('?')[1])
|
|
|
|
|
this.code = urlParams.get('code')
|
|
|
|
|
this.state = urlParams.get('state')
|
|
|
|
|
// // 发送code获取成员信息
|
|
|
|
|
sendCode({ code: this.code, state: this.state, type: 40 })
|
|
|
|
|
.then(async (res) => {
|
|
|
|
|
if (res.data.code == 500) {
|
|
|
|
|
/* Toast.loading({
|
|
|
|
|
duration: 3, // 持续展示 toast
|
|
|
|
|
forbidClick: false,
|
|
|
|
|
message: res.data.msg,
|
|
|
|
|
}) */
|
|
|
|
|
this.firstLogin = true
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
await setToken(res.data)
|
|
|
|
|
await this.$store.dispatch(
|
|
|
|
|
'common/user/setAuthorization',
|
|
|
|
|
res.data.accessToken,
|
|
|
|
|
{
|
|
|
|
|
root: true,
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
await setAccessToken(res.data.accessToken).then(async () => {
|
|
|
|
|
await setLocalStorage('isOutLimit', false).then(() => {
|
|
|
|
|
this.$store.dispatch('common/user/outLimit', null, { root: true })
|
|
|
|
|
})
|
|
|
|
|
await getUserProfile().then((info) => {
|
|
|
|
|
setLocalStorage('userInfo', JSON.stringify(info.data))
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
this.$loading(false)
|
|
|
|
|
//访问用户敏感信息
|
|
|
|
|
// this.$router.replace('/home')
|
|
|
|
|
window.location.href = process.env.VUE_APP_BASE_API + '/#/home'
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
console.log(error, 'error')
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
handleWxLogin() {
|
|
|
|
|
// 发起授权定向
|
|
|
|
@ -123,41 +198,20 @@ export default {
|
|
|
|
|
// scope: 'snsapi_privateinfo',
|
|
|
|
|
// agentid: '1000002',
|
|
|
|
|
// type: 30,
|
|
|
|
|
redirectUri: 'http://expense-h5.lyrfp.com/#/login',
|
|
|
|
|
redirectUri: process.env.VUE_APP_BASE_API + '/#/login',
|
|
|
|
|
}).then((res) => {
|
|
|
|
|
// 构造重定向的 URL
|
|
|
|
|
window.location.href = res.data
|
|
|
|
|
Toast.loading({
|
|
|
|
|
duration: 1.5, // 持续展示 toast
|
|
|
|
|
forbidClick: true,
|
|
|
|
|
message: res.data + '1次',
|
|
|
|
|
})
|
|
|
|
|
let urlParams = new URLSearchParams(window.location.href.split('?')[1])
|
|
|
|
|
let code = urlParams.get('code')
|
|
|
|
|
let state = urlParams.get('state')
|
|
|
|
|
// // 发送code获取成员信息
|
|
|
|
|
sendCode({ code, state, type: 40 })
|
|
|
|
|
.then((res) => {
|
|
|
|
|
Toast.loading({
|
|
|
|
|
duration: 1.5, // 持续展示 toast
|
|
|
|
|
forbidClick: true,
|
|
|
|
|
message: res.code + 'code200',
|
|
|
|
|
})
|
|
|
|
|
//访问用户敏感信息
|
|
|
|
|
console.log(res, '用户敏感信息')
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
Toast.loading({
|
|
|
|
|
duration: 1.5, // 持续展示 toast
|
|
|
|
|
forbidClick: true,
|
|
|
|
|
message: res.code + 'error500',
|
|
|
|
|
})
|
|
|
|
|
if (error.code == 500) {
|
|
|
|
|
this.$fm('首次登录请先账号密码登录绑定')
|
|
|
|
|
this.firstLogin = true
|
|
|
|
|
}
|
|
|
|
|
/* this.$nextTick(() => {
|
|
|
|
|
Toast.loading({
|
|
|
|
|
duration: 3, // 持续展示 toast
|
|
|
|
|
forbidClick: true,
|
|
|
|
|
message: res.data + ,
|
|
|
|
|
})
|
|
|
|
|
}) */
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
// 跳转登录
|
|
|
|
|
handleSetLoginInfo() {
|
|
|
|
|
if (this.isRemeber) {
|
|
|
|
|
const { tenantName, username, password } = JSON.parse(
|
|
|
|
@ -236,6 +290,12 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
window.localStorage.setItem('loginInfo', JSON.stringify(obj))
|
|
|
|
|
}
|
|
|
|
|
// 首次企微登录绑定账号
|
|
|
|
|
if (window.location.href.includes('code')) {
|
|
|
|
|
userBind({ code: this.code, state: this.state, type: 40 })
|
|
|
|
|
.then((res) => [console.log(res, 'userBind res')])
|
|
|
|
|
.catch((err) => [console.log(err, 'userBind err')])
|
|
|
|
|
}
|
|
|
|
|
this.$router.replace('/home')
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|