小程序提交
This commit is contained in:
211
pages/loginModule/employeeAccountApply/employeeAccountApply.js
Normal file
211
pages/loginModule/employeeAccountApply/employeeAccountApply.js
Normal file
@ -0,0 +1,211 @@
|
||||
const { baseUrl } = require('../../../request');
|
||||
const { validate } = require('../../../utils/validate');
|
||||
|
||||
Page({
|
||||
data: {
|
||||
name: '',
|
||||
phone: '',
|
||||
code: '', // 验证码
|
||||
idcard: '', // 身份证号
|
||||
codeSent: false,
|
||||
countdown: 0, // 剩余秒数
|
||||
codeButtonText: '获取验证码',
|
||||
_timer: null,
|
||||
isUploading: false,
|
||||
resumeUploaded: false,
|
||||
resumeFilePath: '',
|
||||
fileCode: '', // 上传文件后端返回的码
|
||||
credential: '', // 用户申请后的唯一凭证,用于查询用户是否审核通过
|
||||
},
|
||||
|
||||
onInput(e) {
|
||||
const field = e.currentTarget.dataset.field;
|
||||
this.setData({
|
||||
[field]: e.detail.value
|
||||
});
|
||||
},
|
||||
|
||||
// 获取验证码(仅校验手机号)
|
||||
getSmsCode() {
|
||||
const { phone } = this.data;
|
||||
|
||||
// 1. 非空校验
|
||||
if (!validate(this.data, { phone: '请输入手机号' })) {
|
||||
return;
|
||||
}
|
||||
// 2. 格式校验
|
||||
if (!/^1\d{10}$/.test(phone)) {
|
||||
return wx.showToast({ title: '手机号格式不正确', icon: 'none' });
|
||||
}
|
||||
|
||||
// 3. 发送验证码请求
|
||||
wx.request({
|
||||
url: baseUrl + '/userInfo/code/pwd',
|
||||
method: 'POST',
|
||||
data: { templateString: phone },
|
||||
success: (res) => {
|
||||
console.log('验证码发送--->',res.data);
|
||||
if (res.data.code === 1) {
|
||||
wx.showToast({ title: '验证码已发送', icon: 'none' });
|
||||
this._startCountdown(60);
|
||||
} else {
|
||||
wx.showToast({ title: res.data.message, icon: 'none' });
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
wx.showToast({ title: '发送失败,请重试', icon: 'none' });
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 开始倒计时
|
||||
_startCountdown(seconds) {
|
||||
this.setData({
|
||||
countdown: seconds,
|
||||
codeButtonText: `${seconds}s后重试`
|
||||
});
|
||||
// 如果已有定时器,不重复创建
|
||||
if (this.data._timer) return;
|
||||
this.data._timer = setInterval(() => {
|
||||
const cd = this.data.countdown - 1;
|
||||
if (cd <= 0) {
|
||||
this._clearTimer();
|
||||
this.setData({
|
||||
countdown: 0,
|
||||
codeButtonText: '获取验证码'
|
||||
});
|
||||
} else {
|
||||
this.setData({
|
||||
countdown: cd,
|
||||
codeButtonText: `${cd}s后重试`
|
||||
});
|
||||
}
|
||||
}, 1000);
|
||||
},
|
||||
|
||||
// 清除倒计时定时器
|
||||
_clearTimer() {
|
||||
if (this.data._timer) {
|
||||
clearInterval(this.data._timer);
|
||||
this.data._timer = null;
|
||||
}
|
||||
},
|
||||
|
||||
// 选择并上传简历
|
||||
chooseResume() {
|
||||
if (this.data.resumeUploaded) return;
|
||||
wx.chooseMessageFile({
|
||||
count: 1,
|
||||
type: 'file',
|
||||
success: res => {
|
||||
const file = res.tempFiles[0];
|
||||
this.uploadResume(file);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 上传简历
|
||||
uploadResume(file) {
|
||||
this.setData({ isUploading: true });
|
||||
wx.uploadFile({
|
||||
url: baseUrl + '/file/upload',
|
||||
method: 'POST',
|
||||
name: 'file',
|
||||
header : {
|
||||
Authorization: wx.getStorageSync('token'),
|
||||
},
|
||||
formData: {
|
||||
biz: 'default', // 传 biz 文本字段
|
||||
},
|
||||
filePath: file.path,
|
||||
success: res => {
|
||||
console.log('简历上传后端返回--->',JSON.parse(res.data));
|
||||
const data = JSON.parse(res.data);
|
||||
console.log('后端返回文件码--->',data.data);
|
||||
if (data.code === 1) {
|
||||
wx.showToast({ title: '上传成功', icon: 'success' });
|
||||
this.setData({
|
||||
isUploading: false,
|
||||
resumeUploaded: true,
|
||||
resumeFilePath: file.path,
|
||||
fileCode: data.data
|
||||
});
|
||||
} else {
|
||||
wx.showToast({ title: data.message || '上传失败', icon: 'none' });
|
||||
this.setData({ isUploading: false });
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
wx.showToast({ title: '上传失败,请重试', icon: 'none' });
|
||||
this.setData({ isUploading: false });
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 提交表单
|
||||
handleSubmit() {
|
||||
const { name, phone, code, idcard, fileCode } = this.data;
|
||||
|
||||
// 校验用户是否填写所有必要信息
|
||||
if (!name || !phone || !code || !idcard || !fileCode) {
|
||||
wx.showToast({ title: '请填写所有信息', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
|
||||
// 姓名只能中文或英文
|
||||
if (!/^[\u4e00-\u9fa5A-Za-z]+$/.test(name)) {
|
||||
wx.showToast({ title: '姓名只能为中英文', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
|
||||
// 提交表单数据到后端
|
||||
wx.request({
|
||||
url: baseUrl + '/advancementApply/add',
|
||||
method: 'POST',
|
||||
header: {
|
||||
Authorization: wx.getStorageSync('token')
|
||||
},
|
||||
data: {
|
||||
name: name,
|
||||
phone: phone,
|
||||
verificationCode: code,
|
||||
idCard: idcard,
|
||||
resume: fileCode
|
||||
},
|
||||
success: res => {
|
||||
console.log('后端返回的申请---->', res);
|
||||
if (res.data.code === 1) {
|
||||
wx.showToast({ title: '验证通过,提交成功', icon: 'success' });
|
||||
|
||||
// 清空表单内容
|
||||
this.setData({
|
||||
name: '',
|
||||
phone: '',
|
||||
code: '',
|
||||
idcard: '',
|
||||
fileCode: '',
|
||||
resumeUploaded: false, // 重置简历上传状态
|
||||
resumeFilePath: '', // 清空简历文件路径
|
||||
credential: '' // 清空凭证
|
||||
});
|
||||
} else {
|
||||
wx.showToast({ title: '系统错误', icon: 'error' });
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 跳转申请须知
|
||||
gotoNotice() {
|
||||
wx.navigateTo({
|
||||
url: '/pages/loginModule/employeeAccountNotice/employeeAccountNotice',
|
||||
})
|
||||
},
|
||||
|
||||
// 跳转我的申请记录
|
||||
gotoQuery() {
|
||||
wx.navigateTo({
|
||||
url: '/pages/loginModule/employeeApplyQuery/employeeApplyQuery',
|
||||
})
|
||||
},
|
||||
});
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
103
pages/loginModule/employeeAccountApply/employeeAccountApply.wxml
Normal file
103
pages/loginModule/employeeAccountApply/employeeAccountApply.wxml
Normal file
@ -0,0 +1,103 @@
|
||||
<view class="flex-col page">
|
||||
<!-- 遮罩层(上传时显示) -->
|
||||
<view wx:if="{{isUploading}}" class="mask">
|
||||
<text class="loading-text">上传中...</text>
|
||||
</view>
|
||||
|
||||
<image
|
||||
class="self-center image"
|
||||
src="./images/logo.png"
|
||||
/>
|
||||
<text class="self-center text">欢迎登陆—青橙校园</text>
|
||||
<view class="flex-col self-stretch group">
|
||||
<view class="flex-col">
|
||||
<view class="flex-row justify-between group_1">
|
||||
<text class="font text_2">员工账号申请</text>
|
||||
<view class="flex-row items-center group_2" bind:tap="gotoNotice">
|
||||
<image
|
||||
class="shrink-0 image_2 image_3"
|
||||
src="./images/right.png"
|
||||
/>
|
||||
<text class="font_2 text_3">员工账号申请须知</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="flex-col mt-15">
|
||||
<!-- 姓名输入 -->
|
||||
<view class="flex-col justify-start section">
|
||||
<input
|
||||
class="flex-col justify-start items-start text-wrapper view input"
|
||||
placeholder="请输入姓名"
|
||||
maxlength="8"
|
||||
bindinput="onInput"
|
||||
data-field="name"
|
||||
value="{{name}}"
|
||||
/>
|
||||
</view>
|
||||
<!-- 手机号输入 -->
|
||||
<view class="flex-col justify-start section_1 mt-21">
|
||||
<input
|
||||
class="flex-col justify-start items-start text-wrapper text-wrapper_1 input_1"
|
||||
placeholder="请输入手机号"
|
||||
maxlength="11"
|
||||
type="number"
|
||||
bindinput="onInput"
|
||||
data-field="phone"
|
||||
value="{{phone}}"
|
||||
/>
|
||||
</view>
|
||||
<!-- 验证码输入 + 发送按钮 -->
|
||||
<view class="flex-row items-center section_3 mt-21">
|
||||
<input
|
||||
class="flex-col justify-start items-start text-wrapper_2 view_3 input_2"
|
||||
placeholder="请输入验证码"
|
||||
type="number"
|
||||
bindinput="onInput"
|
||||
data-field="code"
|
||||
value="{{code}}"
|
||||
/>
|
||||
<view
|
||||
class="flex-col justify-start items-center shrink-0 text-wrapper_3 ml-16"
|
||||
bindtap="getSmsCode"
|
||||
>
|
||||
<text class="text_8">
|
||||
{{ codeButtonText }}
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 身份证号输入 -->
|
||||
<view class="flex-col justify-start items-start section_2 mt-21">
|
||||
<input
|
||||
class="flex-col justify-start items-start text-wrapper_4 view_4 input_3"
|
||||
placeholder="请输入身份证号"
|
||||
type="idcard"
|
||||
bindinput="onInput"
|
||||
data-field="idcard"
|
||||
maxlength="18"
|
||||
value="{{idcard}}"
|
||||
/>
|
||||
</view>
|
||||
<!-- 上传简历 -->
|
||||
<view class="flex-col items-center section_4 mt-21" bindtap="chooseResume">
|
||||
<image
|
||||
class="image_4"
|
||||
src="./images/resume.png"
|
||||
/>
|
||||
<text class="{{resumeUploaded?'upload-success-text':'font_2 text_10 mt-12'}}">
|
||||
{{ resumeUploaded ? '简历上传成功!' : '点击上传简历' }}
|
||||
</text>
|
||||
</view>
|
||||
<!-- 提交按钮 -->
|
||||
<view class="flex-col justify-start items-center text-wrapper_5 mt-21" bindtap="handleSubmit">
|
||||
<text class="text_11">提交申请</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="flex-row justify-center items-center relative group_4 mt-28" bind:tap="gotoQuery">
|
||||
<image
|
||||
class="image_2 pos"
|
||||
src="./images/right.png"
|
||||
/>
|
||||
<text class="font_2 text_12">我的申请记录</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
203
pages/loginModule/employeeAccountApply/employeeAccountApply.wxss
Normal file
203
pages/loginModule/employeeAccountApply/employeeAccountApply.wxss
Normal file
@ -0,0 +1,203 @@
|
||||
/* pages/loginModule/employeeAccountApply/employeeAccountApply.wxss */
|
||||
.mt-15 {
|
||||
margin-top: 28.13rpx;
|
||||
}
|
||||
.mt-21 {
|
||||
margin-top: 39.38rpx;
|
||||
}
|
||||
.page {
|
||||
padding: 67.5rpx 49.69rpx 84.38rpx 51.56rpx;
|
||||
background-color: #ffffff;
|
||||
width: 100%;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
height: 100%;
|
||||
}
|
||||
.image {
|
||||
width: 232.5rpx;
|
||||
height: 232.5rpx;
|
||||
}
|
||||
.text {
|
||||
margin-top: 35.14rpx;
|
||||
color: #1c2023;
|
||||
font-size: 37.5rpx;
|
||||
font-family: AlibabaPuHuiTi;
|
||||
line-height: 35.21rpx;
|
||||
}
|
||||
.group {
|
||||
margin-top: 62.77rpx;
|
||||
}
|
||||
.group_1 {
|
||||
padding-left: 2.77rpx;
|
||||
}
|
||||
.font {
|
||||
font-size: 30rpx;
|
||||
font-family: SourceHanSansCN;
|
||||
line-height: 27.79rpx;
|
||||
color: #b3b3b3;
|
||||
}
|
||||
.text_2 {
|
||||
color: #1c2023;
|
||||
line-height: 28.01rpx;
|
||||
}
|
||||
.group_2 {
|
||||
width: 236.4rpx;
|
||||
}
|
||||
.image_2 {
|
||||
width: 30rpx;
|
||||
height: 30rpx;
|
||||
}
|
||||
.image_3 {
|
||||
margin-left: 206.4rpx;
|
||||
}
|
||||
.font_2 {
|
||||
font-size: 26.25rpx;
|
||||
font-family: SourceHanSansCN;
|
||||
line-height: 24.3rpx;
|
||||
color: #ff8d1a;
|
||||
}
|
||||
.text_3 {
|
||||
margin-left: -236.4rpx;
|
||||
}
|
||||
.section {
|
||||
padding: 20.63rpx 0 18.75rpx;
|
||||
background-color: #ffffff;
|
||||
border-radius: 9.38rpx;
|
||||
box-shadow: 0rpx 3.75rpx 11.25rpx #00000040;
|
||||
}
|
||||
.text-wrapper {
|
||||
margin-left: 16.88rpx;
|
||||
margin-right: 16.88rpx;
|
||||
}
|
||||
.view {
|
||||
padding: 15.92rpx 0 12.67rpx;
|
||||
background-color: #ffffff00;
|
||||
}
|
||||
.section_1 {
|
||||
padding: 20.16rpx 0 19.22rpx;
|
||||
background-color: #ffffff;
|
||||
border-radius: 9.38rpx;
|
||||
box-shadow: 0rpx 3.75rpx 7.5rpx #00000040;
|
||||
}
|
||||
.text-wrapper_1 {
|
||||
padding: 12.64rpx 0 15.92rpx;
|
||||
background-color: #ffffff00;
|
||||
}
|
||||
.section_3 {
|
||||
padding: 19.69rpx 16.88rpx;
|
||||
background-color: #ffffff;
|
||||
border-radius: 9.38rpx;
|
||||
box-shadow: 0rpx 3.75rpx 7.5rpx #00000040;
|
||||
}
|
||||
.text-wrapper_2 {
|
||||
flex: 1 1 0;
|
||||
}
|
||||
.view_3 {
|
||||
padding: 16.73rpx 0 11.74rpx;
|
||||
background-color: #ffffff00;
|
||||
height: 56.25rpx;
|
||||
}
|
||||
.text-wrapper_3 {
|
||||
margin-right: 15rpx;
|
||||
/* padding: 13.16rpx 0 10.93rpx; */
|
||||
background-color: #ff8d1a;
|
||||
border-radius: 9.38rpx;
|
||||
width: 157.5rpx;
|
||||
height: 45rpx;
|
||||
}
|
||||
.text_8 {
|
||||
color: #ffffff;
|
||||
font-size: 22.5rpx;
|
||||
font-family: AlibabaPuHuiTi;
|
||||
line-height: 15.91rpx;
|
||||
}
|
||||
.section_2 {
|
||||
padding: 19.69rpx 0;
|
||||
background-color: #ffffff;
|
||||
border-radius: 9.38rpx;
|
||||
box-shadow: 0rpx 3.75rpx 7.5rpx #00000040;
|
||||
}
|
||||
.text-wrapper_4 {
|
||||
margin-left: 16.88rpx;
|
||||
}
|
||||
.view_4 {
|
||||
padding: 16.86rpx 0 11.46rpx;
|
||||
background-color: #ffffff00;
|
||||
width: 510.63rpx;
|
||||
}
|
||||
.section_4 {
|
||||
padding: 30.81rpx 0 38.16rpx;
|
||||
background-color: #ff8d1a1a;
|
||||
border-radius: 9.38rpx;
|
||||
border: dotted 1.88rpx #ff8d1a;
|
||||
}
|
||||
.image_4 {
|
||||
width: 127.5rpx;
|
||||
height: 127.5rpx;
|
||||
}
|
||||
.text_10 {
|
||||
color: #000000;
|
||||
line-height: 24.23rpx;
|
||||
}
|
||||
.text-wrapper_5 {
|
||||
padding: 36.43rpx 0 33.58rpx;
|
||||
background-color: #ff8d1a;
|
||||
border-radius: 9.38rpx;
|
||||
}
|
||||
.text_11 {
|
||||
color: #ffffff;
|
||||
font-size: 30rpx;
|
||||
font-family: AlibabaPuHuiTi;
|
||||
line-height: 27.49rpx;
|
||||
}
|
||||
.group_4 {
|
||||
padding: 2.66rpx 0 3rpx;
|
||||
}
|
||||
.pos {
|
||||
position: absolute;
|
||||
left: 402.19rpx;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
.text_12 {
|
||||
line-height: 24.34rpx;
|
||||
}
|
||||
.input {
|
||||
padding: 15rpx 16.26rpx 13.13rpx 16.26rpx;
|
||||
}
|
||||
.input_1 {
|
||||
padding: 13.13rpx 16.26rpx 15rpx 16.26rpx;
|
||||
}
|
||||
.input_2 {
|
||||
padding: 16.88rpx 16.26rpx 11.25rpx 16.26rpx;
|
||||
}
|
||||
.input_3 {
|
||||
padding: 16.88rpx 16.26rpx 11.25rpx 16.26rpx;
|
||||
}
|
||||
/* 遮罩层 */
|
||||
.mask {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
z-index: 9999;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
/* 加载中文本 */
|
||||
.loading-text {
|
||||
color: #ffffff;
|
||||
font-size: 34rpx;
|
||||
font-family: AlibabaPuHuiTi;
|
||||
}
|
||||
|
||||
/* 上传成功文字样式 */
|
||||
.upload-success-text {
|
||||
font-size: 30rpx;
|
||||
font-weight: bold;
|
||||
color: #ff8d1a;
|
||||
}
|
BIN
pages/loginModule/employeeAccountApply/images/logo.png
Normal file
BIN
pages/loginModule/employeeAccountApply/images/logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 69 KiB |
BIN
pages/loginModule/employeeAccountApply/images/resume.png
Normal file
BIN
pages/loginModule/employeeAccountApply/images/resume.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
BIN
pages/loginModule/employeeAccountApply/images/right.png
Normal file
BIN
pages/loginModule/employeeAccountApply/images/right.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 321 B |
Reference in New Issue
Block a user