当前位置:网站首页>Method of saving pictures in wechat applet
Method of saving pictures in wechat applet
2022-06-26 04:40:00 【Residual white x】
download (wx.downloadFile) + preservation (wx.saveImageToPhotosAlbum) + to grant authorization (wx.openSetting)
// How to save pictures
serve(img) {
wx.showLoading({
title: ' Loading ...'
});
//wx.downloadFile Method : Download file resources to local
wx.downloadFile({
url: img, // Picture address
success: function (res) {
//wx.saveImageToPhotosAlbum Method : Save picture to system album
wx.saveImageToPhotosAlbum({
filePath: res.tempFilePath, // Image file path
success: function (data) {
wx.hideLoading(); // hide loading Prompt box
wx.showToast({
title: ' Saved successfully ',
icon: 'none'
})
},
// Interface call failed callback function
fail: function (err) {
if (err.errMsg === "saveImageToPhotosAlbum:fail:auth denied" || err.errMsg === "saveImageToPhotosAlbum:fail auth deny" || err.errMsg === "saveImageToPhotosAlbum:fail authorize no response") {
wx.showModal({
title: ' Tips ',
content: ' Please authorize saving to album ',
modalType: false,
success: res => {
if (res.confirm) {
wx.openSetting({
success(settingdata) {
console.log("settingdata", settingdata)
if (settingdata.authSetting['scope.writePhotosAlbum']) {
wx.showToast({
title: ' Authorized success ',
icon: 'none'
})
} else {
wx.showToast({
title: ' privilege grant failed ',
icon: 'none'
})
}
},
fail(failData) {
console.log("failData", failData)
},
complete(finishData) {
console.log("finishData", finishData)
}
})
} else if (res.cancel) {
console.log(' The user clicks cancel ')
}
}
})
}
},
complete(res) {
wx.hideLoading(); // hide loading Prompt box
}
})
}
})
},边栏推荐
- Composer version rollback version switching
- Rdkit chemical formula molecular formula search
- The statistics in the MySQL field become strings, and then they are converted into numbers for sorting
- PHP inherited in class return does not work
- CTF serialization and deserialization
- Minecraft 1.16.5 biochemical 8 module 1.9 version 1.18 version synchronization
- 问题随记 —— pip 换源
- ROS 笔记(07)— 客户端 Client 和服务端 Server 的实现
- Install cenos in the virtual machine
- Your requirements could not be resolved
猜你喜欢

CDN with OSS acceleration

Thinkphp6 implements a simple lottery system

35 year old programmer fired Luna millions of assets and returned to zero in three days. Netizen: it's the same as gambling

文件上传与安全狗

2020-12-18
![Simple personal summary of tp6 multi application deployment -- Part I [original]](/img/7b/65fab1973423081483dacc9bed9594.jpg)
Simple personal summary of tp6 multi application deployment -- Part I [original]

SixTool-多功能多合一代挂助手源码

Multipass中文文档-设置驱动

2022.1.24

PHP small factory moves bricks for three years - interview series - my programming life
随机推荐
Laravel framework Alipay payment fails to receive asynchronous callback request [original]
Ueeditor automatically appends P tags to rich text.br tags always wrap.br tag solutions
Oracle 數據泵導錶
Nightmare
Group by and order by are used together
1.19 learning summary
Guide de la pompe de données Oracle
Large numbers (C language)
Floyd
PHP inherited in class return does not work
Jenkins introduces custom jars
Svn error command revert error previous operation has not finished; run ‘ cleanup‘ if
Introduction to markdown grammar
Physical design of database design (2)
How to use the configured slave data source for the scheduled task configuration class scheduleconfig
Add, delete, modify and query curd in PHP native SQL
BACK-OFF RESTARTING FAILED CONTAINER 的解决方法
"Eight hundred"
08_SpingBoot 集成Redis
2022.2.13