|
@@ -1,80 +1,7 @@
|
|
-<template>
|
|
|
|
- <el-form ref="formRef" size="large" class="login-content-form" :model="state.ruleForm" :rules="rules">
|
|
|
|
- <el-form-item class="login-animation1" prop="username">
|
|
|
|
- <el-input
|
|
|
|
- type="text"
|
|
|
|
- :placeholder="$t('message.account.accountPlaceholder1')"
|
|
|
|
- v-model="ruleForm.username"
|
|
|
|
- clearable
|
|
|
|
- autocomplete="off">
|
|
|
|
- <template #prefix>
|
|
|
|
- <el-icon class="el-input__icon">
|
|
|
|
- <ele-User />
|
|
|
|
- </el-icon>
|
|
|
|
- </template>
|
|
|
|
- </el-input>
|
|
|
|
- </el-form-item>
|
|
|
|
- <el-form-item class="login-animation2" prop="password">
|
|
|
|
- <el-input
|
|
|
|
- :type="isShowPassword ? 'text' : 'password'"
|
|
|
|
- :placeholder="$t('message.account.accountPlaceholder2')"
|
|
|
|
- v-model="ruleForm.password">
|
|
|
|
- <template #prefix>
|
|
|
|
- <el-icon class="el-input__icon">
|
|
|
|
- <ele-Unlock />
|
|
|
|
- </el-icon>
|
|
|
|
- </template>
|
|
|
|
- <template #suffix>
|
|
|
|
- <i
|
|
|
|
- class="iconfont el-input__icon login-content-password"
|
|
|
|
- :class="isShowPassword ? 'icon-yincangmima' : 'icon-xianshimima'"
|
|
|
|
- @click="isShowPassword = !isShowPassword">
|
|
|
|
- </i>
|
|
|
|
- </template>
|
|
|
|
- </el-input>
|
|
|
|
- </el-form-item>
|
|
|
|
- <el-form-item class="login-animation3" v-if="isShowCaptcha" prop="captcha">
|
|
|
|
- <el-col :span="15">
|
|
|
|
- <el-input
|
|
|
|
- type="text"
|
|
|
|
- maxlength="4"
|
|
|
|
- :placeholder="$t('message.account.accountPlaceholder3')"
|
|
|
|
- v-model="ruleForm.captcha"
|
|
|
|
- clearable
|
|
|
|
- autocomplete="off">
|
|
|
|
- <template #prefix>
|
|
|
|
- <el-icon class="el-input__icon">
|
|
|
|
- <ele-Position />
|
|
|
|
- </el-icon>
|
|
|
|
- </template>
|
|
|
|
- </el-input>
|
|
|
|
- </el-col>
|
|
|
|
- <el-col :span="1"></el-col>
|
|
|
|
- <el-col :span="8">
|
|
|
|
- <el-button class="login-content-captcha">
|
|
|
|
- <el-image :src="ruleForm.captchaImgBase" @click="refreshCaptcha" />
|
|
|
|
- </el-button>
|
|
|
|
- </el-col>
|
|
|
|
- </el-form-item>
|
|
|
|
- <el-form-item class="login-animation4">
|
|
|
|
- <el-button
|
|
|
|
- type="primary"
|
|
|
|
- class="login-content-submit"
|
|
|
|
- round
|
|
|
|
- @keyup.enter="loginClick"
|
|
|
|
- @click="loginClick"
|
|
|
|
- :loading="loading.signIn">
|
|
|
|
- <span>{{ $t('message.account.accountBtnText') }}</span>
|
|
|
|
- </el-button>
|
|
|
|
- <el-button type="primary" class="login-content-submit" round @click="qrLoginClick"> 企业微信扫码登录</el-button>
|
|
|
|
- </el-form-item>
|
|
|
|
- </el-form>
|
|
|
|
-</template>
|
|
|
|
-
|
|
|
|
<script lang="ts">
|
|
<script lang="ts">
|
|
-import { toRefs, reactive, defineComponent, computed, onMounted, onUnmounted, ref } from 'vue'
|
|
|
|
|
|
+import { computed, defineComponent, onMounted, onBeforeUnmount, reactive, ref, toRefs } from 'vue'
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
-import { ElMessage, FormInstance, FormRules } from 'element-plus'
|
|
|
|
|
|
+import { ElMessage, FormRules } from 'element-plus'
|
|
import { useI18n } from 'vue-i18n'
|
|
import { useI18n } from 'vue-i18n'
|
|
import Cookies from 'js-cookie'
|
|
import Cookies from 'js-cookie'
|
|
import { storeToRefs } from 'pinia'
|
|
import { storeToRefs } from 'pinia'
|
|
@@ -88,10 +15,8 @@ import * as loginApi from '/@/views/system/login/api'
|
|
import { useUserInfo } from '/@/stores/userInfo'
|
|
import { useUserInfo } from '/@/stores/userInfo'
|
|
import { DictionaryStore } from '/@/stores/dictionary'
|
|
import { DictionaryStore } from '/@/stores/dictionary'
|
|
import { SystemConfigStore } from '/@/stores/systemConfig'
|
|
import { SystemConfigStore } from '/@/stores/systemConfig'
|
|
-import { BtnPermissionStore } from '/@/plugin/permission/store.permission'
|
|
|
|
import { Md5 } from 'ts-md5'
|
|
import { Md5 } from 'ts-md5'
|
|
import { errorMessage } from '/@/utils/message'
|
|
import { errorMessage } from '/@/utils/message'
|
|
-import { getWorkWeChatCode, postWorkWeChatCode } from '../api'
|
|
|
|
import emitter from '/@/utils/emitter'
|
|
import emitter from '/@/utils/emitter'
|
|
|
|
|
|
export default defineComponent({
|
|
export default defineComponent({
|
|
@@ -189,23 +114,19 @@ export default defineComponent({
|
|
}
|
|
}
|
|
|
|
|
|
emitter.on('scan-wecomLogin', (userInfo: any) => {
|
|
emitter.on('scan-wecomLogin', (userInfo: any) => {
|
|
- console.log('进入企业微信扫码登录')
|
|
|
|
- console.log('userInfo', userInfo)
|
|
|
|
- console.log('userInfo.loginInfo.code', userInfo.loginInfo.code)
|
|
|
|
- if (userInfo.loginInfo.code == 2000) {
|
|
|
|
- Session.set('token', userInfo.loginInfo.data.access)
|
|
|
|
- Cookies.set('username', userInfo.loginInfo.data.name)
|
|
|
|
- console.log('写入token')
|
|
|
|
- if (!themeConfig.value.isRequestRoutes) {
|
|
|
|
- // 前端控制路由,2、请注意执行顺序
|
|
|
|
- console.log('成功获取token,开始初始化前端路由')
|
|
|
|
- initFrontEndControlRoutes()
|
|
|
|
- loginSuccess()
|
|
|
|
- } else {
|
|
|
|
- initBackEndControlRoutes()
|
|
|
|
- loginSuccess()
|
|
|
|
- }
|
|
|
|
|
|
+ if (userInfo.loginInfo.code == 2000) {
|
|
|
|
+ Session.set('token', userInfo.loginInfo.data.access)
|
|
|
|
+ Cookies.set('username', userInfo.loginInfo.data.name)
|
|
|
|
+ if (!themeConfig.value.isRequestRoutes) {
|
|
|
|
+ // 前端控制路由,2、请注意执行顺序
|
|
|
|
+ console.log('成功获取token,开始初始化前端路由')
|
|
|
|
+ initFrontEndControlRoutes()
|
|
|
|
+ loginSuccess()
|
|
|
|
+ } else {
|
|
|
|
+ initBackEndControlRoutes()
|
|
|
|
+ loginSuccess()
|
|
}
|
|
}
|
|
|
|
+ }
|
|
})
|
|
})
|
|
|
|
|
|
// 登录成功后的跳转
|
|
// 登录成功后的跳转
|
|
@@ -236,41 +157,16 @@ export default defineComponent({
|
|
NextLoading.start()
|
|
NextLoading.start()
|
|
}
|
|
}
|
|
|
|
|
|
- const qrCode = ref('')
|
|
|
|
-
|
|
|
|
- async function qrLoginClick() {
|
|
|
|
- try {
|
|
|
|
- const response = await getWorkWeChatCode()
|
|
|
|
- window.location.href = response.data
|
|
|
|
- qrCode.value = response.data
|
|
|
|
- // if (qrCode.value) {
|
|
|
|
- console.log(123, this.$route.query.code)
|
|
|
|
- // await WorkWeChatCodeLogin()
|
|
|
|
- // }
|
|
|
|
- } catch (error) {
|
|
|
|
- console.log('error:', error)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- async function WorkWeChatCodeLogin() {
|
|
|
|
- const post = {
|
|
|
|
- code: qrCode.value,
|
|
|
|
- state: 'Wechat',
|
|
|
|
- }
|
|
|
|
- try {
|
|
|
|
- const response = await postWorkWeChatCode(post)
|
|
|
|
- console.log('response', response.data)
|
|
|
|
- } catch (error) {
|
|
|
|
- console.log('error:', error)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
getCaptcha()
|
|
getCaptcha()
|
|
//获取系统配置
|
|
//获取系统配置
|
|
SystemConfigStore().getSystemConfigs()
|
|
SystemConfigStore().getSystemConfigs()
|
|
})
|
|
})
|
|
|
|
|
|
|
|
+ onBeforeUnmount(() => {
|
|
|
|
+ emitter.all.clear()
|
|
|
|
+ })
|
|
|
|
+
|
|
return {
|
|
return {
|
|
refreshCaptcha,
|
|
refreshCaptcha,
|
|
loginClick,
|
|
loginClick,
|
|
@@ -280,14 +176,84 @@ export default defineComponent({
|
|
formRef,
|
|
formRef,
|
|
rules,
|
|
rules,
|
|
...toRefs(state),
|
|
...toRefs(state),
|
|
- qrLoginClick,
|
|
|
|
- qrCode,
|
|
|
|
- WorkWeChatCodeLogin,
|
|
|
|
}
|
|
}
|
|
},
|
|
},
|
|
})
|
|
})
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
+<template>
|
|
|
|
+ <el-form ref="formRef" size="large" class="login-content-form" :model="state.ruleForm" :rules="rules">
|
|
|
|
+ <el-form-item class="login-animation1" prop="username">
|
|
|
|
+ <el-input
|
|
|
|
+ type="text"
|
|
|
|
+ :placeholder="$t('message.account.accountPlaceholder1')"
|
|
|
|
+ v-model="ruleForm.username"
|
|
|
|
+ clearable
|
|
|
|
+ autocomplete="off">
|
|
|
|
+ <template #prefix>
|
|
|
|
+ <el-icon class="el-input__icon">
|
|
|
|
+ <ele-User />
|
|
|
|
+ </el-icon>
|
|
|
|
+ </template>
|
|
|
|
+ </el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item class="login-animation2" prop="password">
|
|
|
|
+ <el-input
|
|
|
|
+ :type="isShowPassword ? 'text' : 'password'"
|
|
|
|
+ :placeholder="$t('message.account.accountPlaceholder2')"
|
|
|
|
+ v-model="ruleForm.password">
|
|
|
|
+ <template #prefix>
|
|
|
|
+ <el-icon class="el-input__icon">
|
|
|
|
+ <ele-Unlock />
|
|
|
|
+ </el-icon>
|
|
|
|
+ </template>
|
|
|
|
+ <template #suffix>
|
|
|
|
+ <i
|
|
|
|
+ class="iconfont el-input__icon login-content-password"
|
|
|
|
+ :class="isShowPassword ? 'icon-yincangmima' : 'icon-xianshimima'"
|
|
|
|
+ @click="isShowPassword = !isShowPassword">
|
|
|
|
+ </i>
|
|
|
|
+ </template>
|
|
|
|
+ </el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item class="login-animation3" v-if="isShowCaptcha" prop="captcha">
|
|
|
|
+ <el-col :span="15">
|
|
|
|
+ <el-input
|
|
|
|
+ type="text"
|
|
|
|
+ maxlength="4"
|
|
|
|
+ :placeholder="$t('message.account.accountPlaceholder3')"
|
|
|
|
+ v-model="ruleForm.captcha"
|
|
|
|
+ clearable
|
|
|
|
+ autocomplete="off">
|
|
|
|
+ <template #prefix>
|
|
|
|
+ <el-icon class="el-input__icon">
|
|
|
|
+ <ele-Position />
|
|
|
|
+ </el-icon>
|
|
|
|
+ </template>
|
|
|
|
+ </el-input>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="1"></el-col>
|
|
|
|
+ <el-col :span="8">
|
|
|
|
+ <el-button class="login-content-captcha">
|
|
|
|
+ <el-image :src="ruleForm.captchaImgBase" @click="refreshCaptcha" />
|
|
|
|
+ </el-button>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item class="login-animation4">
|
|
|
|
+ <el-button
|
|
|
|
+ type="primary"
|
|
|
|
+ class="login-content-submit"
|
|
|
|
+ round
|
|
|
|
+ @keyup.enter="loginClick"
|
|
|
|
+ @click="loginClick"
|
|
|
|
+ :loading="loading.signIn">
|
|
|
|
+ <span>{{ $t('message.account.accountBtnText') }}</span>
|
|
|
|
+ </el-button>
|
|
|
|
+ <!--<el-button type="primary" class="login-content-submit" round @click="qrLoginClick"> 企业微信扫码登录</el-button>-->
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-form>
|
|
|
|
+</template>
|
|
|
|
+
|
|
<style scoped lang="scss">
|
|
<style scoped lang="scss">
|
|
.login-content-form {
|
|
.login-content-form {
|
|
margin-top: 20px;
|
|
margin-top: 20px;
|