From 73e02c791991f5e6310cda05d0cfa36837f9e207 Mon Sep 17 00:00:00 2001 From: "lj7788@126.com" Date: Sat, 13 Sep 2025 15:08:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B0=8F=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../miniprogram/pageage/project_more/index.js | 4 +- .../miniprogram/pages/project_qr/index.js | 1119 +++++++++-------- 2 files changed, 599 insertions(+), 524 deletions(-) diff --git a/yanzhu-ui-app/miniprogram/pageage/project_more/index.js b/yanzhu-ui-app/miniprogram/pageage/project_more/index.js index c6749d00..77a5a2c0 100644 --- a/yanzhu-ui-app/miniprogram/pageage/project_more/index.js +++ b/yanzhu-ui-app/miniprogram/pageage/project_more/index.js @@ -148,8 +148,8 @@ Page({ fbrtDB: res.data.rysh, aqglDb: proUserInfo.subDeptType == "1" ? res.data.aqgl : 0, zlglDb: proUserInfo.subDeptType == "1" ? res.data.zlgl : 0, - aqyhDB: res.data.aqgl, - zlyhDB: res.data.zlgl, + aqyhDB: res.data.aqyh, + zlyhDB: res.data.zlyh, }); } }); diff --git a/yanzhu-ui-app/miniprogram/pages/project_qr/index.js b/yanzhu-ui-app/miniprogram/pages/project_qr/index.js index 1ecd3bd4..da6b4872 100644 --- a/yanzhu-ui-app/miniprogram/pages/project_qr/index.js +++ b/yanzhu-ui-app/miniprogram/pages/project_qr/index.js @@ -1,4 +1,4 @@ -import config from '../../config' +import config from "../../config"; import { setToken, setUserInfo, @@ -7,13 +7,13 @@ import { setOpenId, getSessionKey, setSessionKey, -} from '../../utils/auth' +} from "../../utils/auth"; import { wxNumberLogin, getMaOpenId, getMaPhoneNumber, findUserInfoByCache, -} from '../../api/login' +} from "../../api/login"; import { findProjectInfo, registerSubDepts, @@ -22,8 +22,8 @@ import { findProSubDeptsUser, findProSubDeptsInfo, findProSubDeptsUserById, - findProSubDeptsUserInfo -} from '../../api/project' + findProSubDeptsUserInfo, +} from "../../api/project"; import { findBusExamInfos, findBusTrainingVideos, @@ -31,17 +31,17 @@ import { endPlayUserEduVideo, finishEduVideo, submitBusExamUser, - submitUserSignets -} from '../../api/busEdu' + submitUserSignets, +} from "../../api/busEdu"; import { findDictCache, findCardOcrBack, findCardOcrFront, -} from '../../api/publics' +} from "../../api/publics"; import { securityFileUpload, - securitySignFileUpload -} from '../../utils/request' + securitySignFileUpload, +} from "../../utils/request"; const app = getApp(); Page({ /** @@ -54,7 +54,7 @@ Page({ craftPost: null, leaderDegreeGrade: null, userInfos: {}, - degreeGrade: null + degreeGrade: null, }, parForm: {}, limit: 1, @@ -66,45 +66,58 @@ Page({ initProject: {}, userPhoneNumber: null, userPostList: [], - deptTypeList: [{ - "id": "4", - "text": "劳务分包" - }, { - "id": "5", - "text": "专业分包" - }], + deptTypeList: [ + { + id: "4", + text: "劳务分包", + }, + { + id: "5", + text: "专业分包", + }, + ], craftTypeList: [], craftPostList: [], craftPostAllOrginList: [], - flowNodes: [{ - "id": "1", - "name": "信息登记", - "text": "信息登记" - }, { - "id": "2", - "name": "视频学习", - "text": "视频学习" - }, { - "id": "3", - "name": "在线考试", - "text": "在线考试" - }, { - "id": "4", - "name": "文件签署", - "text": "文件签署" - }], + flowNodes: [ + { + id: "1", + name: "信息登记", + text: "信息登记", + }, + { + id: "2", + name: "视频学习", + text: "视频学习", + }, + { + id: "3", + name: "在线考试", + text: "在线考试", + }, + { + id: "4", + name: "文件签署", + text: "文件签署", + }, + ], active: 0, - posDataList: [{ - 'id': 1, - 'text': '测试', - 'children': [{ - 'id': '2', - 'text': '测试111' - }, { - 'id': '3', - 'text': '测试222' - }] - }], + posDataList: [ + { + id: 1, + text: "测试", + children: [ + { + id: "2", + text: "测试111", + }, + { + id: "3", + text: "测试222", + }, + ], + }, + ], eduCationalType: [], showDetailsName: "", showDetailsPopup: false, @@ -120,22 +133,25 @@ Page({ busExamQuestions: [], time: 3600, // 初始倒计时为 3600 秒 timer: null, - timeStr: '', + timeStr: "", isPapers: false, fileForm: {}, signTime: 120, signTimer: null, - signPath: '', - youWuList: [{ - "id": "0", - "text": "无" - }, { - "id": "1", - "text": "有" - }], - illnessStatus: '', - supIllnessStatus: '', - loadShow: false + signPath: "", + youWuList: [ + { + id: "0", + text: "无", + }, + { + id: "1", + text: "有", + }, + ], + illnessStatus: "", + supIllnessStatus: "", + loadShow: false, }, /** @@ -155,45 +171,45 @@ Page({ } let title = ""; let _userPostList = []; - if (options.SIGID == '1') { + if (options.SIGID == "1") { title = "参建单位信息登记"; _userPostList.push({ - "id": "1", - "text": "委托代理人" + id: "1", + text: "委托代理人", }); - } else if (options.SIGID == '2' || options.SIGID == '3') { - if (options.SIGID == '2') { + } else if (options.SIGID == "2" || options.SIGID == "3") { + if (options.SIGID == "2") { _userPostList.push({ - "id": "2", - "text": "项目经理" + id: "2", + text: "项目经理", }); } else { _userPostList.push({ - "id": "3", - "text": "班组长" + id: "3", + text: "班组长", }); _userPostList.push({ - "id": "5", - "text": "特殊工种" + id: "5", + text: "特殊工种", }); _userPostList.push({ - "id": "6", - "text": "材料员" + id: "6", + text: "材料员", }); _userPostList.push({ - "id": "8", - "text": "安全员" + id: "8", + text: "安全员", }); } title = "参建单位管理人员信息登记"; - } else if (options.SIGID == '4') { + } else if (options.SIGID == "4") { title = "参建单位劳务人员信息登记"; _userPostList.push({ - "id": "4", - "text": "劳务人员" + id: "4", + text: "劳务人员", }); this.setData({ - "form.craftType": '1' + "form.craftType": "1", }); } this.setData({ @@ -217,7 +233,7 @@ Page({ * 获取字典缓存数据 */ getDictCache(signId) { - if (signId == '3') { + if (signId == "3") { // 初始化工种类型 // findDictCache("pro_craft_type").then(res => { // if (res.code == 200) { @@ -236,39 +252,39 @@ Page({ // } // }) // 初始化工种岗位 - findDictCache("pro_craft_post").then(res => { + findDictCache("pro_craft_post").then((res) => { if (res.code == 200) { let list = []; - res.data.forEach(item => { - if (item.cssClass == '1') { + res.data.forEach((item) => { + if (item.cssClass == "1") { list.push({ - "id": item.dictValue, - "text": item.dictLabel + id: item.dictValue, + text: item.dictLabel, }); } }); this.setData({ craftPostList: list, - craftPostAllOrginList: res.data + craftPostAllOrginList: res.data, }); } - }) + }); } // 初始化学历类型 - findDictCache("educational_type").then(res => { + findDictCache("educational_type").then((res) => { if (res.code == 200) { let eduCationalType = []; - res.data.forEach(item => { + res.data.forEach((item) => { eduCationalType.push({ - "id": item.dictValue, - "text": item.dictLabel + id: item.dictValue, + text: item.dictLabel, }); - }) + }); this.setData({ - eduCationalType + eduCationalType, }); } - }) + }); }, /** @@ -276,25 +292,25 @@ Page({ */ getMaOpenId: function () { wx.login({ - success: res => { + success: (res) => { getMaOpenId({ - 'code': res.code - }).then(response => { + code: res.code, + }).then((response) => { setOpenId(response.data.openid); setSessionKey(response.data.sessionKey); }); - } - }) + }, + }); }, /** * 查询单位上级人员信息 */ getProSubDeptsUser(parId) { - findProSubDeptsUserById(parId).then(res => { + findProSubDeptsUserById(parId).then((res) => { if (res.code == 200) { this.setData({ - parForm: res.data + parForm: res.data, }); } }); @@ -302,7 +318,7 @@ Page({ /** * 获取手机号码 - * @param {*} e + * @param {*} e */ getPhoneNumber(e) { if (e.detail.code) { @@ -310,14 +326,14 @@ Page({ openId: getOpenId(), sessionKey: getSessionKey(), iv: e.detail.iv, - encryptedData: e.detail.encryptedData - } - getMaPhoneNumber(data).then(res => { + encryptedData: e.detail.encryptedData, + }; + getMaPhoneNumber(data).then((res) => { if (res.code == 200) { let phoneNumber = res.data; this.initData(phoneNumber); } - }) + }); } else { //用户决绝授权 app.toast("请允许微信手机号一键登录"); @@ -327,34 +343,51 @@ Page({ initData(phoneNumber) { //使用手机号码查询详情 if (this.data.userPost == "1") { - findProSubDeptsInfo(this.data.proId, phoneNumber).then(deptRes => { + findProSubDeptsInfo(this.data.proId, phoneNumber).then((deptRes) => { if (deptRes.code == 200 && deptRes.data) { deptRes.data.subDeptLeaderPhone = phoneNumber; if (deptRes.data.proProjectInfoSubdeptsUsers) { - deptRes.data.leaderDegreeGrade = deptRes.data.proProjectInfoSubdeptsUsers.degreeGrade; - deptRes.data.eduFilePath = deptRes.data.proProjectInfoSubdeptsUsers.eduFilePath; - deptRes.data.subStep = deptRes.data.proProjectInfoSubdeptsUsers.subStep; + deptRes.data.leaderDegreeGrade = + deptRes.data.proProjectInfoSubdeptsUsers.degreeGrade; + deptRes.data.eduFilePath = + deptRes.data.proProjectInfoSubdeptsUsers.eduFilePath; + deptRes.data.subStep = + deptRes.data.proProjectInfoSubdeptsUsers.subStep; } if (deptRes.data.businessLicensePath) { - deptRes.data.businessLicensePath = (this.data.imgBase + deptRes.data.businessLicensePath).split(','); + deptRes.data.businessLicensePath = ( + this.data.imgBase + deptRes.data.businessLicensePath + ).split(","); } if (deptRes.data.subDeptInfos) { let subDeptInfosJSON = JSON.parse(deptRes.data.subDeptInfos); deptRes.data.subDeptInfos = subDeptInfosJSON; if (deptRes.data.subDeptInfos.legalPersonCardImgPos) { - deptRes.data.subDeptInfos.legalPersonCardImgPos = (this.data.imgBase + deptRes.data.subDeptInfos.legalPersonCardImgPos).split(','); + deptRes.data.subDeptInfos.legalPersonCardImgPos = ( + this.data.imgBase + + deptRes.data.subDeptInfos.legalPersonCardImgPos + ).split(","); } if (deptRes.data.subDeptInfos.legalPersonCardImgInv) { - deptRes.data.subDeptInfos.legalPersonCardImgInv = (this.data.imgBase + deptRes.data.subDeptInfos.legalPersonCardImgInv).split(','); + deptRes.data.subDeptInfos.legalPersonCardImgInv = ( + this.data.imgBase + + deptRes.data.subDeptInfos.legalPersonCardImgInv + ).split(","); } } if (deptRes.data.proProjectInfoSubdeptsUsers.userInfos) { - let userInfosJSON = JSON.parse(deptRes.data.proProjectInfoSubdeptsUsers.userInfos); + let userInfosJSON = JSON.parse( + deptRes.data.proProjectInfoSubdeptsUsers.userInfos + ); if (userInfosJSON.cardImgPos) { - deptRes.data.leaderCardImgPos = (this.data.imgBase + userInfosJSON.cardImgPos).split(','); + deptRes.data.leaderCardImgPos = ( + this.data.imgBase + userInfosJSON.cardImgPos + ).split(","); } if (userInfosJSON.cardImgInv) { - deptRes.data.leaderCardImgInv = (this.data.imgBase + userInfosJSON.cardImgInv).split(','); + deptRes.data.leaderCardImgInv = ( + this.data.imgBase + userInfosJSON.cardImgInv + ).split(","); } deptRes.data.proProjectInfoSubdeptsUsers.userInfos = userInfosJSON; deptRes.data.nativePlace = userInfosJSON.nativePlace; @@ -364,15 +397,21 @@ Page({ deptRes.data.contactPhone = userInfosJSON.contactPhone; } if (deptRes.data.proProjectInfoSubdeptsUsers.userPicture) { - deptRes.data.leaderUserPicture = (this.data.imgBase + deptRes.data.proProjectInfoSubdeptsUsers.userPicture).split(','); + deptRes.data.leaderUserPicture = ( + this.data.imgBase + + deptRes.data.proProjectInfoSubdeptsUsers.userPicture + ).split(","); } if (deptRes.data.proProjectInfoSubdeptsUsers.subDeptPowerPath) { - deptRes.data.subDeptLeaderPowerPath = (this.data.imgBase + deptRes.data.proProjectInfoSubdeptsUsers.subDeptPowerPath).split(','); + deptRes.data.subDeptLeaderPowerPath = ( + this.data.imgBase + + deptRes.data.proProjectInfoSubdeptsUsers.subDeptPowerPath + ).split(","); } this.setData({ form: deptRes.data, userPhoneNumber: phoneNumber, - active: deptRes.data.subStep + active: deptRes.data.subStep, }); if (deptRes.data.proProjectInfoSubdeptsUsers.subStep == 1) { this.initBusEduVideos(false); @@ -389,7 +428,7 @@ Page({ } }); } else { - findProSubDeptsUser(this.data.proId, phoneNumber).then(userRes => { + findProSubDeptsUser(this.data.proId, phoneNumber).then((userRes) => { if (userRes.code == 200 && userRes.data) { if (userRes.data.userInfos) { let userInfosJSON = JSON.parse(userRes.data.userInfos); @@ -405,22 +444,30 @@ Page({ userRes.data.cardImgInv = userInfosJSON.cardImgInv; } if (userRes.data.cardImgPos) { - userRes.data.cardImgPos = (this.data.imgBase + userRes.data.cardImgPos).split(','); + userRes.data.cardImgPos = ( + this.data.imgBase + userRes.data.cardImgPos + ).split(","); } if (userRes.data.cardImgInv) { - userRes.data.cardImgInv = (this.data.imgBase + userRes.data.cardImgInv).split(','); + userRes.data.cardImgInv = ( + this.data.imgBase + userRes.data.cardImgInv + ).split(","); } if (userRes.data.userPicture) { - userRes.data.userPicture = (this.data.imgBase + userRes.data.userPicture).split(','); + userRes.data.userPicture = ( + this.data.imgBase + userRes.data.userPicture + ).split(","); } if (userRes.data.subDeptPowerPath) { - userRes.data.subDeptPowerPath = (this.data.imgBase + userRes.data.subDeptPowerPath).split(','); + userRes.data.subDeptPowerPath = ( + this.data.imgBase + userRes.data.subDeptPowerPath + ).split(","); } this.setData({ form: userRes.data, userPhoneNumber: phoneNumber, "form.userPhone": phoneNumber, - active: userRes.data.subStep + active: userRes.data.subStep, }); if (userRes.data.subStep == 1) { this.initBusEduVideos(false); @@ -444,39 +491,41 @@ Page({ */ initBusEduVideos: function (skip) { this.setData({ - active: skip ? (this.data.active + 1) : this.data.active - }) - findBusTrainingVideos(this.data.proId, this.data.userPhoneNumber).then(res => { - if (res.code == 200) { - if (res.data && res.data.length > 0) { - let videoMenus = []; - let videoItems = []; - res.data.forEach(menuItem => { - videoMenus.push({ - 'menuId': menuItem.menuId, - 'menuName': menuItem.menuName + active: skip ? this.data.active + 1 : this.data.active, + }); + findBusTrainingVideos(this.data.proId, this.data.userPhoneNumber).then( + (res) => { + if (res.code == 200) { + if (res.data && res.data.length > 0) { + let videoMenus = []; + let videoItems = []; + res.data.forEach((menuItem) => { + videoMenus.push({ + menuId: menuItem.menuId, + menuName: menuItem.menuName, + }); + menuItem.busTrainingVideos.forEach((videoItem) => { + videoItem.menuId = menuItem.menuId; + videoItem.menuName = menuItem.menuName; + videoItems.push(videoItem); + }); }); - menuItem.busTrainingVideos.forEach(videoItem => { - videoItem.menuId = menuItem.menuId; - videoItem.menuName = menuItem.menuName; - videoItems.push(videoItem); + startPlayUserEduVideo(videoItems[0].remark); + this.setData({ + videoActive: res.data[0].menuId, + eduVideoMenu: videoMenus, + eduVideoItem: videoItems, + videoIdx: 0, + videoUrl: this.data.imgBase + videoItems[0].trainFilePath, + videoTitle: videoItems[0].trainTitle, }); - }); - startPlayUserEduVideo(videoItems[0].remark); - this.setData({ - videoActive: res.data[0].menuId, - eduVideoMenu: videoMenus, - eduVideoItem: videoItems, - videoIdx: 0, - videoUrl: this.data.imgBase + videoItems[0].trainFilePath, - videoTitle: videoItems[0].trainTitle, - }); - } else { - //没有视频时跳过学习... - this.initBusEduQuestion(); + } else { + //没有视频时跳过学习... + this.initBusEduQuestion(); + } } } - }); + ); }, /** @@ -487,14 +536,14 @@ Page({ app.toast("播放失败,这已经是第一个视频了。"); } else { this.setData({ - videoIdx: this.data.videoIdx - 1 + videoIdx: this.data.videoIdx - 1, }); this.data.eduVideoItem.forEach((item, idx) => { if (this.data.videoIdx == idx) { this.setData({ videoActive: item.menuId, videoUrl: this.data.imgBase + item.trainFilePath, - videoTitle: item.trainTitle + videoTitle: item.trainTitle, }); } }); @@ -508,24 +557,31 @@ Page({ let videoSize = this.data.eduVideoItem.length; let currentVideo = this.data.videoIdx + 1; if (currentVideo >= videoSize) { - finishEduVideo(this.data.eduVideoItem[this.data.videoIdx].remark).then(res => { - //视频学习完成... - app.toast("学习完成,您可以开始考试了。", "none", 3000); - }); + finishEduVideo(this.data.eduVideoItem[this.data.videoIdx].remark).then( + (res) => { + //视频学习完成... + app.toast("学习完成,您可以开始考试了。", "none", 3000); + } + ); } else { endPlayUserEduVideo(this.data.eduVideoItem[this.data.videoIdx].remark); startPlayUserEduVideo(this.data.eduVideoItem[currentVideo].remark); - let msg = "正在学习第 " + currentVideo + "个视频,还有 " + (videoSize - currentVideo) + "个视频待学习。"; + let msg = + "正在学习第 " + + currentVideo + + "个视频,还有 " + + (videoSize - currentVideo) + + "个视频待学习。"; app.toast(msg, "none", 1500); this.setData({ - videoIdx: this.data.videoIdx + 1 + videoIdx: this.data.videoIdx + 1, }); this.data.eduVideoItem.forEach((item, idx) => { if (this.data.videoIdx == idx) { this.setData({ videoActive: item.menuId, videoUrl: this.data.imgBase + item.trainFilePath, - videoTitle: item.trainTitle + videoTitle: item.trainTitle, }); } }); @@ -550,8 +606,8 @@ Page({ */ anewBusEduQuestion() { this.setData({ - isPapers: false - }) + isPapers: false, + }); this.initBusEduQuestion(false); }, @@ -560,22 +616,22 @@ Page({ */ initBusEduQuestion: function (skip) { this.setData({ - active: skip ? (this.data.active + 1) : this.data.active + active: skip ? this.data.active + 1 : this.data.active, }); clearInterval(this.data.timer); this.setData({ - time: 3600 + time: 3600, }); this.startCountdown(); // 页面加载时开始倒计时 - findBusExamInfos(this.data.proId, this.data.userPhoneNumber).then(res => { + findBusExamInfos(this.data.proId, this.data.userPhoneNumber).then((res) => { if (res.code == 200) { if (res.data && res.data && res.data.busExamUserResultList) { - res.data.busExamUserResultList.forEach(item => { + res.data.busExamUserResultList.forEach((item) => { item.questionOption = JSON.parse(item.questionOption); }); this.setData({ busExamInfos: res.data, - busExamQuestions: res.data.busExamUserResultList + busExamQuestions: res.data.busExamUserResultList, }); } else { //没有答题时跳过学习... @@ -587,47 +643,48 @@ Page({ /** * 选中单选框 - * @param {*} e + * @param {*} e */ toggleRadio(e) { if (!this.data.isPapers) { - let idxs = e.currentTarget.dataset.id.split('_'); + let idxs = e.currentTarget.dataset.id.split("_"); let _busExamQuestions = this.data.busExamQuestions; - _busExamQuestions[idxs[0]].questionOption.forEach(item => { + _busExamQuestions[idxs[0]].questionOption.forEach((item) => { item.selected = false; - }) + }); _busExamQuestions[idxs[0]].questionOption[idxs[1]].selected = true; let _userAnswer = []; - _busExamQuestions[idxs[0]].questionOption.forEach(item => { + _busExamQuestions[idxs[0]].questionOption.forEach((item) => { if (item.selected) { _userAnswer.push(item.opt); } }); _busExamQuestions[idxs[0]].userAnswer = _userAnswer.toString(); this.setData({ - busExamQuestions: _busExamQuestions + busExamQuestions: _busExamQuestions, }); } }, /** * 选中复选框 - * @param {*} e + * @param {*} e */ toggleCheckbox(e) { if (!this.data.isPapers) { - let idxs = e.currentTarget.dataset.id.split('_'); + let idxs = e.currentTarget.dataset.id.split("_"); let _busExamQuestions = this.data.busExamQuestions; - _busExamQuestions[idxs[0]].questionOption[idxs[1]].selected = !_busExamQuestions[idxs[0]].questionOption[idxs[1]].selected; + _busExamQuestions[idxs[0]].questionOption[idxs[1]].selected = + !_busExamQuestions[idxs[0]].questionOption[idxs[1]].selected; let _userAnswer = []; - _busExamQuestions[idxs[0]].questionOption.forEach(item => { + _busExamQuestions[idxs[0]].questionOption.forEach((item) => { if (item.selected) { _userAnswer.push(item.opt); } }); _busExamQuestions[idxs[0]].userAnswer = _userAnswer.toString(); this.setData({ - busExamQuestions: _busExamQuestions + busExamQuestions: _busExamQuestions, }); } }, @@ -650,7 +707,11 @@ Page({ if (skip == "skip") { _busExamQuestions[i].userAnswer = ""; } else { - app.toast("第" + (i + 1) + "题还未答,请完成考试后再提交试卷!", "none", 1500); + app.toast( + "第" + (i + 1) + "题还未答,请完成考试后再提交试卷!", + "none", + 1500 + ); return false; } } else { @@ -658,19 +719,19 @@ Page({ } } this.setData({ - busExamQuestions: _busExamQuestions + busExamQuestions: _busExamQuestions, }); let that = this; //弹出确认 wx.showModal({ - title: '提示', - content: '是否确认提交试卷信息?', + title: "提示", + content: "是否确认提交试卷信息?", success: function (sm) { if (sm.confirm) { that.submitThePapersValues(); } - } - }) + }, + }); }, /** @@ -679,24 +740,24 @@ Page({ submitThePapersValues() { let examForm = this.data.busExamInfos; let busExamQuestions = this.data.busExamQuestions; - busExamQuestions.forEach(item => { + busExamQuestions.forEach((item) => { item.questionOption = null; }); examForm.busExamUserResultList = busExamQuestions; - submitBusExamUser(examForm).then(res => { + submitBusExamUser(examForm).then((res) => { this.setData({ isPapers: true, - busExamInfos: res.data + busExamInfos: res.data, }); wx.pageScrollTo({ - scrollTop: 0 + scrollTop: 0, }); }); }, /** * 开始签署文件 - * @param {*} skip + * @param {*} skip */ startSignFile(skip) { let _fileForm = {}; @@ -706,10 +767,10 @@ Page({ _fileForm.fPost = ""; _fileForm.fDate = ""; this.setData({ - active: skip ? (this.data.active + 1) : this.data.active, + active: skip ? this.data.active + 1 : this.data.active, fileForm: _fileForm, - signTime: 120 - }) + signTime: 120, + }); clearInterval(this.data.signTimer); this.startSignCountdown(); }, @@ -719,11 +780,7 @@ Page({ * 跳转签名页面 */ startSignFiles() { - let { - signTime, - illnessStatus, - supIllnessStatus - } = this.data; + let { signTime, illnessStatus, supIllnessStatus } = this.data; if (signTime > 0) { app.toast("请仔细阅读各项承诺书及三级安全教育!"); return false; @@ -731,14 +788,14 @@ Page({ if (illnessStatus == "") { app.toast("请选择健康情况!"); wx.pageScrollTo({ - scrollTop: 99999 + scrollTop: 99999, }); return false; } if (supIllnessStatus == "") { app.toast("请选择严重疾病情况!"); wx.pageScrollTo({ - scrollTop: 99999 + scrollTop: 99999, }); return false; } @@ -750,11 +807,11 @@ Page({ * 确认签名 */ sign(e) { - let tempFilePath = e.detail - securitySignFileUpload(tempFilePath).then(res => { + let tempFilePath = e.detail; + securitySignFileUpload(tempFilePath).then((res) => { if (res.code == 200) { this.setData({ - signPath: res.data.url + signPath: res.data.url, }); } }); @@ -764,13 +821,8 @@ Page({ * 提交签名 */ submitSignFiles() { - let { - proId, - signPath, - userPhoneNumber, - illnessStatus, - supIllnessStatus - } = this.data; + let { proId, signPath, userPhoneNumber, illnessStatus, supIllnessStatus } = + this.data; if (illnessStatus == "") { app.toast("请选择身体健康情况!"); return false; @@ -787,14 +839,14 @@ Page({ let that = this; //弹出确认 wx.showModal({ - title: '提示', - content: '是否确认提交文件签署信息?', + title: "提示", + content: "是否确认提交文件签署信息?", success: function (sm) { if (sm.confirm) { that.submitSignFilesValues(); } - } - }) + }, + }); } else { app.toast("信息异常...请刷新页面后重新操作!"); return false; @@ -805,26 +857,21 @@ Page({ * 提交文件签署表单 */ submitSignFilesValues() { - let { - proId, - signPath, - userPhoneNumber, - illnessStatus, - supIllnessStatus - } = this.data; + let { proId, signPath, userPhoneNumber, illnessStatus, supIllnessStatus } = + this.data; let param = {}; param.proId = proId; param.userPhone = userPhoneNumber; param.imgPath = signPath; param.illnessStatus = illnessStatus; param.supIllnessStatus = supIllnessStatus; - submitUserSignets(param).then(res => { + submitUserSignets(param).then((res) => { if (res.code == 200) { this.setData({ active: res.data.subStep, "form.subStep": res.data.subStep, "form.approveStatus": res.data.approveStatus, - "form.eduFilePath": res.data.eduFilePath + "form.eduFilePath": res.data.eduFilePath, }); } }); @@ -838,7 +885,7 @@ Page({ let _eduFilePath = this.data.form.eduFilePath; wx.downloadFile({ // 示例 url,并非真实存在 - url: _baseUrl + '/file/NoSecurity/download?fileName=' + _eduFilePath, + url: _baseUrl + "/file/NoSecurity/download?fileName=" + _eduFilePath, success: function (res) { const filePath = res.tempFilePath; const fileTypes = _eduFilePath.split("."); @@ -846,19 +893,19 @@ Page({ filePath: filePath, fileType: fileTypes[fileTypes.length - 1], success: function (res) { - console.log('打开文档成功') + console.log("打开文档成功"); }, fail: function (res) { - console.log(res) - } - }) - } - }) + console.log(res); + }, + }); + }, + }); }, /** * 根据身份证号获取性别 - * @param {*} idCard + * @param {*} idCard */ getGenderFromIdCard: function (idCard) { // 先判断是否是有效的身份证号码(18位或15位) @@ -867,7 +914,10 @@ Page({ return "未知"; } // 如果是18位身份证,倒数第二位是性别标志 - const genderDigit = idCard.length === 18 ? parseInt(idCard.charAt(16)) : parseInt(idCard.charAt(14)); + const genderDigit = + idCard.length === 18 + ? parseInt(idCard.charAt(16)) + : parseInt(idCard.charAt(14)); // 根据性别标志判断男女 if (genderDigit % 2 === 0) { return "女"; // 偶数为女性 @@ -887,337 +937,337 @@ Page({ * 授权登录 */ getProjectInfo: function (proId) { - findProjectInfo(proId).then(res => { + findProjectInfo(proId).then((res) => { let list = []; list.push({ - 'id': res.data.id, - 'text': res.data.projectName + id: res.data.id, + text: res.data.projectName, }); app.globalData.projectInfoList = list; app.globalData.useProjectId = res.data.id; app.globalData.useProjectName = res.data.projectName; this.setData({ initProject: { - 'id': res.data.id, - 'text': res.data.projectName - } + id: res.data.id, + text: res.data.projectName, + }, }); }); }, /** * 选中单位类型 - * @param {*} e + * @param {*} e */ onSubDeptType(e) { this.setData({ - "form.subDeptType": e.detail.id - }) + "form.subDeptType": e.detail.id, + }); }, /** * 参建单位名称 - * @param {*} e + * @param {*} e */ onSubDeptName(e) { this.setData({ - "form.subDeptName": e.detail.value - }) + "form.subDeptName": e.detail.value, + }); }, /** * 社会信用代码 - * @param {*} e + * @param {*} e */ onSubDeptCode(e) { this.setData({ - "form.subDeptCode": e.detail.value - }) + "form.subDeptCode": e.detail.value, + }); }, /** * 营业执照副本 - * @param {*} options + * @param {*} options */ fileUpload0(options) { let file = options.detail; this.setData({ - "form.businessLicensePath": file + "form.businessLicensePath": file, }); }, /** * 法人身份证正面 - * @param {*} options + * @param {*} options */ fileUpload1(options) { let file = options.detail; this.setData({ - "form.subDeptInfos.legalPersonCardImgPos": file + "form.subDeptInfos.legalPersonCardImgPos": file, }); file.forEach(async (item, idx) => { let obj = await this.syncUploadImage(item); - findCardOcrFront(obj.data.data.url).then(res => { + findCardOcrFront(obj.data.data.url).then((res) => { if (res.code == 200) { this.setData({ "form.subDeptInfos.legalPerson": res.data.name, - "form.subDeptInfos.legalPersonCard": res.data.cardId - }) + "form.subDeptInfos.legalPersonCard": res.data.cardId, + }); if (!res.data.name || !res.data.cardId) { this.setData({ - "form.subDeptInfos.legalPersonCardImgPos": [] + "form.subDeptInfos.legalPersonCardImgPos": [], }); app.toast("身份证正面照识别失败!请重新上传"); } } }); - }) + }); }, /** * 法人身份证反面 - * @param {*} options + * @param {*} options */ fileUpload2(options) { let file = options.detail; this.setData({ - "form.subDeptInfos.legalPersonCardImgInv": file + "form.subDeptInfos.legalPersonCardImgInv": file, }); }, /** 单位法人姓名 */ inputInfoslegalPerson(e) { this.setData({ - "form.subDeptInfos.legalPerson": e.detail.value - }) + "form.subDeptInfos.legalPerson": e.detail.value, + }); }, /** 单位法人身份证号 */ inputInfoslegalPersonCard(e) { this.setData({ - "form.subDeptInfos.legalPersonCard": e.detail.value - }) + "form.subDeptInfos.legalPersonCard": e.detail.value, + }); }, /** 合同约定的承包范围 */ inputContractInfos(e) { this.setData({ - "form.contractInfos": e.detail.value - }) + "form.contractInfos": e.detail.value, + }); }, /** 进入场地时间 */ onInputTime0(e) { this.setData({ - "form.useDates": e.detail - }) + "form.useDates": e.detail, + }); }, /** 计划开工时间 */ onInputTime1(e) { this.setData({ - "form.startWorkDates": e.detail - }) + "form.startWorkDates": e.detail, + }); }, /** 计划完工时间 */ onInputTime2(e) { this.setData({ - "form.endWorkDates": e.detail - }) + "form.endWorkDates": e.detail, + }); }, /** * 委托人身份证反面 - * @param {*} options + * @param {*} options */ fileUpload3(options) { let file = options.detail; this.setData({ - "form.leaderCardImgPos": file + "form.leaderCardImgPos": file, }); file.forEach(async (item, idx) => { let obj = await this.syncUploadImage(item); - findCardOcrFront(obj.data.data.url).then(res => { + findCardOcrFront(obj.data.data.url).then((res) => { if (res.code == 200) { this.setData({ "form.subDeptLeaderName": res.data.name, "form.subDeptLeaderCode": res.data.cardId, "form.nation": res.data.nation, "form.nativePlace": res.data.native, - "form.address": res.data.address - }) + "form.address": res.data.address, + }); if (!res.data.name || !res.data.cardId) { this.setData({ - "form.leaderCardImgPos": [] + "form.leaderCardImgPos": [], }); app.toast("身份证正面照识别失败!请重新上传"); } } }); - }) + }); }, /** * 委托人身份证反面 - * @param {*} options + * @param {*} options */ fileUpload4(options) { let file = options.detail; this.setData({ - "form.leaderCardImgInv": file + "form.leaderCardImgInv": file, }); }, /** * 委托人半身照 - * @param {*} options + * @param {*} options */ fileUpload5(options) { let file = options.detail; this.setData({ - "form.leaderUserPicture": file + "form.leaderUserPicture": file, }); }, /** * 委托人委托书 - * @param {*} options + * @param {*} options */ fileUpload6(options) { let file = options.detail; this.setData({ - "form.subDeptLeaderPowerPath": file + "form.subDeptLeaderPowerPath": file, }); }, /** * 输入负责人姓名 - * @param {*} e + * @param {*} e */ inputLeaderName(e) { this.setData({ - "form.subDeptLeaderName": e.detail.value - }) + "form.subDeptLeaderName": e.detail.value, + }); }, /** * 输入负责人身份证号 - * @param {*} e + * @param {*} e */ inputLeaderCode(e) { this.setData({ - "form.subDeptLeaderCode": e.detail.value - }) + "form.subDeptLeaderCode": e.detail.value, + }); }, /** * 输入负责人联系电话 - * @param {*} e + * @param {*} e */ subDeptLeaderPhone(e) { this.setData({ - "form.subDeptLeaderPhone": e.detail.value - }) + "form.subDeptLeaderPhone": e.detail.value, + }); }, /** * 负责人学历 - * @param {*} e + * @param {*} e */ onLeaderDegreeGrade(e) { this.setData({ - "form.leaderDegreeGrade": e.detail.id - }) + "form.leaderDegreeGrade": e.detail.id, + }); }, /** * 选中岗位级别 - * @param {*} e + * @param {*} e */ onChageUserPost(e) { this.setData({ userPost: e.detail.id, "form.userPost": e.detail.id, - "form.craftPost": null - }) - if (e.detail.id == '3') { + "form.craftPost": null, + }); + if (e.detail.id == "3") { let craftPostList = []; - this.data.craftPostAllOrginList.forEach(item => { - if (item.cssClass == '1') { + this.data.craftPostAllOrginList.forEach((item) => { + if (item.cssClass == "1") { craftPostList.push({ - "id": item.dictValue, - "text": item.dictLabel + id: item.dictValue, + text: item.dictLabel, }); } - }) + }); this.setData({ craftPostList, - "form.craftType": '1', - "form.craftPost": null - }) - } else if (e.detail.id == '5') { + "form.craftType": "1", + "form.craftPost": null, + }); + } else if (e.detail.id == "5") { let craftPostList = []; - this.data.craftPostAllOrginList.forEach(item => { - if (item.cssClass == '2') { + this.data.craftPostAllOrginList.forEach((item) => { + if (item.cssClass == "2") { craftPostList.push({ - "id": item.dictValue, - "text": item.dictLabel + id: item.dictValue, + text: item.dictLabel, }); } - }) + }); this.setData({ craftPostList, - "form.craftType": '2', - "form.craftPost": null - }) + "form.craftType": "2", + "form.craftPost": null, + }); } }, /** * 选中工种类型 - * @param {*} e + * @param {*} e */ onChageCraftType(e) { //设置工种岗位 let craftPostList = []; - this.data.craftPostAllOrginList.forEach(item => { + this.data.craftPostAllOrginList.forEach((item) => { if (item.cssClass == e.detail.id) { craftPostList.push({ - "id": item.dictValue, - "text": item.dictLabel + id: item.dictValue, + text: item.dictLabel, }); } - }) + }); this.setData({ craftPostList, "form.craftType": e.detail.id, - "form.craftPost": null - }) + "form.craftPost": null, + }); }, /** * 选中工种岗位 - * @param {*} e + * @param {*} e */ onChageCraftPost(e) { this.setData({ - "form.craftPost": e.detail.id - }) + "form.craftPost": e.detail.id, + }); }, /** * 个人身份证正面照 - * @param {*} options + * @param {*} options */ fileUploadCardImgPos(options) { let file = options.detail; this.setData({ - "form.cardImgPos": file + "form.cardImgPos": file, }); file.forEach(async (item, idx) => { let obj = await this.syncUploadImage(item); - findCardOcrFront(obj.data.data.url).then(res => { + findCardOcrFront(obj.data.data.url).then((res) => { if (res.code == 200) { if (res.data.nation.indexOf("族") < 0) { res.data.nation = res.data.nation + "族"; @@ -1227,80 +1277,80 @@ Page({ "form.cardCode": res.data.cardId, "form.nation": res.data.nation, "form.nativePlace": res.data.native, - "form.address": res.data.address - }) + "form.address": res.data.address, + }); if (!res.data.name || !res.data.cardId) { this.setData({ - "form.cardImgPos": [] + "form.cardImgPos": [], }); app.toast("身份证正面照识别失败!请重新上传"); } } }); - }) + }); }, /** * 个人身份证反面照 - * @param {*} options + * @param {*} options */ fileUploadCardImgInv(options) { let file = options.detail; this.setData({ - "form.cardImgInv": file + "form.cardImgInv": file, }); }, /** * 个人半身近照 - * @param {*} options + * @param {*} options */ fileUploadUserPicture(options) { let file = options.detail; this.setData({ - "form.userPicture": file + "form.userPicture": file, }); }, /** * 单位委托书 - * @param {*} options + * @param {*} options */ fileUploadDeptPower(options) { let file = options.detail; this.setData({ - "form.subDeptPowerPath": file + "form.subDeptPowerPath": file, }); }, /** * 输入个人姓名 - * @param {*} e + * @param {*} e */ inputUserName(e) { this.setData({ - "form.userName": e.detail.value - }) + "form.userName": e.detail.value, + }); }, /** * 输入个人身份证号 - * @param {*} e + * @param {*} e */ inputUserCode(e) { this.setData({ - "form.cardCode": e.detail.value - }) + "form.cardCode": e.detail.value, + }); }, /** * 个人籍贯 - * @param {*} e + * @param {*} e */ inputOriginNative(e) { this.setData({ - "form.nativePlace": e.detail.value - }) + "form.nativePlace": e.detail.value, + }); }, /** @@ -1309,87 +1359,85 @@ Page({ */ inputOriginNation(e) { this.setData({ - "form.nation": e.detail.value - }) + "form.nation": e.detail.value, + }); }, /** * 个人籍贯地址 - * @param {*} e + * @param {*} e */ inputOriginAddress(e) { this.setData({ - "form.address": e.detail.value - }) + "form.address": e.detail.value, + }); }, /** * 紧急联系人 - * @param {*} e + * @param {*} e */ inputUrgentUser(e) { this.setData({ - "form.emergencyContact": e.detail.value - }) + "form.emergencyContact": e.detail.value, + }); }, /** * 紧急联系人电话 - * @param {*} e + * @param {*} e */ inputUrgentUserPhone(e) { this.setData({ - "form.contactPhone": e.detail.value - }) + "form.contactPhone": e.detail.value, + }); }, /** * 个人文化程度 - * @param {*} e + * @param {*} e */ onDegreeGrade(e) { this.setData({ - "form.degreeGrade": e.detail.id - }) + "form.degreeGrade": e.detail.id, + }); }, /** * 开户行名称 - * @param {*} e + * @param {*} e */ inputBankName(e) { this.setData({ - "form.bankName": e.detail.value - }) + "form.bankName": e.detail.value, + }); }, /** * 开户行网点 - * @param {*} e + * @param {*} e */ inputBankOffice(e) { this.setData({ - "form.bankOffice": e.detail.value - }) + "form.bankOffice": e.detail.value, + }); }, /** * 开户行卡号 - * @param {*} e + * @param {*} e */ inputBankCardNo(e) { this.setData({ - "form.bankCardNo": e.detail.value - }) + "form.bankCardNo": e.detail.value, + }); }, /** * 委托代理提交参建单位信息 */ submitSubDeptValues() { - let { - form - } = this.data; + let { form } = this.data; let subDeptInfos = form.subDeptInfos; if (!subDeptInfos) { subDeptInfos = {}; @@ -1411,11 +1459,17 @@ Page({ app.toast("请上传营业执照副本!"); return false; } - if (!subDeptInfos.legalPersonCardImgPos || subDeptInfos.legalPersonCardImgPos.length == 0) { + if ( + !subDeptInfos.legalPersonCardImgPos || + subDeptInfos.legalPersonCardImgPos.length == 0 + ) { app.toast("请上传法人身份证正面照!"); return false; } - if (!subDeptInfos.legalPersonCardImgInv || subDeptInfos.legalPersonCardImgInv.length == 0) { + if ( + !subDeptInfos.legalPersonCardImgInv || + subDeptInfos.legalPersonCardImgInv.length == 0 + ) { app.toast("请上传法人身份证反面照!"); return false; } @@ -1431,6 +1485,7 @@ Page({ app.toast("请填写合同约定的承包范围!"); return false; } + // 验证计划完工时间不能早于计划开工时间 if (!form.useDates) { app.toast("请选择进入场地时间!"); return false; @@ -1443,6 +1498,21 @@ Page({ app.toast("请选择计划完工时间!"); return false; } + const enterDate = new Date(form.useDates); + const startDate = new Date(form.startWorkDates); + const endDate = new Date(form.endWorkDates); + if (enterDate < startDate) { + app.toast("入场地时间不能早于计划开工时间!"); + return false; + } + if (enterDate > endDate) { + app.toast("入场地时间不能晚于计划完工时间!"); + return false; + } + if (endDate < startDate) { + app.toast("计划完工时间不能早于计划开工时间!"); + return false; + } if (!form.leaderCardImgPos || form.leaderCardImgPos.length == 0) { app.toast("请上传委托人身份证正面照!"); return false; @@ -1455,7 +1525,10 @@ Page({ app.toast("请上传委托人半身近照!"); return false; } - if (!form.subDeptLeaderPowerPath || form.subDeptLeaderPowerPath.length == 0) { + if ( + !form.subDeptLeaderPowerPath || + form.subDeptLeaderPowerPath.length == 0 + ) { app.toast("请上传委托人单位委托书!"); return false; } @@ -1467,7 +1540,8 @@ Page({ app.toast("请填写委托人身份证号!"); return false; } else { - const cardCodePattern = /^[1-9]\d{5}(18|19|20|21|22)?\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}(\d|[Xx])$/; + const cardCodePattern = + /^[1-9]\d{5}(18|19|20|21|22)?\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}(\d|[Xx])$/; if (!cardCodePattern.test(form.subDeptLeaderCode)) { app.toast("身份证号码不正确!"); return false; @@ -1510,14 +1584,14 @@ Page({ let that = this; //弹出确认 wx.showModal({ - title: '提示', - content: '是否确认保存参建单位信息登记?', + title: "提示", + content: "是否确认保存参建单位信息登记?", success: function (sm) { if (sm.confirm) { that.submitSubDeptForm(); } - } - }) + }, + }); }, /** @@ -1525,55 +1599,64 @@ Page({ */ submitSubDeptForm() { let _form = { - ...this.data.form + ...this.data.form, }; let subDeptInfos = { - ..._form.subDeptInfos + ..._form.subDeptInfos, }; this.setData({ - loadShow: true - }) + loadShow: true, + }); let uploadFiles = []; if (_form.businessLicensePath && _form.businessLicensePath.length > 0) { uploadFiles.push({ - type: 'businessLicensePath', - path: _form.businessLicensePath[0] + type: "businessLicensePath", + path: _form.businessLicensePath[0], }); } - if (subDeptInfos.legalPersonCardImgPos && subDeptInfos.legalPersonCardImgPos.length > 0) { + if ( + subDeptInfos.legalPersonCardImgPos && + subDeptInfos.legalPersonCardImgPos.length > 0 + ) { uploadFiles.push({ - type: 'legalPersonCardImgPos', - path: subDeptInfos.legalPersonCardImgPos[0] + type: "legalPersonCardImgPos", + path: subDeptInfos.legalPersonCardImgPos[0], }); } - if (subDeptInfos.legalPersonCardImgInv && subDeptInfos.legalPersonCardImgInv.length > 0) { + if ( + subDeptInfos.legalPersonCardImgInv && + subDeptInfos.legalPersonCardImgInv.length > 0 + ) { uploadFiles.push({ - type: 'legalPersonCardImgInv', - path: subDeptInfos.legalPersonCardImgInv[0] + type: "legalPersonCardImgInv", + path: subDeptInfos.legalPersonCardImgInv[0], }); } if (_form.leaderCardImgPos && _form.leaderCardImgPos.length > 0) { uploadFiles.push({ - type: 'leaderCardImgPos', - path: _form.leaderCardImgPos[0] + type: "leaderCardImgPos", + path: _form.leaderCardImgPos[0], }); } if (_form.leaderCardImgInv && _form.leaderCardImgInv.length > 0) { uploadFiles.push({ - type: 'leaderCardImgInv', - path: _form.leaderCardImgInv[0] + type: "leaderCardImgInv", + path: _form.leaderCardImgInv[0], }); } if (_form.leaderUserPicture && _form.leaderUserPicture.length > 0) { uploadFiles.push({ - type: 'leaderUserPicture', - path: _form.leaderUserPicture[0] + type: "leaderUserPicture", + path: _form.leaderUserPicture[0], }); } - if (_form.subDeptLeaderPowerPath && _form.subDeptLeaderPowerPath.length > 0) { + if ( + _form.subDeptLeaderPowerPath && + _form.subDeptLeaderPowerPath.length > 0 + ) { uploadFiles.push({ - type: 'subDeptLeaderPowerPath', - path: _form.subDeptLeaderPowerPath[0] + type: "subDeptLeaderPowerPath", + path: _form.subDeptLeaderPowerPath[0], }); } let that = this; @@ -1584,10 +1667,10 @@ Page({ obj = { data: { data: { - url: item.path.replace(this.data.imgBase, "") - } - } - } + url: item.path.replace(this.data.imgBase, ""), + }, + }, + }; } else { //这里复杂的图片上传,改为同步上传,因为小程序只能上传一张图片 obj = await that.syncUploadImage(item.path); @@ -1626,17 +1709,22 @@ Page({ leaderUserInfos.cardImgPos = _form.leaderCardImgPos; leaderUserInfos.cardImgInv = _form.leaderCardImgInv; _form.leaderUserInfos = JSON.stringify(leaderUserInfos); - if (_form.proProjectInfoSubdeptsUsers && _form.proProjectInfoSubdeptsUsers.userInfos) { - _form.proProjectInfoSubdeptsUsers.userInfos = JSON.stringify(_form.proProjectInfoSubdeptsUsers.userInfos); + if ( + _form.proProjectInfoSubdeptsUsers && + _form.proProjectInfoSubdeptsUsers.userInfos + ) { + _form.proProjectInfoSubdeptsUsers.userInfos = JSON.stringify( + _form.proProjectInfoSubdeptsUsers.userInfos + ); } - registerSubDepts(_form).then(res => { + registerSubDepts(_form).then((res) => { this.setData({ - loadShow: false + loadShow: false, }); if (res.code == 200) { this.setData({ "form.id": res.data.id, - "form.subStep": res.data.subStep + "form.subStep": res.data.subStep, }); //跳转视频页面... that.initBusEduVideos(true); @@ -1650,12 +1738,9 @@ Page({ * 单位人员信息验证 */ submitSubUserValues() { - let { - form, - userPost - } = this.data; + let { form, userPost } = this.data; //数据效验 - if (userPost == '3' || userPost == '5') { + if (userPost == "3" || userPost == "5") { // if (!form.craftType) { // app.toast("请选择工种类型!"); // return false; @@ -1677,7 +1762,7 @@ Page({ app.toast("请上传进场半身近照!"); return false; } - if (userPost == '2' || userPost == '6') { + if (userPost == "2" || userPost == "6") { if (!form.subDeptPowerPath || form.subDeptPowerPath.length == 0) { app.toast("请上传委托人单位委托书!"); return false; @@ -1691,7 +1776,8 @@ Page({ app.toast("请填写身份证号!"); return false; } else { - const cardCodePattern = /^[1-9]\d{5}(18|19|20|21|22)?\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}(\d|[Xx])$/; + const cardCodePattern = + /^[1-9]\d{5}(18|19|20|21|22)?\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}(\d|[Xx])$/; if (!cardCodePattern.test(form.cardCode)) { app.toast("身份证号码不正确!"); return false; @@ -1734,14 +1820,14 @@ Page({ let that = this; //弹出确认 wx.showModal({ - title: '提示', - content: '是否确认保存参建人员信息登记?', + title: "提示", + content: "是否确认保存参建人员信息登记?", success: function (sm) { if (sm.confirm) { that.submitSubUserForm(); } - } - }) + }, + }); }, /** @@ -1749,34 +1835,34 @@ Page({ */ submitSubUserForm() { let _form = { - ...this.data.form + ...this.data.form, }; this.setData({ - loadShow: true + loadShow: true, }); let uploadFiles = []; if (_form.cardImgPos && _form.cardImgPos.length > 0) { uploadFiles.push({ - type: 'cardImgPos', - path: _form.cardImgPos[0] + type: "cardImgPos", + path: _form.cardImgPos[0], }); } if (_form.cardImgInv && _form.cardImgInv.length > 0) { uploadFiles.push({ - type: 'cardImgInv', - path: _form.cardImgInv[0] + type: "cardImgInv", + path: _form.cardImgInv[0], }); } if (_form.userPicture && _form.userPicture.length > 0) { uploadFiles.push({ - type: 'userPicture', - path: _form.userPicture[0] + type: "userPicture", + path: _form.userPicture[0], }); } if (_form.subDeptPowerPath && _form.subDeptPowerPath.length > 0) { uploadFiles.push({ - type: 'subDeptPowerPath', - path: _form.subDeptPowerPath[0] + type: "subDeptPowerPath", + path: _form.subDeptPowerPath[0], }); } let that = this; @@ -1787,10 +1873,10 @@ Page({ obj = { data: { data: { - url: item.path.replace(this.data.imgBase, "") - } - } - } + url: item.path.replace(this.data.imgBase, ""), + }, + }, + }; } else { //这里复杂的图片上传,改为同步上传,因为小程序只能上传一张图片 obj = await that.syncUploadImage(item.path); @@ -1822,14 +1908,14 @@ Page({ userInfos.cardImgPos = _form.cardImgPos; userInfos.cardImgInv = _form.cardImgInv; _form.userInfos = JSON.stringify(userInfos); - registerSubDeptsUsers(_form).then(res => { + registerSubDeptsUsers(_form).then((res) => { this.setData({ - loadShow: false + loadShow: false, }); if (res.code == 200) { this.setData({ "form.id": res.data.id, - "form.subStep": res.data.subStep + "form.subStep": res.data.subStep, }); //跳转视频页面... this.initBusEduVideos(true); @@ -1841,38 +1927,38 @@ Page({ /** * 委托人半身照 - * @param {*} options + * @param {*} options */ fileUpload7(options) { let file = options.detail; this.setData({ - "form.leaderUserPicture": file + "form.leaderUserPicture": file, }); }, /** * 委托人委托书 - * @param {*} options + * @param {*} options */ fileUpload8(options) { let file = options.detail; this.setData({ - "form.subDeptLeaderPowerPath": file + "form.subDeptLeaderPowerPath": file, }); }, //显示选择 onShowPopup(e) { this.setData({ - showDetailsPopup: true - }) + showDetailsPopup: true, + }); }, //关闭选择 onClosePopup(e) { this.setData({ - showDetailsPopup: false - }) + showDetailsPopup: false, + }); }, /** @@ -1881,8 +1967,8 @@ Page({ onClickNav(e) { this.setData({ chidActiveIndex: null, - mainActiveIndex: e.detail.index - }) + mainActiveIndex: e.detail.index, + }); }, /** @@ -1891,28 +1977,28 @@ Page({ onClickItem(e) { this.setData({ chidActiveIndex: e.detail.id, - showDetailsName: e.detail.detailName - }) + showDetailsName: e.detail.detailName, + }); }, /** * 选中健康问题1 - * @param {*} e + * @param {*} e */ onChangeFileRadio1(e) { this.setData({ - illnessStatus: e.detail.id - }) + illnessStatus: e.detail.id, + }); }, /** * 选中健康问题2 - * @param {*} e + * @param {*} e */ onChangeFileRadio2(e) { this.setData({ - supIllnessStatus: e.detail.id - }) + supIllnessStatus: e.detail.id, + }); }, /** @@ -1923,39 +2009,31 @@ Page({ this.initBusEduVideos(false); } this.setData({ - active: this.data.active - 1 - }) + active: this.data.active - 1, + }); }, /** * 生命周期函数--监听页面初次渲染完成 */ - onReady() { - - }, + onReady() {}, /** * 生命周期函数--监听页面显示 */ - onShow() { - - }, + onShow() {}, /** * 生命周期函数--监听页面隐藏 */ - onHide() { - - }, + onHide() {}, // 启动倒计时 startCountdown() { let that = this; this.setData({ timer: setInterval(() => { - let { - time - } = this.data; + let { time } = this.data; let minutes = Math.floor(time / 60); let seconds = time % 60; if (minutes < 10) minutes = "0" + minutes; @@ -1964,7 +2042,7 @@ Page({ time--; this.setData({ time, - timeStr: minutes + ' 分钟 ' + seconds + ' 秒' + timeStr: minutes + " 分钟 " + seconds + " 秒", }); } else { clearInterval(this.data.timer); // 倒计时结束,清除定时器 @@ -1979,13 +2057,11 @@ Page({ startSignCountdown() { this.setData({ signTimer: setInterval(() => { - let { - signTime - } = this.data; + let { signTime } = this.data; if (signTime > 0) { signTime--; this.setData({ - signTime + signTime, }); } else { clearInterval(this.data.signTimer); // 倒计时结束,清除定时器 @@ -2004,29 +2080,29 @@ Page({ url: _baseUrl + "/file/NoSecurity/upload", // 上传的服务器接口地址 filePath: file, header: { - "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8" + "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8", }, name: "file", //上传的所需字段,后端提供 formData: {}, success: (res) => { // 上传完成操作 - const data = JSON.parse(res.data) + const data = JSON.parse(res.data); resolve({ - data: data - }) + data: data, + }); }, fail: (err) => { //上传失败:修改pedding为reject console.log("访问接口失败", err); wx.showToast({ title: "网络出错,上传失败", - icon: 'none', - duration: 1000 + icon: "none", + duration: 1000, }); - reject(err) - } + reject(err); + }, }); - }) + }); }, /** @@ -2034,11 +2110,11 @@ Page({ */ wxSignLogin() { wxNumberLogin({ - 'username': this.data.userPhoneNumber - }).then(res => { + username: this.data.userPhoneNumber, + }).then((res) => { setToken(res.data.access_token); this.getUserInfoByCache(); - }) + }); }, /** @@ -2053,25 +2129,28 @@ Page({ userInfos: {}, degreeGrade: null, userPhone: this.data.userPhoneNumber, - subDeptLeaderPhone: this.data.userPhoneNumber + subDeptLeaderPhone: this.data.userPhoneNumber, }; let _subDeptNameTemp = this.data.form.subDeptName; this.setData({ form: _form, active: 0, - "parForm.subDeptName": _subDeptNameTemp + "parForm.subDeptName": _subDeptNameTemp, }); }, /** * 查询 * 用户详细信息 - * @param {*} e + * @param {*} e */ getUserInfoByCache: function () { - findUserInfoByCache().then(res => { + findUserInfoByCache().then((res) => { if (res.code == 200) { - res.user.isTechnician = (res.user.roles || []).find(role => role.roleKey.indexOf("zbjsy_") >= 0) != null; + res.user.isTechnician = + (res.user.roles || []).find( + (role) => role.roleKey.indexOf("zbjsy_") >= 0 + ) != null; setUserInfo(res.user); app.globalData.userData = res.user; this.getMyProjectList(); @@ -2085,29 +2164,31 @@ Page({ * 根据项目配置进入不同页面... */ getMyProjectList: function () { - findMyProjectList().then(res => { + findMyProjectList().then((res) => { if (res.code == 200) { app.globalData.projectInfoList = res.rows; if (res.rows.length > 0) { if (res.rows.length == 1) { app.globalData.useProjectId = res.rows[0].id; app.globalData.useProjectName = res.rows[0].projectName; - findProSubDeptsUserInfo(app.globalData.useProjectId).then(detail => { - if (detail.code == 200) { - let userInfo = getUserInfo(); - userInfo.projectUserInfo = detail.data; - setUserInfo(userInfo); - //单项目直接进入项目页面 - wx.redirectTo({ - url: '../../pageage/project_info/index', - }) + findProSubDeptsUserInfo(app.globalData.useProjectId).then( + (detail) => { + if (detail.code == 200) { + let userInfo = getUserInfo(); + userInfo.projectUserInfo = detail.data; + setUserInfo(userInfo); + //单项目直接进入项目页面 + wx.redirectTo({ + url: "../../pageage/project_info/index", + }); + } } - }); + ); } else { //多项目进入项目切换页面 wx.redirectTo({ - url: '../../pageage/project_list/index', - }) + url: "../../pageage/project_list/index", + }); } } else { app.toast("未查询到当前用户项目,信息审核中或人员已离场"); @@ -2128,30 +2209,24 @@ Page({ /** * 页面相关事件处理函数--监听用户下拉动作 */ - onPullDownRefresh() { - - }, + onPullDownRefresh() {}, /** * 页面上拉触底事件的处理函数 */ - onReachBottom() { - - }, + onReachBottom() {}, /** * 用户点击右上角分享 */ - onShareAppMessage() { - - }, + onShareAppMessage() {}, handleOpenPrivacyContract() { // 打开隐私协议页面 wx.openPrivacyContract({ - success: () => { }, // 打开成功 - fail: () => { }, // 打开失败 - complete: () => { } - }) - } -}) \ No newline at end of file + success: () => {}, // 打开成功 + fail: () => {}, // 打开失败 + complete: () => {}, + }); + }, +});