From 9463a158aa065ab3a5f38ac0000090797f5a5326 Mon Sep 17 00:00:00 2001 From: YXQ Date: Wed, 5 Jul 2023 14:06:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 2 +- pages/feedback/feedback.js | 44 ++++++++++++++++++++++-------------- pages/feedback/feedback.wxml | 2 +- pages/login/login.js | 1 - 4 files changed, 29 insertions(+), 20 deletions(-) diff --git a/app.js b/app.js index bb1e811..caa4cff 100644 --- a/app.js +++ b/app.js @@ -16,7 +16,7 @@ App({ globalData: { // 本地环境 - baseUrl:'http://192.168.51.200:8201/mall-portal', + baseUrl:'http://192.168.51.22:8201/mall-portal', // 线上环境 // baseUrl:'https://portal-api.macrozheng.com', token: '', diff --git a/pages/feedback/feedback.js b/pages/feedback/feedback.js index ca1a321..a53c5eb 100644 --- a/pages/feedback/feedback.js +++ b/pages/feedback/feedback.js @@ -8,7 +8,7 @@ Page({ */ data: { array: ['请选择', 'bug问题', '业务问题', '功能使用问题', '其他'], - objectArray: [{ + problemArray: [{ id: 0, name: '请选择' }, @@ -29,16 +29,16 @@ Page({ name: '其他' } ], - index: 0, - srxI: '', - + index: 0, //问题下标 + problemStr:'', //图片数组 addImgBtn: { isBtn: true, text: "+", func: "addImage" }, - imageArr: [] + imageArr: [], //显示图片列表 + upImageArr: [], //需要上传的图片路径 }, bindPickerChange(e) { @@ -49,15 +49,24 @@ Page({ //提交数据 goMyorder() { - if(this.data.index === 0){ + if (this.data.index === 0) { wx.showToast({ title: '请选择问题类型', }); return; } - var problem = objectArray[this.data.index]; //问题类型 - request.post(`/feedBack/push?type=${this.data.index}&describe=${problem}`).then(res=>{ - + var problem = this.data.problemArray[this.data.index]; //问题类型 + var data = { + 'type': this.data.index, + 'describe': this.data.problemStr, + 'imgs':this.data.upImageArr.toString + } + console.log(JSON.stringify(data)) + request.post(`/feedBack/push`, data).then(res => { + wx.showToast({ + title: 'title', + }) + console.log(JSON.stringify(res.data)) }); // wx.switchTab({ // url: '../about/about', @@ -77,7 +86,7 @@ Page({ count: 1, mediaType: ['image'], sourceType: ['album'], - sizeType:['compressed'], + sizeType: ['compressed'], success: res => { var imgSrc = res.tempFiles[0].tempFilePath; _this.addCallBackImage(imgSrc); @@ -88,7 +97,6 @@ Page({ //显示回调图片 addCallBackImage(imageSrc) { - console.log("imgSrc=" + imageSrc); var temp = { isBtn: false, imgUrl: imageSrc, @@ -105,18 +113,20 @@ Page({ upImg(imageSrc) { request.upImgFile(`/feedBack/upload`, imageSrc).then(res => { var resObj = JSON.parse(res.data); - if(resObj.code === 500){ + if (resObj.code > 400) { wx.showModal({ title: '提示', content: resObj.message, complete: (res) => { - if (res.cancel) { - } - if (res.confirm) { - } - //移除图片 + if (res.cancel) {} + if (res.confirm) {} + //上传失败后移除图片 + } }) + } else { + //保存图片路径到数组 + this.data.upImageArr.push(resObj.data.url); } }); }, diff --git a/pages/feedback/feedback.wxml b/pages/feedback/feedback.wxml index c08c652..ddda8f1 100644 --- a/pages/feedback/feedback.wxml +++ b/pages/feedback/feedback.wxml @@ -9,7 +9,7 @@ {{array[index]}} - + diff --git a/pages/login/login.js b/pages/login/login.js index b1b0044..2fdf8f5 100644 --- a/pages/login/login.js +++ b/pages/login/login.js @@ -23,7 +23,6 @@ Page({ }, //登录请求 login() { - console.log('login run'); request.post(`/sso/login?username=${this.data.username}&password=${this.data.userpwd}`).then(res => { console.log(res); if (res.data.code == 200) {