From aec1b6ec73897b5e5f3a85f2985447726a399ed0 Mon Sep 17 00:00:00 2001
From: zuoxiao <zuoxiao>
Date: 星期六, 19 四月 2025 15:56:48 +0800
Subject: [PATCH] 更新灌溉计划页面,添加灌溉计划列表刷新标记,优化项目选择器和时间选择器的逻辑;更新样式以提升用户体验,确保在切换标签时只加载必要的数据。

---
 pages/feedback/feedback.js |  267 ++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 202 insertions(+), 65 deletions(-)

diff --git a/pages/feedback/feedback.js b/pages/feedback/feedback.js
index 023a57c..7887046 100644
--- a/pages/feedback/feedback.js
+++ b/pages/feedback/feedback.js
@@ -2,20 +2,41 @@
   data: {
     recordingSrc: '',
     isRecording: false,
+    isshowVoiceMask: true, //鏄惁鏄剧ず褰曢煶涓�
+    voiceTime: 2, //褰曢煶鏃堕暱
+    gridConfig: {
+      column: 3,
+      width: 160,
+      height: 160,
+    },
+    originFiles: [{
+        url: 'https://tdesign.gtimg.com/mobile/demos/example4.png',
+        name: 'uploaded1.png',
+        type: 'image',
+      },
+      {
+        url: 'https://tdesign.gtimg.com/mobile/demos/example6.png',
+        name: 'uploaded2.png',
+        type: 'image',
+      }
+    ]
   },
 
   onLoad() {
     this.recorderManager = wx.getRecorderManager();
-
     this.recorderManager.onStart(() => {
       console.log('recorder start');
-      this.setData({ isRecording: true });
+      this.setData({
+        isRecording: true
+      });
       this.startWaveformDrawing();
     });
 
     this.recorderManager.onStop((res) => {
       console.log('recorder stop', res);
-      const { tempFilePath } = res;
+      const {
+        tempFilePath
+      } = res;
       this.setData({
         recordingSrc: tempFilePath,
         isRecording: false
@@ -25,73 +46,189 @@
 
     this.recorderManager.onError((res) => {
       console.error(res);
-      this.setData({ isRecording: false });
+      this.setData({
+        isRecording: false
+      });
       this.stopWaveformDrawing();
     });
   },
-
-  startRecording() {
-    if (this.data.isRecording) return;
-
-    wx.authorize({
-      scope: 'scope.record',
-      success: () => {
-        const options = {
-          duration: 60000,
-          sampleRate: 44100,
-          numberOfChannels: 1,
-          encodeBitRate: 192000,
-          format: 'aac',
-          frameSize: 50
-        };
-        this.recorderManager.start(options);
-      },
-      fail: () => {
-        wx.showModal({
-          title: '鎺堟潈澶辫触',
-          content: '璇锋巿鏉冨綍闊冲姛鑳�',
-          showCancel: false
-        });
-      }
+  handleRemove(e) {
+    console.log("handleRemove");
+    const {
+      index
+    } = e.detail;
+    const {
+      originFiles
+    } = this.data;
+    originFiles.splice(index, 1);
+    this.setData({
+      originFiles,
     });
   },
-
-  stopRecording() {
-    if (!this.data.isRecording) return;
-
-    this.recorderManager.stop();
+  handleClick() {
+    console.log("handleClick");
   },
-
-  startWaveformDrawing() {
-    if (this.waveformInterval) return;
-
-    const canvasContext = wx.createCanvasContext('waveform');
-    const drawWaveform = () => {
-      if (!this.data.isRecording) return;
-
-      // 鐢熸垚妯℃嫙鐨勯煶閲忔暟鎹�
-      const data = new Array(100).fill(0).map(() => Math.random() * 100);
-
-      canvasContext.clearRect(0, 0, 300, 100);
-      canvasContext.beginPath();
-      canvasContext.moveTo(0, 50);
-      for (let i = 0; i < data.length; i++) {
-        const x = (i / data.length) * 300;
-        const y = 50 - data[i] / 2;
-        canvasContext.lineTo(x, y);
-      }
-      canvasContext.lineTo(300, 50);
-      canvasContext.stroke();
-      canvasContext.draw();
-
-      this.waveformInterval = setTimeout(drawWaveform, 100);
-    };
-
-    drawWaveform();
+  handleAdd(e) {
+    console.log("handleAdd");
+    const {
+      files
+    } = e.detail;
+    const {
+      originFiles
+    } = this.data;
+    this.setData({
+      originFiles: [...originFiles, ...files], // 姝ゆ椂璁剧疆浜� fileList 涔嬪悗鎵嶄細灞曠ず閫夋嫨鐨勫浘鐗�
+    });
   },
+  /**
+   * 涓婁紶鍥剧墖
+   */
+  onUpload() {
+    wx.uploadFile({
+      url: 'https://example.weixin.qq.com/upload', // 浠呬负绀轰緥锛岄潪鐪熷疄鐨勬帴鍙e湴鍧�
+      filePath: file.url,
+      name: 'file',
+      formData: {
+        user: 'test'
+      },
+      success: () => {
+        this.setData({
+          [`fileList[${length}].status`]: 'done',
+        });
+      },
+    });
+  },
+  //鎸変綇鎸夐挳
+  startHandel () {
+    this.setData({
+     isShowVoiceMask:true
+    })
+    console.log("寮�濮嬪綍闊�")
+    wx.getRecorderManager().start({
+     duration: 0
+    })
+   },
+   //鏉惧紑鎸夐挳
+   endHandle () {
+    this.setData({
+     isShowVoiceMask:false
+    })
+    console.log("缁撴潫")
+    const recorderManager = wx.getRecorderManager()
+    //褰曢煶鍋滄鍑芥暟
+    var that = this;  
+    wx.getRecorderManager().onStop((res) => {
+      const voiceTime =  Math.floor(res.duration/1000)
+      console.log('voiceTime',voiceTime);
+      that.setData({
+        voiceTime
+      })
+      console.log('res',res);
+     const { tempFilePath } = res; //杩欓噷鏉惧紑鎸夐挳 浼氳繑鍥炲綍闊虫湰鍦拌矾寰�
+     audio.src = tempFilePath
+     console.log(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;
+     //   }
+     //  }
+     // })
+    })
+    //瑙﹀彂褰曢煶鍋滄
+    wx.getRecorderManager().stop()
+   },
+// 鎾斁
+handlePlay(e){
+  // 鍊掕鏃�
+  let time = this.data.voiceTime
+  audio.play()
+  let timer1 = -1,timer2 = -1,timer3 = -1,timer4 = -1,timer5 = -1,timer6 = -1;
+  // 绗竴娆℃挱鏀句负0 绗簩娆℃挱鏀�2绉掗挓
+  timer6 = setInterval(()=>{
+    console.log('鏃堕棿',time);
+    if(time <= 0){
+      this.setData({
+        line2Opcity: 1,
+        line3Opcity: 1
+      })
+      clearInterval(timer6)
+      clearTimeout(timer2)
+      clearTimeout(timer3)
+      clearTimeout(timer4)
+      clearTimeout(timer5)
+      return
+    }
+    timer2 = setTimeout(()=>{
+      console.log('timer2');
+      this.setData({
+        line2Opcity: 0,
+        line3Opcity: 0
+      })
+    },300)
+    timer3 = setTimeout(()=>{
+      console.log('timer3');
+        this.setData({
+          line2Opcity: 1,
+          line3Opcity:0
+        })
+    },600)
+    timer4 = setTimeout(()=>{
+      console.log('timer4');
+        this.setData({
+          line2Opcity: 1,
+          line3Opcity: 1
+      })
+    },900)
+    timer5 = setTimeout(()=>{
+      console.log('timer5');
+        this.setData({
+          line2Opcity: 0,
+          line3Opcity: 0
+        })
+    },1200)    
+  },1200)
+  // 鍊掕鏃�
+  timer1 = setInterval(()=>{
+    time--;
+    if(time <= 0){
+      clearInterval(timer1)
+      return
+    }
+},1000)
 
-  stopWaveformDrawing() {
-    clearTimeout(this.waveformInterval);
-    this.waveformInterval = null;
-  }
-});
+}
+
+});
\ No newline at end of file

--
Gitblit v1.8.0