Browse Source

Signed-off-by: yukangzhe <382985154@qq.com>

yukangzhe 4 years ago
parent
commit
3941ea62b1
1 changed files with 31 additions and 7 deletions
  1. 31 7
      pages/doTask/doTask.js

+ 31 - 7
pages/doTask/doTask.js

@@ -8,7 +8,7 @@ const recordManager = wx.getRecorderManager() //录音对象
 const audioContext = wx.createInnerAudioContext() //音频播放对象
 
 var uploader = null //阿里云视频上传对象
-
+const urls = urlDef.urls;
 Page({
 
   /**
@@ -37,13 +37,37 @@ Page({
           })
           return;
         } else {
+          console.log(res)
           var tempFilePath = res.tempFilePath; // 文件临时路径
           console.log("文件临时路径", tempFilePath)
-          // audioContext.src = tempFilePath
-          // audioContext.play()
-          const list = [tempFilePath]
-          that.setData({
-            audioList:that.data.audioList.concat(list)
+          wx.uploadFile({
+            filePath: tempFilePath,
+            name: 'name',
+            url: urls.file_upload,
+            header: util.getHeaders(),
+            success(res) {
+              wx.showToast({
+                title: '上传成功',
+              })
+            
+              const rs = JSON.parse(JSON.parse(JSON.stringify(res.data)))
+              console.log(rs)
+              const list = [rs.data[0].url]
+              that.setData({
+                audioList:that.data.audioList.concat(list)
+              })
+            },
+            fail(res) {
+              wx.showToast({
+                title: '上传失败',
+                icon: 'none'
+              })
+            },
+            complete(res) {
+              wx.hideLoading({
+                success: (res) => {},
+              })
+            }
           })
         }
       });
@@ -121,7 +145,7 @@ Page({
 
   uploadTap: function () {
     const that = this
-    const urls = urlDef.urls;
+    
     wx.chooseImage({
       count: 6,
       sourceType: ['album', 'camera'],