Commit 34b2ccbb by 前端

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

更改授权过程

See merge request !84
2 parents e7aaa522 ff77c3c5
...@@ -74,6 +74,7 @@ ...@@ -74,6 +74,7 @@
], ],
"usingComponents": { "usingComponents": {
"navigation-bar": "/components/NavigationBar/NavigationBar", "navigation-bar": "/components/NavigationBar/NavigationBar",
"authorize":"/components/Authorize/Authorize",
"popup": "/components/Popup/Popup", "popup": "/components/Popup/Popup",
"van-picker": "@vant/weapp/picker/index", "van-picker": "@vant/weapp/picker/index",
"van-popup": "@vant/weapp/popup/index", "van-popup": "@vant/weapp/popup/index",
......
...@@ -52,7 +52,7 @@ Component({ ...@@ -52,7 +52,7 @@ Component({
/** /**
* 禁止滑动 * 禁止滑动
*/ */
noScroll: wx.$util.noScroll(), // noScroll: wx.$util.noScroll(),
cancel(e) { cancel(e) {
let { confirm } = e.currentTarget.dataset let { confirm } = e.currentTarget.dataset
let { buttonType, title } = this.data let { buttonType, title } = this.data
......
...@@ -19,7 +19,7 @@ Page({ ...@@ -19,7 +19,7 @@ Page({
fromLocal: 0, fromLocal: 0,
// 模态框 // 模态框
isShow: true, isShow: true,
showAuth: false,
btnList: [ btnList: [
{ {
src: `${IMGURL}down.png`, src: `${IMGURL}down.png`,
...@@ -203,16 +203,33 @@ Page({ ...@@ -203,16 +203,33 @@ Page({
content: '确认下载海报?', content: '确认下载海报?',
success: async (res) => { success: async (res) => {
if(res.confirm){ if(res.confirm){
let hasAuth = await this.toSetting() wx.getSetting({
if(hasAuth){ success: (res)=> {
this.createImg() if(res.authSetting['scope.writePhotosAlbum']){
} this.createImg()
}else{
this.setData({
showAuth: true
})
}
}
})
} }
}, },
fail: (res) => {}, fail: (res) => {},
complete: (res) => {}, complete: (res) => {},
}) })
}, },
authFail(){
wx.showToast({
title: "下载海报前需要您授权'添加到相册'权限",
icon: "none",
duration: 2500,
});
},
authSuccess(){
this.createImg()
},
toSetting(){ toSetting(){
return new Promise((resolve,reject)=>{ return new Promise((resolve,reject)=>{
wx.getSetting({ wx.getSetting({
......
<product actNum="{{actNum}}" navIdx="{{activeNavIdx}}" senceData="{{senceData}}" isShare="{{true}}"/> <view style="padding-bottom: {{fromLocal==1? 150: 0}}rpx">
<product actNum="{{actNum}}" navIdx="{{activeNavIdx}}" senceData="{{senceData}}" isShare="{{true}}"/>
</view>
<!-- 分享弹框 --> <!-- 分享弹框 -->
<!-- <view class="share-wrap" wx:if="{{isShow && fromLocal==1}}"> <!-- <view class="share-wrap" wx:if="{{isShow && fromLocal==1}}">
<view class="img-wrap" wx:if="{{posterUrl}}"> <view class="img-wrap" wx:if="{{posterUrl}}">
...@@ -36,3 +39,7 @@ ...@@ -36,3 +39,7 @@
</view> </view>
</view> </view>
</view> </view>
<block wx:if="{{showAuth}}">
<authorize scopeType="writePhotosAlbum" buttonType="openSetting" bindfail="authFail" bindsuccess="authSuccess" show="{{showAuth}}"></authorize>
</block>
...@@ -23,6 +23,7 @@ Component({ ...@@ -23,6 +23,7 @@ Component({
curTabIdx:0, //适用产品 curTabIdx:0, //适用产品
intoViewId: 'to-0', intoViewId: 'to-0',
actNum: 0, //场景 actNum: 0, //场景
showAuth: false
}, },
lifetimes:{ lifetimes:{
ready: function (){ ready: function (){
...@@ -124,26 +125,48 @@ Component({ ...@@ -124,26 +125,48 @@ Component({
curTabIdx: idx curTabIdx: idx
}) })
}, },
async downVideo(e) { downVideo(e) {
let hasAuth = await this.toSetting() let {url} = e.target.dataset
if(hasAuth){ this.setData({
let {url} = e.target.dataset curVideoUrl: url
wx.$api.showToast('正在下载视频...') })
wx.downloadFile({ wx.getSetting({
url:url, success: (res)=> {
success (res) { if(res.authSetting['scope.writePhotosAlbum']){
if (res.statusCode === 200) { this.toDown()
}else{
wx.saveVideoToPhotosAlbum({ this.setData({
filePath: res.tempFilePath, showAuth: true
success (res) { })
wx.$api.showToast('下载成功!')
}
})
}
} }
}) }
} })
},
toDown(){
wx.$api.showToast('正在下载视频...')
wx.downloadFile({
url: this.data.curVideoUrl,
success (res) {
if (res.statusCode === 200) {
wx.saveVideoToPhotosAlbum({
filePath: res.tempFilePath,
success (resp) {
wx.$api.showToast('下载成功!')
}
})
}
}
})
},
authFail(){
wx.showToast({
title: "下载视频前需要您授权'添加到相册'权限",
icon: "none",
duration: 2500,
});
},
authSuccess(){
this.toDown()
}, },
toSetting(){ toSetting(){
return new Promise((resolve,reject)=>{ return new Promise((resolve,reject)=>{
......
...@@ -49,4 +49,7 @@ ...@@ -49,4 +49,7 @@
</view> </view>
</block> </block>
</scroll-view> </scroll-view>
</view>
\ No newline at end of file \ No newline at end of file
</view>
<block wx:if="{{showAuth}}">
<authorize scopeType="writePhotosAlbum" buttonType="openSetting" bindfail="authFail" bindsuccess="authSuccess" show="{{showAuth}}"></authorize>
</block>
...@@ -27,7 +27,8 @@ Page({ ...@@ -27,7 +27,8 @@ Page({
changeSale: 0, changeSale: 0,
sceneCodeList:[], sceneCodeList:[],
currentId: 0, currentId: 0,
showPage: false showPage: false,
showAuth: false
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
...@@ -44,24 +45,24 @@ Page({ ...@@ -44,24 +45,24 @@ Page({
if(res?.length>0){ if(res?.length>0){
let sceneCodeList = [] let sceneCodeList = []
let senceData = [...this.data.senceData] let senceData = [...this.data.senceData]
// let res = [ let res = [
// { {
// sceneCode: 'SC001', sceneCode: 'SC001',
// status: 1 status: 1
// }, },
// { {
// sceneCode: 'SC002', sceneCode: 'SC002',
// status: 1 status: 1
// }, },
// { {
// sceneCode: 'SC003', sceneCode: 'SC003',
// status: 1 status: 1
// }, },
// { {
// sceneCode: 'SC004', sceneCode: 'SC004',
// status: 1 status: 1
// } }
// ] ]
res.forEach((item,index) => { res.forEach((item,index) => {
if(item.status==1) { if(item.status==1) {
let sceneTarget = senceData.find(sitem => sitem.sceneCode == item.sceneCode) let sceneTarget = senceData.find(sitem => sitem.sceneCode == item.sceneCode)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!