123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- <template>
- <div>
- <el-form ref="loginRef" :model="loginForm" :rules="loginRules" class="login-form">
- <h3 class="title">{{ title }}</h3>
- <el-form-item prop="username">
- <el-input
- v-model="loginForm.username"
- type="text"
- size="large"
- auto-complete="off"
- placeholder="身份证号"
- >
- <template #prefix>
- <svg-icon icon-class="user" class="el-input__icon input-icon"/>
- </template>
- </el-input>
- </el-form-item>
- <el-form-item prop="password">
- <el-input
- v-model="loginForm.password"
- type="password"
- size="large"
- auto-complete="off"
- placeholder="密码"
- @keyup.enter="handleLogin"
- >
- <template #prefix>
- <svg-icon icon-class="password" class="el-input__icon input-icon"/>
- </template>
- </el-input>
- </el-form-item>
- <el-form-item style="width:100%;">
- <el-button
- :loading="loading"
- size="large"
- type="primary"
- style="width:100%;"
- @click.prevent="handleLogin"
- >
- <span v-if="!loading">登 录</span>
- <span v-else>登 录 中...</span>
- </el-button>
- <el-button @click="forgetPass">忘记密码</el-button>
- <div style="float: right;" v-if="register">
- <router-link class="link-type" :to="'/register'">立即注册</router-link>
- </div>
- </el-form-item>
- </el-form>
- </div>
- </template>
- <script setup>
- import {login} from '@/api/login'
- import useUserStore from '@/store/modules/user'
- import { setToken } from '@/utils/auth'
- const userStore = useUserStore()
- const {proxy} = getCurrentInstance()
- const router = useRouter()
- const route = useRoute()
- const params = route.query
- const loading = ref(false)
- const loginForm = ref({
- username: "",
- password: "",
- loginType: "1",
- rememberMe: false,
- code: "",
- uuid: ""
- })
- const loginRules = {
- username: [{required: true, trigger: "blur", message: "请输入您的身份证号"}],
- password: [{required: true, trigger: "blur", message: "请输入您的密码"}],
- }
- function handleLogin() {
- proxy.$refs.loginRef.validate(valid => {
- if (valid) {
- loading.value = true
- // 调用action的登录方法
- loginForm.value.loginType = "1"
- login(loginForm.value.username, loginForm.value.password, null, null, loginForm.value.loginType).then(resp => {
- setToken(resp.data.access_token)
- router.push({
- path: params.modulePath
- })
- })
- }
- })
- }
- function forgetPass() {
- router.push({
- path : '/xjc-integratedmachine/login/student_forgetpass',
- query:{
- modulePath : params.modulePath
- }
- })
- }
- </script>
- <style scoped>
- </style>
|