From e87f184a75624e30d7ec895d5ef02ac3be5d884a Mon Sep 17 00:00:00 2001
From: odc.xiaohui <xiaohui@Q1>
Date: 星期一, 20 三月 2023 09:59:09 +0800
Subject: [PATCH] 我要报案修改

---
 miniprogram/pages/user/report/submitReport/index.ts |   69 +++++++++++++++++++++++++++++++---
 1 files changed, 62 insertions(+), 7 deletions(-)

diff --git a/miniprogram/pages/user/report/submitReport/index.ts b/miniprogram/pages/user/report/submitReport/index.ts
index 9e2bb55..086251a 100644
--- a/miniprogram/pages/user/report/submitReport/index.ts
+++ b/miniprogram/pages/user/report/submitReport/index.ts
@@ -2,6 +2,8 @@
 const submitReport =getApp()
 Page({
     data: {
+        fileImgList: [],
+        causeIndex: null,
         items:  { name: '鏃ユ湡鏃堕棿閫夋嫨', value: 'dateTime' },
         mode: 'dateTime',
         reportDetail: {},
@@ -16,14 +18,56 @@
             ],
             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,
@@ -90,13 +134,13 @@
         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.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",
@@ -140,5 +184,16 @@
         }
         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
+                    })
+                }
+            })
     }
 })
\ No newline at end of file

--
Gitblit v1.8.0