// pages/register/index.js const $$ = require('../../utils/util'); const app = getApp(); import Toast from '../../components/vant/toast/toast'; // 获取个人信息 function getUserInfoApi() { return $$.request({ url: 'paUser/getUserInfo', type: 'get', service: 'cust' }); } // 获取案件详情 function getCaseDetailApi(submitData) { return $$.request({ url: 'paCaseInfo/getCaseInfo?id=' + submitData, type: 'get', service: 'mediate' }); } // 获取保存的草稿案件 function getDraftCaseApi(type) { return $$.request({ url: 'paCaseInfo/listByInputUserAndStatus?inputStatus=' + type, type: 'get', service: 'mediate' }); } // 保存草稿 or 保存案件 function submitCaseApi(submitData) { return $$.request({ url: 'paCaseInfo/applyCase', type: 'post', submitData, service: 'mediate' }); } // 检查请求中的风险 function checkCaseClaimRiskApi(submitData) { return $$.request({ url: 'guide/checkCaseClaimRisk', type: 'post', submitData, v1: true, service: 'mediate' }); } // 获取历史填写过的人员数据 function getPersonHistoryApi() { return $$.request({ url: 'paCaseInfo/pickUser', type: 'get', service: 'mediate' }); } //类案推荐缓存 function getCaseApi(submitData) { return $$.request({ url: 'guide/cacheLatjCaseGuide', submitData, type: 'get', v1: true, service: 'mediate' }); } //案件特征 function getFeatureApi(submitData) { return $$.request({ url: 'guide/cacheCaseFeature', submitData, type: 'get', v1: true, service: 'mediate' }); } //调解策略及争议焦点 function getCacheOpenAiCaseGuideList(submitData) { return $$.request({ url: 'guide/cacheOpenAiCaseGuideList', submitData, type: 'get', v1: true, service: 'mediate' }); } Page({ /** * 页面的初始数据 */ userInfo: {}, location: [], // 省市区等地理资源 select: {}, // 下拉框数据 goToMaterialSave: false, // 避免跳转到材料上传页面重复保存草稿 data: { imgUrl: $$.url.img, steps: [{ title: '填写申请', icon: '', activeIcon: 'steps-register-1-active.png' }, { title: '预览申请', icon: 'steps-register-2.png', activeIcon: 'steps-register-2-active.png' }, { title: '提交申请', icon: 'steps-register-3.png', activeIcon: 'steps-register-3-active.png' }, ], titleShow: { '09_01001-1': ['自然人', '姓名', '真实姓名'], '09_01001-2': ['法人', '企业名称', '企业全名', '法定代表人姓名'], '09_01001-3': ['机构代表人', '机构名称', '机构全名', '机构代表人姓名'], }, // 用于判断显示的输入框标题 stepsActive: 0, // 步骤条当前下标 submitData: { caseDes: '', caseType: '', caseTypeName: '', caseClaim: '', prov: '', provName: '', city: '', cityName: '', area: '', areaName: '', road: '', roadName: '', village: '', villageName: '', addr: '', wantUserId: '', wantUserName: '', wantUnitId: '', wantUnitName: '', plaintiffList: [], defendantList: [], }, // 表单数据 materialNum: 0, // 纠纷材料总数量 userInfoVisible: false, // 是否采用个人信息更新申请人信息 popup: { formtype: '', // 控制在纠纷信息 or 申请人信息 or 被申请人添加数据 index: 0, // 如为申请人信息 or 被申请人确认下拉选择此参数为下标 }, // 下拉弹出框数据 changeVisible: false, // 是否是修改 recordingVisible: false, // 录音界面是否显示 popupMsg: { show: false, title: '', type: 1, editType: 'add', buttonText: '' }, // 弹窗, type: 1'恢复草稿',2'申请人',3'被申请人', editType: 'add'新增,'edit'修改 tipData: { caseList: [].join("\n"), guideList: [], }, caseText: '', caseTitle: '', similarity: '', showCase: false, popupSelect: { show: false, data: [], activeIndex: null }, // 选择人员 caseCause: [{ value: '22_00039-0005', label: '家庭婚姻纠纷', }, { value: '22_00039-0004', label: '邻里纠纷', }, { value: '22_00039-0019', label: '房屋宅基地纠纷', }, { value: '22_00039-0002', label: '合同纠纷', }, { value: '22_00039-0020', label: '生产经营纠纷', }, { value: '22_00039-0013', label: '损害赔偿纠纷', }, { value: '22_00039-0015', label: '山林土地纠纷', }, { value: '22_00039-0016', label: '征地纠纷', }, { value: '22_00039-0021', label: '环境污染纠纷', }, { value: '22_00039-0001', label: '劳动争议纠纷', }, { value: '22_00039-0006', label: '道路交通事故纠纷', }, { value: '22_00039-0007', label: '医疗纠纷', }, { value: '22_00039-0022', label: '物业管理纠纷', }, { value: '22_00039-0018', label: '消费纠纷', }, { value: '22_00039-0023', label: '旅游纠纷', }, { value: '22_00039-0008', label: '知识产权纠纷', }, { value: '22_00039-0024', label: '互联网纠纷', }, { value: '22_00039-0003', label: '借贷纠纷', }, { value: '22_00039-0009', label: '所有权纠纷', }, { value: '22_00039-0010', label: '继承纠纷', }, { value: '22_00039-0011', label: '人格权纠纷', }, { value: '22_00039-0012', label: '股权转让纠纷', }, { value: '22_00039-0014', label: '建设用地使用权纠纷', }, { value: '22_00039-0017', label: '其他纠纷', }, ], }, //类案推荐展开隐藏 _case() { this.setData({ showDetail: !this.data.showDetail, }) }, // 身份证ocr handleOCR(e) { let that = this; wx.chooseMedia({ count: 1, mediaType: ['image'], success(res2) { const tempFiles = res2.tempFiles[0]; $$.showLoading(); wx.uploadFile({ url: `${$$.baseUrl}${$$.url.sys}/api/v1/fileInfo/wecatRecognition`, filePath: tempFiles.tempFilePath, name: 'file', header: { Authorization: app.globalData.token }, complete(res3) { $$.hideLoading(); if (res3.errMsg === 'uploadFile:ok') { let { code, data } = JSON.parse(res3.data); if (code == -1) { $$.errorModal({ content: '识别失败' }); return; } let item = that.data.popupMsg.data; that.data.popupMsg.data.certiNo = data?.ocrResult.certificateNumber; that.data.popupMsg.data[item.perClass === '09_01001-1' ? 'trueName' : 'deputy'] = data?.ocrResult.trueName; that.setData({ popupMsg: that.data.popupMsg }); } }, }); }, }); }, // 表单修改 handleChange(e) { let formtype = e.currentTarget.dataset.formtype, key = e.currentTarget.dataset.key, value = e.detail; if (formtype === 'popupMsg') { // 修改申请人and被申请人的form this.data.popupMsg.data[key] = value; } else { this.data.submitData[key] = value; } this.setData({ submitData: this.data.submitData }); }, // 删除意向调解信息 handleDeleteWant() { let that = this; $$.showModal({ content: '确定删除意向调解信息吗?', success: (res) => { if (res.confirm) { let obj = { wantUserId: '', wantUserName: '', wantUnitId: '', wantUnitName: '', }; that.setData({ submitData: { ...that.data.submitData, ...obj } }); } }, }); }, // 下拉框选择确认 handleConfirmPicker({ detail }) { let type = this.data.popup.type, value = detail.detail.value, arr = []; this.data.popup.visible = false; if (type === 'caseCause') { arr = ['caseType', 'caseTypeName']; arr.forEach((x, t) => { this.data.submitData[x] = value[0][t === 0 ? 'value' : 'label']; }); } else if (type === 'location') { arr = [ ['prov', 'provName'], ['city', 'cityName'], ['area', 'areaName'], ['road', 'roadName'], ['village', 'villageName'], ]; arr.forEach((x, t) => { this.data.submitData[x[0]] = value[t]?.value || ''; this.data.submitData[x[1]] = value[t]?.label || ''; }); } this.setData({ popup: this.data.popup, submitData: this.data.submitData }); }, // 多行下拉选择时,省市区选择 handleChangeColumns(e) { if (this.data.popup.type === 'location') { let selectData = $$.changeLocation(e, this.location, this.data.popup.selectData); this.setData({ popup: { ...this.data.popup, selectData } }); } }, // 下拉框选择开启 handleShowPopup(e) { let type = e.currentTarget.dataset.type; let selectData = []; if (type === 'location') { if (this.location.length === 0) { return false; } let selectOption = JSON.parse(JSON.stringify(this.location)); let arr = $$.getLocationIndex(this.location, this.data.submitData); // 计算默认的市区县下标 selectData = [{ values: selectOption, defaultIndex: arr[0] }, { values: selectOption[arr[0]].children, defaultIndex: arr[1] }, { values: selectOption[arr[0]].children[arr[1]].children || [], defaultIndex: arr[2] }, { values: selectOption[arr[0]].children[arr[1]].children[arr[2]].children || [], defaultIndex: arr[3] }, ]; selectData.forEach((x) => { x.values.forEach((y) => { delete y.children; }); }); } else { let selectOption = this.select[type]; selectData = [{ values: selectOption, defaultIndex: 0 }]; } this.setData({ popup: { formtype: e.currentTarget.dataset.formtype, index: e.currentTarget.dataset.index, visible: true, title: e.currentTarget.dataset.title, type: type, selectData: selectData, }, }); }, // 关闭下拉框选择 handleClosePopup() { this.data.popup.visible = false; this.setData({ popup: this.data.popup }); }, // 调解请求输入时额外的需求操作 handlecaseClaimFocus() { if (!this.data.submitData.caseClaim) { this.data.submitData.caseClaim = '请求1:'; this.setData({ submitData: this.data.submitData }); } }, // 点击新增 or 删除 or 修改 申请人或被申请人 handleEditParty(e) { let that = this; let formtype = e.currentTarget.dataset.formtype, index = e.currentTarget.dataset.index, edittype = e.currentTarget.dataset.edittype, agent = e.currentTarget.dataset.agent; let type = formtype === 'plaintiffList' ? 2 : 3; if (edittype === 'delete') { // 点击删除 $$.showModal({ content: '确定删除当前人员信息吗?', success: (res) => { if (res.confirm) { let formtype_ = that.data.popupMsg.type === 2 ? 'plaintiffList' : 'defendantList'; let partyIndex = that.data.popupMsg.partyIndex; if (this.data.popupMsg.partyTabActive === '2') { that.data.submitData[formtype_][partyIndex].agent = null; } else { that.data.submitData[formtype_].splice(partyIndex, 1); } that.setData({ submitData: that.data.submitData, popupMsg: { show: false } }); } }, }); } else if (edittype === 'edit') { // 点击修改 let data = this.data.submitData[formtype][index]; this.setData({ popupMsg: { show: true, title: formtype === 'plaintiffList' ? '修改申请人' : '修改被申请人', type: type, editType: 'edit', buttonText: '保存信息', partyArr: this.select['personClass'], partyTabActive: agent ? '2' : '1', partyIndex: index, perClassIndex: agent ? 0 : data.perClass === '09_01001-1' ? 0 : data.perClass === '09_01001-2' ? 1 : 2, data: agent ? data.agent : data, }, }); } else { // 点击增加 this.setData({ popupMsg: { show: true, title: formtype === 'plaintiffList' ? '增加申请人' : '增加被申请人', type: type, editType: 'add', buttonText: '保存信息', partyArr: this.select['personClass'], partyTabActive: '1', // 当事人代理人tab下标 perClassIndex: 0, // 当事人类型下标 data: { id: $$.getBusinessId(), perClass: '09_01001-1', perClassName: '自然人', trueName: '', deputy: '', mobile: '', certiNo: '', }, }, }); } }, // 切换增加弹窗的'1'当事人,'2'代理人 handleChangeTab(e) { if (this.data.popupMsg.editType === 'edit') { Toast.fail('不支持修改类型'); return false; } this.setData({ popupMsg: { ...this.data.popupMsg, partyTabActive: e.detail.name, perClassIndex: 0, partyIndex: 0, data: { ...this.data.popupMsg.data, perClass: '09_01001-1', perClassName: '自然人', trueName: '', deputy: '', mobile: '', certiNo: '', }, }, }); }, // 切换增加弹窗的人员类型 handleChangePerClass(e) { if (this.data.popupMsg.editType === 'edit') { Toast.fail('不支持修改类型'); return false; } let value = e.currentTarget.dataset.item; let index = e.currentTarget.dataset.index; let arr = ['perClass', 'perClassName']; arr.forEach((x, t) => { this.data.popupMsg.data[x] = value[t === 0 ? 'value' : 'label']; }); this.data.popupMsg.data.trueName = ''; this.data.popupMsg.data.deputy = ''; this.data.popupMsg.perClassIndex = index; this.setData({ popupMsg: this.data.popupMsg }); }, // 选择代理人 handleSelectAgent(e) { this.setData({ popupMsg: { ...this.data.popupMsg, partyIndex: e.currentTarget.dataset.index, }, }); }, // 底部弹窗操作,恢复草稿 handleClickPopupMsg() { if (this.data.popupMsg.type === 1) { // 恢复草稿 this.setData({ materialNum: this.data.popupMsg.submitData.fileSize, userInfoVisible: false, submitData: { ...this.data.submitData, ...this.data.popupMsg.submitData, ...this.data.popupMsg.intentionObj }, popupMsg: { show: false }, }); } else { // 当事人保存 let popupMsg = this.data.popupMsg; let data = this.data.popupMsg.data; // 信息校验 let msg = null; let arr = this.data.submitData[popupMsg.type === 2 ? 'defendantList' : 'plaintiffList']; let arr2 = this.data.submitData[popupMsg.type === 2 ? 'plaintiffList' : 'defendantList']; console.log('arr2', arr2); console.log('arr', arr); console.log('data', data); console.log('popupMsg', popupMsg); forEach: for (let t = 0; t < arr.length; t++) { if (arr[t].certiNo === data.certiNo && !!$$.verifyEmpty(data.certiNo)) { msg = '申请人与被申请人不能相同'; break forEach; } } forEach: for (let t = 0; t < arr2.length; t++) { if (arr2[t].certiNo === data.certiNo && !!$$.verifyEmpty(data.certiNo) && arr2[t].perClass === data.perClass && t !== popupMsg.partyIndex) { msg = `与${popupMsg.type === 3 ? '被' : ''}申请人不能重复`; break forEach; } } // 被申请人可不需要手机号码,申请人和代理人需要 if ( (data.mobile && !$$.mobileRegExp(data.mobile) && popupMsg.type === 3) || (!$$.mobileRegExp(data.mobile) && popupMsg.type === 2) || (!$$.mobileRegExp(data.mobile) && popupMsg.partyTabActive === '2') ) { msg = '请输入正确的手机号码'; } if (!$$.verifyEmpty(data.trueName) || (data.perClass !== '09_01001-1' && !$$.verifyEmpty(data.deputy))) { msg = '请补充' + (popupMsg.type === 3 ? '被' : '') + '申请人方的' + (popupMsg.partyTabActive === '1' ? '当事人' : '代理人') + '信息'; } if (popupMsg.partyTabActive === '1') { } // 增加申请人的信息 // if (!arr2[popupMsg.partyIndex]?.trueName || !arr2[popupMsg.partyIndex]?.mobile) { // msg = '请补充申请人方的当事人信息'; // } if (msg) { Toast.fail(msg); return; } if (popupMsg.partyTabActive === '2' && typeof popupMsg.partyIndex !== 'number') { Toast.fail('请选择代理对象'); return; } if (popupMsg.partyTabActive === '2' && arr2[popupMsg.partyIndex]?.certiNo === data.certiNo) { Toast.fail('代理人与当事人不能相同'); return; } let type = popupMsg.type === 2 ? 'plaintiffList' : 'defendantList'; if (popupMsg.partyTabActive === '2') { this.data.submitData[type][popupMsg.partyIndex] = { ...this.data.submitData[type][popupMsg.partyIndex] }; this.data.submitData[type][popupMsg.partyIndex].agent = { ...this.data.submitData[type][popupMsg.partyIndex].agent, ...data }; } else { if (popupMsg.editType === 'add') { this.data.submitData[type] = [...this.data.submitData[type], data]; } else { this.data.submitData[type][popupMsg.partyIndex] = { ...this.data.submitData[type][popupMsg.partyIndex], ...data }; } } this.setData({ submitData: this.data.submitData, popupMsg: { show: false } }); } }, // 关闭底部弹窗 handleClosePopupMsg() { if (this.data.popupMsg.type === 1) { this.getUserInfo(this.data.popupMsg.intentionObj); } else { this.setData({ popupMsg: { show: false } }); } }, // 关闭选择人员 handleVisiblePopupSelect(e) { let type = e.currentTarget.dataset.type; if (type === 'open') { this.getPersonHistory(); } else { this.setData({ popupSelect: { show: false } }); } }, // 选择人员 handleSelectPerson(e) { this.setData({ popupSelect: { ...this.data.popupSelect, activeIndex: e.currentTarget.dataset.index } }); }, // 确定历史人员数据填充 handleConfirmPerson() { if (typeof this.data.popupSelect.activeIndex !== 'number') { Toast.fail('请选择人员'); return; } let data = this.data.popupSelect.data[this.data.popupSelect.activeIndex] || {}; this.data.popupMsg.perClassIndex = this.data.popupMsg.partyTabActive === '2' ? 0 : data.perClass === '09_01001-1' ? 0 : data.perClass === '09_01001-2' ? 1 : 2; this.data.popupMsg.data = { ...this.data.popupMsg.data, perClass: data.perClass, perClassName: data.perClassName, trueName: data.trueName, deputy: data.deputy, mobile: data.mobile, certiNo: data.certiNo, }; this.setData({ popupSelect: { show: false }, popupMsg: this.data.popupMsg }); }, // 跳转至材料上传页面 handleGoToMaterial() { // 先保存 if (this.data.submitData.inputStatus !== '2') { this.goToMaterialSave = true; this.saveCase(); } // 获取人员数据保存至全局变量中,方便附件上传页面获取有多少人员 let person = []; let arr = ['plaintiffList', 'defendantList']; arr.forEach((y) => { this.data.submitData[y].forEach((x) => { if (x.trueName) { person.push({ id: x.id, perClass: x.perClass, perClassName: x.perClassName, trueName: x.trueName, }); } if (x.agent && x.agent.trueName) { person.push({ agent: true, id: x.agent.id, perClass: x.agent.perClass, perClassName: x.agent.perClassName, trueName: x.agent.trueName, }); } }); }); app.globalData.material.person = person; wx.navigateTo({ url: '../../pages/materialShow/index?caseId=' + this.data.submitData.id + '&editVisible=true', }); }, // 下一步 or 上一步 handleNext(e) { let type = e.currentTarget.dataset.type; let content = this.data.tipData.guideList.length === 0 ? '请再次仔细核对您的申请信息,确定提交调解申请吗?' : `根据人工智能大数据分析,您的请求可调整为:【${this.data.tipData.guideList}】(以上建议仅供参考),确定提交调解申请吗?` if (type === 'next' && this.data.stepsActive === 0) { // this.checkCaseDetail(); this.fengxian(); } else if (type === 'next' && this.data.stepsActive === 1) { let that = this; $$.showModal({ title: '申请提交确认', content: content, success: (res) => { if (res.confirm) { that.submitCase(); } }, }); } else if (type === 'back' && this.data.stepsActive === 1) { this.setData({ stepsActive: 0 }); } }, // 校验提交信息的必填项并下一步 checkCaseDetail() { let msg = ''; let submitData = this.data.submitData; let arr1 = [{ key: 'area', title: '纠纷发生地' }, { key: 'caseDes', title: '纠纷描述' }, { key: 'caseClaim', title: '调解请求' }, ]; forEach: for (let i = 0; i < arr1.length; i++) { if (!$$.verifyEmpty(submitData[arr1[i].key])) { msg = arr1[i].title; break forEach; } } if (msg) { Toast.fail(msg + '未填写'); return false; } if (submitData.plaintiffList.length === 0) { Toast.fail('至少添加一名申请人'); return false; } if (submitData.plaintiffList?.length > 0) { if (!submitData.plaintiffList[0].trueName) { Toast.fail('至少添加一名申请人'); return false; } } if (submitData.defendantList.length === 0) { Toast.fail('至少添加一名被申请人'); return false; } if (submitData.defendantList?.length > 0) { if (!submitData.defendantList[0].trueName) { Toast.fail('至少添加一名申请人'); return false; } } if (msg) { Toast.fail(msg); return false; } // this.fengxian(); this.setData({ stepsActive: 1 }); }, // 返回首页 handleGoHomepage() { if (this.data.changeVisible) { wx.navigateBack({ delta: 1, }); return false; } wx.reLaunch({ url: '../../pages/homePage/index', }); }, // 录音组件开启 and 关闭触发 handleVisibleRecording(e) { this.setData({ recordingVisible: !this.data.recordingVisible }); }, // 获取录音转写的文字 handleGetWords(e) { let key = e.currentTarget.dataset.type; let value = e.detail; if (key === 'caseDes') { this.data.submitData[key] = this.data.submitData[key] + value; this.setData({ submitData: this.data.submitData, recordingVisible: !this.data.recordingVisible }); } else { if (!this.data.submitData.caseClaim) { this.data.submitData[key] = '请求1:' + value; } else { this.data.submitData[key] = this.data.submitData[key] + value; } this.setData({ submitData: this.data.submitData, recordingVisible: !this.data.recordingVisible }); } }, // 退出页面保存草稿前判断,如果地址没有更改则不需要保存。 handleCheckSave() { if (this.data.popupMsg.type === 1 && this.data.popupMsg.show) { // 恢复草稿弹窗时退出不保存 return; } if (this.goToMaterialSave || this.data.stepsActive !== 0 || this.data.submitData.inputStatus === '2') { // 跳转纠纷材料 || 不在第一步骤 || 修改时则不保存 this.goToMaterialSave = false; return; } // 地址变动后保存草稿 let save = false; if (['prov', 'city', 'area', 'road', 'village'].map((x) => this.data.submitData[x]).join('') !== this.userInfo.address) save = true; let arr = ['caseDes', 'caseType', 'caseTypeName', 'caseClaim', 'addr', 'wantUserId', 'wantUserName', 'wantUnitId', 'wantUnitName']; arr.forEach((x) => { if ($$.verifyEmpty(this.data.submitData[x])) save = true; }); if (this.data.submitData['plaintiffList'].length > 1 || this.data.submitData['defendantList'].length > 0) { save = true; } if (save) { this.saveCase(); } }, async fengxian() { let that = this; $$.showLoading(); let submitData = this.data.submitData; const res = await checkCaseClaimRiskApi({ caseDes: submitData.caseDes, caseClaim: submitData.caseClaim, caseTypeName: submitData.caseTypeName, }); $$.hideLoading(); if (res.type) { if (res.data?.case_risk_claims || res.data?.guide_risk_claims) { if (res.data?.case_risk_claims.length && res.data?.guide_risk_claims.length) { let caseList = res.data?.case_risk_claims; let guideList = res.data?.guide_risk_claims; let caseText = res.data?.caseText; let caseTitle = res.data?.caseTitle; let similarity = res.data?.similarity; if (!this.data.tipData.guideList || JSON.stringify(this.data.tipData.guideList) !== JSON.stringify(guideList)) { this.setData({ 'tipData.guideList': guideList, 'tipData.caseList': caseList, caseText: caseText, caseTitle: caseTitle, similarity: similarity, showCase: true, }); } else { this.checkCaseDetail(); } that.setData({ tipData: { caseList, guideList } }) } else { this.setData({ 'tipData.guideList': [], 'tipData.caseList': [], }); this.checkCaseDetail(); } } } }, // 上传案件 async submitCase() { $$.showLoading(); let submitData = this.data.submitData; submitData.inputStatus = '2'; submitData.process = null; const res = await submitCaseApi(submitData); $$.hideLoading(); if (res.type) { if (this.data.changeVisible) { // 用于当“我的调解”页面等其他页面进入修改时,修改后返回更新数据凭证 app.globalData.caseMsg.handleVisible = true; } this.setData({ stepsActive: 2 }); let caseId = res.data; // 在这里调用接口 // getCaseApi({ // caseId, // start_page_num: '0', // end_page_num: '100' // }); // getFeatureApi({ // caseId, // }) // getCacheOpenAiCaseGuideList({ // caseId, // guideTypes: '5,6' // }) } }, // 保存草稿 async saveCase() { let submitData = this.data.submitData; submitData.inputStatus = '1'; const res = await submitCaseApi(submitData); if (res.type) { console.log('保存成功'); } }, // 修改案件 时 获取案件信息 async getCaseData(caseId, changeVisible) { $$.showLoading(); const res = await getCaseDetailApi(caseId); $$.hideLoading(); if (res.type) { this.setData({ materialNum: res.data.fileSize, userInfoVisible: false, submitData: res.data, changeVisible: changeVisible, }); } }, // 获取当前页面是否存在草稿 async getDraftCase(options) { let intentionObj = {}; if (options.type) { // 找他调页面跳转进入赋值意向调解信息 let arr = []; if (options.type === '1') { arr = ['wantUserId', 'wantUserName']; } else { arr = ['wantUnitId', 'wantUnitName']; } intentionObj[arr[0]] = options.id; intentionObj[arr[1]] = options.name; } $$.showLoading(); const res = await getDraftCaseApi('1'); if (res.type) { if (res.data?.id) { $$.hideLoading(); this.userInfo = { address: ['prov', 'city', 'area', 'road', 'village'].map((x) => res.data[x]).join('') }; this.setData({ popupMsg: { show: true, title: '恢复草稿', buttonText: '恢复草稿', type: 1, intentionObj, submitData: res.data } }); } else { this.getUserInfo(intentionObj); } } else { this.getUserInfo(intentionObj); } }, // 获取个人信息,填充个人信息材料至第一个申请人处,如有草稿则不执行 async getUserInfo(intentionObj) { let obj = {}, locationObj = {}; const res = await getUserInfoApi(); $$.hideLoading(); if (res.type) { this.data.userInfoVisible = true; obj = { trueName: res.data.trueName || '', certiNo: res.data.idcard || '', mobile: res.data.mobile || '', address: ['prov', 'city', 'area', 'road', 'village'].map((x) => res.data[x]).join(''), }; ['prov', 'provName', 'city', 'cityName', 'area', 'areaName', 'road', 'roadName', 'village', 'villageName'].forEach((x) => { locationObj[x] = res.data[x] || ''; }); } this.data.submitData.plaintiffList[0] = { perClass: '09_01001-1', perClassName: '自然人', id: $$.getBusinessId(), ...obj }; this.userInfo = obj; this.setData({ userInfoVisible: this.data.userInfoVisible, submitData: { ...this.data.submitData, ...intentionObj, ...locationObj, id: $$.getBusinessId() }, popupMsg: { show: false }, }); }, // 获取选择人员 async getPersonHistory() { $$.showLoading(); const res = await getPersonHistoryApi(); $$.hideLoading(); if (res.type) { this.setData({ popupSelect: { show: true, data: res.data || [] } }); } }, // 请求下拉框资源 async getSelectOptionData() { const res = await $$.commonRequest({ url: `${$$.url.assets}selectOption.json`, type: 'get' }); if (res) { this.select.cardType = res.data.cardType || []; this.select.caseCause = this.data.caseCause || []; this.select.personClass = res.data.personClass || []; } }, // 获取省市区等地理资源 async getLocationData() { $$.showLoading(); const res = await $$.commonRequest({ url: `${$$.url.assets}locationSelect.json`, type: 'get' }); $$.hideLoading(); if (res) { let location = []; $$.province.forEach((x) => { location.push(res[x][0]); }); this.location = location; } }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.getLocationData(); this.getSelectOptionData(); if (options.change) { this.getCaseData(options.caseId, true); } else { this.getDraftCase(options); } }, /** * 生命周期函数--监听页面显示 */ onShow: function () { if (app.globalData.material.data.length !== 0) { // 计算附件数量 let num = 0; app.globalData.material.data.forEach((x) => { num = num + x.num; }); app.globalData.material.data = []; this.setData({ materialNum: num }); } }, onHide: function () { this.handleCheckSave(); }, onUnload: function () { this.handleCheckSave(); }, });