that the this = const
the let new new fileName = a Date () valueOf ();.
the let filePath = wx.env.USER_DATA_PATH + '/' + + fileName '.jpg'
wx.downloadFile ({
URL: srcUrl, here // Interface the image address returned
filePath: filePath,
Success: function (RES) {
// save the picture to the album system
wx.saveImageToPhotosAlbum ({
filePath: filePath,
Success (Data) {
the let filemgr = wx.getFileSystemManager ()
fileMgr.unlink ({
filePath : filePath,
Success () {
the console.log (222);
}
})
},
Fail (Data) {
wx.showToast ({
title: data.errMsg,
icon: 'none',
DURATION: 2000
})
IF (data.errMsg === "saveImageToPhotosAlbum: Fail auth deny") {
console.log ( "user initially refused, we would like to initiate a reauthorization ")
the console.log ( 'open window disposed')
wx.openSetting ({
success (settingdata) {
the console.log (settingdata)
IF (settingdata.authSetting [ 'scope.writePhotosAlbum']) {
the console.log ( 'Get permission success save, click again to give hints pictures into the album. ')
} the else {
console.log (' failure to obtain permission, do not give permission to give prompt can not use the normal '))
}
}
})
}
}
})
},
fail: function (res) {
}
})
Small micro-channel program saves images to albums (solve saveimagetophotosalbum: problems fail invalid file type and saveImageToPhotosAlbum: fail auth deny the problem)
Guess you like
Origin www.cnblogs.com/wxl99180426/p/12447258.html
Recommended
Ranking