jwg 7 months ago
parent 4c1d597a57
commit 655f354ad9

@ -11,6 +11,17 @@ export function loginIn(data) {
data data
}) })
} }
// 企业登录
export function Wxlogin(data) {
return request({
url: 'system/auth/social-auth-redirect',
method: 'get',
headers: {
isToken: false
},
params: data
})
}
// 获取个人权限信息 // 获取个人权限信息
export function getUserInfo() { export function getUserInfo() {

@ -7,29 +7,48 @@
<div class="logo-text logo-text-new">OA办公每一天都高效</div> <div class="logo-text logo-text-new">OA办公每一天都高效</div>
<div class="round"></div> <div class="round"></div>
</div> </div>
<div style="width: 90%;z-index: 10;"> <div style="width: 90%; z-index: 10">
<div class="login-form"> <div class="login-form">
<div style="border-bottom: 1px solid #ddd; padding-bottom: 0.3rem;"> <div style="border-bottom: 1px solid #ddd; padding-bottom: 0.3rem">
<div class="userName">企业</div> <div class="userName">企业</div>
<input v-model="loginForm.tenantName" placeholder="请输入企业名称" /> <input
v-model="loginForm.tenantName"
placeholder="请输入企业名称"
/>
</div> </div>
<div style="border-bottom: 1px solid #ddd; padding-bottom: 0.3rem;"> <div style="border-bottom: 1px solid #ddd; padding-bottom: 0.3rem">
<div class="userName">账号</div> <div class="userName">账号</div>
<input v-model="loginForm.username" placeholder="请输入用户名" /> <input v-model="loginForm.username" placeholder="请输入用户名" />
</div> </div>
<div style="border-bottom: 1px solid #ddd; padding-bottom: 0.3rem;"> <div style="border-bottom: 1px solid #ddd; padding-bottom: 0.3rem">
<div class="password">密码</div> <div class="password">密码</div>
<input v-model="loginForm.password" type="password" placeholder="请输入密码" /> <input
v-model="loginForm.password"
type="password"
placeholder="请输入密码"
/>
</div> </div>
</div> </div>
<div class="whiteSpace"></div> <div class="whiteSpace"></div>
<div class="btn-box"> <div class="btn-box">
<van-button type="info" style="width: 100%" @click="handleLogin" loading-text="...">登录</van-button> <van-button
type="info"
style="width: 100%"
@click="handleLogin"
loading-text="登录中..."
>登录</van-button
>
</div> </div>
<div class="btn-box rember-box"> <div class="btn-box rember-box">
<van-checkbox v-model="isRemeber" @change="handleCheck" shape="square"></van-checkbox> <van-checkbox v-model="isRemeber" @change="handleCheck" shape="square"
>记住密码</van-checkbox
>
</div> </div>
</div> </div>
<!-- 企业微信登录 -->
<van-button type="primary" @click="handleWxLogin"
>企业微信登录</van-button
>
</div> </div>
<!-- 图形验证码 --> <!-- 图形验证码 -->
<!-- <Verify ref="verify" :captcha-type="'blockPuzzle'" :img-size="{width:'10rem',height:'5rem'}" @success="handleLogin" /> --> <!-- <Verify ref="verify" :captcha-type="'blockPuzzle'" :img-size="{width:'10rem',height:'5rem'}" @success="handleLogin" /> -->
@ -38,23 +57,22 @@
<script> <script>
import { mapGetters, mapActions } from 'vuex' import { mapGetters, mapActions } from 'vuex'
import { getCaptchaEnable, getTenantEnable } from "@/utils/ruoyi"; import { getCaptchaEnable, getTenantEnable } from '@/utils/ruoyi'
import { getTenantIdByName } from "@/api/system/tenant"; import { getTenantIdByName } from '@/api/system/tenant'
import { import { Wxlogin } from '@/api/login'
setTenantId import { setTenantId } from '@/utils/auth'
} from "@/utils/auth";
export default { export default {
data() { data() {
return { return {
loginForm: { loginForm: {
loginType: "", loginType: '',
username: "", // admin username: '', // admin
password: "", // admin123 password: '', // admin123
captchaVerification: "", captchaVerification: '',
mobile: "", mobile: '',
mobileCode: "", mobileCode: '',
rememberMe: false, rememberMe: false,
tenantName: "", // tenantName: '', //
}, },
systemInfo: {}, systemInfo: {},
checked: false, checked: false,
@ -67,7 +85,7 @@ export default {
// Verify // Verify
}, },
computed: { computed: {
...mapGetters(['devSystemList', 'devUserList']) ...mapGetters(['devSystemList', 'devUserList']),
}, },
created() { created() {
// //
@ -85,13 +103,21 @@ export default {
// this.captchaEnable = getCaptchaEnable(); // this.captchaEnable = getCaptchaEnable();
}, },
methods: { methods: {
handleWxLogin() {
Wxlogin({ type: 30, redirectUri: '/home' }).then((res) => {
console.log(res)
window.location.href = res.data
})
},
handleSetLoginInfo() { handleSetLoginInfo() {
if (this.isRemeber) { if (this.isRemeber) {
const { tenantName, username, password } = JSON.parse(window.localStorage.getItem('loginInfo') || {}) const { tenantName, username, password } = JSON.parse(
window.localStorage.getItem('loginInfo') || {}
)
this.loginForm = { this.loginForm = {
tenantName, tenantName,
username, username,
password password,
} }
} else { } else {
window.localStorage.removeItem('loginInfo') window.localStorage.removeItem('loginInfo')
@ -99,8 +125,10 @@ export default {
}, },
handleSetTenantId() { handleSetTenantId() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
getTenantIdByName(this.loginForm.tenantName).then(res => { // getTenantIdByName(this.loginForm.tenantName)
const tenantId = res.data.id; .then((res) => {
//
const tenantId = res.data.id
window.localStorage.setItem('cn', res.data.name) window.localStorage.setItem('cn', res.data.name)
if (tenantId && tenantId >= 0) { if (tenantId && tenantId >= 0) {
setTenantId(tenantId) setTenantId(tenantId)
@ -108,9 +136,10 @@ export default {
} else { } else {
reject() reject()
} }
}).catch(() => { })
.catch(() => {
reject() reject()
}); })
}) })
}, },
handleCheck(val) { handleCheck(val) {
@ -141,12 +170,14 @@ export default {
return return
} }
this.$loading(true) this.$loading(true)
this.handleSetTenantId().then(() => { this.handleSetTenantId()
.then(() => {
this.developLogin({ this.developLogin({
vm: this, vm: this,
username: this.loginForm.username, username: this.loginForm.username,
password: this.loginForm.password, password: this.loginForm.password,
}).then(() => { })
.then(() => {
// //
if (this.isRemeber) { if (this.isRemeber) {
let obj = { let obj = {
@ -157,10 +188,12 @@ export default {
window.localStorage.setItem('loginInfo', JSON.stringify(obj)) window.localStorage.setItem('loginInfo', JSON.stringify(obj))
} }
this.$router.replace('/home') this.$router.replace('/home')
}).catch(() => { })
.catch(() => {
this.$loading(false) this.$loading(false)
}) })
}).catch(() => { })
.catch(() => {
this.$fm('企业信息错误!') this.$fm('企业信息错误!')
this.$loading(false) this.$loading(false)
}) })
@ -174,8 +207,8 @@ export default {
}, },
handleDevUser(val) { handleDevUser(val) {
this.loginForm.devUserTitle = val.title this.loginForm.devUserTitle = val.title
} },
} },
} }
</script> </script>

@ -22,7 +22,9 @@ module.exports = {
proxy: { proxy: {
// detail: https://cli.vuejs.org/config/#devserver-proxy // detail: https://cli.vuejs.org/config/#devserver-proxy
['/proxy-api']: { ['/proxy-api']: {
target: `http://localhost:48080`, // target: `http://localhost:48080`,
// target: `http://192.168.3.81:48080`,
target: `http://192.168.3.243:48080`,
// target: `http://api-dashboard.yudao.iocoder.cn`, // target: `http://api-dashboard.yudao.iocoder.cn`,
changeOrigin: true, changeOrigin: true,
pathRewrite: { pathRewrite: {

Loading…
Cancel
Save