当前位置:网站首页>Comment enregistrer une image dans une applet Wechat
Comment enregistrer une image dans une applet Wechat
2022-06-26 04:40:00 【Blanc résiduel X】
Télécharger(wx.downloadFile) + Enregistrer(wx.saveImageToPhotosAlbum) +Autorisation(wx.openSetting)
// Comment enregistrer une image
serve(img) {
wx.showLoading({
title: 'Chargement...'
});
//wx.downloadFileMéthodes:Télécharger les ressources du fichier localement
wx.downloadFile({
url: img, //Adresse de l'image
success: function (res) {
//wx.saveImageToPhotosAlbumMéthodes:Enregistrer l'image dans l'album système
wx.saveImageToPhotosAlbum({
filePath: res.tempFilePath, //Chemin du fichier image
success: function (data) {
wx.hideLoading(); //Cacher loading Boîte de sollicitation
wx.showToast({
title: 'Enregistrer avec succès',
icon: 'none'
})
},
// Fonction de rappel pour l'appel d'interface échoué
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: 'Conseils',
content: ' Veuillez autoriser l'enregistrement dans l'album ',
modalType: false,
success: res => {
if (res.confirm) {
wx.openSetting({
success(settingdata) {
console.log("settingdata", settingdata)
if (settingdata.authSetting['scope.writePhotosAlbum']) {
wx.showToast({
title: 'Autorisation réussie',
icon: 'none'
})
} else {
wx.showToast({
title: 'L'autorisation a échoué',
icon: 'none'
})
}
},
fail(failData) {
console.log("failData", failData)
},
complete(finishData) {
console.log("finishData", finishData)
}
})
} else if (res.cancel) {
console.log('Cliquez sur Annuler')
}
}
})
}
},
complete(res) {
wx.hideLoading(); //Cacher loading Boîte de sollicitation
}
})
}
})
},
边栏推荐
- #微信小程序# 在小程序里面退出退出小程序(navigator以及API--wx.exitMiniProgram)
- Advanced learning of MySQL (learning from Shang Silicon Valley teacher Zhou Yang)
- Introduction to markdown grammar
- Database design (I)
- Multipass中文文档-设置驱动
- Nightmare
- Laravel pay payment access process
- MySQL index details
- CTF serialization and deserialization
- PHP installation SSH2 extension
猜你喜欢
NVM installation and use and NPM package installation failure record
2021-01-31
Zhimeng CMS will file a lawsuit against infringing websites
Nabicat connection: local MySQL & cloud service MySQL and error reporting
Multipass中文文档-设置驱动
#微信小程序# 在小程序里面退出退出小程序(navigator以及API--wx.exitMiniProgram)
Introduction to markdown grammar
1.20 learning summary
[geek challenge 2019] rce me
2022.2.11
随机推荐
Svn error command revert error previous operation has not finished; run ‘ cleanup‘ if
[H5 development] 01 take you to experience H5 development from a simple page ~ the whole page implementation process from static page to interface adjustment manual teaching
There is no response to redirection and jump in the laravel constructor [original]
How to use the configured slave data source for the scheduled task configuration class scheduleconfig
SSH password free login, my server password free login to the other server, the other server password free login to your server
Laravel access error could not be opened
Is education important or ability important in software testing
防撤回测试记录
2020-12-18
Database design (3): database maintenance and optimization
Numpy random number
6、 Project practice --- identifying cats and dogs
Performance test comparison between PHP framework jsnpp and thinkphp6
Thinkphp6 using kindeditor
Physical design of database design (2)
问题随记 —— pip 换源
Create alicloud test instances
修改Oracle连接数
A troubleshooting of website crash due to high CPU
CTF crypto (I) some simple encoding and encryption