From ddbd8c7ea87b66d5a9c4362ce284d12a4ae970d1 Mon Sep 17 00:00:00 2001 From: zuoxiao <470321431@qq.com> Date: 星期五, 01 十一月 2024 14:24:50 +0800 Subject: [PATCH] 1绑定相关。2首页修改开关阀提示。3.问题反馈相关功能 --- pages/feedback/feedback.js | 248 +++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 206 insertions(+), 42 deletions(-) diff --git a/pages/feedback/feedback.js b/pages/feedback/feedback.js index cec1120..3e08801 100644 --- a/pages/feedback/feedback.js +++ b/pages/feedback/feedback.js @@ -1,6 +1,10 @@ const audio = wx.createInnerAudioContext() const recorderManager = wx.getRecorderManager() const { + get, + post +} = require('../../api/request.js'); +const { BASEURL } = require('../../api/config') const app = getApp() @@ -23,14 +27,18 @@ height: 160, }, originFiles: [], - feedBackList: Array(19).fill({ - createTime: "2023-05-06 12:36:25", - responseTime: "2023-05-07 12:36:25" - }), - contentValue: '', //鍙嶉璇︽儏 - accSavePath: '', //涓婁紶鐨勯煶棰戞枃浠舵帴鍙h繑鍥炵殑鍦板潃 - photoSavePath: [] //涓婁紶鐨勭収鐗囨枃浠惰繑鍥炵殑鍦板潃 + contentValue: '', //鍙嶉璇︽儏 + accSavePath: [], //涓婁紶鐨勯煶棰戞枃浠舵帴鍙h繑鍥炵殑鍦板潃 + photoSavePath: [], //涓婁紶鐨勭収鐗囨枃浠惰繑鍥炵殑鍦板潃 + phoneNumber: "", + lat: "", + lng: "", + loading: false, + hasMore: true, + pageCurr: 1, + pageSize: 20, + listData: [], //宸叉彁闂鍒楄〃 }, onLoad() { @@ -94,6 +102,22 @@ recorderManager.onError((err) => { console.log('褰曢煶閿欒', err); }); + wx.getLocation({ + type: 'wgs84', // 杩斿洖鍙互鐢ㄤ簬 `wx.openLocation` 鐨勭粡绾害 + success: (res) => { + console.log('鑾峰彇浣嶇疆鎴愬姛', res); + this.setData({ + lat: res.latitude, + lng: res.longitude, + }); + }, + fail: function (err) { + console.error('鑾峰彇浣嶇疆澶辫触', err); + } + }); + }, + onReady() { + this.getList(); }, //涓婁紶闊抽鏂囦欢 upACC(tempFilePath) { @@ -106,8 +130,16 @@ 'tag': app.globalData.tag, 'appId': app.globalData.AppID, }, - success: function (res) { //鍚庡彴杩斿洖缁欏墠绔瘑鍒悗鐨勬枃瀛� + success: (res) => { //鍚庡彴杩斿洖缁欏墠绔瘑鍒悗鐨勬枃瀛� console.log('褰曢煶涓婁紶鎴愬姛', res); + let jsonData = JSON.parse(res.data) + let audioObj = { + webPath: jsonData.content.webPath, + id: jsonData.content.id + }; + this.setData({ + accSavePath: [audioObj] + }) }, fail: (err) => { // 澶勭悊涓婁紶澶辫触鐨勯�昏緫 @@ -115,6 +147,7 @@ } }) }, + //鍒犻櫎鍥剧墖 handleRemove(e) { console.log("handleRemove"); const { @@ -132,7 +165,7 @@ }); originFiles.splice(index, 1); this.setData({ - originFiles, + originFiles: originFiles, }); }, @@ -158,7 +191,7 @@ return { ...item, status: 'loading', - uploadTask: this.onUploadPhoto(e.detail.files[0].url) + uploadTask: this.onUploadPhoto(item.url) }; // 淇濈暀鎵�鏈夊叾浠栧瓧娈碉紝骞舵坊鍔� displayText 瀛楁 }); // 鏇存柊鍒楄〃鏁版嵁 @@ -174,7 +207,7 @@ */ onUploadPhoto(imgPath) { const uploadTask = wx.uploadFile({ - url: BASEURL + "wx/webFile/upPhone", // 浠呬负绀轰緥锛岄潪鐪熷疄鐨勬帴鍙e湴鍧� + url: BASEURL + "wx/webFile/upPhoto", // 浠呬负绀轰緥锛岄潪鐪熷疄鐨勬帴鍙e湴鍧� filePath: imgPath, name: 'file', header: { @@ -183,6 +216,26 @@ }, success: (res) => { console.log('鍥剧墖涓婁紶鎴愬姛', res); + let jsonData = JSON.parse(res.data) + // 鏇存柊鍥剧墖涓婁紶鎴愬姛鐘舵�� + const updatedFiles = this.data.originFiles.map((file) => { + console.log('鍥剧墖涓婁紶鎴愬姛銆嬨�媢pdatedFiles', file + "++++++++++" + imgPath); + if (file.url === imgPath) { + return { + ...file, + status: undefined, // 涓婁紶鎴愬姛鐘舵�� + uploadTask: undefined, // 娓呯悊涓婁紶浠诲姟 + webPath: jsonData.content.webPath, + id: jsonData.content.id + }; + } + return file; + }); + // 灏嗗垱寤虹殑瀵硅薄娣诲姞鍒癷mages鏁扮粍涓� + this.setData({ + originFiles: updatedFiles, + }) + }, fail: (err) => { // 澶勭悊涓婁紶澶辫触鐨勯�昏緫 @@ -342,47 +395,60 @@ }); }, onPullDownRefresh() { - this.setData({ - isRefreshing: false - }); + this.getList(true); }, - feelBack() { + //涓婁紶闂 + feelBackPost() { wx.showLoading({ title: '姝e湪鎻愪氦...', // 鍔犺浇鎻愮ず鏂囧瓧 mask: true // 鏄惁鏄剧ず閫忔槑钂欏眰锛岄槻姝㈣Е鎽哥┛閫忥紝榛樿涓� false }); + this.data.originFiles.map((file) => { + let imageObj = { + webPath: file.webPath, + id: file.id + }; + this.setData({ + photoSavePath: [...this.data.photoSavePath, imageObj] + }) + }) const app = getApp(); const data = { - content: this.data.contentValue, //鍙栨按鍙D - image: this.data.vcId, //铏氭嫙鍗D - operator: app.globalData.sessionId, //鎿嶄綔鍛� - forceOpen: !!isforce // 浣跨敤閫昏緫闈炴搷浣滅 !! 鏉ョ‘淇� isForce 鏄竷灏斿�� + images: this.data.photoSavePath, + audios: this.data.accSavePath, + content: this.data.contentValue, + lng: this.data.lng, + lat: this.data.lat, + clientId: app.globalData.clientId, + phone: this.data.phoneNumber }; post({ - url: "operation/feedback/add", + url: "wx/issue/addIssueReport", data: data }).then(response => { - // 澶勭悊鎴愬姛鍝嶅簲 console.log('璇锋眰鎴愬姛:', response); // 鍔犺浇瀹屾垚鍚庨殣钘忓姞杞藉姩鐢� wx.hideLoading(); //瀹屾垚鍚庡洖鍒伴椤� - wx.reLaunch({ - url: '/pages/home/home?param=true' // 棣栭〉鐨勮矾寰勶紝鏍规嵁瀹為檯鎯呭喌濉啓 - }); + wx.showToast({ + title: '鎻愪氦鎴愬姛', + icon: 'success', + duration: 2000, + success() {} + }) + setTimeout(() => { + wx.navigateBack({ + delta: 1 + }); + }, 2000); }).catch(error => { // 鍔犺浇瀹屾垚鍚庨殣钘忓姞杞藉姩鐢� wx.hideLoading(); // 澶勭悊閿欒鍝嶅簲 console.error('璇锋眰澶辫触:', error); - // if (error.code === "10005") { - // this.setData({ - // showDialog: false, - // showForceConfirm: true - // }) - // } else { + this.setData({ showErrorDialog: true, errorData: error.msg @@ -396,19 +462,19 @@ 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); + if (this.data.contentValue !== "" || this.data.photoSavePath.length > 0 || this.data.accSavePath !== "") { + if (this.data.phoneNumber !== "" && this.data.phoneNumber.length !== 11) { + wx.showToast({ + title: '鑱旂郴鐢佃瘽閿欒', + icon: 'error', + duration: 2000, + success() {} + }) + } else { + this.feelBackPost(); + } } else { wx.showToast({ title: '璇疯緭鍏ヤ竴椤瑰弽棣堝唴瀹�', @@ -418,6 +484,104 @@ }) } + }, + //鐩戝惉鎵嬫満鍙风殑杈撳叆 + phoneInput(e) { + this.setData({ + phoneNumber: e.detail.value + }); + }, + //鐩戝惉 + contentInput(e) { + this.setData({ + contentValue: e.detail.value + }); + }, + //鑾峰彇宸叉彁闂鍒楄〃 + getList(isRefresh) { + if (isRefresh) { + this.setData({ + isRefreshing: false, + pageCurr: 1, + }); + } + const app = getApp(); + const params = { + url: 'wx/issue/getIssueReports', + data: { + clientId: app.globalData.clientId + } + }; + get(params).then(data => { + const updatedList = data.content.obj.map(item => { + if (item.replyTime === "" || item.replyTime === null) { + item.replyTime = "鏈洖澶�" + } + return item; + }); + this.setData({ + listData: [...this.data.listData, ...updatedList], + isRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚 + isWXRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚 + loading: false, + hasMore: this.data.pageCurr < data.content.pageTotal + }) + this.updateDisplayText(); + }).catch(err => { + // 閿欒鍥炶皟 + this.setData({ + isRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚 + isWXRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚 + loading: false + }) + wx.showToast({ + title: err.msg, + icon: 'error', + duration: 3000 + }) + }); + }, + //鍔犺浇鏇村 + loadMore() { + if (this.data.hasMore && !this.data.loading) { + this.setData({ + loading: true, + pageCurr: this.data.pageCurr + 1 + }) + this.getList(); + } + }, + onDelete(e) { + const item = e.currentTarget.dataset.item; + const that = this; + wx.showLoading({ + title: '姝e湪寮哄埗鍒犻櫎璇风◢鍊�...', // 鍔犺浇鎻愮ず鏂囧瓧 + mask: true // 鏄惁鏄剧ず閫忔槑钂欏眰锛岄槻姝㈣Е鎽哥┛閫忥紝榛樿涓� false + }); + that.setData({ + lastIntakeName: intakeName + }) + const data = { + vcNum: item.vcNum, //鍙栨按鍙D + rtuAddr: item.rtuAddr, //闃�鎺у櫒鍦板潃 + }; + post({ + url: "wx/issue/deleteIssueReport", + data: data, + timeout: 180000 + }).then(response => { + // 澶勭悊鎴愬姛鍝嶅簲 + console.log('璇锋眰鎴愬姛:', response); + // 鍔犺浇瀹屾垚鍚庨殣钘忓姞杞藉姩鐢� + wx.hideLoading(); + //閲嶆柊鑾峰彇鍒楄〃鍒锋柊鏁版嵁 + this.getList(); + }).catch(error => { + // 鍔犺浇瀹屾垚鍚庨殣钘忓姞杞藉姩鐢� + wx.hideLoading(); + // 澶勭悊閿欒鍝嶅簲 + console.error('璇锋眰澶辫触:', error); + }); } }); \ No newline at end of file -- Gitblit v1.8.0