function saveImgToPhotosAlbum(url) { return new Promise((reslove, reject) => { if (url) { // console.log(url,"url") uni.showLoading({ title: '保存中', mask: true }) uni.getSetting({ success(res) { uni.downloadFile({ url: url, success: function (res) { // console.log(res) var temp = res.tempFilePath uni.saveImageToPhotosAlbum({ filePath: temp, success: function (res) { uni.hideLoading() reslove(res) }, fail: function (err) { uni.hideLoading() reject(err) } }) }, fail: function (err) { // console.log(err,"err") uni.hideLoading() // wx.utils.alert('保存失败') uni.showToast({ title: '保存失败', icon: 'none', mask: true, }) } }) }, fail(res) { } }) } else { wx.showLoading({ title: '请稍等', mask: true }) setTimeout(() => { uni.hideLoading() }, 1000) } }) } module.exports = { saveImgToPhotosAlbum }