From a78e279a1af2a810d27feb943d180f3093fa63a6 Mon Sep 17 00:00:00 2001 From: liyj <1003249715@qq.com> Date: Mon, 09 Sep 2024 15:35:51 +0800 Subject: [PATCH] Merge branch 'master' of http://120.79.193.119:9090/r/gzzfw/frontEnd/gzDyh --- gz-wxparty/pages/register/index.js | 289 +++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 266 insertions(+), 23 deletions(-) diff --git a/gz-wxparty/pages/register/index.js b/gz-wxparty/pages/register/index.js index b290991..676c490 100644 --- a/gz-wxparty/pages/register/index.js +++ b/gz-wxparty/pages/register/index.js @@ -12,6 +12,36 @@ }); } +// 附件上传的id +function getByIdApi(param) { + return $$.request({ + url: 'caseUtils/getNewTimeCaseId', + type: 'get', + submitData: param || {}, + service: 'utils' + }); +} + +// 删除附件 +function delfileApi(id) { + return $$.request({ + url: 'fileInfo/deleteFileById?id=' + id, + type: 'get', + service: 'sys', + }); +} + +function getawApi(submitData) { + return $$.request({ + url: 'case-law/get-clain-rise-case', + type: 'post', + ai: true, + submitData, + service: 'mediate', + }); +} + + function caseRegisterSaveApi(submitData) { return $$.request({ url: 'caseInfo/caseRegister', @@ -30,6 +60,7 @@ select: {}, // 下拉框数据 goToMaterialSave: false, // 避免跳转到材料上传页面重复保存草稿 agreementMsg: '', // 服务协议 + ownerId: '', //附件上传id data: { stepText: 5, //用户须知倒计时5秒 timer: null, // 用于存储定时器的引用 @@ -71,9 +102,8 @@ amount: '', caseDes: '', caseClaim: '', - plaintiffList: [], - defendantList: [], }, // 表单数据 + fileList: [], //表单附件 addPersonData: {}, //添加的当事人 materialNum: 0, // 纠纷材料总数量 userInfoVisible: false, // 是否采用个人信息更新申请人信息 @@ -283,15 +313,28 @@ this.setData({ popupVisible: false }); + if (this.data.oneList?.length === 0) { + this.setData({ + addMePlaintiff: true + }) + } }, // 下一步 or 上一步 handleNext(e) { let type = e.currentTarget.dataset.type; if (type === 'next' && this.data.stepsActive === 0) { - this.setData({ - stepsActive: 1 - }); + if (this.data.oneList?.length <= 0) { + $$.showToast({ + title: '请至少添加一名当事人', + duration: 500 + }); + } else { + this.setData({ + stepsActive: 1 + }); + this.getById(); + } return; } if (type === 'back' && this.data.stepsActive === 1) { @@ -301,12 +344,58 @@ return; } if (type === 'next' && this.data.stepsActive === 1) { + let newData = this.data.submitData; + + console.log('this.data.submitData', this.data.submitData); + if (!newData.caseType) { + $$.showToast({ + title: '请选择纠纷类型', + duration: 500 + }); + return; + } + if (!newData.occurTime) { + $$.showToast({ + title: '请选择纠纷发生时间', + duration: 500 + }); + return; + } + if (!newData.addr) { + $$.showToast({ + title: '请选择纠纷发生地', + duration: 500 + }); + return; + } + if (!newData.caseDes) { + $$.showToast({ + title: '请填写事项概况', + duration: 500 + }); + return; + } + if (!newData.caseClaim) { + $$.showToast({ + title: '请填写事项申请', + duration: 500 + }); + return; + } + if (!this.data.fileList?.length <= 0) { + // 附件上传提示 + this.setData({ + showFileTip: true + }) + return; + } + // 提交AI接口 + this.getaw(newData); this.setData({ stepsActive: 2 }); return; } - if (type === 'back' && this.data.stepsActive === 2) { this.setData({ stepsActive: 1 @@ -324,8 +413,35 @@ this.caseRegisterSave({ ...data, personList, - agentList + agentList, + id: this.data.ownerId, }); + } + }, + + async getaw(data) { + let newData = { + caseDes: data.caseDes, + caseClaim: data.caseClaim, + caseId: this.data.ownerId, + } + const res = await getawApi(newData); + if (res.type) { + console.log('res.data', res.data); + this.setData({ + AIData: res.data || {} + }) + } + }, + + async getById() { + $$.showLoading(); + const res = await getByIdApi(); + $$.hideLoading(); + if (res.type) { + this.setData({ + ownerId: res.data || '' + }) } }, @@ -334,7 +450,10 @@ const res = await caseRegisterSaveApi(params); $$.hideLoading(); if (res.type) { - Toast('提交成功'); + // Toast('提交成功'); + this.setData({ + saveStatus: true + }) } }, @@ -343,6 +462,54 @@ let url = e.currentTarget.dataset.url; wx.navigateTo({ url: url, + }); + }, + + // 图片识别 + ocrClick(e) { + let key = e.currentTarget.dataset.key; + let keyNum = e.currentTarget.dataset.keyNum; + let that = this; + wx.chooseMedia({ + count: 1, + mediaType: ['image'], + success(res2) { + const tempFiles = res2.tempFiles[0]; + $$.showLoading(); + wx.uploadFile({ + url: `${$$.baseUrl}${$$.url.sys}/api/wechat/fileInfo/recognitionText`, + 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 wordsResult = data?.ocrResult?.wordsResult.join(''); + let wordsResultNum = data?.ocrResult?.wordsResultNum; + console.log('wordsResult', wordsResult); + that.setData({ + submitData: { + ...that.data.submitData, + [key]: wordsResult + }, + [keyNum]: wordsResultNum + }); + } + }, + }); + }, }); }, @@ -384,21 +551,98 @@ }) }, - // 获取省市区等地理资源 - async getLocationData() { - $$.showLoading(); - const res = await $$.commonRequest({ - url: `${$$.url.assets}locationSelect.json`, - type: 'get' + // 上传文件图片 + async handleUploadFile(e) { + let id = e.currentTarget.dataset.id; + let type = e.currentTarget.dataset.type; + let that = this; + this.filesArr = []; + wx.chooseMedia({ + mediaType: ['image'], + success(res2) { + const tempFiles = res2.tempFiles; + // 多个文件逐一上传 + tempFiles.forEach((x, t) => { + $$.showLoading('上传中...'); + wx.uploadFile({ + url: `${$$.baseUrl}${$$.url.sys}/api/wechat/fileInfo/upload?mainId=${id}&ownerId=${id}&ownerType=${type}`, + filePath: x.tempFilePath, + name: 'file', + header: { + Authorization: app.globalData.token + }, + complete(res) { + $$.hideLoading(); + if (res.errMsg === 'uploadFile:ok') { + const getData = JSON.parse(res.data) + const file = { + ...getData.data[0], + wxurl: x.tempFilePath + }; + that.setData({ + fileList: that.data.fileList.concat(file) + }) + $$.showToast({ + icon: 'success', + title: '上传成功', + duration: 500 + }); + } else { + $$.showToast({ + title: '上传失败', + duration: 500 + }); + } + + }, + }); + }); + }, }); - $$.hideLoading(); - if (res) { - let location = []; - $$.province.forEach((x) => { - location.push(res[x][0]); - }); - this.location = location; - } + }, + + // 预览图片 + handlePreviewImage(e) { + let item = e.currentTarget.dataset.item; + console.log('item', item); + let index = e.currentTarget.dataset.index; + wx.previewImage({ + current: item.wxurl, + urls: [item.wxurl] // 需要预览的图片http链接列表 + }); + }, + + // 删除图片 + async handleDelImage(e) { + let item = e.currentTarget.dataset.item; + let index = e.currentTarget.dataset.index; + let id = e.currentTarget.dataset.id; + let type = e.currentTarget.dataset.type; + $$.showModal({ + title: '删除材料确认', + content: '确定删除材料' + item.name + '吗?', + cancelText: '我再想想', + confirmText: '确定删除', + success: async (res) => { + if (res.confirm) { + $$.showLoading(); + const res = await delfileApi(id); + if (res.type) { + $$.showToast({ + icon: 'success', + title: '删除成功', + duration: 500 + }); + let list = this.data.fileList.filter((i, idx) => idx !== index); + console.log('list', list); + this.setData({ + fileList: list + }) + } + } + }, + }); + }, // 请求下拉框资源 @@ -521,7 +765,6 @@ * 生命周期函数--监听页面加载 */ onLoad: function () { - this.getLocationData(); let agreement = wx.getStorageSync('agreement'); if (!agreement) { this.getAgreement(); -- Gitblit v1.8.0