/**
* 保存到相册
*/
savePhone: function() {
var that = this
//一、判断用户是否开启权限
wx.getSetting({
success: function(res) {
if (res.authSetting["scope.writePhotosAlbum"] == true) {
console.log("用户已开启相册访问");
} else {
console.log("用户未开启相册访问");
var status = res.authSetting["scope.writePhotosAlbum"]
if (typeof(status) == "undefined") {
console.log("--------未定义------");
} else {
wx.showModal({
title: '相册访问授权',
content: '相册访问授权未开启,无法完成操作',
confirmText: '开启授权',
confirmColor: '#345391',
cancelText: '仍然拒绝',
cancelColor: '#999999',
success: function(res) {
if (res.confirm) {
wx.openSetting({
})
}
if (res.cancel) {
wx.showModal({
title: '操作失败',
content: '相册访问授权未开启,操作失败',
confirmText: '太遗憾了',
confirmColor: '#345391',
showCancel: false
})
}
}
})
}
}
}
})
//二、保存图片到相册
wx.saveImageToPhotosAlbum({
filePath: that.data.prurl,
success(res) {
wx.showModal({
content: '图片已保存到相册,赶紧晒一下吧~',
showCancel: false,
confirmText: '好哒',
confirmColor: '#72B9C3',
success: function(res) {
if (res.confirm) {
console.log('用户点击确定');
that.setData({
canvasHidden: true
})
}
}
})
}
})
},