Files
intc-vue-h5/src/pages/register.vue
2026-07-12 14:23:18 +08:00

306 lines
7.7 KiB
Vue

<template>
<view class="register-container">
<view class="background-decoration"></view>
<view class="header-section">
<text class="page-title">用户注册</text>
<text class="page-subtitle">创建你的账号</text>
</view>
<view class="form-section">
<view class="form-card">
<uni-forms ref="form" :value="user" labelWidth="80px">
<uni-forms-item name="username" required label="账号">
<uni-easyinput v-model="user.username" placeholder="请输入账号" />
</uni-forms-item>
<uni-forms-item name="password" required label="密码">
<uni-easyinput type="password" v-model="user.password" placeholder="请输入密码" />
</uni-forms-item>
<uni-forms-item name="confirmPassword" required label="确认密码">
<uni-easyinput type="password" v-model="user.confirmPassword" placeholder="请确认密码" />
</uni-forms-item>
</uni-forms>
<view class="tips-card">
<view class="tips-header">
<uni-icons type="info" size="16" color="#E8841A"></uni-icons>
<text class="tips-title">密码要求</text>
</view>
<view class="tips-list">
<view class="tip-item">
<text class="tip-dot"></text>
<text class="tip-text">账号长度为 6-20 个字符</text>
</view>
<view class="tip-item">
<text class="tip-dot"></text>
<text class="tip-text">密码长度为 8-20 个字符</text>
</view>
<view class="tip-item">
<text class="tip-dot"></text>
<text class="tip-text">必须同时包含大写字母小写字母数字和特殊字符</text>
</view>
<view class="tip-item">
<text class="tip-dot"></text>
<text class="tip-text">密码不能包含空格</text>
</view>
<view class="tip-item">
<text class="tip-dot"></text>
<text class="tip-text">两次密码输入必须一致</text>
</view>
</view>
</view>
<view class="action-btn">
<button class="register-btn" @click="handleRegister">
<text class="btn-text">立即注册</text>
</button>
</view>
</view>
</view>
<view class="footer-section">
<text class="copyright-text">Copyright © {{ currentYear }} qdintc All Rights Reserved.</text>
</view>
<u-toast ref="uToast"></u-toast>
</view>
</template>
<script>
import { register } from "@/api/login"
import { validatePassword } from "@/utils/validate"
export default {
data() {
return {
// 动态显示当前年份
currentYear: new Date().getFullYear(),
user: {
username: '',
password: '',
resource: '1',
confirmPassword: '',
code: '',
uuid: ''
},
rules: {
username: {
rules: [{
required: true,
errorMessage: '账号不能为空',
},
{
minLength: 6,
maxLength: 20,
errorMessage: '账号长度在 6 到 20 个字符'
}
]
},
password: {
rules: [{
required: true,
errorMessage: '密码不能为空',
},
{
validateFunction: (rule, value) => validatePassword(value).valid,
errorMessage: '密码需 8-20 位,且须同时含大小写字母、数字和特殊字符'
}
]
},
confirmPassword: {
rules: [{
required: true,
errorMessage: '确认密码不能为空'
}, {
validateFunction: (rule, value, data) => data.password === value,
errorMessage: '两次输入的密码不一致'
}
]
}
}
}
},
onReady() {
this.$refs.form.setRules(this.rules)
},
methods: {
handleRegister() {
this.$refs.form.validate().then(res => {
register(this.user)
.then((res) => {
uni.showToast({
title: '注册成功,请登录',
icon: 'success',
duration: 2000
});
uni.navigateTo({ url: `/pages/login` })
})
})
}
}
}
</script>
<style lang="scss" scoped>
page {
background: linear-gradient(160deg, #FFF3D6 0%, #FFE0A0 60%, #FFCC6E 100%);
min-height: 100%;
height: 100%;
}
.register-container {
min-height: 100vh;
background: linear-gradient(160deg, #FFF3D6 0%, #FFE0A0 60%, #FFCC6E 100%);
display: flex;
flex-direction: column;
position: relative;
.background-decoration {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: radial-gradient(circle at top right, rgba(255, 255, 255, 0.35) 0%, transparent 60%);
pointer-events: none;
}
.header-section {
padding: 100rpx 48rpx 60rpx;
position: relative;
z-index: 1;
.page-title {
display: block;
font-size: 48rpx;
font-weight: 700;
color: #8B4500;
margin-bottom: 12rpx;
}
.page-subtitle {
display: block;
font-size: 26rpx;
color: rgba(139, 69, 0, 0.65);
}
}
.form-section {
flex: 1;
padding: 0 48rpx 32rpx;
position: relative;
z-index: 1;
overflow-y: auto;
overflow-x: hidden;
min-height: 0;
/* 隐藏滚动条 */
&::-webkit-scrollbar {
display: none !important;
width: 0 !important;
height: 0 !important;
}
scrollbar-width: none !important;
-ms-overflow-style: none !important;
.form-card {
background: #ffffff;
border-radius: 32rpx;
padding: 48rpx 40rpx;
box-shadow: 0 16rpx 48rpx rgba(0, 0, 0, 0.15);
}
}
.tips-card {
background: linear-gradient(135deg, rgba(232, 132, 26, 0.06) 0%, rgba(245, 166, 35, 0.06) 100%);
border-radius: 20rpx;
padding: 24rpx;
margin-top: 32rpx;
border: 2rpx solid rgba(232, 132, 26, 0.2);
}
.tips-header {
display: flex;
align-items: center;
margin-bottom: 16rpx;
.tips-title {
color: #E8841A;
font-size: 26rpx;
font-weight: 600;
margin-left: 8rpx;
}
}
.tips-list {
.tip-item {
display: flex;
align-items: flex-start;
margin-bottom: 8rpx;
&:last-child {
margin-bottom: 0;
}
.tip-dot {
color: #E8841A;
font-size: 24rpx;
margin-right: 8rpx;
line-height: 36rpx;
}
.tip-text {
flex: 1;
color: #606266;
font-size: 24rpx;
line-height: 36rpx;
}
}
}
.action-btn {
margin-top: 48rpx;
.register-btn {
width: 100%;
height: 96rpx;
background: linear-gradient(135deg, #E8841A 0%, #F5A623 100%);
border-radius: 48rpx;
border: none;
box-shadow: 0 12rpx 32rpx rgba(232, 132, 26, 0.4);
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s ease;
&::after {
border: none;
}
&:active {
transform: scale(0.98);
box-shadow: 0 8rpx 24rpx rgba(232, 132, 26, 0.3);
}
.btn-text {
color: #ffffff;
font-size: 32rpx;
font-weight: 600;
}
}
}
.footer-section {
padding: 60rpx 48rpx 80rpx;
text-align: center;
position: relative;
z-index: 1;
.copyright-text {
color: #8B4500;
font-size: 24rpx;
}
}
}
</style>