微信小程序canvas 證件照制作( 三 )

  1. 在源碼中修改調用
【微信小程序canvas 證件照制作】const polyfill = require('../../../util/btoa.js');const {btoa, atob} = polyfill;下載證件照到手機相冊export const savePoster = (url) => {const that = thiswx.saveImageToPhotosAlbum({filePath: url,success: function() {wx.showToast({title: '保存成功',icon: 'none',duration: 1500});},fail(err) {if (err.errMsg === "saveImageToPhotosAlbum:fail:auth denied" || err.errMsg === "saveImageToPhotosAlbum:fail auth deny" || err.errMsg === "saveImageToPhotosAlbum:fail authorize no response") {wx.showModal({title: '提示',content: '需要您授權保存相冊',showCancel: false,success: modalSuccess => {wx.openSetting({success(settingdata) {if (settingdata.authSetting['scope.writePhotosAlbum']) {wx.saveImageToPhotosAlbum({filePath: url,success: function () {wx.showToast({title: '保存成功',icon: 'success',duration: 2000})},})} else {wx.showToast({title: '授權失敗,請稍后重新獲取',icon: 'none',duration: 1500});}}})}})}}})}下面是利用canvas 做的小應用,歡迎大家掃描體驗,并提出建議 。讓我們共同進步
微信小程序canvas 證件照制作

文章插圖
[項目代碼] https://gitee.com/eyes-star/txy-mp.git
微信小程序canvas 證件照制作

文章插圖
[項目代碼] https://gitee.com/eyes-star/zjz-mp.git

推薦閱讀