登录更改

main
xy 3 weeks ago
parent 0300220d28
commit b1c8859634
  1. 1209
      package-lock.json
  2. 4
      package.json
  3. 16
      src/api/user.ts
  4. 111
      src/layout/loginPage.vue
  5. 2
      tsconfig.json

1209
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -21,7 +21,7 @@
"@kjgl77/datav-vue3": "^1.7.3", "@kjgl77/datav-vue3": "^1.7.3",
"axios": "^1.7.2", "axios": "^1.7.2",
"echarts": "^5.6.0", "echarts": "^5.6.0",
"element-plus": "^2.9.5", "element-plus": "^2.9.6",
"insert-css": "^2.0.0", "insert-css": "^2.0.0",
"lib-flexible": "^0.3.2", "lib-flexible": "^0.3.2",
"pinia": "^2.1.7", "pinia": "^2.1.7",
@ -40,6 +40,8 @@
"postcss-scss": "^4.0.9", "postcss-scss": "^4.0.9",
"px2rem-loader": "^0.1.9", "px2rem-loader": "^0.1.9",
"typescript": "^5.2.2", "typescript": "^5.2.2",
"unplugin-auto-import": "^19.1.1",
"unplugin-vue-components": "^28.4.1",
"vite": "^5.3.1", "vite": "^5.3.1",
"vue-tsc": "^2.0.21" "vue-tsc": "^2.0.21"
} }

@ -0,0 +1,16 @@
import request from '@/utils/request'
export const getCode = (time: any) => {
return request({
url: '/sys/randomImage/' + time,
})
}
// 注册
export const sturegister = (data: any) => {
return request({
url: '/sys/user/sturegister',
method: 'POST',
data,
})
}

