1》所有真机 https://mdapi.zjwist.com/mediainfo3/get/282264
真机返回 tempFilePath: "wxfile://tmp_8a9ac20f2668d82b48eda9157d6dba4fd0c7fd6ff8bef084c593bbce5efca43a.unknown"
模拟器 返回 tempFilePath: "http://tmp/wxda75989e3497bf5e.o6zAJs0l9iSa4k6xu3q9PFnprXy4.wFdvvTfsymXXf91f8a4d204c0c50b1fcc5fb48e7251c"
2》 华为手机所有网络图片返回都是错误的
例子1 : https://mdapi.zjwist.com/mediainfo3/get/282264 返回 tempFilePath: "wxfile://tmp_523ae1f473b90ea45ed60150bd75f8bd27c7df6c128613214c644324d5853d83.unknown"
例子2 : https://mdapi.zjwist.com/mediainfo3/get/415694 返回tempFilePath: "wxfile://tmp_1151ea5596a616803c3cb811d2d79d152fb27ec7081d5e15c4bdcbea0f81f39e.unknown"
ondowntap(e) {
var url = "https://mdapi.zjwist.com/mediainfo3/get/282264";
var that =this;
console.log("------", url);
wx.showLoading({
title: "图片下载中",
})
wx.downloadFile({
url: url,
success: function (res) {
console.log("------", res);
wx.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success(result) {
console.log("-----success-", result);
wx.hideLoading()
wx.showToast({
title: "下载完成",
icon: 'none',
duration: 1000,
});
}
})
},
fail: function (res) {
console.log("------fail", res);
wx.hideLoading()
}
})
}
看看这个https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.saveImageToPhotosAlbum.html
//点击保存到相册
确定好用户有授权保存,因为有字数限制我就不发了,下方是图片的保存方法,本地地址和缓存地址都是可以用的
saveImage: function (e) {
var that = this
wx.saveImageToPhotosAlbum({
filePath: that.data.form_picture,
success() {
wx.showToast({
title: '保存成功',
icon: 'none'
})
},
fail() {
wx.showToast({
title: '保存失败',
icon: 'none'
})
}
})
},
let that = this;
if (that.data.form_picture != '') {
wx.getSetting({
success: res => {
if (!res.authSetting['scope.writePhotosAlbum']) {//未授权的话发起授权
wx.authorize({
scope: 'scope.writePhotosAlbum',
success: () => {//用户允许授权,保存到相册
this.saveImage();
},
fail: () => {
wx.showModal({
title: '授权提示',
content: '需要您授权保存相册功能',
showCancel: false,
confirmText: '进入设置',
confirmColor: '#576B95',
success: modalSuccess => {
wx.openSetting({
success: (res) => {
if (!res.authSetting['scope.writePhotosAlbum']) {
wx.showToast({
title: '获取权限失败',
icon: 'none'
})
} else {
this.saveImage();
}
}
})
}
})
}
})
} else {
this.saveImage();
}
}
})
} else {
wx.showToast({
title: '图片加载失败',
icon: 'none'
})
}
},
saveImage: function (e) {
var that = this
wx.saveImageToPhotosAlbum({
filePath: that.data.form_picture,
success() {
wx.showToast({
title: '保存成功',
icon: 'none'
})
},
fail() {
wx.showToast({
title: '保存失败',
icon: 'none'
})
}
})
},