小程序
小游戏
企业微信
微信支付
扫描小程序码分享
ios端想要实现打开附件后,下载到本地和转发附件的功能
2 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
文档里有相关接口就支持
--↓↓👍点击“有用”是回答的动力哦
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
ios端想要实现打开附件后,下载到本地和转发附件的功能。
我是这样实现的ios端 用wx.downloadFile下载到本地 然后去查找 并且改名 然后改名的打开
--↓↓👍点赞是回答的动力哦
wx.downloadFile({
url: '',
success: function (res) {
var filePath = res.tempFilePath
wx.openDocument({
filePath: filePath,
console.log('预览打开文档成功')
},fail:function(res){
console.log('预览打开文档失败')
}
})
//下载
downFn: function(urlPath) {
let fileName = urlPath.split('/');
fileName = fileName[fileName.length - 1];
var docListInfo = this.data.docListInfo;
globalData.util.emma(fileName)
globalData.util.emma(urlPath.split("."))
var url = this.data.serverPath + urlPath;
var that = this;
globalData.util.emma(wx.env.USER_DATA_PATH, "wx.env.USER_DATA_PATH")
url: url,
success(res) {
if (res.statusCode === 200) {
globalData.util.emma("downloadFile")
globalData.util.emma(res)
fs.saveFile({
// tempFilePath: res.filePath,
tempFilePath: res.tempFilePath,
filePath: "wxfile://usr//Yinfo//" + fileName,
globalData.util.emma("成功")
globalData.util.emma(docListInfo)
for (var i in docListInfo) {
globalData.util.emma(i)
docListInfo[i].checked = false;
if (docListInfo[i].fileName == fileName) {
docListInfo[i].down = true
that.setData({
docListInfo,
selectAll: false
wx.showToast({
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
文档里有相关接口就支持
--↓↓👍点击“有用”是回答的动力哦
ios端想要实现打开附件后,下载到本地和转发附件的功能。
我是这样实现的ios端 用wx.downloadFile下载到本地 然后去查找 并且改名 然后改名的打开
--↓↓👍点赞是回答的动力哦
wx.downloadFile({
url: '',
success: function (res) {
var filePath = res.tempFilePath
wx.openDocument({
filePath: filePath,
success: function (res) {
console.log('预览打开文档成功')
},fail:function(res){
console.log('预览打开文档失败')
}
})
}
//下载
downFn: function(urlPath) {
let fileName = urlPath.split('/');
fileName = fileName[fileName.length - 1];
var docListInfo = this.data.docListInfo;
globalData.util.emma(fileName)
globalData.util.emma(urlPath.split("."))
var url = this.data.serverPath + urlPath;
var that = this;
globalData.util.emma(wx.env.USER_DATA_PATH, "wx.env.USER_DATA_PATH")
wx.downloadFile({
url: url,
success(res) {
if (res.statusCode === 200) {
globalData.util.emma("downloadFile")
globalData.util.emma(res)
fs.saveFile({
// tempFilePath: res.filePath,
tempFilePath: res.tempFilePath,
filePath: "wxfile://usr//Yinfo//" + fileName,
success(res) {
globalData.util.emma("成功")
globalData.util.emma(docListInfo)
for (var i in docListInfo) {
globalData.util.emma(i)
docListInfo[i].checked = false;
if (docListInfo[i].fileName == fileName) {
docListInfo[i].down = true
}
}
globalData.util.emma(docListInfo)
that.setData({
docListInfo,
selectAll: false
})
wx.showToast({
--↓↓👍点赞是回答的动力哦
--↓↓👍点赞是回答的动力哦