Browse Source

附件下载

zhaoxiaohai 2 năm trước cách đây
mục cha
commit
eb88e35d84
1 tập tin đã thay đổi với 22 bổ sung0 xóa
  1. 22 0
      components/My_accessory/index.js

+ 22 - 0
components/My_accessory/index.js

@@ -49,6 +49,28 @@ Component({
                         if (res.confirm) that.triggerEvent("deleteFile", item);
                     }
                 })
+            } else if (this.data.butType == '下载') {
+                wx.downloadFile({
+                    url: item.url,
+                    success(res) {
+                        if (res.statusCode === 200) {
+                            wx.shareFileMessage({
+                                filePath: res.tempFilePath,
+                                fileName: item.document,
+                                success(res) {
+                                    console.log("转发", res)
+                                },
+                                fail: console.error,
+                            })
+                        } else {
+                            wx.showToast({
+                                title: '微信下载保存失败',
+                                icon: "none"
+                            })
+                        }
+                    }
+                })
+
             }
         },
         callback(e) {