Commit bd912229 by 前端

Merge branch 'zq_dev_3.0' into 'v3.0'

设置权限判断

See merge request !83
2 parents 30880d7a 76eac997
...@@ -201,16 +201,43 @@ Page({ ...@@ -201,16 +201,43 @@ Page({
download() { download() {
wx.showModal({ wx.showModal({
content: '确认下载海报?', content: '确认下载海报?',
success: (res) => { success: async (res) => {
console.log(res)
if(res.confirm){ if(res.confirm){
let hasAuth = await this.toSetting()
if(hasAuth){
this.createImg() this.createImg()
} }
}
}, },
fail: (res) => {}, fail: (res) => {},
complete: (res) => {}, complete: (res) => {},
}) })
}, },
toSetting(){
return new Promise((resolve,reject)=>{
wx.getSetting({
success: (res)=> {
if(res.authSetting['scope.writePhotosAlbum']){
resolve(true)
}else{
wx.openSetting({
success :(resp)=> {
if(resp.authSetting['scope.writePhotosAlbum']){
resolve(true)
}else{
wx.showToast({
title: "下载海报前需要您授权'添加到相册'权限",
icon: "none",
duration: 2500,
});
}
}
})
}
}
})
})
},
//模态框关闭 //模态框关闭
modelClose() { modelClose() {
// this.setData({ // this.setData({
......
...@@ -124,7 +124,9 @@ Component({ ...@@ -124,7 +124,9 @@ Component({
curTabIdx: idx curTabIdx: idx
}) })
}, },
downVideo(e) { async downVideo(e) {
let hasAuth = await this.toSetting()
if(hasAuth){
let {url} = e.target.dataset let {url} = e.target.dataset
wx.$api.showToast('正在下载视频...') wx.$api.showToast('正在下载视频...')
wx.downloadFile({ wx.downloadFile({
...@@ -141,6 +143,32 @@ Component({ ...@@ -141,6 +143,32 @@ Component({
} }
} }
}) })
}
},
toSetting(){
return new Promise((resolve,reject)=>{
wx.getSetting({
success: (res)=> {
if(res.authSetting['scope.writePhotosAlbum']){
resolve(true)
}else{
wx.openSetting({
success :(resp)=> {
if(resp.authSetting['scope.writePhotosAlbum']){
resolve(true)
}else{
wx.showToast({
title: "下载视频前需要您授权'添加到相册'权限",
icon: "none",
duration: 2500,
});
}
}
})
}
}
})
})
}, },
getImgHeight(){ getImgHeight(){
let query = wx.createSelectorQuery().in(this) let query = wx.createSelectorQuery().in(this)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!