@ -6,43 +6,49 @@
<div class="main-content"> <div class="main-content">
<el-row style="display: flex; justify-content: center;"> <el-row style="display: flex; justify-content: center;">
<el-col> <el-col>
<el-form :rules="rules" :model="formModel" ref="formRef" size="large" autocomplete="off" <el-form style="margin-top: 40px;" :rules="rules" :model="formModel" ref="formRef" size="large" autocomplete="off"
v-if="isRegister"> v-if="isRegister">
<el-form-item prop="username"> <el-form-item prop="username">
<el-input v-model="formModel.username" :prefix-icon="User" placeholder="请输入账号"></el-input> <el-input v-model="formModel.username" :prefix-icon="User" placeholder="请输入账号"></el-input>
</el-form-item> </el-form-item>
<el-form-item prop="studentNumb"> <el-form-item prop="workno">
<el-input v-model="formModel.studentNumb" :prefix-icon="Avatar" <el-input v-model="formModel.workno" :prefix-icon="Avatar" placeholder="请输入学号"></el-input>
placeholder="请输入学号"></el-input>
</el-form-item> </el-form-item>
<el-form-item prop="name"> <el-form-item prop="realname">
<el-input v-model="formModel.name" :prefix-icon="Stamp" placeholder="请输入姓名"></el-input> <el-input v-model="formModel.realname" :prefix-icon="Stamp" placeholder="请输入姓名"></el-input>
</el-form-item> </el-form-item>
<el-form-item prop="password"> <el-form-item prop="password">
<el-input v-model="formModel.password" :prefix-icon="Lock" type="password" <el-input v-model="formModel.password" :prefix-icon="Lock" type="password"
placeholder="请输入密码"></el-input> placeholder="请输入密码"></el-input>
</el-form-item> </el-form-item>
<el-form-item prop="repassword"> <el-form-item prop="confirmPassword">
<el-input v-model="formModel.repassword" :prefix-icon="Lock" type="password" <el-input v-model="formModel.confirmPassword" :prefix-icon="Lock" type="password"
placeholder="请输入再次密码"></el-input> placeholder="请输入再次密码"></el-input>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<div class="captcha">
<el-input v-model="formModel.smscode" style="height: 0.21rem" maxlength="4"
:prefix-icon="Lock" />
<div class="code" @click="getcodeinfo">
<img :src="codeUrl" alt="" srcset="" />
</div>
</div>
</el-form-item>
<el-form-item style="margin-top: -20px;">
<el-button style="color: #3ad7e2; background-color: #0e2e5e; width: 150px;" class="button" <el-button style="color: #3ad7e2; background-color: #0e2e5e; width: 150px;" class="button"
type="primary" auto-insert-space @click="register"> type="primary" auto-insert-space @click="registered">
注册 注册
</el-button> </el-button>
<el-button style="color: #3ad7e2;background-color: #0e2e5e;width: 150px;" class="button" <el-button style="color: #3ad7e2;background-color: #0e2e5e;width: 150px;" class="button"
type="primary" auto-insert-space @click="isRegister = false"> type="primary" auto-insert-space @click="$emits('backLogin')">
返回到登录页 返回到登录页
</el-button> </el-button>
</el-form-item> </el-form-item>
<el-form-item>
</el-form-item> <!-- <el-form-item class=" flex">
<!-- <el-form-item class="flex"> <el-link type="info" :underline="false" @click="isRegister = false">
<el-link type="info" :underline="false" @click="isRegister = false"> 返回
返回 </el-link>
</el-link>
</el-form-item> --> </el-form-item> -->
</el-form> </el-form>
<el-form :model="formModel" :rules="rules" ref="formRef" size="large" autocomplete="off" v-else <el-form :model="formModel" :rules="rules" ref="formRef" size="large" autocomplete="off" v-else
@ -62,12 +68,12 @@
</div> </div>
</div> </div>
</el-form-item> </el-form-item>
<el-form-item label="学号" prop="studentNumb"> <el-form-item label="学号" prop="workno">
<el-input v-model="formModel.studentNumb" :prefix-icon="Avatar" placeholder="请输入学号"></el-input> <el-input v-model="formModel.workno" :prefix-icon="Avatar" placeholder="请输入学号"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="密码" prop="password"> <el-form-item label="密码" prop="password">
<el-input name="password" :prefix-icon="Lock" type="password" <el-input name="password" :prefix-icon="Lock" type="password" placeholder="请输入密码"
placeholder="请输入密码" v-model="formModel.password"></el-input> v-model="formModel.password"></el-input>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button class="hexagon-button" type="primary" auto-insert-space>登录</el-button> <el-button class="hexagon-button" type="primary" auto-insert-space>登录</el-button>
@ -92,16 +98,18 @@ import settingStore from "@/store/modules/setting";
import { User, Lock, Avatar, Stamp } from '@element-plus/icons-vue' import { User, Lock, Avatar, Stamp } from '@element-plus/icons-vue'
const setting = settingStore(); const setting = settingStore();
console.log(setting.title); console.log(setting.title);
import { ref } from 'vue' import { getCode, sturegister } from '@/api/user'
import { onMounted, reactive, ref, toRefs, watch } from 'vue'
const $emits = defineEmits(['backLogin'])
const isRegister = ref(false) const isRegister = ref(false)
const formRef=ref() const formRef=ref()
const formModel = ref({ const formModel = ref({
username: '', username: '',
studentNumb: '', workno: '',
name: '', realname: '',
password: '', password: '',
repassword: '' confirmPassword: '',
smscode: '',
}) })
// //
const rules = { const rules = {
@ -109,11 +117,11 @@ const rules = {
{ required: true, message: '请输入用户名', trigger: 'blur' }, { required: true, message: '请输入用户名', trigger: 'blur' },
{ min: 5, max: 30, message: '用户名长度最小五位最大三十位', trigger: ['change', 'blur'] } { min: 5, max: 30, message: '用户名长度最小五位最大三十位', trigger: ['change', 'blur'] }
], ],
studentNumb:[ workno:[
{ required: true, message: '请输入学号', trigger: 'blur' }, { required: true, message: '请输入学号', trigger: 'blur' },
{ min: 5, max: 11, message: '学号长度最小五位最大三十位', trigger: ['change', 'blur'] } { min: 5, max: 11, message: '学号长度最小五位最大三十位', trigger: ['change', 'blur'] }
], ],
name: [ realname: [
{ required: true, message: '请输入姓名', trigger: 'blur' }, { required: true, message: '请输入姓名', trigger: 'blur' },
], ],
password: [ password: [
@ -124,7 +132,7 @@ const rules = {
trigger: ['change', 'blur'] trigger: ['change', 'blur']
} }
], ],
repassword: [ confirmPassword: [
{ required: true, message: '请再次输入密码', trigger: 'blur' }, { required: true, message: '请再次输入密码', trigger: 'blur' },
{ {
max: 15, max: 15,
@ -146,10 +154,31 @@ const rules = {
], ],
} }
const register=async()=>{
const registered=async()=>{
await formRef.value.validate() await formRef.value.validate()
console.log('开始注册i请求'); console.log('开始注册请求');
let data = {
// checkKey: 1629428467008,
password: formModel.value.password,
realname: formModel.value.realname,
smscode: formModel.value.smscode,
username: formModel.value.username,
workno: formModel.value.workno,
}
const res: any = await sturegister(data)
if (res.code === 200) {
// ElMessage.success(``)
console.log(res.message);
$emits('backLogin')
} else {
// ElMessage.warning(res.message)
console.log(res.message);
getcodeinfo()
}
console.log(res)
} }
// import { useRouter } from 'vue-router' // import { useRouter } from 'vue-router'
// const router = useRouter() // const router = useRouter()
@ -157,6 +186,24 @@ const register=async()=>{
// router.push('/') // router.push('/')
// } // }
//
const codeUrl = ref('')
const getcodeinfo = async () => {
const res: any = await getCode(1629428467008)
codeUrl.value = res.result
console.log(codeUrl.value)
}
getcodeinfo()
watch(isRegister,()=>{
formModel.value={
password:'' ,
realname: '',
smscode: '',
username: '',
workno: '',
confirmPassword: '',
}
})
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
@ -198,7 +245,7 @@ const register=async()=>{
} }
.hexagon-button { .hexagon-button {
margin-top: 30px; margin-top: 10px;
/* 应用clip-path属性来创建六边形形状 */ /* 应用clip-path属性来创建六边形形状 */
width: 180px; width: 180px;
height: 50px; height: 50px;

@ -7,7 +7,7 @@
"skipLibCheck": true, "skipLibCheck": true,
/* Bundler mode */ /* Bundler mode */
"moduleResolution": "bundler", "moduleResolution": "node",
"allowImportingTsExtensions": true, "allowImportingTsExtensions": true,
"resolveJsonModule": true, "resolveJsonModule": true,
"isolatedModules": true, "isolatedModules": true,

Loading…
Cancel
Save