first commit

This commit is contained in:
2025-10-16 21:32:16 +08:00
commit c446df73b5
229 changed files with 499497 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
{
"navigationBarTitleText": "申请加入货运团队",
"navigationBarBackgroundColor": "#1aad19",
"navigationBarTextStyle": "white",
"usingComponents": {}
}

View File

@@ -0,0 +1,181 @@
// pages/apply/apply.ts
import userService from '../../services/userService';
Page({
/**
* 页面的初始数据
*/
data: {
applyForm: {
name: '',
idCard: '',
phone: ''
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad() {
console.log('申请页面加载');
},
/**
* 表单输入处理
*/
onApplyFormInput(e: any) {
const { field } = e.currentTarget.dataset;
const { value } = e.detail;
this.setData({
[`applyForm.${field}`]: value
});
},
/**
* 取消按钮点击
*/
onCancel() {
// 返回上一页
wx.navigateBack();
},
/**
* 提交申请
*/
async onSubmit() {
const { name, idCard, phone } = this.data.applyForm;
// 表单验证
if (!this.validateForm()) {
return;
}
try {
wx.showLoading({
title: '提交中...',
mask: true
});
// 调用API提交申请
const result = await this.submitApplication({ name, idCard, phone });
if (result.success) {
wx.showToast({
title: '申请提交成功',
icon: 'success',
duration: 2000
});
// 更新全局用户信息
const app = getApp<any>();
if (app.globalData.userInfo) {
app.globalData.userInfo = {
...app.globalData.userInfo,
name: result.employeeInfo.name,
phone: result.employeeInfo.phone,
role: result.employeeInfo.role
};
console.log('全局用户信息已更新:', app.globalData.userInfo);
}
// 延迟返回并刷新首页
setTimeout(() => {
// 获取当前页面栈
const pages = getCurrentPages();
if (pages.length >= 2) {
// 获取首页实例并调用刷新方法
const indexPage = pages[pages.length - 2];
if (indexPage && indexPage.refreshPageAfterLogin) {
indexPage.refreshPageAfterLogin();
}
}
wx.navigateBack();
}, 1500);
} else {
wx.showToast({
title: result.message || '提交失败',
icon: 'none',
duration: 2000
});
}
} catch (error) {
console.error('提交申请失败:', error);
wx.showToast({
title: '网络错误,请重试',
icon: 'none',
duration: 2000
});
} finally {
wx.hideLoading();
}
},
/**
* 表单验证
*/
validateForm(): boolean {
const { name, idCard, phone } = this.data.applyForm;
if (!name || !idCard || !phone) {
wx.showToast({
title: '请填写完整信息',
icon: 'none',
duration: 2000
});
return false;
}
// 身份证号验证
if (idCard.length !== 18) {
wx.showToast({
title: '请输入正确的身份证号',
icon: 'none',
duration: 2000
});
return false;
}
// 手机号验证
if (!/^1[3-9]\d{9}$/.test(phone)) {
wx.showToast({
title: '请输入正确的手机号',
icon: 'none',
duration: 2000
});
return false;
}
return true;
},
/**
* 提交申请到服务器
*/
async submitApplication(data: any): Promise<any> {
try {
// 先执行微信登录获取token
const loginResult = await userService.wxLogin();
if (!loginResult.success) {
throw new Error('微信登录失败,请重试');
}
// 调用实际的注册接口
return await userService.register({
name: data.name,
phone: data.phone
});
} catch (error) {
console.error('注册流程失败:', error);
throw error;
}
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
console.log('申请页面卸载');
}
});

View File

@@ -0,0 +1,67 @@
<!--pages/apply/apply.wxml-->
<view class="apply-container">
<!-- 页面头部 -->
<view class="apply-header">
<text class="apply-title">加入货运团队</text>
<text class="apply-subtitle">请填写您的个人信息</text>
</view>
<!-- 表单内容 -->
<scroll-view class="apply-content" scroll-y>
<view class="apply-form">
<!-- 姓名输入 -->
<view class="apply-form-group">
<text class="apply-form-label">姓名</text>
<input
class="apply-form-input"
type="text"
value="{{applyForm.name}}"
data-field="name"
bindinput="onApplyFormInput"
placeholder="请输入您的真实姓名"
placeholder-class="apply-form-placeholder"
maxlength="20"
/>
<view class="apply-form-underline"></view>
</view>
<!-- 身份证号输入 -->
<view class="apply-form-group">
<text class="apply-form-label">身份证号</text>
<input
class="apply-form-input"
type="idcard"
value="{{applyForm.idCard}}"
data-field="idCard"
bindinput="onApplyFormInput"
placeholder="请输入18位身份证号码"
placeholder-class="apply-form-placeholder"
maxlength="18"
/>
<view class="apply-form-underline"></view>
</view>
<!-- 手机号输入 -->
<view class="apply-form-group">
<text class="apply-form-label">手机号</text>
<input
class="apply-form-input"
type="number"
value="{{applyForm.phone}}"
data-field="phone"
bindinput="onApplyFormInput"
placeholder="请输入11位手机号码"
placeholder-class="apply-form-placeholder"
maxlength="11"
/>
<view class="apply-form-underline"></view>
</view>
</view>
</scroll-view>
<!-- 底部操作按钮 -->
<view class="apply-footer">
<button class="apply-btn-cancel" bindtap="onCancel">取消</button>
<button class="apply-btn-confirm" bindtap="onSubmit" form-type="submit">提交申请</button>
</view>
</view>

View File

@@ -0,0 +1,140 @@
/* pages/apply/apply.wxss */
.apply-container {
min-height: 100vh;
background-color: #f5f5f5;
display: flex;
flex-direction: column;
}
/* 页面头部 */
.apply-header {
background: linear-gradient(135deg, #1aad19, #179b16);
color: white;
padding: 40rpx 30rpx;
border-radius: 0 0 30rpx 30rpx;
box-shadow: 0 4rpx 20rpx rgba(26, 173, 25, 0.3);
}
.apply-title {
font-size: 40rpx;
font-weight: bold;
display: block;
margin-bottom: 10rpx;
}
.apply-subtitle {
font-size: 28rpx;
opacity: 0.9;
}
/* 表单内容 */
.apply-content {
flex: 1;
padding: 30rpx;
}
.apply-form {
background-color: white;
border-radius: 20rpx;
padding: 40rpx 30rpx;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.08);
}
.apply-form-group {
margin-bottom: 40rpx;
position: relative;
}
.apply-form-group:last-child {
margin-bottom: 0;
}
.apply-form-label {
display: block;
font-size: 32rpx;
font-weight: 500;
color: #333;
margin-bottom: 20rpx;
}
.apply-form-input {
width: 100%;
height: 80rpx;
font-size: 32rpx;
padding: 0 20rpx;
border: none;
background-color: #f8f9fa;
border-radius: 12rpx;
box-sizing: border-box;
}
.apply-form-input:focus {
background-color: #e8f5e8;
}
.apply-form-placeholder {
color: #999;
font-size: 28rpx;
}
.apply-form-underline {
height: 2rpx;
background: linear-gradient(90deg, transparent, #1aad19, transparent);
margin-top: 10rpx;
opacity: 0.5;
}
/* 底部操作按钮 */
.apply-footer {
padding: 30rpx;
background-color: white;
border-top: 1rpx solid #eee;
display: flex;
gap: 20rpx;
}
.apply-btn-cancel {
flex: 1;
height: 88rpx;
background-color: #f5f5f5;
color: #666;
border: none;
border-radius: 12rpx;
font-size: 32rpx;
font-weight: 500;
}
.apply-btn-cancel:active {
background-color: #e8e8e8;
}
.apply-btn-confirm {
flex: 2;
height: 88rpx;
background: linear-gradient(135deg, #1aad19, #179b16);
color: white;
border: none;
border-radius: 12rpx;
font-size: 32rpx;
font-weight: bold;
}
.apply-btn-confirm:active {
background: linear-gradient(135deg, #179b16, #158a15);
}
/* 响应式设计 */
@media (min-width: 768px) {
.apply-container {
max-width: 600rpx;
margin: 0 auto;
border-radius: 20rpx;
margin-top: 40rpx;
margin-bottom: 40rpx;
box-shadow: 0 8rpx 40rpx rgba(0, 0, 0, 0.12);
}
.apply-header {
border-radius: 20rpx 20rpx 0 0;
}
}