登录页面
This commit is contained in:
parent
477eb6bbe8
commit
a474d7a8b2
11
src/App.vue
11
src/App.vue
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<el-config-provider :locale="locale" :size="config.size" :zIndex="config.zIndex" :button="config.button">
|
<el-config-provider :locale="locale2" :size="config.size" :zIndex="config.zIndex" :button="config.button">
|
||||||
<router-view></router-view>
|
<router-view></router-view>
|
||||||
</el-config-provider>
|
</el-config-provider>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import {useI18n} from 'vue-i18n'
|
import {useI18n} from 'vue-i18n'
|
||||||
import {computed} from 'vue'
|
import {computed} from 'vue'
|
||||||
|
const {locale, messages} = useI18n()
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
size: "default",
|
size: "default",
|
||||||
|
|
@ -16,9 +17,13 @@ const config = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const locale = computed(() => {
|
const locale2 = computed(() => {
|
||||||
const {locale, messages} = useI18n()
|
|
||||||
return messages.value[locale.value]
|
return messages.value[locale.value]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
console.log('%c SAAS %c 里派提供技术支持', 'background:#4caf50;color:#fff;border-radius:3px;', '')
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
@use '@/style/style.scss';
|
||||||
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -6,5 +6,8 @@ export default {
|
||||||
},
|
},
|
||||||
menu: async function (data = {}) {
|
menu: async function (data = {}) {
|
||||||
return await http.get("v1/menu", data)
|
return await http.get("v1/menu", data)
|
||||||
}
|
},
|
||||||
|
captcha: async function(data = {}){
|
||||||
|
return await http.get("v1/captcha", data);
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,5 +2,34 @@ export default {
|
||||||
system: {
|
system: {
|
||||||
webTitleDev: 'Property Management System (Testing)',
|
webTitleDev: 'Property Management System (Testing)',
|
||||||
webTitle: 'Property Management System',
|
webTitle: 'Property Management System',
|
||||||
|
},
|
||||||
|
login: {
|
||||||
|
slogan: 'SpringCloud Alibaba Microservices Architecture',
|
||||||
|
describe: 'The community group',
|
||||||
|
signInTitle: 'Sign in',
|
||||||
|
accountLogin: 'Account sign in',
|
||||||
|
rememberMe: 'Remember me',
|
||||||
|
forgetPassword: 'Forget password',
|
||||||
|
signIn: 'Sign in',
|
||||||
|
signInOther: 'Sign in with',
|
||||||
|
userPlaceholder: 'user / phone / email',
|
||||||
|
userError: 'Please input a user name',
|
||||||
|
PWPlaceholder: 'Please input a password',
|
||||||
|
codePlaceholder: 'Please input a code',
|
||||||
|
PWError: 'Please input a password',
|
||||||
|
codeError: 'Please input a code',
|
||||||
|
wechatLoginTitle: 'QR code sign in',
|
||||||
|
wechatLoginMsg: 'Please use wechat to scan and log in | Auto scan after 3 seconds of simulation',
|
||||||
|
wechatLoginResult: 'Scanned | Please click authorize login in the device',
|
||||||
|
backLogin: 'Return to Login'
|
||||||
|
},
|
||||||
|
user: {
|
||||||
|
dynamic: 'Dynamic',
|
||||||
|
info: 'User Info',
|
||||||
|
settings: 'Settings',
|
||||||
|
nightmode: 'night mode',
|
||||||
|
nightmode_msg: 'Suitable for low light environment,The current night mode is beta',
|
||||||
|
language: 'language',
|
||||||
|
language_msg: 'Translation in progress,Temporarily translated the text of this view',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2,5 +2,34 @@ export default {
|
||||||
system: {
|
system: {
|
||||||
webTitleDev: '物业管理系统(测试)',
|
webTitleDev: '物业管理系统(测试)',
|
||||||
webTitle: '物业管理系统',
|
webTitle: '物业管理系统',
|
||||||
|
},
|
||||||
|
login: {
|
||||||
|
slogan: 'SpringCloud Alibaba 微服务架构',
|
||||||
|
describe: '便民服务',
|
||||||
|
signInTitle: '用户登录',
|
||||||
|
accountLogin: '账号登录',
|
||||||
|
rememberMe: '记住密码',
|
||||||
|
forgetPassword: '忘记密码',
|
||||||
|
signIn: '登录',
|
||||||
|
signInOther: '其他登录方式',
|
||||||
|
userPlaceholder: '用户名 / 手机 / 邮箱',
|
||||||
|
userError: '请输入用户名',
|
||||||
|
PWPlaceholder: '请输入密码',
|
||||||
|
codePlaceholder: '请输入验证码',
|
||||||
|
PWError: '请输入密码',
|
||||||
|
codeError: '请输入验证码',
|
||||||
|
wechatLoginTitle: '二维码登录',
|
||||||
|
wechatLoginMsg: '请使用微信扫一扫登录 | 模拟3秒后自动扫描',
|
||||||
|
wechatLoginResult: '已扫描 | 请点击授权登录',
|
||||||
|
backLogin: '返回登录'
|
||||||
|
},
|
||||||
|
user: {
|
||||||
|
dynamic: '近期动态',
|
||||||
|
info: '个人信息',
|
||||||
|
settings: '设置',
|
||||||
|
nightmode: '黑夜模式',
|
||||||
|
nightmode_msg: '适合光线较弱的环境,当前黑暗模式为beta版本',
|
||||||
|
language: '语言',
|
||||||
|
language_msg: '翻译进行中,暂翻译了本视图的文本',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
11
src/pi.ts
11
src/pi.ts
|
|
@ -1,19 +1,8 @@
|
||||||
import config from "./config"
|
|
||||||
import api from './api'
|
|
||||||
import tools from './utils/tools'
|
|
||||||
import http from "./utils/request"
|
|
||||||
|
|
||||||
import * as elIcons from '@element-plus/icons-vue'
|
import * as elIcons from '@element-plus/icons-vue'
|
||||||
import {App} from "vue";
|
import {App} from "vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
install(app: App) {
|
install(app: App) {
|
||||||
//挂载全局对象
|
|
||||||
app.config.globalProperties.$CONFIG = config;
|
|
||||||
app.config.globalProperties.$TOOLS = tools;
|
|
||||||
app.config.globalProperties.$HTTP = http;
|
|
||||||
app.config.globalProperties.$API = api;
|
|
||||||
|
|
||||||
//统一注册el-icon图标
|
//统一注册el-icon图标
|
||||||
for (let icon in elIcons) {
|
for (let icon in elIcons) {
|
||||||
app.component(`ElIcon${icon}`, elIcons[icon])
|
app.component(`ElIcon${icon}`, elIcons[icon])
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
@import '~element-plus/theme-chalk/src/dark/css-vars.scss';
|
@use 'element-plus/theme-chalk/src/dark/css-vars.scss';
|
||||||
|
|
||||||
html.dark {
|
html.dark {
|
||||||
//变量
|
//变量
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
@import 'app.scss';
|
@use 'app.scss';
|
||||||
@import 'fix.scss';
|
@use 'fix.scss';
|
||||||
@import 'pages.scss';
|
@use 'pages.scss';
|
||||||
@import 'media.scss';
|
@use 'media.scss';
|
||||||
@import 'dark.scss';
|
@use 'dark.scss';
|
||||||
|
|
|
||||||
|
|
@ -24,12 +24,12 @@ axios.interceptors.request.use((config) => {
|
||||||
//响应拦截
|
//响应拦截
|
||||||
axios.interceptors.response.use((response) => {
|
axios.interceptors.response.use((response) => {
|
||||||
let res = response.data
|
let res = response.data
|
||||||
if (res.code == 0) {
|
if (res.code == 200) {
|
||||||
return Promise.resolve(res)
|
return Promise.resolve(res)
|
||||||
} else if (res.code == 1) { // 操作失败拦截
|
} else if (res.code == 400) { // 操作失败拦截
|
||||||
ElNotification.error({title: '操作失败', message: res.msg});
|
ElNotification.error({title: '操作失败', message: res.msg});
|
||||||
return Promise.reject(res)
|
return Promise.reject(res)
|
||||||
} else if (res.code == 2) { // 权限不足拦截
|
} else if (res.code == 500) { // 权限不足拦截
|
||||||
ElNotification.error({title: '权限不足', message: res.msg});
|
ElNotification.error({title: '权限不足', message: res.msg});
|
||||||
return Promise.reject(res)
|
return Promise.reject(res)
|
||||||
} else { // 登录失效拦截
|
} else { // 登录失效拦截
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,12 @@ const tools = {
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return [null, err]
|
return [null, err]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
crypto: {
|
||||||
|
//MD5加密
|
||||||
|
MD5(data){
|
||||||
|
return CryptoJS.MD5(data).toString()
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
<template>
|
|
||||||
<el-container>
|
|
||||||
<el-header style="height:50px;">
|
|
||||||
<div class="common-header-left">
|
|
||||||
<div class="common-header-logo">
|
|
||||||
<img :alt="$CONFIG.APP_NAME" src="img/logo.png">
|
|
||||||
<label>{{$CONFIG.APP_NAME}}</label>
|
|
||||||
</div>
|
|
||||||
<div class="common-header-title">{{title}}</div>
|
|
||||||
</div>
|
|
||||||
<div class="common-header-right">
|
|
||||||
<router-link to="/login">{{$t('login.back_login')}}</router-link>
|
|
||||||
</div>
|
|
||||||
</el-header>
|
|
||||||
<el-main>
|
|
||||||
<div class="common-container">
|
|
||||||
<h2 class="common-title">{{title}}</h2>
|
|
||||||
<div class="common-main el-card">
|
|
||||||
<slot></slot>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</el-main>
|
|
||||||
</el-container>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
props: {
|
|
||||||
title: { type: String, default: "" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
</style>
|
|
||||||
|
|
@ -1,130 +0,0 @@
|
||||||
<template>
|
|
||||||
<el-form ref="loginForm" :model="form" :rules="rules" label-width="0" size="large">
|
|
||||||
<el-form-item prop="user">
|
|
||||||
<el-input v-model="form.username" prefix-icon="el-icon-user" clearable :placeholder="$t('login.userPlaceholder')"></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item prop="password">
|
|
||||||
<el-input v-model="form.password" prefix-icon="el-icon-lock" clearable show-password :placeholder="$t('login.PWPlaceholder')"></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item prop="veryCode">
|
|
||||||
<el-input v-model="form.code" prefix-icon="el-icon-iphone" clearable :placeholder="$t('login.codePlaceholder')">
|
|
||||||
<template #append>
|
|
||||||
<el-image :src="verImage" @click="getCode" style="padding: 1px;"/>
|
|
||||||
</template>
|
|
||||||
</el-input>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item style="margin-bottom: 10px;">
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-checkbox :label="$t('login.rememberMe')" v-model="form.autologin"></el-checkbox>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="12" class="login-forgot">
|
|
||||||
<router-link to="/reset_password">{{ $t('login.forgetPassword') }}?</router-link>
|
|
||||||
</el-col>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item>
|
|
||||||
<el-button type="primary" style="width: 100%;" :loading="islogin" round @click="login">{{ $t('login.signIn') }}</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts" setup>
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
|
|
||||||
export default {
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
form: {
|
|
||||||
username: "",
|
|
||||||
password: "",
|
|
||||||
code: "",
|
|
||||||
uuid: "",
|
|
||||||
autologin: false
|
|
||||||
},
|
|
||||||
verImage: '',
|
|
||||||
rules: {
|
|
||||||
username: [
|
|
||||||
{required: true, message: this.$t('login.userError'), trigger: 'blur'}
|
|
||||||
],
|
|
||||||
password: [
|
|
||||||
{required: true, message: this.$t('login.PWError'), trigger: 'blur'}
|
|
||||||
],
|
|
||||||
code: [
|
|
||||||
{required: true, message: this.$t('login.codeError'), trigger: 'blur'}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
islogin: false,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.getCode()
|
|
||||||
this.rememberMe()
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
rememberMe() {
|
|
||||||
const data = this.$TOOLS.data.get("ACCOUNT")
|
|
||||||
if (data) {
|
|
||||||
this.form.username = data.username
|
|
||||||
this.form.password = data.password
|
|
||||||
this.form.autologin = true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
async getCode() {
|
|
||||||
// const res = await this.$API.auth.verify();
|
|
||||||
// this.form.uuid = res.data.uuid
|
|
||||||
// this.verImage = res.data.image
|
|
||||||
this.form.code = "";
|
|
||||||
},
|
|
||||||
async login(){
|
|
||||||
// 校验登录
|
|
||||||
const validate = await this.$refs.loginForm.validate().catch(() => {});
|
|
||||||
if(!validate){ return false }
|
|
||||||
|
|
||||||
this.islogin = true
|
|
||||||
const data = {
|
|
||||||
username: this.form.username,
|
|
||||||
password: this.$TOOL.crypto.MD5(this.form.password),
|
|
||||||
uuid: this.form.uuid,
|
|
||||||
code: this.form.code
|
|
||||||
};
|
|
||||||
// 登录接口
|
|
||||||
const [res, err] = await this.$TOOLS.go(this.$API.auth.token(data))
|
|
||||||
this.islogin = false
|
|
||||||
if (err) {
|
|
||||||
await this.getCode();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
this.$TOOL.data.set("TOKEN", res.data.token, res.data.expireIn)
|
|
||||||
// 记住密码
|
|
||||||
if (this.form.autologin) {
|
|
||||||
this.$TOOL.data.set("ACCOUNT", {
|
|
||||||
username: this.form.username,
|
|
||||||
password: this.form.password
|
|
||||||
})
|
|
||||||
}
|
|
||||||
// 获取账号信息
|
|
||||||
await this.getInfo()
|
|
||||||
// 获取菜单信息
|
|
||||||
// await this.getMenu()
|
|
||||||
},
|
|
||||||
async getInfo() {
|
|
||||||
const [res, err] = await this.$TOOLS.go(this.$API.auth.getAccountInfo())
|
|
||||||
if (err) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
this.$TOOL.data.set("USER_INFO", res.data)
|
|
||||||
// 登录成功跳转首页
|
|
||||||
this.$router.replace({path: '/'})
|
|
||||||
this.$message.success("Login Success 登录成功")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
:deep(.el-input-group__append, .el-input-group__prepend) {
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
@ -1,151 +0,0 @@
|
||||||
<template>
|
|
||||||
<sc-dialog v-model="showWechatLogin" title="扫码登录" :width="400" destroy-on-close :showFullscreen="false" @closed="$emit('closed')">
|
|
||||||
<div class="qrCodeLogin">
|
|
||||||
<sc-qr-code class="qrCode" :text="wechatLoginCode" :size="200"></sc-qr-code>
|
|
||||||
<p class="msg">{{wechatLoginMsg}}</p>
|
|
||||||
<div class="qrCodeLogin-result" v-if="isWechatLoginResult">
|
|
||||||
<el-result v-if="loading" icon="success" :sub-title="wechatLoginMsg"></el-result>
|
|
||||||
<el-result v-else icon="error" :sub-title="wechatLoginMsg">
|
|
||||||
<template #extra>
|
|
||||||
<el-button type="primary" link @click="reGetCode()">重新获取</el-button>
|
|
||||||
</template>
|
|
||||||
</el-result>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</sc-dialog>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: "wechatLogin",
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
showWechatLogin: false,
|
|
||||||
wechatLoginCode: "",
|
|
||||||
isWechatLoginResult: false,
|
|
||||||
wechatLoginMsg: "",
|
|
||||||
t1: null,
|
|
||||||
loading: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
unmounted() {
|
|
||||||
this.clearTimer()
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
open() {
|
|
||||||
this.getLogin()
|
|
||||||
this.showWechatLogin = true;
|
|
||||||
return this
|
|
||||||
},
|
|
||||||
reGetCode() {
|
|
||||||
this.isWechatLoginResult = false
|
|
||||||
this.wechatLoginCode = ""
|
|
||||||
this.wechatLoginMsg = ""
|
|
||||||
this.loading = true
|
|
||||||
this.getLogin()
|
|
||||||
},
|
|
||||||
async getLogin() {
|
|
||||||
if (!this.wechatLoginCode) {
|
|
||||||
await this.getCode()
|
|
||||||
}
|
|
||||||
const that = this;
|
|
||||||
that.t1 = setInterval(async ()=>{
|
|
||||||
const res = await that.$API.auth.getQrCode({qrcode: this.wechatLoginCode});
|
|
||||||
that.wechatLoginMsg = res.msg
|
|
||||||
if (res.data.state == 1) { // 已扫码待授权
|
|
||||||
that.isWechatLoginResult = true
|
|
||||||
that.loading = true
|
|
||||||
}else if(res.data.state == 2) { // 授权成功
|
|
||||||
that.isWechatLoginResult = true
|
|
||||||
that.loading = true
|
|
||||||
that.clearTimer()
|
|
||||||
// 登录
|
|
||||||
this.$TOOL.data.set("TOKEN", res.data.token, res.data.expireIn)
|
|
||||||
// 获取账号信息
|
|
||||||
await this.getInfo()
|
|
||||||
// 获取菜单信息
|
|
||||||
await this.getMenu()
|
|
||||||
}else if(res.data.state == 3) { // 已过期
|
|
||||||
that.clearTimer()
|
|
||||||
that.isWechatLoginResult = true
|
|
||||||
that.loading = false
|
|
||||||
}else {
|
|
||||||
that.isWechatLoginResult = false
|
|
||||||
that.loading = true
|
|
||||||
}
|
|
||||||
},1000)
|
|
||||||
},
|
|
||||||
clearTimer() {
|
|
||||||
clearInterval(this.t1)
|
|
||||||
this.t1 = null
|
|
||||||
},
|
|
||||||
async getCode() {
|
|
||||||
const res = await this.$API.auth.qrcode();
|
|
||||||
this.wechatLoginCode = res.data.qrcode
|
|
||||||
this.wechatLoginMsg = res.msg
|
|
||||||
},
|
|
||||||
async getInfo() {
|
|
||||||
const [res, err] = await this.$TOOL.go(this.$API.auth.getAccountInfo())
|
|
||||||
if (err) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
this.$TOOL.data.set("USER_INFO", res.data)
|
|
||||||
},
|
|
||||||
async getMenu() {
|
|
||||||
const [res, err] = await this.$TOOL.go(this.$API.auth.getMenuInfo())
|
|
||||||
if (err) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if(res.data.menus.length===0){
|
|
||||||
this.islogin = false
|
|
||||||
this.$alert("当前用户无任何菜单权限,请联系系统管理员", "无权限访问", {
|
|
||||||
type: 'error',
|
|
||||||
center: true
|
|
||||||
})
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
this.$TOOLS.data.set("MENU", this.makeMenu(res.data.menus, 0))
|
|
||||||
this.$TOOL.data.set("PERMISSIONS", res.data.buttons)
|
|
||||||
this.$TOOL.data.set("ROLE", res.data.roles)
|
|
||||||
// 登录成功跳转首页
|
|
||||||
this.$router.replace({
|
|
||||||
path: '/'
|
|
||||||
})
|
|
||||||
this.$message.success("Login Success 登录成功")
|
|
||||||
},
|
|
||||||
makeMenu(menus, parent_id = 0) {
|
|
||||||
const arr = [];
|
|
||||||
for (let item of menus) {
|
|
||||||
if(item.parent_id === parent_id){
|
|
||||||
// 数据格式处理
|
|
||||||
const tmp = {
|
|
||||||
name: item['name'],
|
|
||||||
path: '/' + item['path'],
|
|
||||||
component: item['path'],
|
|
||||||
meta: {
|
|
||||||
'title': item['title'],
|
|
||||||
'icon': item['icon'],
|
|
||||||
'hidden': item['hidden'],
|
|
||||||
'type': 'menu'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const children = this.makeMenu(menus, item.menu_id);
|
|
||||||
if (children.length > 0) {
|
|
||||||
tmp['children'] = children
|
|
||||||
}
|
|
||||||
arr.push(tmp)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return arr
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.qrCodeLogin {text-align: center;position: relative;padding: 20px 0;}
|
|
||||||
.qrCodeLogin img.qrCode {background: #fff;padding:20px;border-radius:10px;}
|
|
||||||
.qrCodeLogin p.msg {margin-top: 15px;}
|
|
||||||
.qrCodeLogin .qrCodeLogin-result {position: absolute;top:0;left:0;right: 0;bottom: 0;text-align: center;background: var(--el-bg-color);}
|
|
||||||
</style>
|
|
||||||
|
|
@ -4,14 +4,26 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="login_main">
|
<div class="login_main">
|
||||||
<div class="login_config">
|
<div class="login_config">
|
||||||
<el-button :icon="config.dark?'el-icon-sunny':'el-icon-moon'" circle type="info" @click="configDark"></el-button>
|
<el-button :icon="config.dark?'el-icon-sunny':'el-icon-moon'" circle type="info"
|
||||||
|
@click="configDark"></el-button>
|
||||||
<el-dropdown trigger="click" placement="bottom-end" @command="configLang">
|
<el-dropdown trigger="click" placement="bottom-end" @command="configLang">
|
||||||
<el-button circle>
|
<el-button circle>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 512 512"><path d="M478.33 433.6l-90-218a22 22 0 0 0-40.67 0l-90 218a22 22 0 1 0 40.67 16.79L316.66 406h102.67l18.33 44.39A22 22 0 0 0 458 464a22 22 0 0 0 20.32-30.4zM334.83 362L368 281.65L401.17 362z" fill="currentColor"></path><path d="M267.84 342.92a22 22 0 0 0-4.89-30.7c-.2-.15-15-11.13-36.49-34.73c39.65-53.68 62.11-114.75 71.27-143.49H330a22 22 0 0 0 0-44H214V70a22 22 0 0 0-44 0v20H54a22 22 0 0 0 0 44h197.25c-9.52 26.95-27.05 69.5-53.79 108.36c-31.41-41.68-43.08-68.65-43.17-68.87a22 22 0 0 0-40.58 17c.58 1.38 14.55 34.23 52.86 83.93c.92 1.19 1.83 2.35 2.74 3.51c-39.24 44.35-77.74 71.86-93.85 80.74a22 22 0 1 0 21.07 38.63c2.16-1.18 48.6-26.89 101.63-85.59c22.52 24.08 38 35.44 38.93 36.1a22 22 0 0 0 30.75-4.9z" fill="currentColor"></path></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet"
|
||||||
|
viewBox="0 0 512 512">
|
||||||
|
<path
|
||||||
|
d="M478.33 433.6l-90-218a22 22 0 0 0-40.67 0l-90 218a22 22 0 1 0 40.67 16.79L316.66 406h102.67l18.33 44.39A22 22 0 0 0 458 464a22 22 0 0 0 20.32-30.4zM334.83 362L368 281.65L401.17 362z"
|
||||||
|
fill="currentColor"></path>
|
||||||
|
<path
|
||||||
|
d="M267.84 342.92a22 22 0 0 0-4.89-30.7c-.2-.15-15-11.13-36.49-34.73c39.65-53.68 62.11-114.75 71.27-143.49H330a22 22 0 0 0 0-44H214V70a22 22 0 0 0-44 0v20H54a22 22 0 0 0 0 44h197.25c-9.52 26.95-27.05 69.5-53.79 108.36c-31.41-41.68-43.08-68.65-43.17-68.87a22 22 0 0 0-40.58 17c.58 1.38 14.55 34.23 52.86 83.93c.92 1.19 1.83 2.35 2.74 3.51c-39.24 44.35-77.74 71.86-93.85 80.74a22 22 0 1 0 21.07 38.63c2.16-1.18 48.6-26.89 101.63-85.59c22.52 24.08 38 35.44 38.93 36.1a22 22 0 0 0 30.75-4.9z"
|
||||||
|
fill="currentColor"></path>
|
||||||
|
</svg>
|
||||||
</el-button>
|
</el-button>
|
||||||
<template #dropdown>
|
<template #dropdown>
|
||||||
<el-dropdown-menu>
|
<el-dropdown-menu>
|
||||||
<el-dropdown-item v-for="item in lang" :key="item.value" :command="item" :class="{'selected':config.lang==item.value}">{{item.name}}</el-dropdown-item>
|
<el-dropdown-item v-for="item in lang" :key="item.value" :command="item"
|
||||||
|
:class="{'selected':config.lang==item.value}">{{ item.name }}
|
||||||
|
</el-dropdown-item>
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
</template>
|
</template>
|
||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
|
|
@ -19,40 +31,64 @@
|
||||||
<div class="login-form">
|
<div class="login-form">
|
||||||
<div class="login-header">
|
<div class="login-header">
|
||||||
<div class="logo">
|
<div class="logo">
|
||||||
<img :alt="$CONFIG.APP_NAME" src="./images/logo.png">
|
<img :alt="sysConfig.APP_NAME" :src="'./images/logo.png'">
|
||||||
<label>{{$CONFIG.APP_NAME}}</label>
|
<label>{{ sysConfig.APP_NAME }}</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<password-form></password-form>
|
<el-form ref="loginForm" :model="form" :rules="rules" label-width="0" size="large">
|
||||||
<template v-if="$CONFIG.MY_SHOW_LOGIN_OAUTH">
|
<el-form-item prop="user">
|
||||||
<el-divider>{{ $t('login.signInOther') }}</el-divider>
|
<el-input v-model="form.username" prefix-icon="el-icon-user" clearable
|
||||||
<div class="login-oauth">
|
:placeholder="t('login.userPlaceholder')"></el-input>
|
||||||
<el-button type="success" icon="sc-icon-wechat" circle @click="wechatLogin"></el-button>
|
</el-form-item>
|
||||||
</div>
|
<el-form-item prop="password">
|
||||||
|
<el-input v-model="form.password" prefix-icon="el-icon-lock" clearable show-password
|
||||||
|
:placeholder="t('login.PWPlaceholder')"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item prop="veryCode">
|
||||||
|
<el-input v-model="form.code" prefix-icon="el-icon-iphone" clearable
|
||||||
|
:placeholder="t('login.codePlaceholder')">
|
||||||
|
<template #append>
|
||||||
|
<el-image :src="verImage" @click="getCode" style="padding: 1px;"/>
|
||||||
</template>
|
</template>
|
||||||
|
</el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item style="margin-bottom: 10px;">
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-checkbox :label="t('login.rememberMe')" v-model="form.autologin"></el-checkbox>
|
||||||
|
</el-col>
|
||||||
|
<!-- <el-col :span="12" class="login-forgot">-->
|
||||||
|
<!-- <router-link to="/reset_password">{{ t('login.forgetPassword') }}?</router-link>-->
|
||||||
|
<!-- </el-col>-->
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" style="width: 100%;" :loading="isLogin" round @click="login">
|
||||||
|
{{ t('login.signIn') }}
|
||||||
|
</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<wechat-dialog v-if="showWechatLogin" ref="wechatDialog" @closed="showWechatLogin=false"/>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup name="Login">
|
||||||
import passwordForm from './components/passwordForm'
|
import {getCurrentInstance, ref, onMounted, watch} from 'vue'
|
||||||
import wechatDialog from './components/wechatLogin'
|
import {useI18n} from 'vue-i18n'
|
||||||
|
import {useRouter} from 'vue-router';
|
||||||
|
import tools from "@/utils/tools.js";
|
||||||
|
import sysConfig from "@/config/index.js";
|
||||||
|
import api from "@/api/index.js";
|
||||||
|
|
||||||
export default {
|
const {proxy} = getCurrentInstance();
|
||||||
name: "login",
|
const {t, locale} = useI18n()
|
||||||
components: {
|
const router = useRouter();
|
||||||
passwordForm,
|
|
||||||
wechatDialog
|
let config = ref({
|
||||||
},
|
lang: tools.data.get('APP_LANG') || sysConfig.LANG,
|
||||||
data() {
|
dark: tools.data.get('APP_DARK') || false
|
||||||
return {
|
})
|
||||||
config: {
|
|
||||||
lang: this.$TOOLS.data.get('APP_LANG') || this.$CONFIG.LANG,
|
const lang = ref([
|
||||||
dark: this.$TOOLS.data.get('APP_DARK') || false
|
|
||||||
},
|
|
||||||
lang: [
|
|
||||||
{
|
{
|
||||||
name: '简体中文',
|
name: '简体中文',
|
||||||
value: 'zh-cn',
|
value: 'zh-cn',
|
||||||
|
|
@ -61,85 +97,218 @@
|
||||||
name: 'English',
|
name: 'English',
|
||||||
value: 'en',
|
value: 'en',
|
||||||
}
|
}
|
||||||
|
])
|
||||||
|
|
||||||
|
let form = ref({
|
||||||
|
username: "",
|
||||||
|
password: "",
|
||||||
|
code: "",
|
||||||
|
uuid: "",
|
||||||
|
autologin: false
|
||||||
|
})
|
||||||
|
let verImage = ref("")
|
||||||
|
const rules = ref({
|
||||||
|
username: [
|
||||||
|
{required: true, message: t('login.userError'), trigger: 'blur'}
|
||||||
],
|
],
|
||||||
showWechatLogin: false
|
password: [
|
||||||
}
|
{required: true, message: t('login.PWError'), trigger: 'blur'}
|
||||||
},
|
],
|
||||||
watch:{
|
code: [
|
||||||
'config.dark'(val){
|
{required: true, message: t('login.codeError'), trigger: 'blur'}
|
||||||
if(val){
|
]
|
||||||
|
})
|
||||||
|
let isLogin = ref(false);
|
||||||
|
|
||||||
|
// mounted
|
||||||
|
onMounted(() => {
|
||||||
|
getCode()
|
||||||
|
rememberMe()
|
||||||
|
})
|
||||||
|
|
||||||
|
watch(() => config.value.dark, (val) => {
|
||||||
|
if (val) {
|
||||||
document.documentElement.classList.add("dark")
|
document.documentElement.classList.add("dark")
|
||||||
this.$TOOLS.data.set("APP_DARK", val)
|
tools.data.set("APP_DARK", val)
|
||||||
}else{
|
} else {
|
||||||
document.documentElement.classList.remove("dark")
|
document.documentElement.classList.remove("dark")
|
||||||
this.$TOOLS.data.remove("APP_DARK")
|
tools.data.remove("APP_DARK")
|
||||||
}
|
}
|
||||||
},
|
})
|
||||||
'config.lang'(val){
|
|
||||||
this.$i18n.locale = val
|
watch(() => config.value.lang, (val) => {
|
||||||
this.$TOOLS.data.set("APP_LANG", val)
|
locale.value = val
|
||||||
|
tools.data.set("APP_LANG", val)
|
||||||
|
})
|
||||||
|
|
||||||
|
function rememberMe() {
|
||||||
|
const data = tools.data.get("ACCOUNT")
|
||||||
|
if (data) {
|
||||||
|
form.value.username = data.username
|
||||||
|
form.value.password = data.password
|
||||||
|
form.value.autologin = true
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
methods: {
|
|
||||||
configDark(){
|
async function getCode() {
|
||||||
this.config.dark = this.config.dark ? false : true
|
const res = await api.auth.captcha();
|
||||||
},
|
form.value.uuid = res.data.uuid
|
||||||
configLang(command){
|
verImage.value = res.data.image
|
||||||
this.config.lang = command.value
|
form.value.code = "";
|
||||||
},
|
}
|
||||||
wechatLogin(){
|
|
||||||
this.showWechatLogin = true
|
async function login() {
|
||||||
this.$nextTick(() => {
|
// 校验登录
|
||||||
this.$refs.wechatDialog.open()
|
const validate = await proxy.$refs.loginForm.validate().catch(() => {
|
||||||
|
});
|
||||||
|
if (!validate) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
isLogin.value = true
|
||||||
|
const data = {
|
||||||
|
username: form.value.username,
|
||||||
|
password: tools.crypto.MD5(form.value.password),
|
||||||
|
uuid: form.value.uuid,
|
||||||
|
code: form.value.code
|
||||||
|
};
|
||||||
|
// 登录接口
|
||||||
|
const [res, err] = await tools.go(api.auth.login(data))
|
||||||
|
isLogin.value = false
|
||||||
|
if (err) {
|
||||||
|
await getCode();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
tools.data.set("TOKEN", res.data.token, res.data.expireIn)
|
||||||
|
// 记住密码
|
||||||
|
if (form.value.autologin) {
|
||||||
|
tools.data.set("ACCOUNT", {
|
||||||
|
username: form.value.username,
|
||||||
|
password: form.value.password
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
// 获取账号信息
|
||||||
|
await getInfo()
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getInfo() {
|
||||||
|
const [res, err] = await tools.go(api.auth.getAccountInfo())
|
||||||
|
if (err) {
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
}
|
tools.data.set("USER_INFO", res.data)
|
||||||
|
// 登录成功跳转首页
|
||||||
|
router.replace({path: '/'})
|
||||||
|
proxy.$message.success("Login Success 登录成功")
|
||||||
|
}
|
||||||
|
|
||||||
|
function configDark() {
|
||||||
|
config.value.dark = !config.value.dark
|
||||||
|
}
|
||||||
|
function configLang(command) {
|
||||||
|
config.value.lang = command.value
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.login_bg {width: 100%;height: 100%;background: #fff;display: flex;}
|
.login_bg {
|
||||||
.login_adv {width: 33.3333%;background-color: #555;background-size: cover;background-repeat: no-repeat;position: relative;}
|
width: 100%;
|
||||||
.login_adv__title {color: #fff;padding: 40px;position: absolute;top:0px;left:0px;right: 0px;z-index: 2;}
|
height: 100%;
|
||||||
.login_adv__title h2 {font-size: 40px;}
|
background: #fff;
|
||||||
.login_adv__title h4 {font-size: 18px;margin-top: 10px;font-weight: normal;}
|
display: flex;
|
||||||
.login_adv__title p {font-size: 14px;margin-top:10px;line-height: 1.8;color: rgba(255,255,255,0.6);}
|
}
|
||||||
.login_adv__title div {margin-top: 10px;display: flex;align-items: center;}
|
|
||||||
.login_adv__title div span {margin-right: 15px;}
|
|
||||||
.login_adv__title div i {font-size: 40px;}
|
|
||||||
.login_adv__title div i.add {font-size: 20px;color: rgba(255,255,255,0.6);}
|
|
||||||
.login_adv__bottom {position: absolute;left:0px;right: 0px;bottom: 0px;color: #fff;padding: 40px;z-index: 3;}
|
|
||||||
.login_adv__mask {position: absolute;top:0px;left:0px;right: 0px;bottom: 0px;z-index: 1;}
|
|
||||||
|
|
||||||
.login_main {flex: 1;overflow: auto;display:flex;}
|
.login_adv {
|
||||||
.login-form {width: 400px;margin: auto;padding:20px 0;}
|
width: 33.3333%;
|
||||||
.login-header {margin-bottom: 40px;}
|
background-color: #555;
|
||||||
.login-header .logo {display: flex;align-items: center;}
|
background-size: cover;
|
||||||
.login-header .logo img {width: 40px;height: 40px;vertical-align: bottom;margin-right: 10px;}
|
background-repeat: no-repeat;
|
||||||
.login-header .logo label {font-size: 26px;font-weight: bold;}
|
position: relative;
|
||||||
.login-oauth {display: flex;justify-content:space-around;}
|
}
|
||||||
.login-form .el-divider {margin-top:40px;}
|
|
||||||
|
|
||||||
.login-form {}
|
.login_main {
|
||||||
.login-form:deep(.el-tabs) .el-tabs__header {margin-bottom: 25px;}
|
flex: 1;
|
||||||
.login-form:deep(.el-tabs) .el-tabs__header .el-tabs__item {font-size: 14px;}
|
overflow: auto;
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
.login-form:deep(.login-forgot) {text-align: right;}
|
.login-form {
|
||||||
.login-form:deep(.login-forgot) a {color: var(--el-color-primary);}
|
width: 400px;
|
||||||
.login-form:deep(.login-forgot) a:hover {color: var(--el-color-primary-light-3);}
|
margin: auto;
|
||||||
|
padding: 20px 0;
|
||||||
|
}
|
||||||
|
|
||||||
.login_config {position: absolute;top:20px;right: 20px;}
|
.login-header {
|
||||||
|
margin-bottom: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
.login-form:deep(.login-msg-yzm) {display: flex;width: 100%;}
|
.login-header .logo {
|
||||||
.login-form:deep(.login-msg-yzm) .el-button {margin-left: 10px;--el-button-size:42px;}
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 1200px){
|
.login-header .logo img {
|
||||||
.login-form {width: 340px;}
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
vertical-align: bottom;
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-header .logo label {
|
||||||
|
font-size: 26px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-form:deep(.login-forgot) {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-form:deep(.login-forgot) a {
|
||||||
|
color: var(--el-color-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-form:deep(.login-forgot) a:hover {
|
||||||
|
color: var(--el-color-primary-light-3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.login_config {
|
||||||
|
position: absolute;
|
||||||
|
top: 20px;
|
||||||
|
right: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-form:deep(.login-msg-yzm) {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1200px) {
|
||||||
|
.login-form {
|
||||||
|
width: 340px;
|
||||||
}
|
}
|
||||||
@media (max-width: 1000px){
|
}
|
||||||
.login_main {display: block;}
|
|
||||||
.login_main .login_config {position: static;padding:20px 20px 0 20px;text-align: right;}
|
@media (max-width: 1000px) {
|
||||||
.login-form {width:100%;padding:20px 40px;}
|
.login_main {
|
||||||
.login_adv {display: none;}
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.login_main .login_config {
|
||||||
|
position: static;
|
||||||
|
padding: 20px 20px 0 20px;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-form {
|
||||||
|
width: 100%;
|
||||||
|
padding: 20px 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login_adv {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.el-input-group__append, .el-input-group__prepend) {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
// 如果使用 Vite 4+ 推荐官方类型
|
// 如果使用 Vite 4+ 推荐官方类型
|
||||||
interface ImportMeta {
|
interface ImportMeta {
|
||||||
|
readonly env: ImportMetaEnv
|
||||||
readonly glob: (
|
readonly glob: (
|
||||||
pattern: string,
|
pattern: string,
|
||||||
options?: { eager?: boolean; import?: string, query?: string }
|
options?: { eager?: boolean; import?: string, query?: string }
|
||||||
|
|
@ -11,10 +12,6 @@ interface ImportMetaEnv {
|
||||||
readonly VITE_APP_TITLE: string
|
readonly VITE_APP_TITLE: string
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ImportMeta {
|
|
||||||
readonly env: ImportMetaEnv
|
|
||||||
}
|
|
||||||
|
|
||||||
declare module '*.vue' {
|
declare module '*.vue' {
|
||||||
import type { DefineComponent } from 'vue'
|
import type { DefineComponent } from 'vue'
|
||||||
const component: DefineComponent<{}, {}, any>
|
const component: DefineComponent<{}, {}, any>
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,10 @@ export default defineConfig(({mode, command}) => {
|
||||||
host: true,
|
host: true,
|
||||||
// open: true,
|
// open: true,
|
||||||
proxy: {
|
proxy: {
|
||||||
'/api': {
|
'/dev-api': {
|
||||||
target: 'https://mock.apipost.net/mock/2a749651c864000/',
|
target: 'https://dev.api.leapy.cn/merchant/',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
rewrite: (p) => p.replace(/^\/api/, '')
|
rewrite: (p) => p.replace(/^\/dev-api/, '')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue