| | |
| | | const submitReport =getApp() |
| | | Page({ |
| | | data: { |
| | | fileImgList: [], |
| | | causeIndex: null, |
| | | items: { name: '日期时间选择', value: 'dateTime' }, |
| | | mode: 'dateTime', |
| | | reportDetail: {}, |
| | |
| | | images: [], |
| | | materials:"", |
| | | cheatTime:"", |
| | | arraySex: [ |
| | | {sex:'男',id:1}, |
| | | {sex:'女',id:0} |
| | | ], |
| | | sexId:0 |
| | | }, |
| | | afterReadImg(event: { detail: { file: any; }; }){ |
| | | const { file } = event.detail; |
| | | let that=this |
| | | console.log(file); |
| | | |
| | | // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式 |
| | | wx.uploadFile({ |
| | | // filePath: this.data.imagesFile[index].tempFilePath, |
| | | header: { |
| | | 'token': wx.getStorageSync('token'), |
| | | 'content-type': 'application/json' |
| | | }, |
| | | url: submitReport.globalData.url+"/minio/upload", |
| | | filePath: file.url, |
| | | name: 'file', |
| | | formData: { user: 'test' }, |
| | | success(res) { |
| | | // 上传完成需要更新 fileList |
| | | const { fileImgList = [] } = that.data; |
| | | fileImgList.push({ ...file, url: res.data }); |
| | | that.setData({ fileImgList }); |
| | | |
| | | |
| | | const result = JSON.parse(res.data) |
| | | |
| | | that.setData({ |
| | | materials: that.data.materials+=result.data+"," |
| | | }) |
| | | console.log(that.data.materials); |
| | | }, |
| | | }); |
| | | }, |
| | | //选择案件 |
| | | pickCause(e: { detail: { value: string | number; }; }) { |
| | | console.log(e); |
| | | this.setData({ |
| | | causeIndex: e.detail.value |
| | | }) |
| | | this.data.reportDetail.causeId = this.data.causeList[e.detail.value].id |
| | | }, |
| | | uploadImage() { |
| | | wx.chooseMedia({ |
| | | sourceType:['camera'], |
| | | mediaType: ['image'], |
| | | success: res => { |
| | | this.setData({ |
| | | imagesFile: res.tempFiles |
| | | }) |
| | | console.log(this.data.imagesFile); |
| | | |
| | | for (let index = 0; index < this.data.imagesFile.length; index++) { |
| | | wx.uploadFile({ |
| | | filePath: this.data.imagesFile[index].tempFilePath, |
| | |
| | | url: submitReport.globalData.url+"/minio/upload", |
| | | success: res => { |
| | | const result = JSON.parse(res.data) |
| | | this.data.images.push({ |
| | | url:submitReport.globalData.imageUrl+"/img/"+result.data |
| | | }) |
| | | this.setData({ |
| | | images:this.data.images |
| | | }) |
| | | if(index< this.data.imagesFile.length-1){ |
| | | this.data.materials+=result.data+"," |
| | | }else{ |
| | | this.data.materials+=result.data |
| | | } |
| | | this.setData({ |
| | | materials:this.data.materials |
| | | }) |
| | | this.data.images.push({ |
| | | url:submitReport.globalData.imageUrl+"/img/"+result.data |
| | | }) |
| | | this.setData({ |
| | | images:this.data.images |
| | | }) |
| | | this.setData({ |
| | | materials: this.data.materials+=result.data+"," |
| | | }) |
| | | console.log(this.data.materials); |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | } |
| | | }) |
| | |
| | | onPickerChange(e){ |
| | | console.log(e) |
| | | this.data.cheatTime=e.detail.value |
| | | }, |
| | | subSex(e){ |
| | | console.log(e); |
| | | |
| | | }, |
| | | bindPickerChangeSex(e){ |
| | | console.log(e); |
| | | this.setData({ |
| | | sexId:e.detail.value |
| | | }) |
| | | }, |
| | | getMoney:function(e){ |
| | | console.log(e.detail.value) |
| | |
| | | }) |
| | | }, |
| | | pass() { |
| | | this.data.reportDetail.materials=this.data.materials |
| | | this.data.materials=this.data.materials.substring(0,this.data.materials.length-1); |
| | | this.data.reportDetail.reportMaterials=this.data.materials |
| | | this.data.reportDetail.userId=wx.getStorageSync('id') |
| | | this.data.reportDetail.cheatTime=this.data.cheatTime |
| | | if ( this.data.reportDetail.materials == null|| this.data.reportDetail.information==null|| this.data.reportDetail.reportDescription==null) { |
| | | wx.showToast({ |
| | | icon: "none", |
| | | title: '请完整填完表单!', |
| | | }) |
| | | return |
| | | } |
| | | // if ( this.data.reportDetail.information==null|| this.data.reportDetail.reportDescription==null) { |
| | | // wx.showToast({ |
| | | // icon: "none", |
| | | // title: '请完整填完表单!', |
| | | // }) |
| | | // return |
| | | // } |
| | | wx.request( |
| | | { |
| | | url: submitReport.globalData.url+"/wx/user/addReport", |
| | |
| | | } |
| | | this.data.cheatTime = date.getFullYear() + "-" + month + "-" + day + " " + hours+":"+minutes+":"+secends |
| | | console.log( this.data.cheatTime) |
| | | wx.request( |
| | | { |
| | | url: submitReport.globalData.url+ "/cause/getCauseList", |
| | | method: "GET", |
| | | header: { 'token': wx.getStorageSync('token')}, |
| | | success: (res) => { |
| | | this.setData({ |
| | | causeList: res.data.data.records |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | }) |