安瑾然
2023-03-21 b4661f300194a13c4bc391f2f45a3f7a0a8dff08
miniprogram/pages/user/report/submitReport/index.ts
@@ -3,6 +3,7 @@
import Toast from '@vant/weapp/toast/toast';
Page({
    data: {
        aaaform: {},
        capture:['camera'],
        beforList:'a',
        amountInvolved:'',
@@ -67,12 +68,8 @@
        })
    },
    afterReadImg(event: { detail: { file: any; }; },name){
        console.log(event,name);
        const { file } = event.detail;
        let that=this
        console.log(file);
        // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
        wx.uploadFile({
            // filePath:  this.data.imagesFile[index].tempFilePath,
@@ -92,30 +89,26 @@
            const { cardIdList = [] } = that.data;
            let result = JSON.parse(res.data)
            if (that.data.beforList=='a') {
                cardIdList.push({ ...file, url: res.data });
                    cardIdList.push({ ...file, url: result.data });
                that.setData({ cardIdList });
            }else if(that.data.beforList=='b'){
                fileImgList.push({ ...file, url: res.data });
                    fileImgList.push({ ...file, url: result.data });
                that.setData({ fileImgList });
            }else if(that.data.beforList=='c'){
                transactionReceiptList.push({ ...file, url: res.data });
                    transactionReceiptList.push({ ...file, url: result.data });
                that.setData({ transactionReceiptList });
            }else if(that.data.beforList=='d'){
                otherList.push({ ...file, url: res.data });
                    otherList.push({ ...file, url: result.data });
                that.setData({ otherList });
            }
            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
        })
@@ -129,8 +122,6 @@
                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,
@@ -151,7 +142,6 @@
                                this.setData({
                                    materials: this.data.materials+=result.data+","
                                })
                                console.log(this.data.materials);
                        } 
                    })            
                }
@@ -161,15 +151,11 @@
    },
//被骗时间
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
})
@@ -178,16 +164,13 @@
})
},
getMoney:function(e){
 console.log(e.detail.value)
 this.data.reportDetail.amountInvolved=e.detail.value
},
getDe:function(e){
    console.log(e.detail.value)
    this.data.reportDetail.reportDescription=e.detail.value
   },
   getInfor:function(e){
    this.data.reportDetail.information=e.detail.value
    console.log(e.detail.value)
   },
    //通过
    cancel(){
@@ -196,7 +179,6 @@
       })
    },
    pass() {
        console.log(this.data.realName);
        if (this.data.realName=='') {
            Toast('请输入姓名!');
            return
@@ -219,21 +201,24 @@
        if (this.data.fileImgList.length!=0||this.data.transactionReceiptList.length!=0||this.data.otherList.length!=0) {
          
        }else{
            Toast('相关合同,交易凭证,其他;必填一项!');
            return
        }
        this.data.materials=this.data.materials.substring(0,this.data.materials.length-1);
        this.data.reportDetail.amountInvolved=this.data.amountInvolved,
        this.data.reportDetail.workingLocation=this.data.workingLocation,
        this.data.reportDetail.Location=this.data.Location,
        this.data.reportDetail.userIdCard=this.data.userIdCard,
        this.data.reportDetail.sex=this.data.sex,
        this.data.reportDetail.realName=this.data.realName,
        this.data.reportDetail.phone=this.data.phone,
        this.data.reportDetail.amountInvolved = this.data.amountInvolved
        this.data.reportDetail.workingLocation = this.data.workingLocation
        this.data.reportDetail.location = this.data.Location
        this.data.reportDetail.userIdCard = this.data.userIdCard
        this.data.reportDetail.sex = this.data.sex
        this.data.reportDetail.realName = this.data.realName
        this.data.reportDetail.phone = this.data.phone
        this.data.reportDetail.reportMaterials=this.data.materials
        this.data.reportDetail.userId=wx.getStorageSync('id')
        this.data.reportDetail.cheatTime=this.data.cheatTime
        this.data.reportDetail.idCardMaterials = this.data.cardIdList.map(res => res.url).join(',')
        this.data.reportDetail.contractMaterials = this.data.fileImgList.map(res => res.url).join(',')
        this.data.reportDetail.transactionMaterials = this.data.transactionReceiptList.map(res => res.url).join(',')
        this.data.reportDetail.elseMaterials = this.data.otherList.map(res => res.url).join(',')
        // if (  this.data.reportDetail.information==null||  this.data.reportDetail.reportDescription==null) {
        //     wx.showToast({
        //         icon: "none",
@@ -250,16 +235,14 @@
                    'token': wx.getStorageSync('token'),
                    'content-type': 'application/json'
                }, success: (res) => {
                    console.log(res)
                    wx.reLaunch({
                        url:'../../report/index'
                    })
                }
            })
    },
    onLoad(e) {
        let that = this
        let phone = wx.getStorageSync('phone')
        this.setData({
            phone:phone
@@ -287,17 +270,86 @@
            secends = "0" + secends
        }
        this.data.cheatTime = date.getFullYear() + "-" + month + "-" + day + " " + hours+":"+minutes+":"+secends
        console.log( this.data.cheatTime)
        this.loadData(e)
        wx.request(
            {
                url: submitReport.globalData.url+  "/cause/getCauseList",
                url: submitReport.globalData.url + "/cause/getVxCauseList?phone=" + that.data.phone,
                method: "GET",
                header: { 'token': wx.getStorageSync('token')},
                success: (res) => {
                    let causes = res.data.data
                    console.log(that.data.aaaform);
                    if (e.id) {
                        causes.push({
                            id: that.data.aaaform.causeId,
                            name: that.data.aaaform.description
                        })
                    }
                    this.setData({
                        causeList: res.data.data.records
                        causeList: causes,
                        causeIndex: causes.findIndex(i => i.id == that.data.aaaform.causeId)
                    })
                }
            })
    },
    loadData(e: any) {
        let that = this
        const { arraySex } = this.data
        if (e.id) {
            wx.request({
                url: submitReport.globalData.url + "/report/rejectReport/" + e.id,
                method: "GET",
                header: { 'token': wx.getStorageSync('token') },
                success: res => {
                    let form = res.data.data
                    this.setData({
                        aaaform: form,
                        realName: form.realName,
                        phone: form.mobile,
                        userIdCard: form.userIdCard,
                        amountInvolved: form.amountInvolved,
                        sex: form.sex,
                        sexId: arraySex.filter(i => i.sex == form.sex)[0].code,
                        Location: form.location,
                        workingLocation: form.workingLocation,
                        cardIdList: form.idCardMaterials.split(',').map(i => {
                            return {
                                thumb: that.imgComplete(i),
                                url: i,
                                type: "image",
                                size: 999999
                            }
                        }),
                        fileImgList: form.contractMaterials.split(',').map(i => {
                            return {
                                thumb: that.imgComplete(i),
                                url: i,
                                type: "image",
                                size: 999999
                            }
                        }),
                        transactionReceiptList: form.transactionMaterials.split(',').map(i => {
                            return {
                                thumb: that.imgComplete(i),
                                url: i,
                                type: "image",
                                size: 999999
                            }
                        }),
                        otherList: form.elseMaterials.split(',').map(i => {
                            return {
                                thumb: that.imgComplete(i),
                                url: i,
                                type: "image",
                                size: 999999
                            }
                        })
                    })
                }
            })
        }
    },
    imgComplete(file: String): String {
        return submitReport.globalData.imageUrl + "/img/" + file
    }
})