# Conflicts:
#	frontend/vite.config.js
This commit is contained in:
2025-05-06 15:02:42 +08:00
15 changed files with 935 additions and 32 deletions
+7
View File
@@ -13,6 +13,13 @@
"navigationStyle": "custom"
}
},
{
"path": "pages/login/register",
"style": {
"navigationBarTitleText": "注册",
"navigationStyle": "custom"
}
},
{
"path": "pages/activity/list/index",
"style": {
+1 -1
View File
@@ -2,7 +2,7 @@
<view class="page-container">
<view class="header">
<image class="header-bg"
src="https://erp-bucket.pek3b.qingstor.com/assistant/89c4b573-c54f-467a-b703-0bc44679ab08.png"
src="/static/img/index.png"
mode="aspectFill"></image>
</view>
+13 -6
View File
@@ -109,11 +109,11 @@
立即登录
</view>
<!-- &lt;!&ndash; 注册链接 &ndash;&gt;-->
<!-- <view class="register-link">-->
<!-- <text>没有账号?</text>-->
<!-- <text class="link">去注册</text>-->
<!-- </view>-->
<!-- 注册链接 -->
<view class="register-link" @click="navigateToRegister">
<text>没有账号?</text>
<text class="link">去注册</text>
</view>
</view>
</view>
</view>
@@ -317,6 +317,13 @@ async function handleLogin() {
Toast({message: e.message, theme: 'error'})
}
}
function navigateToRegister(){
uni.redirectTo({
url: '/pages/login/register'
})
}
</script>
<style lang="less" scoped>
@@ -500,7 +507,7 @@ body {
.register-link {
margin-top: 16px;
text-align: center;
font-size: 14px;
font-size: 28rpx;
color: #666;
.link {
+664
View File
@@ -0,0 +1,664 @@
<template>
<view class="register-container">
<view class="title-area">
<image class="bg-image" src="/static/login-bg.jpg" mode="aspectFill"></image>
<view class="overlay"></view>
<view class="title-content">
<text class="main-title">JOIN US</text>
<view class="sub-title-container">
<text class="sub-title">用户注册</text>
</view>
</view>
</view>
<view class="form-wrapper">
<!-- 注册表单区域 -->
<view class="form-container">
<view class="form-title">填写信息</view>
<!-- 姓名输入框 -->
<view class="input-box">
<view class="input-icon-container">
<t-icon name="user" size="22px" class="input-icon"/>
</view>
<input
class="input"
type="text"
v-model="formData.name"
placeholder="请输入姓名"
maxlength="20"
/>
</view>
<!-- 手机号码输入框 -->
<view class="input-box">
<view class="input-icon-container">
<t-icon name="mobile" size="22px" class="input-icon"/>
</view>
<input
class="input"
type="tel"
v-model="formData.phone"
placeholder="请输入手机号"
maxlength="11"
/>
</view>
<!-- 单位输入框 -->
<view class="input-box" @click="showUnitPicker = true">
<view class="input-icon-container">
<t-icon name="home" size="22px" class="input-icon"/>
</view>
<view class="input placeholder" :class="{'has-value': formData.unitName}">
{{ formData.unitName || '请选择单位' }}
</view>
<t-icon name="chevron-right" size="20px" class="arrow-icon"/>
</view>
<!-- 身份证输入框 -->
<view class="input-box">
<view class="input-icon-container">
<t-icon name="id-card" size="22px" class="input-icon"/>
</view>
<input
class="input"
type="text"
v-model="formData.idCard"
placeholder="请输入身份证号码"
maxlength="18"
/>
</view>
<!-- 验证码输入框 -->
<view class="input-box">
<view class="input-icon-container">
<t-icon name="shield-check" size="22px" class="input-icon"/>
</view>
<input
class="input"
type="number"
v-model="formData.verificationCode"
placeholder="请输入验证码"
maxlength="6"
/>
<view class="verify-code-btn" @click="sendVerificationCode" :class="{ disabled: countdown > 0 }">
{{ countdown > 0 ? `${countdown}秒` : '获取验证码' }}
</view>
</view>
<!-- 注册按钮 -->
<view class="submit-btn" :class="{ disabled: !isFormValid }" @click="handleRegister">
{{ registering ? '注册中...' : '立即注册' }}
</view>
<!-- 登录链接 -->
<view class="login-link-box">
<text>已有账号?</text>
<text class="link-text" @click="goToLogin">立即登录</text>
</view>
</view>
</view>
<!-- 自定义单位选择弹窗 -->
<t-popup v-model="showUnitPicker" placement="bottom">
<view class="custom-picker">
<view class="custom-picker-header">
<view class="cancel-btn" @click="showUnitPicker = false">取消</view>
<view class="picker-title">选择单位</view>
<view class="confirm-btn" @click="confirmUnitSelection">确定</view>
</view>
<!-- 搜索框 -->
<view class="search-box">
<t-icon name="search" size="22px" class="search-icon" />
<input
class="search-input"
type="text"
v-model="searchKeyword"
placeholder="搜索单位"
@input="handleSearch"
/>
<t-icon
v-if="searchKeyword"
name="close-circle-filled"
size="22px"
class="clear-icon"
@click="clearSearch"
/>
</view>
<!-- 单位列表 -->
<scroll-view
scroll-y
class="units-scroll-view"
scroll-with-animation
:scroll-into-view="scrollViewId"
>
<view
v-for="unit in filteredUnits"
:key="unit.id"
:id="'unit-' + unit.id"
class="unit-item"
:class="{'unit-selected': selectedUnitId === unit.id}"
@click="selectUnit(unit)"
>
<text class="unit-name">{{ unit.name }}</text>
<t-icon v-if="selectedUnitId === unit.id" name="check" size="22px" class="check-icon"/>
</view>
<view v-if="filteredUnits.length === 0" class="empty-result">
<t-icon name="info-circle" size="40rpx" class="empty-icon"/>
<text class="empty-text">未找到匹配的单位</text>
</view>
</scroll-view>
</view>
</t-popup>
</view>
</template>
<script setup>
import { ref, reactive, computed, onMounted, watch, nextTick, getCurrentInstance } from 'vue';
import { Toast } from 'tdesign-mobile-vue';
import { useRequest } from "@/utils/request";
// 表单数据
const formData = reactive({
name: '',
phone: '',
unitId: '',
unitName: '',
idCard: '',
verificationCode: ''
});
// 验证码倒计时
const countdown = ref(0);
const sendingCode = ref(false);
const registering = ref(false);
// 单位选择相关
const showUnitPicker = ref(false);
const unitList = ref([]);
const searchKeyword = ref('');
const selectedUnitId = ref('');
const scrollViewId = ref('');
// 筛选单位列表
const filteredUnits = computed(() => {
if (!searchKeyword.value) {
return unitList.value;
}
return unitList.value.filter(unit =>
unit.name.toLowerCase().includes(searchKeyword.value.toLowerCase())
);
});
// 表单验证
const isFormValid = computed(() => {
return formData.name &&
formData.phone &&
formData.phone.length === 11 &&
formData.unitId &&
formData.idCard &&
formData.idCard.length === 18 &&
formData.verificationCode;
});
// 当选择器打开时,预设选中当前已选单位
watch(showUnitPicker, (newVal) => {
if (newVal && formData.unitId) {
selectedUnitId.value = formData.unitId;
// 设置scrollViewId以触发滚动
scrollViewId.value = `unit-${formData.unitId}`;
} else {
selectedUnitId.value = '';
}
// 清空搜索关键词
searchKeyword.value = '';
});
// 搜索处理
const handleSearch = () => {
// 实时搜索,不需要额外处理,由计算属性完成
};
// 清除搜索
const clearSearch = () => {
searchKeyword.value = '';
};
// 选择单位
const selectUnit = (unit) => {
selectedUnitId.value = unit.id;
scrollViewId.value = `unit-${unit.id}`;
};
// 确认选择
const confirmUnitSelection = () => {
if (!selectedUnitId.value) {
Toast({ message: '请选择单位', theme: 'warning' });
return;
}
const selectedUnit = unitList.value.find(unit => unit.id === selectedUnitId.value);
if (selectedUnit) {
formData.unitId = selectedUnit.id;
formData.unitName = selectedUnit.name;
}
showUnitPicker.value = false;
};
// 获取单位列表
const getUnitList = async () => {
try {
const { code, data, msg } = await useRequest().get('/open/common/units');
if (code === 0) {
unitList.value = data || [];
} else {
Toast({ message: msg || '获取单位列表失败', theme: 'error' });
}
} catch (error) {
console.error('获取单位列表失败', error);
Toast({ message: '获取单位列表失败', theme: 'error' });
}
};
// 发送验证码
const sendVerificationCode = async () => {
if (!formData.phone || formData.phone.length !== 11) {
Toast({ message: '请输入正确的手机号', theme: 'error' });
return;
}
if (countdown.value > 0) return;
sendingCode.value = true;
try {
const { code, msg } = await useRequest().post('/client/auth/send-verification-code', {
phone: formData.phone,
type: 'register'
});
if (code === 0) {
Toast({ message: '验证码已发送' });
startCountdown();
} else {
Toast({ message: msg || '发送验证码失败', theme: 'error' });
}
} catch (error) {
console.error('发送验证码失败', error);
Toast({ message: '发送验证码失败', theme: 'error' });
} finally {
sendingCode.value = false;
}
};
// 倒计时
const startCountdown = () => {
countdown.value = 60;
const timer = setInterval(() => {
countdown.value--;
if (countdown.value <= 0) {
clearInterval(timer);
}
}, 1000);
};
// 注册
const handleRegister = async () => {
if (!isFormValid.value) {
Toast({ message: '请完善注册信息', theme: 'error' });
return;
}
registering.value = true;
try {
const { code, msg } = await useRequest().post('/client/auth/register', {
name: formData.name,
phone: formData.phone,
unitId: formData.unitId,
idCard: formData.idCard,
verificationCode: formData.verificationCode
});
if (code === 0) {
Toast({ message: '注册成功' });
// 注册成功后跳转到登录页
setTimeout(() => {
uni.navigateTo({
url: '/pages/login/index'
});
}, 1500);
} else {
Toast({ message: msg || '注册失败', theme: 'error' });
}
} catch (error) {
console.error('注册失败', error);
Toast({ message: '注册失败', theme: 'error' });
} finally {
registering.value = false;
}
};
// 显示协议
const showAgreement = () => {
uni.navigateTo({
url: '/pages/agreement/index'
});
};
// 显示隐私政策
const showPrivacy = () => {
uni.navigateTo({
url: '/pages/privacy/index'
});
};
// 跳转登录页面
const goToLogin = () => {
uni.navigateTo({
url: '/pages/login/index'
});
};
// 页面加载时获取单位列表
onMounted(() => {
getUnitList();
});
</script>
<style scoped lang="less">
.register-container {
display: flex;
flex-direction: column;
min-height: 100vh;
background-color: #ffffff;
}
.title-area {
position: relative;
height: 380rpx;
overflow: hidden;
}
.bg-image {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 1;
}
.overlay {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
background: linear-gradient(to bottom, rgba(244, 90, 90, 0.8), rgba(244, 90, 90, 0.5));
z-index: 2;
}
.title-content {
position: relative;
z-index: 3;
padding: 80rpx 40rpx;
display: flex;
flex-direction: column;
}
.main-title {
font-size: 68rpx;
font-weight: bold;
color: #fff;
margin-bottom: 20rpx;
letter-spacing: 2rpx;
text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}
.sub-title-container {
display: flex;
align-items: center;
}
.sub-title {
font-size: 38rpx;
color: #fff;
font-weight: 500;
text-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}
.form-wrapper {
position: relative;
background-color: #ffffff;
padding: 0 40rpx;
margin-top: -60rpx;
z-index: 10;
border-radius: 50rpx 50rpx 0 0;
}
.form-container {
padding: 60rpx 0 50rpx;
}
.form-title {
font-size: 32rpx;
font-weight: bold;
color: #333;
margin-bottom: 40rpx;
text-align: center;
}
.input-box {
display: flex;
align-items: center;
padding: 20rpx 0;
margin-bottom: 30rpx;
position: relative;
border-bottom: 1px solid #f0f0f0;
transition: border-color 0.3s;
}
.input-box:focus-within {
border-bottom-color: #f45a5a;
}
.input-icon-container {
display: flex;
align-items: center;
justify-content: center;
width: 70rpx;
height: 70rpx;
border-radius: 50%;
background: rgba(244, 90, 90, 0.1);
margin-right: 20rpx;
}
.input-icon {
color: #f45a5a;
}
.arrow-icon {
color: #ccc;
}
.input {
flex: 1;
font-size: 28rpx;
height: 40rpx;
line-height: 40rpx;
color: #333;
}
.placeholder {
color: #999;
}
.has-value {
color: #333;
}
.verify-code-btn {
padding: 10rpx 20rpx;
background-color: #f45a5a;
color: #fff;
font-size: 26rpx;
border-radius: 8rpx;
text-align: center;
min-width: 180rpx;
margin-left: 10rpx;
}
.disabled {
background-color: #f8a8a8;
color: #fff;
pointer-events: none;
}
.submit-btn {
background: linear-gradient(135deg, #f45a5a, #f78484);
height: 90rpx;
border-radius: 45rpx;
color: #fff;
font-size: 32rpx;
display: flex;
align-items: center;
justify-content: center;
margin: 50rpx 0 30rpx;
transition: transform 0.2s;
}
.submit-btn:active {
transform: scale(0.98);
}
.submit-btn.disabled {
opacity: 0.7;
background: #ccc;
}
.login-link-box {
text-align: center;
font-size: 28rpx;
color: #666;
margin: 20rpx 0;
}
.link-text {
color: #f45a5a;
}
.custom-picker {
width: 100%;
background-color: #ffffff;
border-radius: 20rpx 20rpx 0 0;
overflow: hidden;
display: flex;
flex-direction: column;
max-height: 80vh;
}
.custom-picker-header {
display: flex;
align-items: center;
padding: 20rpx;
border-bottom: 1px solid #f5f5f5;
}
.cancel-btn, .confirm-btn {
padding: 10rpx 20rpx;
border-radius: 8rpx;
color: #f45a5a;
font-size: 28rpx;
}
.confirm-btn {
font-weight: bold;
}
.picker-title {
flex: 1;
text-align: center;
font-size: 32rpx;
font-weight: bold;
color: #333;
}
.search-box {
display: flex;
align-items: center;
padding: 20rpx;
border-bottom: 1px solid #f5f5f5;
background-color: #f9f9f9;
border-radius: 8rpx;
margin: 20rpx;
}
.search-icon {
margin-right: 10rpx;
color: #999;
}
.search-input {
flex: 1;
font-size: 28rpx;
height: 60rpx;
line-height: 60rpx;
color: #333;
}
.clear-icon {
margin-left: 10rpx;
color: #ccc;
}
.units-scroll-view {
flex: 1;
height: 60vh;
padding-bottom: 30rpx;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
}
.unit-item {
display: flex;
align-items: center;
justify-content: center;
padding: 26rpx 30rpx;
border-bottom: 1px solid #f5f5f5;
}
.unit-selected {
background-color: rgba(244, 90, 90, 0.1);
}
.unit-name {
flex: 1;
font-size: 28rpx;
color: #333;
text-align: center;
}
.check-icon {
position: absolute;
right: 30rpx;
color: #f45a5a;
}
.empty-result {
display: flex;
flex-direction: column;
align-items: center;
padding: 100rpx 40rpx;
}
.empty-icon {
margin-bottom: 20rpx;
color: #ccc;
}
.empty-text {
font-size: 28rpx;
color: #999;
}
</style>
Binary file not shown.

After

Width:  |  Height:  |  Size: 206 KiB

+2 -1
View File
@@ -124,6 +124,7 @@ async function routeInterceptor(args, whiteList) {
export const getDefaultWhiteList = () => {
return [
'/pages/index/index',
'/pages/login/index'
'/pages/login/index',
'/pages/login/register'
]
}