From eb64e401aa8f22f510914a21ec3cf89e1594f6cb Mon Sep 17 00:00:00 2001 From: zuoxiao <470321431@qq.com> Date: 星期一, 28 十月 2024 17:59:44 +0800 Subject: [PATCH] 1.修复开泵成功后跳转回首页时提示登录的bug --- pages/feedback/feedback.js | 197 +++++++++++++++++++++++++++++++++--------------- 1 files changed, 135 insertions(+), 62 deletions(-) diff --git a/pages/feedback/feedback.js b/pages/feedback/feedback.js index d98f891..cec1120 100644 --- a/pages/feedback/feedback.js +++ b/pages/feedback/feedback.js @@ -1,5 +1,9 @@ const audio = wx.createInnerAudioContext() const recorderManager = wx.getRecorderManager() +const { + BASEURL +} = require('../../api/config') +const app = getApp() Page({ data: { isRefreshing: false, @@ -18,13 +22,15 @@ width: 160, height: 160, }, - originFiles: [ - ], + originFiles: [], feedBackList: Array(19).fill({ createTime: "2023-05-06 12:36:25", responseTime: "2023-05-07 12:36:25" }), - contentValue:''//鍙嶉璇︽儏 + contentValue: '', //鍙嶉璇︽儏 + accSavePath: '', //涓婁紶鐨勯煶棰戞枃浠舵帴鍙h繑鍥炵殑鍦板潃 + photoSavePath: [] //涓婁紶鐨勭収鐗囨枃浠惰繑鍥炵殑鍦板潃 + }, onLoad() { @@ -65,7 +71,7 @@ time: 3000 }) } else { - + that.setData({ voiceTime: voiceTime, isShowVoiceMask: false, @@ -78,47 +84,9 @@ } = res; //杩欓噷鏉惧紑鎸夐挳 浼氳繑鍥炲綍闊虫湰鍦拌矾寰� audio.src = tempFilePath console.log(tempFilePath); + that.upACC(tempFilePath); } - //涓婁紶褰曞埗鐨勯煶棰戝埌鏈嶅姟鍣� - // wx.uploadFile({ - // url: '鎺ュ彛鍦板潃' + api.voice, //鎺ュ彛鍦板潃 - // name: 'file', //涓婁紶鏂囦欢鍚� - // filePath: tempFilePath, - // success: function (res) { //鍚庡彴杩斿洖缁欏墠绔瘑鍒悗鐨勬枃瀛� - // var model = res.data - // var modeljson = JSON.parse(model) - // if (modeljson.status_code == 500) { - // wx.showToast({ - // title: '璇煶杞崲澶辫触', - // image: '/assets/image/icon/fail@2x.png' - // }) - // return false; - // } - // if (modeljson.meta.status_code === 200 && !modeljson.data.err_msg) { - // var saymessage = modeljson.data.message; - // wx.setStorageSync('sayinfo', saymessage) - // that.setData({ - // inpvalue: saymessage - // }) - // setTimeout(() =>{ - // wx.navigateTo({ - // url: '../loding/loding' - // }) - - // },2000) - // setTimeout(() => { - // wx.hideLoading(); - // }, 100) - // } else if (modeljson.data.err_msg) { - // wx.showToast({ - // title: '璇峰ぇ澹拌璇�', - // image: '/assets/image/icon/fail@2x.png' - // }) - // return false; - // } - // } - // }) }); recorderManager.onStart(() => { console.log('褰曢煶寮�濮�'); @@ -126,6 +94,26 @@ recorderManager.onError((err) => { console.log('褰曢煶閿欒', err); }); + }, + //涓婁紶闊抽鏂囦欢 + upACC(tempFilePath) { + //涓婁紶褰曞埗鐨勯煶棰戝埌鏈嶅姟鍣� + wx.uploadFile({ + url: BASEURL + "wx/webFile/upPhone", //鎺ュ彛鍦板潃 + name: 'file', //涓婁紶鏂囦欢鍚� + filePath: tempFilePath, + header: { + 'tag': app.globalData.tag, + 'appId': app.globalData.AppID, + }, + success: function (res) { //鍚庡彴杩斿洖缁欏墠绔瘑鍒悗鐨勬枃瀛� + console.log('褰曢煶涓婁紶鎴愬姛', res); + }, + fail: (err) => { + // 澶勭悊涓婁紶澶辫触鐨勯�昏緫 + console.log('褰曢煶涓婁紶澶辫触', err); + } + }) }, handleRemove(e) { console.log("handleRemove"); @@ -135,13 +123,28 @@ const { originFiles } = this.data; + let imgPath = e.detail.file.url; + const updatedFiles = this.data.originFiles.map((file) => { + //褰撲笂浼犲け璐ョ偣鍑绘椂閲嶆柊涓婁紶 + if (file.url === imgPath && file.uploadTask) { + file.uploadTask.abort(); + } + }); originFiles.splice(index, 1); this.setData({ originFiles, }); + }, - handleClick() { + handleClick(e) { console.log("handleClick"); + let imgPath = e.detail.file.url; + const updatedFiles = this.data.originFiles.map((file) => { + //褰撲笂浼犲け璐ョ偣鍑绘椂閲嶆柊涓婁紶 + if (file.url === imgPath && file.status === "reload") { + this.onUploadPhoto(imgPath); + } + }); }, handleAdd(e) { console.log("handleAdd"); @@ -151,27 +154,74 @@ const { originFiles } = this.data; - this.setData({ - originFiles: [...originFiles, ...files], // 姝ゆ椂璁剧疆浜� fileList 涔嬪悗鎵嶄細灞曠ず閫夋嫨鐨勫浘鐗� + const updatedList = files.map(item => { + return { + ...item, + status: 'loading', + uploadTask: this.onUploadPhoto(e.detail.files[0].url) + }; // 淇濈暀鎵�鏈夊叾浠栧瓧娈碉紝骞舵坊鍔� displayText 瀛楁 }); + // 鏇存柊鍒楄〃鏁版嵁 + this.setData({ + originFiles: [...originFiles, ...updatedList], // 姝ゆ椂璁剧疆浜� fileList 涔嬪悗鎵嶄細灞曠ず閫夋嫨鐨勫浘鐗� + }); + }, + handleSuccess(e) { + }, /** * 涓婁紶鍥剧墖 */ - onUpload() { - wx.uploadFile({ - url: 'https://example.weixin.qq.com/upload', // 浠呬负绀轰緥锛岄潪鐪熷疄鐨勬帴鍙e湴鍧� - filePath: file.url, + onUploadPhoto(imgPath) { + const uploadTask = wx.uploadFile({ + url: BASEURL + "wx/webFile/upPhone", // 浠呬负绀轰緥锛岄潪鐪熷疄鐨勬帴鍙e湴鍧� + filePath: imgPath, name: 'file', - formData: { - user: 'test' + header: { + 'tag': app.globalData.tag, + 'appId': app.globalData.AppID, }, - success: () => { - this.setData({ - [`fileList[${length}].status`]: 'done', + success: (res) => { + console.log('鍥剧墖涓婁紶鎴愬姛', res); + }, + fail: (err) => { + // 澶勭悊涓婁紶澶辫触鐨勯�昏緫 + const updatedFiles = this.data.originFiles.map((file) => { + if (file.url === imgPath) { + return { + ...file, + percent: progress, + status: "reload", // 涓婁紶澶辫触鐘舵�� + }; + } + return file; }); - }, + this.setData({ + originFiles: updatedFiles, + }); + } }); + if (uploadTask) { + uploadTask.onProgressUpdate((res) => { + //澶勭悊 + const progress = Math.round((res.progress / 100) * 100) + const updatedFiles = this.data.originFiles.map((file) => { + if (file.url === imgPath) { + return { + ...file, + percent: progress, + status: progress < 100 ? 'loading' : undefined, // 鏇存柊鐘舵�� + uploadTask: progress < 100 ? file.uploadTask : undefined, // 淇濇寔鎴栧垹闄ploadTask + }; + } + return file; + }); + this.setData({ + originFiles: updatedFiles, + }); + }); + } + return uploadTask; }, //鎸変綇鎸夐挳 startHandel() { @@ -296,7 +346,7 @@ isRefreshing: false }); }, - feelBack(){ + feelBack() { wx.showLoading({ title: '姝e湪鎻愪氦...', // 鍔犺浇鎻愮ず鏂囧瓧 mask: true // 鏄惁鏄剧ず閫忔槑钂欏眰锛岄槻姝㈣Е鎽哥┛閫忥紝榛樿涓� false @@ -340,11 +390,34 @@ // } }); }, - handleDelete(){ - this.setData({ - isShowVoiceView:false, - voiceTime:0, - }) + handleDelete() { + this.setData({ + isShowVoiceView: false, + voiceTime: 0, + }) + }, + submit() { + if (this.data.contentValue !== "" || this.data.photoSavePath.length>0 || this.data.accSavePath !== "") { + wx.showToast({ + title: '鎻愪氦鎴愬姛', + icon: 'success', + duration: 2000, + success() {} + }) + setTimeout(() => { + wx.navigateBack({ + delta: 1 + }); + }, 2000); + } else { + wx.showToast({ + title: '璇疯緭鍏ヤ竴椤瑰弽棣堝唴瀹�', + icon: 'error', + duration: 2000, + success() {} + }) + } + } }); \ No newline at end of file -- Gitblit v1.8.0