From 4a9faf7cacb6e9fb579b62947afeb1130ec7bb5f Mon Sep 17 00:00:00 2001 From: mengfanliang <mengfanliang@zcloudchina.com> Date: Tue, 18 Feb 2025 16:54:09 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BA=BA=E8=84=B8=E8=AE=A4=E8=AF=81?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E6=B7=BB=E5=8A=A0=E6=89=AB=E6=8F=8F=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/index.js | 5 + .../train_management/face_authentication.nvue | 10 +- pages/train_management/index.vue | 321 ++++++++++-------- 3 files changed, 186 insertions(+), 150 deletions(-) diff --git a/api/index.js b/api/index.js index ac03429..19f6f2b 100644 --- a/api/index.js +++ b/api/index.js @@ -77,4 +77,9 @@ export const getHistoricalApprovalRecords = (params) => post("/app/Task/getHis", * 获取班级管理分页列表 */ export const getClassList = (params) => post("/app/stagestudentrelation/pageTaskByUser", params); + +/** + * 获取是否上传人脸信息 + */ +export const getIsUploadFace = (params) => post("/app/user/getUserFace", params); // ********************* end *********************** diff --git a/pages/train_management/face_authentication.nvue b/pages/train_management/face_authentication.nvue index 41198fd..834ed19 100644 --- a/pages/train_management/face_authentication.nvue +++ b/pages/train_management/face_authentication.nvue @@ -60,12 +60,13 @@ export default { // scan_face 扫码 // learning_certification 学习认证 // meeting_attendance 会议签到 - const typeKey = ["scan_face", "learning_certification"]; + const typeKey = ["facial_input", "scan_face", "learning_certification"]; if (!typeKey.includes(query.type)) { uni.$u.toast("type参数错误"); return; } this.isFirst = query.isFirst || ""; + if (query.type === "facial_input") this.btnTextStr = "人脸认证"; if (query.type === "scan_face") this.btnTextStr = "签到"; if (query.type === "learning_certification") this.btnTextStr = "开始考试"; this.type = query.type; @@ -74,7 +75,7 @@ export default { }, onBackPress(event) { if (event.from === "backbutton") { - if ( + if (this.type === "facial_input" || (this.type === "scan_face" && this.isFirst === "1") || this.type === "learning_certification" ) { @@ -125,7 +126,10 @@ export default { speech.indexOf("base64,") + 7, ); try { - if (this.type === "scan_face") { + if (this.type === "facial_input") { + uni.$u.toast("人脸认证成功"); + uni.navigateBack({ delta: 1 }); + } else if (this.type === "scan_face") { // await setScanCodeToVerifyFace({ // USERAVATARPREFIX, // USERAVATARURL, diff --git a/pages/train_management/index.vue b/pages/train_management/index.vue index 2fdae96..c52c9b1 100644 --- a/pages/train_management/index.vue +++ b/pages/train_management/index.vue @@ -1,6 +1,6 @@ <template> <view class="content"> - <u-list @scrolltolower="scrolltolower"> + <u-list @scrolltolower="scrolltolower" v-if="trainList.length > 0"> <u-list-item v-for="(item, index) in trainList" :key="index"> <view class="container_item"> <view class="container_item_name"> @@ -28,14 +28,10 @@ </view> <view class="content_text"> <view class="content_bottom"> - <view> - <text class="content_label">任务状态: </text>{{ handleCalcTaskStatus(item.taskStatus) }} - </view> + <view> <text class="content_label">任务状态: </text>{{ handleCalcTaskStatus(item.taskStatus) }} </view> <view class="action-row"> - <u-button size="mini" type="primary" text="签到信息" - @click="signInInformation(item.classId)" /> - <u-button size="mini" type="primary" text="考试记录" - @click="ExamRecord(item.classId)" /> + <u-button size="mini" type="primary" text="签到信息" @click="signInInformation(item.classId)" /> + <u-button size="mini" type="primary" text="考试记录" @click="ExamRecord(item.classId)" /> </view> </view> </view> @@ -43,163 +39,194 @@ </view> </u-list-item> </u-list> + + <empty v-else></empty> </view> </template> <script> - import { getClassList } from '../../api'; - - export default { - data() { - return { - pageSize: 10, - currentPage: 1, - totalPage: 0, - trainList: [], - taskStatusMap: { - 0: '未开始', - 1: '进行中' - } - } - }, +import { getClassList, getIsUploadFace } from '../../api' - /* 监听页面显示,页面每次出现在屏幕上都触发,包括从下级页面点返回露出当前页面 */ - onShow() { - this.resetList() - }, - - methods: { - async getData() { - let resData = await getClassList({ - showCount: this.pageSize, - currentPage: this.currentPage, - }); - console.log(resData) - this.trainList = [...this.trainList, ...resData.page.list]; - this.totalPage = resData.page.totalPage; - }, - resetList() { - this.pageSize = 10 - this.currentPage = 1 - this.trainList = [] - this.getData() - }, - scrolltolower() { - this.currentPage++ - if (this.totalPage >= this.currentPage) this.getData() - }, - /** - * 右上角自定义扫码图标触发事件 - */ - onNavigationBarButtonTap(e) { - // 只允许通过手机相机扫码 - uni.scanCode({ - // scanType: ['qrCode'], // 仅支持二维码扫码 - onlyFromCamera: false, // 是否只能从相机扫码,不允许从相册选择图片 - hideAlbum: false, // 隐藏相册,不允许从相册选择图片,只能从相机扫码 - success: function(res) { - if (res.result === '0') { - // 签到二维码方式进入 - uni.$u.route({ - url: '/pages/train_management/realname_info_auth', - params: { - type: 'scan_face', - } - }) - } else if (res.result === '1') { - // 考试二维码方式进入 - uni.$u.route({ - url: '/pages/train_management/face_authentication', - params: { - type: 'learning_certification' - } - }) - } - }, - fail: function(error) { - console.log("error :>> ", error) - }, - complete: function(result) { - console.log("扫码完成,正在跳转功能页!") - } - }); - }, - handleCalcTaskStatus(type) { - return this.taskStatusMap[type] - }, - /** - * 签到信息 - */ - signInInformation(classId) { - uni.$u.route({ - url: '/pages/train_management/sign_information', - params: { - classId - } - }) - }, - /** - * 考试记录 - */ - ExamRecord(classId) { - uni.$u.route({ - url: '/pages/train_management/exam_record', - params: { - classId - } - }) +export default { + data() { + return { + pageSize: 10, + currentPage: 1, + totalPage: 0, + trainList: [], + taskStatusMap: { + 0: '未开始', + 1: '进行中' } } + }, + + async onLoad(query) { + console.log('页面加载完成 :>> ', query) + // await this.getUserFaceCompleted() + }, + + /* 监听页面显示,页面每次出现在屏幕上都触发,包括从下级页面点返回露出当前页面 */ + onShow() { + this.resetList() + }, + + methods: { + async getData() { + let resData = await getClassList({ + showCount: this.pageSize, + currentPage: this.currentPage + }) + this.trainList = [...this.trainList, ...resData.page.list] + this.totalPage = resData.page.totalPage + }, + resetList() { + this.pageSize = 10 + this.currentPage = 1 + this.trainList = [] + this.getData() + }, + scrolltolower() { + this.currentPage++ + if (this.totalPage >= this.currentPage) this.getData() + }, + /** + * 获取是否已经完成上传人脸信息 + */ + // async getUserFaceCompleted() { + // const userFaceData = await getIsUploadFace() + // console.log('userFaceData :>> ', userFaceData) + // if (!userFaceData?.data) { + // uni.showModal({ + // title: '温馨提示', + // content: '检测到您还未完成人脸信息读取,请先完成人脸信息认证!', + // success: function (res) { + // if (res.confirm) { + // uni.$u.route({ + // url: '/pages/train_management/face_authentication', + // params: { + // type: 'facial_input' + // } + // }) + // } else if (res.cancel) { + // uni.navigateBack({ delta: 1 }); + // } + // } + // }) + // } + // }, + /** + * 右上角自定义扫码图标触发事件 + */ + onNavigationBarButtonTap(e) { + // 只允许通过手机相机扫码 + uni.scanCode({ + // scanType: ['qrCode'], // 仅支持二维码扫码 + onlyFromCamera: false, // 是否只能从相机扫码,不允许从相册选择图片 + hideAlbum: false, // 隐藏相册,不允许从相册选择图片,只能从相机扫码 + success: function (res) { + if (res.result === '0') { + // 签到二维码方式进入 + uni.$u.route({ + url: '/pages/train_management/realname_info_auth', + params: { + type: 'scan_face' + } + }) + } else if (res.result === '1') { + // 考试二维码方式进入 + uni.$u.route({ + url: '/pages/train_management/face_authentication', + params: { + type: 'learning_certification' + } + }) + } + }, + fail: function (error) { + console.log('error :>> ', error) + }, + complete: function (result) { + console.log('扫码完成,正在跳转功能页!') + } + }) + }, + handleCalcTaskStatus(type) { + return this.taskStatusMap[type] + }, + /** + * 签到信息 + */ + signInInformation(classId) { + uni.$u.route({ + url: '/pages/train_management/sign_information', + params: { + classId + } + }) + }, + /** + * 考试记录 + */ + ExamRecord(classId) { + uni.$u.route({ + url: '/pages/train_management/exam_record', + params: { + classId + } + }) + } } +} </script> <style scoped lang="scss"> - .container_item { - padding-left: 16rpx; +.container_item { + padding-left: 16rpx; - .container_item_name { - font-size: 32rpx; - font-weight: 500; - margin-bottom: 20rpx; - } + .container_item_name { + font-size: 32rpx; + font-weight: 500; + margin-bottom: 20rpx; + } - .container_item_content { - display: flex; - flex-direction: column; - gap: 8rpx; + .container_item_content { + display: flex; + flex-direction: column; + gap: 8rpx; - .content_text { - color: #acafb3; - font-size: 30rpx; + .content_text { + color: #acafb3; + font-size: 30rpx; - .content_label { - display: inline-block; - width: 220rpx; - } + .content_label { + display: inline-block; + width: 220rpx; + } - .content_value { - display: inline-block; - transform: translateY(8rpx); - padding: 0; - width: 452rpx; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; - } + .content_value { + display: inline-block; + transform: translateY(8rpx); + padding: 0; + width: 452rpx; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + } - .content_bottom { - display: flex; - align-items: center; - justify-content: space-between; - } + .content_bottom { + display: flex; + align-items: center; + justify-content: space-between; + } - .action-row { - display: flex; - align-items: center; - justify-content: center; - gap: 16rpx; - } + .action-row { + display: flex; + align-items: center; + justify-content: center; + gap: 16rpx; } } } -</style> \ No newline at end of file +} +</style> From 40bfdf1cf7bdd585e9ab7ca1969e7a0fe1cc3abf Mon Sep 17 00:00:00 2001 From: mengfanliang <mengfanliang@zcloudchina.com> Date: Wed, 19 Feb 2025 14:06:10 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=E4=BA=BA=E5=91=98=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E9=A1=B5=E9=9D=A2=E6=8E=A5=E5=8F=A3=E5=85=A5=E5=8F=82?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/index.js | 2 +- pages/train_management/index.vue | 13 +- pages/train_management/realname_info_auth.vue | 589 ++++++++---------- 3 files changed, 285 insertions(+), 319 deletions(-) diff --git a/api/index.js b/api/index.js index d2a1e65..ba3fd25 100644 --- a/api/index.js +++ b/api/index.js @@ -74,5 +74,5 @@ export const getHistoricalApprovalRecords = (params) => post("/app/Task/getHis", // ********************* start *********************** export const getIsUploadFace = (params) => post("/app/user/getUserFace", params); // 获取是否上传人脸信息 export const getClassList = (params) => post("/app/stagestudentrelation/pageTaskByUser", params); //获取班级列表 -export const joinClass = (params) => post("/app/student/joinClass", params); //实名认证信息提交 +export const joinClass = (params) => uploads("/app/student/joinClass", params); // 实名认证信息提交 // ********************* end *********************** diff --git a/pages/train_management/index.vue b/pages/train_management/index.vue index 34f28dc..25a280a 100644 --- a/pages/train_management/index.vue +++ b/pages/train_management/index.vue @@ -101,21 +101,24 @@ export default { // scanType: ['qrCode'], // 仅支持二维码扫码 onlyFromCamera: false, // 是否只能从相机扫码,不允许从相册选择图片 hideAlbum: false, // 隐藏相册,不允许从相册选择图片,只能从相机扫码 - success: function (res) { - if (res.result === '0') { + success: function (response) { + const { id, type } = JSON.parse(response.result); + if (type === '0') { // 签到二维码方式进入 uni.$u.route({ url: '/pages/train_management/realname_info_auth', params: { - type: 'scan_face' + type: 'scan_face', + classId: id } }) - } else if (res.result === '1') { + } else if (type === '1') { // 考试二维码方式进入 uni.$u.route({ url: '/pages/train_management/face_authentication', params: { - type: 'learning_certification' + type: 'learning_certification', + classId: id } }) } diff --git a/pages/train_management/realname_info_auth.vue b/pages/train_management/realname_info_auth.vue index 6c750d0..4abe76c 100644 --- a/pages/train_management/realname_info_auth.vue +++ b/pages/train_management/realname_info_auth.vue @@ -1,76 +1,70 @@ <template> - <view class="content"> - <view class="top-title">学员信息</view> + <view class="content"> + <view class="top-title">学员信息</view> - <u-gap height="20" bgColor="#f2f2f2" /> + <u-gap height="20" bgColor="#f2f2f2" /> - <view class="content_body"> - <u--form labelPosition="left" :model="ruleFormData" :rules="rules" ref="uFormRef"> - <u-form-item labelWidth="70" label="姓名" prop="userInfo.name" borderBottom required> - <u--input v-model="ruleFormData.userInfo.name" placeholder="请输入姓名..." border="none"></u--input> - </u-form-item> - <u-form-item labelWidth="80" label="联系电话" prop="userInfo.phone" borderBottom required> - <u--input v-model="ruleFormData.userInfo.phone" type="number" placeholder="请输入联系电话..." - border="none"></u--input> - </u-form-item> - <u-form-item labelWidth="80" label="身份证号" prop="userInfo.userIdCard" borderBottom required> - <u--input v-model="ruleFormData.userInfo.userIdCard" placeholder="请输入身份证号..." border="none"></u--input> - </u-form-item> - <u-form-item labelWidth="70" label="性别" prop="userInfo.sex" borderBottom required> - <u-radio-group v-model="ruleFormData.userInfo.sex" placement="row" class="radio-group__style" - @change="groupChange"> - <u-radio v-for="(item, index) in sexsList" :key="index" :label="item.name" :name="item.name"> - </u-radio> - </u-radio-group> - </u-form-item> - <u-form-item labelWidth="70" label="学历" prop="userInfo.degreeOfEducation" borderBottom required - @click="handleEducationClick"> - <u--input v-model="ruleFormData.userInfo.degreeOfEducation" readonly placeholder="请选择学历..." border="none"></u--input> - <!-- <u-action-sheet :show="showEducationPopper" :actions="educationActions" title="请选择学历" - @close="showEducationPopper = false" @select="handleSelectEducation"> - </u-action-sheet> --> - </u-form-item> - <u-form-item labelWidth="70" label="职业" prop="userInfo.job" borderBottom required> - <u--input v-model="ruleFormData.userInfo.job" placeholder="请输入职业..." border="none"></u--input> - </u-form-item> - <u-form-item labelWidth="125" label="职业资格等级证书" prop="userInfo.gradeCertificate" borderBottom required> - <u-upload :fileList="ruleFormData.userInfo.gradeCertificate" :previewFullImage="true" @afterRead="afterRead" - @delete="deletePic" name="1" multiple :maxCount="1"></u-upload> - </u-form-item> - <u-form-item labelWidth="120" label="获得证书时间" prop="userInfo.certificateAcquisitionTime" borderBottom required - @click="showCertificateGetTime"> - <u--input v-model="ruleFormData.userInfo.certificateAcquisitionTime" readonly placeholder="请选择获得证书时间..." - border="none"></u--input> - </u-form-item> - <u-form-item label="手写签字" prop="userInfo.writeSign" borderBottom required labelPosition="top" labelWidth="auto"> - <view style="flex: 1;"> - <u-button type="primary" size="mini" text="签字" - :customStyle="{ position: 'absolute', top: '-46upx', right: '20upx', width: '100upx' }" - @click="signVisible = true" /> - <view v-if="ruleFormData.userInfo.writeSign"> - <u-image width="400rpx" height="200rpx" :src="ruleFormData.userInfo.writeSign" /> - </view> - </view> - </u-form-item> - </u--form> + <view class="content_body"> + <u--form labelPosition="left" :model="ruleFormData" :rules="rules" ref="uFormRef"> + <u-form-item labelWidth="70" label="姓名" prop="userInfo.name" borderBottom required> + <u--input v-model="ruleFormData.userInfo.name" placeholder="请输入姓名..." border="none"></u--input> + </u-form-item> + <u-form-item labelWidth="80" label="联系电话" prop="userInfo.phone" borderBottom required> + <u--input v-model="ruleFormData.userInfo.phone" type="number" placeholder="请输入联系电话..." border="none"></u--input> + </u-form-item> + <u-form-item labelWidth="80" label="身份证号" prop="userInfo.userIdCard" borderBottom required> + <u--input v-model="ruleFormData.userInfo.userIdCard" placeholder="请输入身份证号..." border="none"></u--input> + </u-form-item> + <u-form-item labelWidth="70" label="性别" prop="userInfo.sex" borderBottom required> + <u-radio-group v-model="ruleFormData.userInfo.sex" placement="row" class="radio-group__style"> + <u-radio v-for="(item, index) in sexsList" :key="index" :label="item.name" :name="item.name"> </u-radio> + </u-radio-group> + </u-form-item> + <u-form-item labelWidth="70" label="学历" prop="userInfo.degreeOfEducation" borderBottom required @click="handleEducationClick"> + <u--input v-model="ruleFormData.userInfo.degreeOfEducation" readonly placeholder="请选择学历..." border="none"></u--input> + </u-form-item> + <u-form-item labelWidth="70" label="职业" prop="userInfo.job" borderBottom required> + <u--input v-model="ruleFormData.userInfo.job" placeholder="请输入职业..." border="none"></u--input> + </u-form-item> + <u-form-item labelWidth="125" label="职业资格等级证书" prop="userInfo.gradeCertificate" borderBottom required> + <u-upload :fileList="ruleFormData.userInfo.gradeCertificate" previewFullImage @afterRead="afterRead" @delete="deletePic" name="1" multiple :maxCount="1"></u-upload> + </u-form-item> + <u-form-item labelWidth="120" label="获得证书时间" prop="userInfo.certificateAcquisitionTime" borderBottom required @click="showCertificateGetTime"> + <u--input v-model="ruleFormData.userInfo.certificateAcquisitionTime" readonly placeholder="请选择获得证书时间..." border="none"></u--input> + </u-form-item> + <u-form-item label="手写签字" prop="userInfo.writeSign" borderBottom required labelPosition="top" labelWidth="auto"> + <view style="flex: 1"> + <u-button type="primary" size="mini" text="签字" :customStyle="{ position: 'absolute', top: '-46upx', right: '20upx', width: '100upx' }" @click="signVisible = true" /> + <view v-if="ruleFormData.userInfo.writeSign"> + <u-image width="400rpx" height="200rpx" :src="ruleFormData.userInfo.writeSign" /> + </view> + </view> + </u-form-item> + </u--form> - <view class="mt-10"> - <u-button type="primary" text="下一步" @click="$u.debounce(fnSubmit, 1000, true)" /> - </view> + <view class="mt-10"> + <u-button type="primary" text="下一步" @click="$u.debounce(fnSubmit, 1000, true)" /> + </view> + </view> - </view> + <sign :signShow.sync="signVisible" @confirm="handleSign" /> + <u-datetime-picker + :show="showCertificateGetTimePopper" + mode="datetime" + v-model="defaultDatetimePicker" + :round="12" + :custom-style="{ + borderRadius: '24rpx', + overflow: 'hidden', + '--picker-header-radius': '24rpx 24rpx 0 0', + '--picker-confirm-radius': '12rpx' + }" + @confirm="handleCertificateGetTimeConfirm" + @cancel="handleCertificateGetTimeCancel" + ></u-datetime-picker> - <sign :signShow.sync="signVisible" @confirm="handleSign" /> - <u-datetime-picker :show="showCertificateGetTimePopper" mode="date" :round="12" :custom-style="{ - borderRadius: '24rpx', - overflow: 'hidden', - '--picker-header-radius': '24rpx 24rpx 0 0', - '--picker-confirm-radius': '12rpx' - }" @confirm="handleCertificateGetTimeConfirm" @cancel="handleCertificateGetTimeCancel"></u-datetime-picker> - - <u-picker ref="uPicker" :show="singleChoice" :columns="singleChoiceColumns" keyName="NAME" - @confirm="fnSingleChoiceConfirm" @cancel="fnSingleChoiceCancel"></u-picker> - </view> + <u-picker ref="uPicker" :show="singleChoice" :columns="singleChoiceColumns" keyName="NAME" @confirm="fnSingleChoiceConfirm" @cancel="fnSingleChoiceCancel"></u-picker> + </view> </template> <script> @@ -79,260 +73,229 @@ import Sign from '@/components/sign/sign.vue' import { validateFieldPhone, validateFieldIdCard } from '@/utils/formValidateField.js' export default { - data() { - return { - routeQuery: {}, - sexsList: [ - { - label: '1', - name: '男' - }, - { - label: '0', - name: '女' - } - ], - singleChoice: false, - showCertificateGetTimePopper: false, - signVisible: false, - educationActions: [ - { - id: '0', - name: '小学', - }, - { - id: '1', - name: '初中', - }, - { - id: '2', - name: '高中', - }, - { - id: '3', - name: '大学专科', - }, - { - id: '4', - name: '大学本科', - }, - { - id: '5', - name: '研究生', - }, - { - id: '6', - name: '博士', - }, - { - id: '7', - name: '其他', - } - ], - singleChoiceColumns: [], - ruleFormData: { - userInfo: { - name: '', // 姓名 - phone: '', // 联系电话 - userIdCard: '', // 身份证号 - sex: '男', // 性别 - degreeOfEducation: '', // 学历 - job: '', // 职业 - gradeCertificate: [], // 等级证书 - certificateAcquisitionTime: '', // 获取证书时间 - writeSign: '', // 手写签字 - } - }, - rules: { - 'userInfo.name': { - type: 'string', - required: true, - message: '请填写姓名', - trigger: ['blur', 'change'] - }, - 'userInfo.phone': [ - { - required: true, - message: '请输入手机号', - trigger: ['change', 'blur'], - }, - { - validator: validateFieldPhone, - trigger: ['change', 'blur'], - } - ], - 'userInfo.userIdCard': [ - { - type: 'string', - required: true, - message: '请填写身份证号', - trigger: ['blur', 'change'] - }, - { - validator: validateFieldIdCard, - trigger: ['change', 'blur'], - } - ], - 'userInfo.sex': { - type: 'string', - required: true, - message: '请选择性别', - trigger: ['change'] - }, - 'userInfo.degreeOfEducation': { - type: 'string', - required: true, - message: '请选择学历', - trigger: ['blur', 'change'] - }, - 'userInfo.job': { - type: 'string', - required: true, - message: '请输入职业', - trigger: ['blur', 'change'] - }, - 'userInfo.gradeCertificate': [ - { - type: 'array', - required: true, - message: '请上传等级证书', - trigger: ['blur', 'change'] - } - ], - 'userInfo.certificateAcquisitionTime': { - type: 'string', - required: true, - message: '请选择获取证书时间', - trigger: ['blur', 'change'] - }, - 'userInfo.writeSign': [ - { - type: 'string', - required: true, - message: '请填写手写签字', - trigger: ['blur', 'change'] - } - ] - } - } - }, - - onLoad(query) { - this.routeQuery = query; - }, - - methods: { - groupChange(n) { - console.log('groupChange', n); - }, - radioChange(n) { - console.log('radioChange', n); - }, - handleEducationClick() { - this.$refs.uPicker.setIndexs([0]) - this.fnGetDataDictionary('d7d80f08d73a4accbccf4fd3d8d1d867') - this.singleChoice = true - }, - fnSingleChoiceConfirm(event) { - console.log(event, "sdfasdgf") - this.$set(this.ruleFormData.userInfo, 'degreeOfEducation', event.value[0].NAME) - this.$set(this.ruleFormData.userInfo, 'degreeOfEducation' + '_BIANMA', event.value[0].BIANMA) - this.singleChoice = false + data() { + return { + routeQuery: {}, // 上一个页面带过来的路由参数 + sexsList: [ + { + label: '1', + name: '男' + }, + { + label: '0', + name: '女' + } + ], + singleChoice: false, + showCertificateGetTimePopper: false, + signVisible: false, + defaultDatetimePicker: Number(new Date()), + singleChoiceColumns: [], + ruleFormData: { + userInfo: { + name: '', // 姓名 + phone: '', // 联系电话 + userIdCard: '', // 身份证号 + sex: '男', // 性别 + degreeOfEducation: '', // 学历 + job: '', // 职业 + gradeCertificate: [], // 等级证书 + certificateAcquisitionTime: '', // 获取证书时间 + writeSign: '' // 手写签字 + } + }, + rules: { + 'userInfo.name': { + type: 'string', + required: true, + message: '请填写姓名', + trigger: ['blur', 'change'] + }, + 'userInfo.phone': [ + { + required: true, + message: '请输入手机号', + trigger: ['change', 'blur'] + }, + { + validator: validateFieldPhone, + trigger: ['change', 'blur'] + } + ], + 'userInfo.userIdCard': [ + { + type: 'string', + required: true, + message: '请填写身份证号', + trigger: ['blur', 'change'] + }, + { + validator: validateFieldIdCard, + trigger: ['change', 'blur'] + } + ], + 'userInfo.sex': { + type: 'string', + required: true, + message: '请选择性别', + trigger: ['change'] + }, + 'userInfo.degreeOfEducation': { + type: 'string', + required: true, + message: '请选择学历', + trigger: ['blur', 'change'] + }, + 'userInfo.job': { + type: 'string', + required: true, + message: '请输入职业', + trigger: ['blur', 'change'] + }, + 'userInfo.gradeCertificate': [ + { + type: 'array', + required: true, + message: '请上传等级证书', + trigger: ['blur', 'change'] + } + ], + 'userInfo.certificateAcquisitionTime': { + type: 'string', + required: true, + message: '请选择获取证书时间', + trigger: ['blur', 'change'] + }, + 'userInfo.writeSign': [ + { + type: 'string', + required: true, + message: '请填写手写签字', + trigger: ['blur', 'change'] + } + ] + } + } }, - async fnGetDataDictionary(DICTIONARIES_ID) { - let resData = await getDataDictionary({ - DICTIONARIES_ID - }) - this.singleChoiceColumns = [resData.list] - }, - handleSelectEducation(event) { - this.ruleFormData.userInfo.degreeOfEducation = event.name; - }, - async afterRead(event) { - // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式 - let lists = [].concat(event.file); - let fileListLen = this.ruleFormData.userInfo.gradeCertificate.length; - lists.map((item) => { - this.ruleFormData.userInfo.gradeCertificate.push({ - ...item, - status: "uploading", - message: "上传中", - }); - }); - // console.log('this.ruleFormData.userInfo.gradeCertificate :>> ', this.ruleFormData.userInfo.gradeCertificate); - // for (let i = 0; i < lists.length; i++) { - // const result = await this.uploadFilePromise(lists[i].url); - // let item = this.ruleFormData.userInfo.gradeCertificate[fileListLen]; - // this.ruleFormData.userInfo.gradeCertificate.splice( - // fileListLen, - // 1, - // Object.assign(item, { - // status: "success", - // message: "", - // url: result, - // }) - // ); - // fileListLen++; - // } - }, - deletePic(event) { - this.gradeCertificateList.splice(event.index, 1); - }, - showCertificateGetTime() { - this.showCertificateGetTimePopper = true; - }, - handleCertificateGetTimeConfirm(event) { - this.ruleFormData.userInfo.certificateAcquisitionTime = uni.$u.timeFormat(event.value, 'yyyy-mm-dd') - this.handleCertificateGetTimeCancel() - }, - handleCertificateGetTimeCancel() { - this.showCertificateGetTimePopper = false; - }, - handleSign(event) { - this.ruleFormData.userInfo.writeSign = event.filePath; - }, - async fnSubmit() { - try { - await this.$refs.uFormRef.validate() - try { - console.log("this.ruleFormData.userInfo : >>", this.ruleFormData.userInfo); - await joinClass({ - form: this.form, - calssId: this.routeQuery.calssId, - }) - uni.$u.toast('保存成功') - uni.$u.route({ - url: '/pages/train_management/face_authentication', - params: { ...this.routeQuery } - }) - } catch { - } - } catch { - uni.$u.toast('请补全必填项') - } - } - } + onLoad(query) { + this.routeQuery = query // 接收上一个页面传递过来的路由参数 + }, + + methods: { + handleEducationClick() { + this.$refs.uPicker.setIndexs([0]) + this.fnGetDataDictionary('d7d80f08d73a4accbccf4fd3d8d1d867') + this.singleChoice = true + }, + fnSingleChoiceConfirm(event) { + this.$set(this.ruleFormData.userInfo, 'degreeOfEducation', event.value[0].NAME) + this.$set(this.ruleFormData.userInfo, 'degreeOfEducation' + '_BIANMA', event.value[0].BIANMA) + this.fnSingleChoiceCancel() + }, + fnSingleChoiceCancel() { + this.singleChoice = false + }, + async fnGetDataDictionary(DICTIONARIES_ID) { + let resData = await getDataDictionary({ + DICTIONARIES_ID + }) + this.singleChoiceColumns = [resData.list] + }, + handleSelectEducation(event) { + this.ruleFormData.userInfo.degreeOfEducation = event.name + }, + async afterRead(event) { + let lists = [].concat(event.file) + lists.map((item) => { + this.ruleFormData.userInfo.gradeCertificate.push({ + ...item, + status: 'success', + message: '' + }) + }) + }, + deletePic(event) { + this.ruleFormData.userInfo.gradeCertificate.splice(event.index, 1) + }, + showCertificateGetTime() { + this.showCertificateGetTimePopper = true + }, + handleCertificateGetTimeConfirm(event) { + this.ruleFormData.userInfo.certificateAcquisitionTime = uni.$u.timeFormat(event.value, 'yyyy-mm-dd hh:MM') + this.handleCertificateGetTimeCancel() + }, + handleCertificateGetTimeCancel() { + this.showCertificateGetTimePopper = false + }, + handleSign(event) { + this.ruleFormData.userInfo.writeSign = event.filePath + }, + async fnSubmit() { + const classId = this.routeQuery.classId + await this.$refs.uFormRef + .validate() + .then(async () => { + let files = [] + if (this.ruleFormData.userInfo.gradeCertificate[0]) { + files.push({ + name: 'certificatefile', + file: this.ruleFormData.userInfo.gradeCertificate[0], + uri: this.ruleFormData.userInfo.gradeCertificate[0].url + }) + } + if (this.ruleFormData.userInfo.writeSign) { + files.push({ + name: 'signfile', + uri: this.ruleFormData.userInfo.writeSign + }) + } + // const certificatefileLists = this.ruleFormData.userInfo.gradeCertificate.map(so => so.url); // 接入组合多个证书的上传, 返回数组 + const params = { ...this.ruleFormData.userInfo } + delete params.gradeCertificate + delete params.writeSign + await joinClass({ + files, + formData: { ...params, classId } + }) + .then(() => { + uni.$u.toast('保存成功') + setTimeout(() => { + uni.$u.route({ + url: '/pages/train_management/face_authentication', + params: { ...this.routeQuery, type: 'scan_face' } + }) + }, 1500) + }) + .catch((err) => { + if (err) uni.$u.toast(err.msg) + }) + }) + .catch((e) => { + uni.$u.toast('请补全必填项') + }) + } + } } </script> <style scoped lang="scss"> .content { - .top-title { - padding: 20rpx; - text-align: center; - font-size: 54rpx; - font-weight: bold; - } + .top-title { + padding: 20rpx; + text-align: center; + font-size: 54rpx; + font-weight: bold; + } - .content_body { - padding: 20rpx 30rpx; + .content_body { + padding: 20rpx 30rpx; - .radio-group__style { - display: flex; - flex-direction: row; - gap: 60rpx; - } - } + .radio-group__style { + display: flex; + flex-direction: row; + gap: 60rpx; + } + } } </style>