沙盘演示系统应用的微信小程序
zuoxiao
2024-10-28 eb64e401aa8f22f510914a21ec3cf89e1594f6cb
pages/feedback/feedback.js
@@ -3,6 +3,7 @@
const {
  BASEURL
} = require('../../api/config')
const app = getApp()
Page({
  data: {
    isRefreshing: false,
@@ -29,6 +30,7 @@
    contentValue: '', //反馈详情
    accSavePath: '', //上传的音频文件接口返回的地址
    photoSavePath: [] //上传的照片文件返回的地址
  },
  onLoad() {
@@ -98,10 +100,18 @@
    //上传录制的音频到服务器
    wx.uploadFile({
      url: BASEURL + "wx/webFile/upPhone", //接口地址
      name: 'file.acc', //上传文件名
      name: 'file', //上传文件名
      filePath: tempFilePath,
      header: {
        'tag': app.globalData.tag,
        'appId': app.globalData.AppID,
      },
      success: function (res) { //后台返回给前端识别后的文字
        console.log('录音上传成功', res);
      },
      fail: (err) => {
        // 处理上传失败的逻辑
        console.log('录音上传失败', err);
      }
    })
  },
@@ -124,7 +134,7 @@
    this.setData({
      originFiles,
    });
  },
  handleClick(e) {
    console.log("handleClick");
@@ -167,8 +177,12 @@
      url: BASEURL + "wx/webFile/upPhone", // 仅为示例,非真实的接口地址
      filePath: imgPath,
      name: 'file',
      success: () => {
      header: {
        'tag': app.globalData.tag,
        'appId': app.globalData.AppID,
      },
      success: (res) => {
        console.log('图片上传成功', res);
      },
      fail: (err) => {
        // 处理上传失败的逻辑  
@@ -381,6 +395,29 @@
      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() {}
      })
    }
  }
});