小程序下载图片保存到手机相册失败?
小程序下载图片保存到手机相册失败,相关域名都设置了,
点击保存图片,–弹框加载-----出现正在下载图片字样时候立刻消失显示下载失败。分享到朋友圈和保存图片都是一样的问题。分享到微信聊天没问题
getFormid: function(t) {},
save1: function(t) {
var a = this;
console.log(t);
var e = t.currentTarget.dataset.img[0], i = t.currentTarget.dataset.goodsid, n = t.currentTarget.dataset.content;
a.setData({
share: !1,
shareImg: e,
goodsid: i,
share_content: n
});
},
save: function(e) {
var i = this, n = a.siteInfo.uniacid, s = e.target.dataset.content, o = a.getUserId(), c = e.target.dataset.img, u = e.target.dataset.qid;
i.setData({
showModalStatus: !0,
qid: u
});
var d = e.target.dataset.goodsid;
0 == d ? (i.setData({
showModalStatus: !1
}), wx.hideLoading(), setTimeout(function() {
wx.setClipboardData({
data: s,
success: function(t) {
wx.showLoading({
title: "正在下载图片"
}), "" != c && i.xiazaiTupian(c, 0);
}
});
}, 800)) : a.util.request({
url: t.CreatGoodsCode,
data: {
goodsId: d,
user_id: o,
uniacid: n
},
cachetime: 0,
success: function(e) {
"" != e.data.data.img && a.util.request({
url: t.CreatPoster,
data: {
goodsCode: e.data.data.img,
user_id: o,
goodsId: d
},
cachetime: 0,
success: function(t) {
var a = [ t.data.data ].concat(c);
i.setData({
showModalStatus: !1
}), wx.setClipboardData({
data: s,
success: function(t) {
wx.showLoading({
title: "正在下载图片"
}), "" != a && i.xiazaiTupian(a, 0);
}
});
}
});
}
});
},
xiazaiTupian: function(e, i) {
var n = this;
i = i || 0, wx.getSetting({
success: function(s) {
void 0 === s.authSetting["scope.writePhotosAlbum"] ? wx.downloadFile({
url: e[i],
success: function(s) {
var o = s.tempFilePath;
wx.saveImageToPhotosAlbum({
filePath: o,
success: function() {
(i += 1) < e.length ? n.xiazaiTupian(e, i) : (wx.hideLoading(), wx.showModal({
title: "提示",
content: "素材文案已复制,图片已保存至相册,快去分享吧!",
confirmText: "我知道了",
showCancel: !1,
success: function(e) {
e.confirm ? a.util.request({
url: t.UpdateQuanShareTimes,
data: {
qid: n.data.qid
},
cachetime: 0,
success: function(t) {}
}) : e.cancel;
}
}));
},
fail: function() {
(i += 1) < e.length ? n.xiazaiTupian(e, i) : (wx.hideLoading(), wx.showModal({
title: "提示",
content: "素材文案已复制,图片已保存至相册,快去分享吧!",
confirmText: "我知道了",
showCancel: !1,
success: function(e) {
e.confirm ? a.util.request({
url: t.UpdateQuanShareTimes,
data: {
qid: n.data.qid
},
cachetime: 0,
success: function(t) {}
}) : e.cancel;
}
})), wx.showToast({
title: "第" + i + "张下载失败",
icon: "none"
});
}
});
},
fail: function(t) {
wx.hideLoading(), wx.showToast({
title: "下载失败",
icon: "none"
});
}
}) : !0 === s.authSetting["scope.writePhotosAlbum"] ? wx.downloadFile({
url: e[i],
success: function(s) {
var o = s.tempFilePath;
wx.saveImageToPhotosAlbum({
filePath: o,
success: function() {
(i += 1) < e.length ? n.xiazaiTupian(e, i) : (wx.hideLoading(), wx.showModal({
title: "提示",
content: "素材文案已复制,图片已保存至相册,快去分享吧!",
confirmText: "我知道了",
showCancel: !1,
success: function(e) {
e.confirm ? a.util.request({
url: t.UpdateQuanShareTimes,
data: {
qid: n.data.qid
},
cachetime: 0,
success: function(t) {}
}) : e.cancel;
}
}));
},
fail: function() {
(i += 1) < e.length ? n.xiazaiTupian(e, i) : (wx.hideLoading(), wx.showModal({
title: "提示",
content: "素材文案已复制,图片已保存至相册,快去分享吧!",
confirmText: "我知道了",
showCancel: !1,
success: function(e) {
e.confirm ? a.util.request({
url: t.UpdateQuanShareTimes,
data: {
qid: n.data.qid
},
cachetime: 0,
success: function(t) {}
}) : e.cancel;
}
})), wx.showToast({
title: "第" + i + "张下载失败",
icon: "none"
});
}
});
},
fail: function(t) {
wx.hideLoading(), wx.showToast({
title: "下载失败",
icon: "none"
});
}
}) : !1 === s.authSetting["scope.writePhotosAlbum"] && wx.showModal({
title: "温馨提示",
content: "您需要授权后,才能使用图片功能,是否重新授权",
confirmColor: "#39b54a",
success: function(s) {
s.confirm ? wx.openSetting({
success: function(s) {
!0 === s.authSetting["scope.writePhotosAlbum"] && wx.downloadFile({
url: e[i],
success: function(s) {
var o = s.tempFilePath;
wx.saveImageToPhotosAlbum({
filePath: o,
success: function() {
(i += 1) < e.length ? n.xiazaiTupian(e, i) : (wx.hideLoading(), wx.showModal({
title: "提示",
content: "素材文案已复制,图片已保存至相册,快去分享吧!",
confirmText: "我知道了",
showCancel: !1,
success: function(e) {
e.confirm ? a.util.request({
url: t.UpdateQuanShareTimes,
data: {
qid: n.data.qid
},
cachetime: 0,
success: function(t) {}
}) : e.cancel;
}
}));
},
fail: function() {
(i += 1) < e.length ? n.xiazaiTupian(e, i) : (wx.hideLoading(), wx.showModal({
title: "提示",
content: "素材文案已复制,图片已保存至相册,快去分享吧!",
confirmText: "我知道了",
showCancel: !1,
success: function(e) {
e.confirm ? a.util.request({
url: t.UpdateQuanShareTimes,
data: {
qid: n.data.qid
},
cachetime: 0,
success: function(t) {}
}) : e.cancel;
}
})), wx.showToast({
title: "第" + i + "张下载失败",
icon: "none"
});
}
});
},
fail: function(t) {
wx.hideLoading(), wx.showToast({
title: "下载失败",
icon: "none"
});
}
});
},
fail: function(t) {}
}) : s.cancel;
}
});
}
});
},